2010-05-06 00:29:58 +02:00
|
|
|
package com.osmand.data;
|
|
|
|
|
2010-05-15 14:54:26 +02:00
|
|
|
import com.osmand.osm.Entity;
|
2010-08-13 01:46:45 +02:00
|
|
|
import com.osmand.osm.Relation;
|
2010-05-06 00:29:58 +02:00
|
|
|
import com.osmand.osm.OSMSettings.OSMTagKey;
|
|
|
|
|
2010-05-27 13:02:02 +02:00
|
|
|
public class Amenity extends MapObject {
|
2010-05-06 00:29:58 +02:00
|
|
|
|
|
|
|
|
2010-05-16 23:49:11 +02:00
|
|
|
private String subType;
|
|
|
|
private AmenityType type;
|
2010-06-01 23:16:56 +02:00
|
|
|
private String openingHours;
|
2010-05-06 00:29:58 +02:00
|
|
|
|
2010-05-23 09:59:12 +02:00
|
|
|
public Amenity(Entity entity){
|
2010-05-27 13:02:02 +02:00
|
|
|
super(entity);
|
2010-05-23 09:59:12 +02:00
|
|
|
this.type = getType(entity);
|
|
|
|
this.subType = getSubType(entity);
|
2010-06-01 23:16:56 +02:00
|
|
|
this.openingHours = entity.getTag(OSMTagKey.OPENING_HOURS);
|
2010-05-06 00:29:58 +02:00
|
|
|
}
|
|
|
|
|
2010-05-16 23:49:11 +02:00
|
|
|
public Amenity(){
|
|
|
|
}
|
|
|
|
|
2010-06-16 17:05:06 +02:00
|
|
|
public String convertToAmenityTag(){
|
|
|
|
switch (getType()) {
|
|
|
|
case SHOP:
|
|
|
|
return OSMTagKey.SHOP.getValue();
|
|
|
|
case LEISURE:
|
|
|
|
return OSMTagKey.LEISURE.getValue();
|
|
|
|
case HISTORIC:
|
|
|
|
return OSMTagKey.HISTORIC.getValue();
|
2010-06-27 19:15:29 +02:00
|
|
|
case NATURAL:
|
|
|
|
return OSMTagKey.NATURAL.getValue();
|
2010-06-16 17:05:06 +02:00
|
|
|
case TOURISM:
|
|
|
|
return OSMTagKey.TOURISM.getValue();
|
|
|
|
case SPORT:
|
|
|
|
return OSMTagKey.SPORT.getValue();
|
|
|
|
default:
|
|
|
|
return OSMTagKey.AMENITY.getValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-11 12:28:09 +02:00
|
|
|
protected String getSubType(Entity node) {
|
|
|
|
if (node.getTag(OSMTagKey.SHOP) != null) {
|
2010-05-06 00:29:58 +02:00
|
|
|
return node.getTag(OSMTagKey.SHOP);
|
2010-06-27 19:15:29 +02:00
|
|
|
} else if (node.getTag(OSMTagKey.NATURAL) != null) {
|
|
|
|
return node.getTag(OSMTagKey.NATURAL);
|
2010-06-11 12:28:09 +02:00
|
|
|
} else if (node.getTag(OSMTagKey.TOURISM) != null) {
|
2010-05-06 00:29:58 +02:00
|
|
|
return node.getTag(OSMTagKey.TOURISM);
|
2010-06-11 12:28:09 +02:00
|
|
|
} else if (node.getTag(OSMTagKey.SPORT) != null) {
|
|
|
|
return node.getTag(OSMTagKey.SPORT);
|
|
|
|
} else if (node.getTag(OSMTagKey.LEISURE) != null) {
|
2010-05-06 00:29:58 +02:00
|
|
|
return node.getTag(OSMTagKey.LEISURE);
|
2010-06-11 12:28:09 +02:00
|
|
|
} else if (node.getTag(OSMTagKey.HISTORIC) != null) {
|
|
|
|
return node.getTag(OSMTagKey.HISTORIC);
|
|
|
|
} else if (node.getTag(OSMTagKey.INTERNET_ACCESS) != null) {
|
2010-06-19 19:01:40 +02:00
|
|
|
return "internet_access"; //$NON-NLS-1$
|
2010-06-11 12:28:09 +02:00
|
|
|
} else if (node.getTag(OSMTagKey.AMENITY) != null) {
|
|
|
|
return node.getTag(OSMTagKey.AMENITY);
|
|
|
|
}
|
2010-06-19 19:01:40 +02:00
|
|
|
return ""; //$NON-NLS-1$
|
2010-05-06 00:29:58 +02:00
|
|
|
}
|
|
|
|
|
2010-05-23 09:59:12 +02:00
|
|
|
protected AmenityType getType(Entity node){
|
2010-05-06 00:29:58 +02:00
|
|
|
if(node.getTag(OSMTagKey.SHOP) != null){
|
|
|
|
return AmenityType.SHOP;
|
2010-06-27 19:15:29 +02:00
|
|
|
} else if(node.getTag(OSMTagKey.NATURAL) != null){
|
|
|
|
return AmenityType.NATURAL;
|
2010-05-06 00:29:58 +02:00
|
|
|
} else if(node.getTag(OSMTagKey.TOURISM) != null){
|
|
|
|
return AmenityType.TOURISM;
|
2010-06-16 17:05:06 +02:00
|
|
|
} else if(node.getTag(OSMTagKey.LEISURE) != null){
|
|
|
|
return AmenityType.LEISURE;
|
|
|
|
} else if(node.getTag(OSMTagKey.SPORT) != null){
|
|
|
|
return AmenityType.SPORT;
|
2010-06-11 12:28:09 +02:00
|
|
|
} else if(node.getTag(OSMTagKey.HISTORIC) != null){
|
|
|
|
return AmenityType.HISTORIC;
|
|
|
|
} else if(AmenityType.amenityMap.containsKey(node.getTag(OSMTagKey.AMENITY))){
|
|
|
|
return AmenityType.amenityMap.get(node.getTag(OSMTagKey.AMENITY));
|
2010-05-06 00:29:58 +02:00
|
|
|
}
|
|
|
|
return AmenityType.OTHER;
|
|
|
|
}
|
|
|
|
|
2010-05-16 23:49:11 +02:00
|
|
|
public AmenityType getType(){
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSubType(){
|
|
|
|
return subType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setType(AmenityType type) {
|
|
|
|
this.type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSubType(String subType) {
|
|
|
|
this.subType = subType;
|
|
|
|
}
|
|
|
|
|
2010-05-15 14:54:26 +02:00
|
|
|
public static boolean isAmenity(Entity n){
|
2010-08-13 01:46:45 +02:00
|
|
|
if(n instanceof Relation){
|
|
|
|
// it could be collection of amenities
|
|
|
|
return false;
|
|
|
|
}
|
2010-05-06 00:29:58 +02:00
|
|
|
if(n.getTag(OSMTagKey.AMENITY) != null){
|
|
|
|
return true;
|
|
|
|
} else if(n.getTag(OSMTagKey.SHOP) != null){
|
|
|
|
return true;
|
2010-06-27 19:15:29 +02:00
|
|
|
} else if(n.getTag(OSMTagKey.NATURAL) != null){
|
|
|
|
return true;
|
2010-05-06 00:29:58 +02:00
|
|
|
} else if(n.getTag(OSMTagKey.LEISURE) != null){
|
|
|
|
return true;
|
2010-06-16 17:05:06 +02:00
|
|
|
} else if(n.getTag(OSMTagKey.SPORT) != null){
|
|
|
|
return true;
|
2010-05-06 00:29:58 +02:00
|
|
|
} else if(n.getTag(OSMTagKey.TOURISM) != null){
|
|
|
|
return true;
|
2010-06-11 12:28:09 +02:00
|
|
|
} else if(n.getTag(OSMTagKey.HISTORIC) != null){
|
|
|
|
return true;
|
|
|
|
} else if(n.getTag(OSMTagKey.INTERNET_ACCESS) != null){
|
|
|
|
return true;
|
2010-05-06 00:29:58 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-05-14 23:05:18 +02:00
|
|
|
|
2010-06-01 23:16:56 +02:00
|
|
|
public String getOpeningHours() {
|
|
|
|
return openingHours;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOpeningHours(String openingHours) {
|
|
|
|
this.openingHours = openingHours;
|
|
|
|
}
|
|
|
|
|
2010-05-06 00:29:58 +02:00
|
|
|
|
2010-06-01 23:16:56 +02:00
|
|
|
public String getSimpleFormat(boolean en){
|
2010-06-19 19:01:40 +02:00
|
|
|
return AmenityType.toPublicString(type) + " : " + getStringWithoutType(en); //$NON-NLS-1$
|
2010-05-06 00:29:58 +02:00
|
|
|
}
|
|
|
|
|
2010-06-01 23:16:56 +02:00
|
|
|
public String getStringWithoutType(boolean en){
|
2010-06-02 00:15:19 +02:00
|
|
|
String n = getName(en);
|
|
|
|
if(n.length() == 0){
|
|
|
|
return getSubType();
|
|
|
|
}
|
2010-06-19 19:01:40 +02:00
|
|
|
return getSubType() + " " + n; //$NON-NLS-1$
|
2010-05-09 15:06:13 +02:00
|
|
|
}
|
|
|
|
|
2010-05-06 00:29:58 +02:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2010-06-01 23:16:56 +02:00
|
|
|
return getSimpleFormat(false);
|
2010-05-06 00:29:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-27 13:02:02 +02:00
|
|
|
public void doDataPreparation() {
|
|
|
|
|
|
|
|
}
|
2010-05-06 00:29:58 +02:00
|
|
|
|
|
|
|
}
|