diff --git a/TripKitAndroid/src/main/java/com/skedgo/geocoding/GCSkedgoResult.java b/TripKitAndroid/src/main/java/com/skedgo/geocoding/GCSkedgoResult.java index 7442ad6c..c5aa455a 100644 --- a/TripKitAndroid/src/main/java/com/skedgo/geocoding/GCSkedgoResult.java +++ b/TripKitAndroid/src/main/java/com/skedgo/geocoding/GCSkedgoResult.java @@ -1,9 +1,13 @@ package com.skedgo.geocoding; +import androidx.annotation.Nullable; + import com.skedgo.geocoding.agregator.GCSkedGoResultInterface; import org.jetbrains.annotations.NotNull; +import java.util.List; + public class GCSkedgoResult extends GCResult implements GCSkedGoResultInterface { @NotNull @@ -12,10 +16,21 @@ public class GCSkedgoResult extends GCResult implements GCSkedGoResultInterface // popularity json field from skedgo's json private int popularity; - public GCSkedgoResult(String name, double lat, double lng, @NotNull String resultClass, Integer popularity ){ + @Nullable + private List modeIdentifiers; + + public GCSkedgoResult( + String name, + double lat, + double lng, + @NotNull String resultClass, + Integer popularity, + @Nullable List modeIdentifiers + ){ super(name, lat, lng); this.popularity = popularity; this.resultClass = resultClass; + this.modeIdentifiers = modeIdentifiers; } @NotNull @@ -40,4 +55,10 @@ public void setPopularity(int popularity) { public boolean isStopLocation(){ return this.resultClass.equalsIgnoreCase("StopLocation"); } + + @Nullable + @Override + public List getModeIdentifiers() { + return modeIdentifiers; + } } diff --git a/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/GCSkedGoResultInterface.java b/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/GCSkedGoResultInterface.java index c309d382..c54f43f4 100644 --- a/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/GCSkedGoResultInterface.java +++ b/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/GCSkedGoResultInterface.java @@ -1,5 +1,9 @@ package com.skedgo.geocoding.agregator; +import androidx.annotation.Nullable; + +import java.util.List; + public interface GCSkedGoResultInterface extends GCResultInterface { // skedgo result class (class json field) @@ -7,4 +11,6 @@ public interface GCSkedGoResultInterface extends GCResultInterface { // skedgo result popularity (popularity json field) int getPopularity(); + @Nullable + List getModeIdentifiers(); } diff --git a/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/MultiSourceGeocodingAggregator.java b/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/MultiSourceGeocodingAggregator.java index 5467c2d6..1f376484 100644 --- a/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/MultiSourceGeocodingAggregator.java +++ b/TripKitAndroid/src/main/java/com/skedgo/geocoding/agregator/MultiSourceGeocodingAggregator.java @@ -194,7 +194,10 @@ private ScoringResult calculateSkedGoScoring(GCQuery query, GCSkedGoResultInt // int popularityScore = (Math.min(popularity, GOOD_SCORE)) / (GOOD_SCORE / 100) int popularityScore = ((Math.min(popularity, GOOD_SCORE)) / (GOOD_SCORE / 100)) * 2; - popularityScore = GeocodeUtilities.rangedScoreForScore(popularityScore, 30, 80); + popularityScore = (candidate.getModeIdentifiers() != null && !candidate.getModeIdentifiers().isEmpty()) ? + GeocodeUtilities.rangedScoreForScore(popularityScore, 50, 90) : + GeocodeUtilities.rangedScoreForScore(popularityScore, 30, 80); + if (popularity > GOOD_SCORE) { int moreThanGood = popularityScore / GOOD_SCORE; int bonus = GeocodeUtilities.rangedScoreForScore(moreThanGood, 0, 10); @@ -208,7 +211,9 @@ private ScoringResult calculateSkedGoScoring(GCQuery query, GCSkedGoResultInt if (!query.getQueryText().isEmpty()){ int nameScore = GeocodeUtilities.scoreBasedOnNameMatchBetweenSearchTerm(query.getQueryText(), candidate.getName()); - int totalScore = GeocodeUtilities.rangedScoreForScore(nameScore,0,50); + int totalScore = (candidate.getModeIdentifiers() != null && !candidate.getModeIdentifiers().isEmpty()) ? + GeocodeUtilities.rangedScoreForScore(nameScore,50,90): + GeocodeUtilities.rangedScoreForScore(nameScore,0,50); scoringResult.setScore(totalScore); scoringResult.setNameScore(nameScore); return scoringResult; @@ -284,71 +289,4 @@ private ScoringResult calculateRegionsScoring(GCQuery query, GCAppResultInter return scoringResult; } - -// private List> removeDuplicates(List> list) { -// int count = list.size(); -// List> withoutDuplicates = new ArrayList<>(); -// for (int i = 0; i < count; i++) { -// GroupScoringResult groupScoringResult; -// ScoringResult scoringResult; -// if (list.get(i) instanceof ScoringResult) { -// groupScoringResult = new GroupScoringResult(); -// groupScoringResult.addDuplicate((ScoringResult) list.get(i)); -// scoringResult = (ScoringResult) list.get(i); -// } -// else{ -// groupScoringResult = (GroupScoringResult) list.get(i); -// scoringResult = (ScoringResult) groupScoringResult.getDuplicates().get(0); -// } -// -// for (int j = i + 1; j < count; j++) { -// if (scoringResult.equals(list.get(j))) { -// if (list.get(j) instanceof ScoringResult) -// groupScoringResult.addDuplicate((ScoringResult) list.get(j)); -// else -// groupScoringResult.addDuplicates(list.get(j).getDuplicates()); -// list.remove(j--); -// count--; -// } -// } -// withoutDuplicates.add(i, groupScoringResult); -// } -// return GeocodeUtilities.sortByScore(withoutDuplicates); -// } - - -// private List> removeDuplicates(List> list) { -// -// Set> treeSet = new TreeSet<>(new Comparator>() { -// @Override -// public int compare(MGAResultInterface o1, MGAResultInterface o2) { -// ScoringResult scoringResult = (ScoringResult) o1.getClassRepresentative(); -// if (scoringResult.equals(o2)){ -// GroupScoringResult o1Group = (GroupScoringResult) o1; -// if (!o1.equals(o2)) { -// GroupScoringResult o2Group = (GroupScoringResult) o2; -// List> o1Duplicates = new ArrayList<>(o1Group.getDuplicates()); -// o1Group.addDuplicates(new ArrayList<>(o2Group.getDuplicates())); -// o2Group.addDuplicates(o1Duplicates); -// -// } -// } -// return scoringResult.equals(o2) ? 0 : 1; -// } -// }); -// -// for (MGAResultInterface o : list){ -// GroupScoringResult groupScoringResult; -// if (o instanceof ScoringResult) { -// groupScoringResult = new GroupScoringResult(); -// groupScoringResult.addDuplicate((ScoringResult) o); -// } -// else{ -// groupScoringResult = (GroupScoringResult) o; -// } -// treeSet.add(groupScoringResult); -// } -// -// return new ArrayList>(treeSet); -// } }