Fix order of entities

This commit is contained in:
Victor Shcherb 2016-07-31 20:16:18 +02:00
parent 2c08623541
commit 963014b8f4
4 changed files with 19 additions and 3 deletions

View file

@ -251,7 +251,11 @@ public class Amenity extends MapObject {
public int compareTo(MapObject o) { public int compareTo(MapObject o) {
int cmp = super.compareTo(o); int cmp = super.compareTo(o);
if(cmp == 0 && o instanceof Amenity) { 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; return cmp;
} }
@ -260,7 +264,8 @@ public class Amenity extends MapObject {
public boolean equals(Object o) { public boolean equals(Object o) {
boolean res = super.equals(o); boolean res = super.equals(o);
if (res && o instanceof Amenity) { 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; return res;
} }

View file

@ -42,6 +42,9 @@ public class PoiType extends AbstractPoiType {
if(isReference()) { if(isReference()) {
return referenceType.getOsmTag(); return referenceType.getOsmTag();
} }
if(osmTag != null && osmTag.startsWith("osmand_amenity")) {
return "amenity";
}
return osmTag; return osmTag;
} }

View file

@ -503,7 +503,9 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
for (PoiType s : ct.getPoiTypes()) { for (PoiType s : ct.getPoiTypes()) {
if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) { if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) {
addMapEntryAdapter(subCategories, s.getTranslation(), s); addMapEntryAdapter(subCategories, s.getTranslation(), s);
addMapEntryAdapter(subCategories, s.getKeyName().replace('_', ' '), s); if(!s.getKeyName().contains("osmand")) {
addMapEntryAdapter(subCategories, s.getKeyName().replace('_', ' '), s);
}
} }
} }
} }

View file

@ -242,6 +242,12 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
}, lat, lon, lat, lon, -1, null); }, lat, lon, lat, lon, -1, null);
MapPoiTypes types = app.getPoiTypes(); MapPoiTypes types = app.getPoiTypes();
for (Amenity amenity : amenities) {
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, lang);
if (poiSimpleFormat.equals(name)) {
return amenity;
}
}
for (Amenity amenity : amenities) { for (Amenity amenity : amenities) {
String amenityName = amenity.getName(lang, true); String amenityName = amenity.getName(lang, true);
if (Algorithms.isEmpty(amenityName)) { if (Algorithms.isEmpty(amenityName)) {