fix issue 167
git-svn-id: https://osmand.googlecode.com/svn/trunk@668 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
parent
750bfccc70
commit
36308e57cd
1 changed files with 22 additions and 4 deletions
|
@ -3,6 +3,7 @@ package net.osmand.data;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.Algoritms;
|
||||
import net.osmand.osm.Entity;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.osm.Node;
|
||||
|
@ -82,14 +83,20 @@ public class Amenity extends MapObject {
|
|||
AmenityType type = MapRenderingTypes.getAmenityType(t, entity.getTag(t));
|
||||
if (type != null) {
|
||||
String subtype = MapRenderingTypes.getAmenitySubtype(t, entity.getTag(t));
|
||||
amenitiesList.add(shift, new Amenity(entity, type, subtype));
|
||||
shift++;
|
||||
Amenity a = new Amenity(entity, type, subtype);
|
||||
if(checkAmenitiesToAdd(a, amenitiesList)){
|
||||
amenitiesList.add(shift, a);
|
||||
shift++;
|
||||
}
|
||||
} else {
|
||||
type = MapRenderingTypes.getAmenityType(t, null);
|
||||
if (type != null) {
|
||||
String subtype = MapRenderingTypes.getAmenitySubtype(t, entity.getTag(t));
|
||||
// add amenity to the end
|
||||
amenitiesList.add(new Amenity(entity, type, subtype));
|
||||
Amenity a = new Amenity(entity, type, subtype);
|
||||
if(checkAmenitiesToAdd(a, amenitiesList)){
|
||||
// add amenity to the end
|
||||
amenitiesList.add(a);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -98,6 +105,17 @@ public class Amenity extends MapObject {
|
|||
return amenitiesList;
|
||||
}
|
||||
|
||||
private static boolean checkAmenitiesToAdd(Amenity a, List<Amenity> amenitiesList){
|
||||
// check amenity for duplication
|
||||
for(Amenity b : amenitiesList){
|
||||
if(b.getType() == a.getType() && Algoritms.objectEquals(a.getSubType(), b.getSubType())){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public String getOpeningHours() {
|
||||
return openingHours;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue