OsmAnd/OsmAnd-java/src/net/osmand/osm/PoiCategory.java

98 lines
1.9 KiB
Java
Raw Normal View History

2015-01-19 22:22:27 +01:00
package net.osmand.osm;
2015-01-20 23:32:35 +01:00
import java.util.ArrayList;
2015-07-15 09:09:07 +02:00
import java.util.HashSet;
2015-04-06 23:24:25 +02:00
import java.util.LinkedHashSet;
2015-01-20 23:32:35 +01:00
import java.util.List;
2015-04-06 23:24:25 +02:00
import java.util.Map;
2015-07-15 09:09:07 +02:00
import java.util.Set;
2015-01-20 23:32:35 +01:00
2015-02-18 23:21:57 +01:00
2016-05-30 14:06:53 +02:00
public class PoiCategory extends PoiFilter implements Comparable<PoiCategory> {
2015-02-18 23:21:57 +01:00
2015-01-20 23:32:35 +01:00
private List<PoiFilter> poiFilters = new ArrayList<PoiFilter>();
2015-07-15 09:09:07 +02:00
private Set<PoiType> basemapPoi = null;
2015-02-18 23:21:57 +01:00
private int regId;
private String defaultTag;
public PoiCategory(MapPoiTypes registry, String keyName, int regId) {
2015-01-27 01:05:40 +01:00
super(registry, null, keyName);
2015-02-18 23:21:57 +01:00
this.regId = regId;
2015-01-19 22:22:27 +01:00
}
2015-02-18 23:21:57 +01:00
2015-01-20 23:32:35 +01:00
public void addPoiType(PoiFilter poi) {
poiFilters.add(poi);
2015-01-19 22:22:27 +01:00
}
2015-02-18 23:21:57 +01:00
2015-01-27 01:05:40 +01:00
public List<PoiFilter> getPoiFilters() {
return poiFilters;
}
2015-01-20 23:32:35 +01:00
2015-02-18 23:21:57 +01:00
public String getDefaultTag() {
if(defaultTag == null) {
2016-05-30 14:06:53 +02:00
return keyName; }
2015-02-18 23:21:57 +01:00
return defaultTag;
}
public void setDefaultTag(String defaultTag) {
this.defaultTag = defaultTag;
}
2015-04-06 23:24:25 +02:00
public Map<PoiCategory, LinkedHashSet<String>> putTypes(
Map<PoiCategory, LinkedHashSet<String>> acceptedTypes) {
acceptedTypes.put(this, null);
addReferenceTypes(acceptedTypes);
return acceptedTypes;
}
2015-02-18 23:21:57 +01:00
public boolean isWiki() {
return keyName.equals(MapPoiTypes.OSM_WIKI_CATEGORY);
}
public int ordinal() {
return regId;
}
2015-04-05 13:51:01 +02:00
2015-07-15 09:09:07 +02:00
public void addBasemapPoi(PoiType pt) {
if(basemapPoi == null) {
basemapPoi = new HashSet<PoiType>();
}
basemapPoi.add(pt);
}
2015-04-05 13:51:01 +02:00
2015-07-15 09:09:07 +02:00
public boolean containsBasemapPoi(PoiType pt) {
if(basemapPoi == null) {
return false;
}
return basemapPoi.contains(pt);
}
2016-05-30 14:06:53 +02:00
@Override
public boolean equals(Object o) {
if (!(o instanceof PoiCategory)) {
return false;
}
PoiCategory other = (PoiCategory) o;
return regId == other.regId;
}
@Override
public int hashCode() {
return regId;
}
@Override
public int compareTo(PoiCategory poiCategory) {
return Double.compare(regId, poiCategory.regId);
}
@Override
public String toString() {
return keyName + " (" + regId + ")";
}
2015-01-19 22:22:27 +01:00
}