From 963014b8f47e853bfecdefaa30057830e137d0e2 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 31 Jul 2016 20:16:18 +0200 Subject: [PATCH] Fix order of entities --- OsmAnd-java/src/net/osmand/data/Amenity.java | 9 +++++++-- OsmAnd-java/src/net/osmand/osm/PoiType.java | 3 +++ .../net/osmand/plus/osmedit/EditPoiDialogFragment.java | 4 +++- .../net/osmand/plus/search/QuickSearchListFragment.java | 6 ++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/data/Amenity.java b/OsmAnd-java/src/net/osmand/data/Amenity.java index 9551149042..ded7390f05 100644 --- a/OsmAnd-java/src/net/osmand/data/Amenity.java +++ b/OsmAnd-java/src/net/osmand/data/Amenity.java @@ -251,7 +251,11 @@ public class Amenity extends MapObject { public int compareTo(MapObject o) { int cmp = super.compareTo(o); if(cmp == 0 && o instanceof Amenity) { - return ((Amenity) o).getType().getKeyName().compareTo(getType().getKeyName()); + int kn = ((Amenity) o).getType().getKeyName().compareTo(getType().getKeyName()); + if(kn == 0) { + kn = ((Amenity) o).getSubType().compareTo(getSubType()); + } + return kn; } return cmp; } @@ -260,7 +264,8 @@ public class Amenity extends MapObject { public boolean equals(Object o) { boolean res = super.equals(o); if (res && o instanceof Amenity) { - return ((Amenity) o).getType().getKeyName().equals(getType().getKeyName()); + return Algorithms.stringsEqual(((Amenity) o).getType().getKeyName(), getType().getKeyName()) + && Algorithms.stringsEqual(((Amenity) o).getSubType(), getSubType()); } return res; } diff --git a/OsmAnd-java/src/net/osmand/osm/PoiType.java b/OsmAnd-java/src/net/osmand/osm/PoiType.java index ad01a36d45..faea63fe10 100644 --- a/OsmAnd-java/src/net/osmand/osm/PoiType.java +++ b/OsmAnd-java/src/net/osmand/osm/PoiType.java @@ -42,6 +42,9 @@ public class PoiType extends AbstractPoiType { if(isReference()) { return referenceType.getOsmTag(); } + if(osmTag != null && osmTag.startsWith("osmand_amenity")) { + return "amenity"; + } return osmTag; } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java index b629eee781..7ffc7fe59d 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/EditPoiDialogFragment.java @@ -503,7 +503,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment { for (PoiType s : ct.getPoiTypes()) { if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) { addMapEntryAdapter(subCategories, s.getTranslation(), s); - addMapEntryAdapter(subCategories, s.getKeyName().replace('_', ' '), s); + if(!s.getKeyName().contains("osmand")) { + addMapEntryAdapter(subCategories, s.getKeyName().replace('_', ' '), s); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index cfbbc5dfdd..141ca98e35 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -242,6 +242,12 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment { }, lat, lon, lat, lon, -1, null); MapPoiTypes types = app.getPoiTypes(); + for (Amenity amenity : amenities) { + String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, lang); + if (poiSimpleFormat.equals(name)) { + return amenity; + } + } for (Amenity amenity : amenities) { String amenityName = amenity.getName(lang, true); if (Algorithms.isEmpty(amenityName)) {