Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ private Amenity readPoiPoint(int left31, int right31, int top31, int bottom31,
}
}
am.setRegionName(region.getName());
am.initOrder();
return am;
case OsmandOdb.OsmAndPoiBoxDataAtom.DX_FIELD_NUMBER:
x = (codedIS.readSInt32() + (px << (BASE_POI_ZOOM - zoom))) << BASE_POI_SHIFT;
Expand Down
20 changes: 20 additions & 0 deletions OsmAnd-java/src/main/java/net/osmand/data/Amenity.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ public class Amenity extends MapObject {
public int getOrder() {
return order;
}
public void initOrder() {
if (type == null || subType == null)
return;
int ord = 0;
for (String type : subType.split(";")) {
PoiType poiType = getType().getPoiTypeByKeyName(type);
if (poiType != null) {
int order = poiType.getOrder();
ord = ord == 0 ? order : Math.min(ord, order);
}
}
setOrder(ord);
}

public void setOrder(int order) {
this.order = order;
Expand Down Expand Up @@ -1033,4 +1046,11 @@ public Map<String, String> getOsmTags() {

return result;
}

public boolean isTransport() {
if (type != null) {
return "transportation".equals(type.getKeyName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"transportation" to constant

}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,15 @@ protected void processAmenity(Amenity amenity, Set<String> contentLocales, boole
if (syntheticAmenity.getType() == null && type != null) {
syntheticAmenity.setType(type);
}
if (syntheticAmenity.getOrder() != amenity.getOrder()) {
int original = syntheticAmenity.getOrder();
int external = amenity.getOrder();
syntheticAmenity.setOrder(original == 0 ? external : Math.min(original, external));
if (external < original && type != null) {
// set new type if order is less
syntheticAmenity.setType(type);
}
}
String subType = amenity.getSubType();
if (subType != null) {
updateAmenitySubTypes(syntheticAmenity, subType);
Expand Down
15 changes: 15 additions & 0 deletions OsmAnd-java/src/main/java/net/osmand/search/SearchUICore.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,8 @@ public boolean sameSearchResult(SearchResult r1, SearchResult r2) {

if (type1.equals("natural")) {
similarityRadius = 50000;
} else if (type1.equals("transportation")) {
similarityRadius = 1000;
} else if (subType1.equals(subType2)) {
if (subType1.contains("cn_ref") || subType1.contains("wn_ref")
|| (subType1.startsWith("route_hiking_") && subType1.endsWith("n_poi"))) {
Expand Down Expand Up @@ -1163,6 +1165,7 @@ public JSONObject createTestJSON(SearchResultCollection searchResult) {
private enum ResultCompareStep {
TOP_VISIBLE,
FOUND_WORD_COUNT, // more is better (top)
TRANSPORTATION_ORDER,
OBF_RESOURCE,
UNKNOWN_PHRASE_MATCH_WEIGHT, // more is better (top)
SEARCH_DISTANCE_IF_NOT_BY_NAME,
Expand Down Expand Up @@ -1263,6 +1266,18 @@ public int compare(SearchResult o1, SearchResult o2, SearchResultComparator c) {
}
break;
}
case TRANSPORTATION_ORDER:
if (o1.object instanceof Amenity a1 && o2.object instanceof Amenity a2
&& a1.isTransport() && a2.isTransport()) {
int order1 = a1.getOrder();
int order2 = a2.getOrder();
String name1 = a1.getName();
String name2 = a2.getName();
if (order1 != order2 && name1.equals(name2)) {
return Double.compare(order1, order2);
}
}
break;
case COMPARE_BY_DISTANCE:
double s1 = o1.getSearchDistance(c.loc, 1);
double s2 = o2.getSearchDistance(c.loc, 1);
Expand Down
Loading