2010-05-06 00:29:58 +02:00
|
|
|
package com.osmand.data;
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2010-05-13 20:02:30 +02:00
|
|
|
import com.osmand.Algoritms;
|
2010-05-15 14:54:26 +02:00
|
|
|
import com.osmand.osm.Entity;
|
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
|
|
|
// http://wiki.openstreetmap.org/wiki/Amenity
|
|
|
|
public enum AmenityType {
|
|
|
|
SUSTENANCE, // restaurant, cafe ...
|
|
|
|
EDUCATION, // school, ...
|
|
|
|
TRANSPORTATION, // car_wash, parking, ...
|
|
|
|
FINANCE, // bank, atm, ...
|
|
|
|
HEALTHCARE, // hospital ...
|
|
|
|
ENTERTAINMENT, // cinema, ... (+! sauna, brothel)
|
|
|
|
TOURISM, // hotel, sights, museum ..
|
|
|
|
SHOP, // convenience (product), clothes...
|
|
|
|
LEISURE, // sport
|
|
|
|
OTHER, // grave-yard, police, post-office
|
2010-05-16 23:49:11 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
public static AmenityType fromString(String s){
|
|
|
|
return AmenityType.valueOf(s.toUpperCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String valueToString(AmenityType t){
|
|
|
|
return t.toString().toLowerCase();
|
|
|
|
}
|
2010-05-06 00:29:58 +02:00
|
|
|
}
|
|
|
|
private static Map<String, AmenityType> prebuiltMap = new LinkedHashMap<String, AmenityType>();
|
|
|
|
static {
|
|
|
|
prebuiltMap.put("restaurant", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("food_court", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("fast_food", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("drinking_water", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("bbq", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("pub", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("bar", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("cafe", AmenityType.SUSTENANCE);
|
|
|
|
prebuiltMap.put("biergarten", AmenityType.SUSTENANCE);
|
|
|
|
|
|
|
|
prebuiltMap.put("kindergarten", AmenityType.EDUCATION);
|
|
|
|
prebuiltMap.put("school", AmenityType.EDUCATION);
|
|
|
|
prebuiltMap.put("college", AmenityType.EDUCATION);
|
|
|
|
prebuiltMap.put("library", AmenityType.EDUCATION);
|
|
|
|
prebuiltMap.put("university", AmenityType.EDUCATION);
|
|
|
|
|
|
|
|
prebuiltMap.put("ferry_terminal", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("bicycle_parking", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("bicycle_rental", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("bus_station", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("car_rental", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("car_sharing", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("car_wash", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("grit_bin", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("parking", AmenityType.TRANSPORTATION);
|
|
|
|
prebuiltMap.put("taxi", AmenityType.TRANSPORTATION);
|
|
|
|
|
|
|
|
prebuiltMap.put("atm", AmenityType.FINANCE);
|
|
|
|
prebuiltMap.put("bank", AmenityType.FINANCE);
|
|
|
|
prebuiltMap.put("bureau_de_change", AmenityType.FINANCE);
|
|
|
|
|
|
|
|
prebuiltMap.put("pharmacy", AmenityType.HEALTHCARE);
|
|
|
|
prebuiltMap.put("hospital", AmenityType.HEALTHCARE);
|
|
|
|
prebuiltMap.put("baby_hatch", AmenityType.HEALTHCARE);
|
|
|
|
prebuiltMap.put("dentist", AmenityType.HEALTHCARE);
|
|
|
|
prebuiltMap.put("doctors", AmenityType.HEALTHCARE);
|
|
|
|
prebuiltMap.put("veterinary", AmenityType.HEALTHCARE);
|
2010-05-09 00:42:56 +02:00
|
|
|
prebuiltMap.put("first_aid", AmenityType.HEALTHCARE);
|
2010-05-06 00:29:58 +02:00
|
|
|
|
|
|
|
prebuiltMap.put("architect_office", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("arts_centre", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("cinema", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("community_centre", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("fountain", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("nightclub", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("stripclub", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("studio", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("theatre", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("sauna", AmenityType.ENTERTAINMENT);
|
|
|
|
prebuiltMap.put("brothel", AmenityType.ENTERTAINMENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-05-23 09:59:12 +02:00
|
|
|
protected String getSubType(Entity node){
|
2010-05-06 00:29:58 +02:00
|
|
|
if(node.getTag(OSMTagKey.AMENITY) != null){
|
|
|
|
return node.getTag(OSMTagKey.AMENITY);
|
|
|
|
} else if(node.getTag(OSMTagKey.SHOP) != null){
|
|
|
|
return node.getTag(OSMTagKey.SHOP);
|
|
|
|
} else if(node.getTag(OSMTagKey.TOURISM) != null){
|
|
|
|
return node.getTag(OSMTagKey.TOURISM);
|
|
|
|
} else if(node.getTag(OSMTagKey.LEISURE) != null){
|
|
|
|
return node.getTag(OSMTagKey.LEISURE);
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
} else if(node.getTag(OSMTagKey.TOURISM) != null){
|
|
|
|
return AmenityType.TOURISM;
|
|
|
|
} else if(node.getTag(OSMTagKey.LEISURE) != null){
|
|
|
|
return AmenityType.LEISURE;
|
|
|
|
} else if(prebuiltMap.containsKey(node.getTag(OSMTagKey.AMENITY))){
|
|
|
|
return prebuiltMap.get(node.getTag(OSMTagKey.AMENITY));
|
|
|
|
}
|
|
|
|
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-05-06 00:29:58 +02:00
|
|
|
if(n.getTag(OSMTagKey.AMENITY) != null){
|
|
|
|
return true;
|
|
|
|
} else if(n.getTag(OSMTagKey.SHOP) != null){
|
|
|
|
return true;
|
|
|
|
} else if(n.getTag(OSMTagKey.LEISURE) != null){
|
|
|
|
return true;
|
|
|
|
} else if(n.getTag(OSMTagKey.TOURISM) != null){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
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-05-13 20:02:30 +02:00
|
|
|
return Algoritms.capitalizeFirstLetterAndLowercase(getType().toString()) +
|
2010-06-02 00:15:19 +02:00
|
|
|
" : " + getStringWithoutType(en);
|
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();
|
|
|
|
}
|
|
|
|
return getSubType() + " " + n;
|
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
|
|
|
|
|
|
|
}
|