Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ba489295c3
1 changed files with 123 additions and 122 deletions
|
@ -33,65 +33,65 @@ public class MapPoiTypes {
|
||||||
private List<PoiCategory> categories = new ArrayList<PoiCategory>();
|
private List<PoiCategory> categories = new ArrayList<PoiCategory>();
|
||||||
private PoiCategory otherCategory;
|
private PoiCategory otherCategory;
|
||||||
private PoiCategory otherMapCategory;
|
private PoiCategory otherMapCategory;
|
||||||
|
|
||||||
static final String OSM_WIKI_CATEGORY = "osmwiki";
|
static final String OSM_WIKI_CATEGORY = "osmwiki";
|
||||||
private PoiTranslator poiTranslator = null;
|
private PoiTranslator poiTranslator = null;
|
||||||
private boolean init;
|
private boolean init;
|
||||||
|
|
||||||
public MapPoiTypes(String fileName){
|
public MapPoiTypes(String fileName) {
|
||||||
this.resourceName = fileName;
|
this.resourceName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface PoiTranslator {
|
public interface PoiTranslator {
|
||||||
|
|
||||||
public String getTranslation(AbstractPoiType type);
|
public String getTranslation(AbstractPoiType type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MapPoiTypes getDefaultNoInit() {
|
public static MapPoiTypes getDefaultNoInit() {
|
||||||
if(DEFAULT_INSTANCE == null){
|
if (DEFAULT_INSTANCE == null) {
|
||||||
DEFAULT_INSTANCE = new MapPoiTypes(null);
|
DEFAULT_INSTANCE = new MapPoiTypes(null);
|
||||||
}
|
}
|
||||||
return DEFAULT_INSTANCE;
|
return DEFAULT_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setDefault(MapPoiTypes types) {
|
public static void setDefault(MapPoiTypes types) {
|
||||||
DEFAULT_INSTANCE = types;
|
DEFAULT_INSTANCE = types;
|
||||||
DEFAULT_INSTANCE.init();
|
DEFAULT_INSTANCE.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MapPoiTypes getDefault() {
|
public static MapPoiTypes getDefault() {
|
||||||
if(DEFAULT_INSTANCE == null){
|
if (DEFAULT_INSTANCE == null) {
|
||||||
DEFAULT_INSTANCE = new MapPoiTypes(null);
|
DEFAULT_INSTANCE = new MapPoiTypes(null);
|
||||||
DEFAULT_INSTANCE.init();
|
DEFAULT_INSTANCE.init();
|
||||||
}
|
}
|
||||||
return DEFAULT_INSTANCE;
|
return DEFAULT_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInit() {
|
public boolean isInit() {
|
||||||
return init;
|
return init;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiCategory getOtherPoiCategory() {
|
public PoiCategory getOtherPoiCategory() {
|
||||||
return otherCategory;
|
return otherCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiCategory getOtherMapCategory() {
|
public PoiCategory getOtherMapCategory() {
|
||||||
if(otherMapCategory == null) {
|
if (otherMapCategory == null) {
|
||||||
otherMapCategory = getPoiCategoryByName("Other", true);
|
otherMapCategory = getPoiCategoryByName("Other", true);
|
||||||
}
|
}
|
||||||
return otherMapCategory;
|
return otherMapCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PoiFilter> getTopVisibleFilters() {
|
public List<PoiFilter> getTopVisibleFilters() {
|
||||||
List<PoiFilter> lf = new ArrayList<PoiFilter>();
|
List<PoiFilter> lf = new ArrayList<PoiFilter>();
|
||||||
for(PoiCategory pc : categories) {
|
for (PoiCategory pc : categories) {
|
||||||
if(pc.isTopVisible()) {
|
if (pc.isTopVisible()) {
|
||||||
lf.add(pc);
|
lf.add(pc);
|
||||||
}
|
}
|
||||||
for(PoiFilter p : pc.getPoiFilters()) {
|
for (PoiFilter p : pc.getPoiFilters()) {
|
||||||
if(p.isTopVisible()) {
|
if (p.isTopVisible()) {
|
||||||
lf.add(p);
|
lf.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,53 +110,53 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiCategory getUserDefinedCategory() {
|
public PoiCategory getUserDefinedCategory() {
|
||||||
return otherCategory;
|
return otherCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiType getPoiTypeByKey(String name) {
|
public PoiType getPoiTypeByKey(String name) {
|
||||||
for(PoiCategory pc : categories) {
|
for (PoiCategory pc : categories) {
|
||||||
PoiType pt = pc.getPoiTypeByKeyName(name);
|
PoiType pt = pc.getPoiTypeByKeyName(name);
|
||||||
if(pt != null && !pt.isReference()) {
|
if (pt != null && !pt.isReference()) {
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractPoiType getAnyPoiTypeByKey(String name) {
|
public AbstractPoiType getAnyPoiTypeByKey(String name) {
|
||||||
for(PoiCategory pc : categories) {
|
for (PoiCategory pc : categories) {
|
||||||
if(pc.getKeyName().equals(name)) {
|
if (pc.getKeyName().equals(name)) {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
for(PoiFilter pf : pc.getPoiFilters()) {
|
for (PoiFilter pf : pc.getPoiFilters()) {
|
||||||
if(pf.getKeyName().equals(name)) {
|
if (pf.getKeyName().equals(name)) {
|
||||||
return pf;
|
return pf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PoiType pt = pc.getPoiTypeByKeyName(name);
|
PoiType pt = pc.getPoiTypeByKeyName(name);
|
||||||
if(pt != null && !pt.isReference()) {
|
if (pt != null && !pt.isReference()) {
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) {
|
public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) {
|
||||||
Map<String, PoiType> translation = new HashMap<String, PoiType>();
|
Map<String, PoiType> translation = new HashMap<String, PoiType>();
|
||||||
for(PoiCategory pc : categories) {
|
for (PoiCategory pc : categories) {
|
||||||
if(skipNonEditable && pc.isNotEditableOsm()) {
|
if (skipNonEditable && pc.isNotEditableOsm()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for(PoiType pt : pc.getPoiTypes()) {
|
for (PoiType pt : pc.getPoiTypes()) {
|
||||||
if(pt.isReference() ) {
|
if (pt.isReference()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(pt.getBaseLangType() != null) {
|
if (pt.getBaseLangType() != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(skipNonEditable && pt.isNotEditableOsm()) {
|
if (skipNonEditable && pt.isNotEditableOsm()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
translation.put(pt.getKeyName().replace('_', ' ').toLowerCase(), pt);
|
translation.put(pt.getKeyName().replace('_', ' ').toLowerCase(), pt);
|
||||||
|
@ -165,11 +165,11 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
|
public List<AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
|
||||||
List<AbstractPoiType> tm = new ArrayList<AbstractPoiType>();
|
List<AbstractPoiType> tm = new ArrayList<AbstractPoiType>();
|
||||||
for (PoiCategory pc : categories) {
|
for (PoiCategory pc : categories) {
|
||||||
if(pc == otherMapCategory) {
|
if (pc == otherMapCategory) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addIf(tm, pc, matcher);
|
addIf(tm, pc, matcher);
|
||||||
|
@ -177,18 +177,18 @@ public class MapPoiTypes {
|
||||||
addIf(tm, pt, matcher);
|
addIf(tm, pt, matcher);
|
||||||
}
|
}
|
||||||
for (PoiType pt : pc.getPoiTypes()) {
|
for (PoiType pt : pc.getPoiTypes()) {
|
||||||
if (pt.isReference()){
|
if (pt.isReference()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addIf(tm, pt, matcher);
|
addIf(tm, pt, matcher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tm;
|
return tm;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIf(List<AbstractPoiType> tm, AbstractPoiType pc, StringMatcher matcher) {
|
private void addIf(List<AbstractPoiType> tm, AbstractPoiType pc, StringMatcher matcher) {
|
||||||
if(matcher.matches(pc.getTranslation()) || matcher.matches(pc.getKeyName().replace('_', ' '))) {
|
if (matcher.matches(pc.getTranslation()) || matcher.matches(pc.getKeyName().replace('_', ' '))) {
|
||||||
tm.add(pc);
|
tm.add(pc);
|
||||||
}
|
}
|
||||||
List<PoiType> additionals = pc.getPoiAdditionals();
|
List<PoiType> additionals = pc.getPoiAdditionals();
|
||||||
|
@ -204,7 +204,7 @@ public class MapPoiTypes {
|
||||||
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
Map<String, PoiType> translation = new TreeMap<String, PoiType>();
|
||||||
for (PoiType pt : pc.getPoiTypes()) {
|
for (PoiType pt : pc.getPoiTypes()) {
|
||||||
translation.put(pt.getTranslation(), pt);
|
translation.put(pt.getTranslation(), pt);
|
||||||
|
|
||||||
if (!onlyTranslation) {
|
if (!onlyTranslation) {
|
||||||
// translation.put(pt.getKeyName(), pt);
|
// translation.put(pt.getKeyName(), pt);
|
||||||
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(pt.getKeyName().replace('_', ' ')), pt);
|
translation.put(Algorithms.capitalizeFirstLetterAndLowercase(pt.getKeyName().replace('_', ' ')), pt);
|
||||||
|
@ -212,40 +212,41 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiCategory getPoiCategoryByName(String name) {
|
public PoiCategory getPoiCategoryByName(String name) {
|
||||||
return getPoiCategoryByName(name, false);
|
return getPoiCategoryByName(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiCategory getPoiCategoryByName(String name, boolean create) {
|
public PoiCategory getPoiCategoryByName(String name, boolean create) {
|
||||||
if(name.equals("leisure") && !create) {
|
if (name.equals("leisure") && !create) {
|
||||||
name = "entertainment";
|
name = "entertainment";
|
||||||
}
|
}
|
||||||
if(name.equals("historic") && !create) {
|
if (name.equals("historic") && !create) {
|
||||||
name = "tourism";
|
name = "tourism";
|
||||||
}
|
}
|
||||||
for(PoiCategory p : categories ) {
|
for (PoiCategory p : categories) {
|
||||||
if(p.getKeyName().equalsIgnoreCase(name)) {
|
if (p.getKeyName().equalsIgnoreCase(name)) {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(create) {
|
if (create) {
|
||||||
PoiCategory lastCategory = new PoiCategory(this, name, categories.size());
|
PoiCategory lastCategory = new PoiCategory(this, name, categories.size());
|
||||||
categories.add(lastCategory);
|
categories.add(lastCategory);
|
||||||
return lastCategory;
|
return lastCategory;
|
||||||
}
|
}
|
||||||
return otherCategory;
|
return otherCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiTranslator getPoiTranslator() {
|
public PoiTranslator getPoiTranslator() {
|
||||||
return poiTranslator;
|
return poiTranslator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPoiTranslator(PoiTranslator poiTranslator) {
|
public void setPoiTranslator(PoiTranslator poiTranslator) {
|
||||||
this.poiTranslator = poiTranslator;
|
this.poiTranslator = poiTranslator;
|
||||||
sortList(categories);
|
sortList(categories);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
init(null);
|
init(null);
|
||||||
}
|
}
|
||||||
|
@ -255,7 +256,7 @@ public class MapPoiTypes {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
List<PoiType> referenceTypes = new ArrayList<PoiType>();
|
List<PoiType> referenceTypes = new ArrayList<PoiType>();
|
||||||
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
||||||
if(resourceName != null) {
|
if (resourceName != null) {
|
||||||
this.resourceName = resourceName;
|
this.resourceName = resourceName;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -294,28 +295,28 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
lastCategory.addPoiType(tp);
|
lastCategory.addPoiType(tp);
|
||||||
} else if (name.equals("poi_additional")) {
|
} else if (name.equals("poi_additional")) {
|
||||||
if(lastCategory == null) {
|
if (lastCategory == null) {
|
||||||
lastCategory = getOtherMapCategory();
|
lastCategory = getOtherMapCategory();
|
||||||
}
|
}
|
||||||
PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null);
|
PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null);
|
||||||
if("true".equals(parser.getAttributeValue("", "lang"))) {
|
if ("true".equals(parser.getAttributeValue("", "lang"))) {
|
||||||
for(String lng : MapRenderingTypes.langs) {
|
for (String lng : MapRenderingTypes.langs) {
|
||||||
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, lng, baseType);
|
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, lng, baseType);
|
||||||
}
|
}
|
||||||
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, "en", baseType);
|
parsePoiAdditional(parser, lastCategory, lastFilter, lastType, "en", baseType);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (name.equals("poi_type")) {
|
} else if (name.equals("poi_type")) {
|
||||||
if(lastCategory == null) {
|
if (lastCategory == null) {
|
||||||
lastCategory = getOtherMapCategory();
|
lastCategory = getOtherMapCategory();
|
||||||
}
|
}
|
||||||
lastType = parsePoiType(allTypes, parser, lastCategory, lastFilter, null, null);
|
lastType = parsePoiType(allTypes, parser, lastCategory, lastFilter, null, null);
|
||||||
if("true".equals(parser.getAttributeValue("", "lang"))) {
|
if ("true".equals(parser.getAttributeValue("", "lang"))) {
|
||||||
for(String lng : MapRenderingTypes.langs) {
|
for (String lng : MapRenderingTypes.langs) {
|
||||||
parsePoiType(allTypes, parser, lastCategory, lastFilter, lng, lastType);
|
parsePoiType(allTypes, parser, lastCategory, lastFilter, lng, lastType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (tok == XmlPullParser.END_TAG) {
|
} else if (tok == XmlPullParser.END_TAG) {
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
|
@ -359,11 +360,11 @@ public class MapPoiTypes {
|
||||||
private PoiType parsePoiAdditional(XmlPullParser parser, PoiCategory lastCategory, PoiFilter lastFilter,
|
private PoiType parsePoiAdditional(XmlPullParser parser, PoiCategory lastCategory, PoiFilter lastFilter,
|
||||||
PoiType lastType, String lang, PoiType langBaseType) {
|
PoiType lastType, String lang, PoiType langBaseType) {
|
||||||
String oname = parser.getAttributeValue("", "name");
|
String oname = parser.getAttributeValue("", "name");
|
||||||
if(lang != null) {
|
if (lang != null) {
|
||||||
oname += ":" + lang;
|
oname += ":" + lang;
|
||||||
}
|
}
|
||||||
String otag = parser.getAttributeValue("", "tag");
|
String otag = parser.getAttributeValue("", "tag");
|
||||||
if(lang != null) {
|
if (lang != null) {
|
||||||
otag += ":" + lang;
|
otag += ":" + lang;
|
||||||
}
|
}
|
||||||
PoiType tp = new PoiType(this, lastCategory, oname);
|
PoiType tp = new PoiType(this, lastCategory, oname);
|
||||||
|
@ -396,12 +397,12 @@ public class MapPoiTypes {
|
||||||
private PoiType parsePoiType(final Map<String, PoiType> allTypes, XmlPullParser parser, PoiCategory lastCategory,
|
private PoiType parsePoiType(final Map<String, PoiType> allTypes, XmlPullParser parser, PoiCategory lastCategory,
|
||||||
PoiFilter lastFilter, String lang, PoiType langBaseType) {
|
PoiFilter lastFilter, String lang, PoiType langBaseType) {
|
||||||
String oname = parser.getAttributeValue("", "name");
|
String oname = parser.getAttributeValue("", "name");
|
||||||
if(lang != null) {
|
if (lang != null) {
|
||||||
oname += ":" + lang;
|
oname += ":" + lang;
|
||||||
}
|
}
|
||||||
PoiType tp = new PoiType(this, lastCategory, oname);
|
PoiType tp = new PoiType(this, lastCategory, oname);
|
||||||
String otag = parser.getAttributeValue("", "tag");
|
String otag = parser.getAttributeValue("", "tag");
|
||||||
if(lang != null) {
|
if (lang != null) {
|
||||||
otag += ":" + lang;
|
otag += ":" + lang;
|
||||||
}
|
}
|
||||||
tp.setBaseLangType(langBaseType);
|
tp.setBaseLangType(langBaseType);
|
||||||
|
@ -424,15 +425,15 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
allTypes.put(tp.getKeyName(), tp);
|
allTypes.put(tp.getKeyName(), tp);
|
||||||
lastCategory.addPoiType(tp);
|
lastCategory.addPoiType(tp);
|
||||||
if("true".equals(parser.getAttributeValue("", "basemap"))) {
|
if ("true".equals(parser.getAttributeValue("", "basemap"))) {
|
||||||
lastCategory.addBasemapPoi(tp);
|
lastCategory.addBasemapPoi(tp);
|
||||||
}
|
}
|
||||||
return tp;
|
return tp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findDefaultOtherCategory() {
|
private void findDefaultOtherCategory() {
|
||||||
PoiCategory pc = getPoiCategoryByName("user_defined_other");
|
PoiCategory pc = getPoiCategoryByName("user_defined_other");
|
||||||
if(pc == null) {
|
if (pc == null) {
|
||||||
throw new IllegalArgumentException("No poi category other");
|
throw new IllegalArgumentException("No poi category other");
|
||||||
}
|
}
|
||||||
otherCategory = pc;
|
otherCategory = pc;
|
||||||
|
@ -440,26 +441,26 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
public List<PoiCategory> getCategories(boolean includeMapCategory) {
|
public List<PoiCategory> getCategories(boolean includeMapCategory) {
|
||||||
ArrayList<PoiCategory> lst = new ArrayList<PoiCategory>(categories);
|
ArrayList<PoiCategory> lst = new ArrayList<PoiCategory>(categories);
|
||||||
if(!includeMapCategory) {
|
if (!includeMapCategory) {
|
||||||
lst.remove(getOtherMapCategory());
|
lst.remove(getOtherMapCategory());
|
||||||
}
|
}
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void print(MapPoiTypes df) {
|
private static void print(MapPoiTypes df) {
|
||||||
List<PoiCategory> pc = df.getCategories(true);
|
List<PoiCategory> pc = df.getCategories(true);
|
||||||
for(PoiCategory p : pc) {
|
for (PoiCategory p : pc) {
|
||||||
System.out.println("Category " + p.getKeyName());
|
System.out.println("Category " + p.getKeyName());
|
||||||
for(PoiFilter f : p.getPoiFilters()) {
|
for (PoiFilter f : p.getPoiFilters()) {
|
||||||
System.out.println(" Filter " + f.getKeyName());
|
System.out.println(" Filter " + f.getKeyName());
|
||||||
print(" ", f);
|
print(" ", f);
|
||||||
}
|
}
|
||||||
print(" ", p);
|
print(" ", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PoiType getPoiAdditionalByKey(AbstractPoiType p, String name) {
|
private PoiType getPoiAdditionalByKey(AbstractPoiType p, String name) {
|
||||||
List<PoiType> pp = p.getPoiAdditionals();
|
List<PoiType> pp = p.getPoiAdditionals();
|
||||||
if (pp != null) {
|
if (pp != null) {
|
||||||
|
@ -495,11 +496,11 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void print(String indent, PoiFilter f) {
|
private static void print(String indent, PoiFilter f) {
|
||||||
for(PoiType pt : f.getPoiTypes()) {
|
for (PoiType pt : f.getPoiTypes()) {
|
||||||
System.out.println(indent + " Type " + pt.getKeyName() +
|
System.out.println(indent + " Type " + pt.getKeyName() +
|
||||||
(pt.isReference() ? (" -> " + pt.getReferenceType().getCategory().getKeyName() ): ""));
|
(pt.isReference() ? (" -> " + pt.getReferenceType().getCategory().getKeyName()) : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,20 +510,20 @@ public class MapPoiTypes {
|
||||||
// print(DEFAULT_INSTANCE) ;
|
// print(DEFAULT_INSTANCE) ;
|
||||||
// System.out.println("-----------------");
|
// System.out.println("-----------------");
|
||||||
List<PoiFilter> lf = DEFAULT_INSTANCE.getTopVisibleFilters();
|
List<PoiFilter> lf = DEFAULT_INSTANCE.getTopVisibleFilters();
|
||||||
for(PoiFilter l : lf) {
|
for (PoiFilter l : lf) {
|
||||||
System.out.println("----------------- " + l.getKeyName());
|
System.out.println("----------------- " + l.getKeyName());
|
||||||
// print("", l);
|
// print("", l);
|
||||||
Map<PoiCategory, LinkedHashSet<String>> m =
|
Map<PoiCategory, LinkedHashSet<String>> m =
|
||||||
l.putTypes(new LinkedHashMap<PoiCategory, LinkedHashSet<String>>());
|
l.putTypes(new LinkedHashMap<PoiCategory, LinkedHashSet<String>>());
|
||||||
// System.out.println(m);
|
// System.out.println(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTranslation(AbstractPoiType abstractPoiType) {
|
public String getTranslation(AbstractPoiType abstractPoiType) {
|
||||||
if(poiTranslator != null) {
|
if (poiTranslator != null) {
|
||||||
String translation = poiTranslator.getTranslation(abstractPoiType);
|
String translation = poiTranslator.getTranslation(abstractPoiType);
|
||||||
if(!Algorithms.isEmpty(translation)) {
|
if (!Algorithms.isEmpty(translation)) {
|
||||||
return translation;
|
return translation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,21 +535,21 @@ public class MapPoiTypes {
|
||||||
return getPoiCategoryByName(t.getKeyName()) != otherCategory;
|
return getPoiCategoryByName(t.getKeyName()) != otherCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Map<String, PoiType> poiTypesByTag = new LinkedHashMap<String, PoiType>();
|
Map<String, PoiType> poiTypesByTag = new LinkedHashMap<String, PoiType>();
|
||||||
|
|
||||||
public void initPoiTypesByTag() {
|
public void initPoiTypesByTag() {
|
||||||
if(!poiTypesByTag.isEmpty()) {
|
if (!poiTypesByTag.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(PoiCategory poic : categories) {
|
for (PoiCategory poic : categories) {
|
||||||
for(PoiType p : poic.getPoiTypes()) {
|
for (PoiType p : poic.getPoiTypes()) {
|
||||||
initPoiType(p);
|
initPoiType(p);
|
||||||
for(PoiType pts : p.getPoiAdditionals()) {
|
for (PoiType pts : p.getPoiAdditionals()) {
|
||||||
initPoiType(pts);
|
initPoiType(pts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(PoiType p : poic.getPoiAdditionals()) {
|
for (PoiType p : poic.getPoiAdditionals()) {
|
||||||
initPoiType(p);
|
initPoiType(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,76 +557,76 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
|
|
||||||
private void initPoiType(PoiType p) {
|
private void initPoiType(PoiType p) {
|
||||||
if(!p.isReference()) {
|
if (!p.isReference()) {
|
||||||
String key = null;
|
String key = null;
|
||||||
if(p.isAdditional()) {
|
if (p.isAdditional()) {
|
||||||
key = p.isText() ? p.getOsmTag() :
|
key = p.isText() ? p.getOsmTag() :
|
||||||
(p.getOsmTag() + "/" + p.getOsmValue());
|
(p.getOsmTag() + "/" + p.getOsmValue());
|
||||||
} else {
|
} else {
|
||||||
key = p.getOsmTag() + "/" + p.getOsmValue();
|
key = p.getOsmTag() + "/" + p.getOsmValue();
|
||||||
}
|
}
|
||||||
if(poiTypesByTag.containsKey(key)) {
|
if (poiTypesByTag.containsKey(key)) {
|
||||||
throw new UnsupportedOperationException("!! Duplicate poi type " + key);
|
throw new UnsupportedOperationException("!! Duplicate poi type " + key);
|
||||||
}
|
}
|
||||||
poiTypesByTag.put(key, p);
|
poiTypesByTag.put(key, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Amenity parseAmenity(String tag, String val, boolean relation, Map<String, String> otherTags) {
|
public Amenity parseAmenity(String tag, String val, boolean relation, Map<String, String> otherTags) {
|
||||||
initPoiTypesByTag();
|
initPoiTypesByTag();
|
||||||
PoiType pt = poiTypesByTag.get(tag+"/"+val);
|
PoiType pt = poiTypesByTag.get(tag + "/" + val);
|
||||||
if(pt == null) {
|
if (pt == null) {
|
||||||
pt = poiTypesByTag.get(tag);
|
pt = poiTypesByTag.get(tag);
|
||||||
}
|
}
|
||||||
if(pt == null || pt.isAdditional()) {
|
if (pt == null || pt.isAdditional()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(!Algorithms.isEmpty(pt.getOsmTag2())) {
|
if (!Algorithms.isEmpty(pt.getOsmTag2())) {
|
||||||
if(!Algorithms.objectEquals(otherTags.get(pt.getOsmTag2()), pt.getOsmValue2())) {
|
if (!Algorithms.objectEquals(otherTags.get(pt.getOsmTag2()), pt.getOsmValue2())) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pt.getCategory() == getOtherMapCategory()) {
|
if (pt.getCategory() == getOtherMapCategory()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String nameValue = otherTags.get("name");
|
String nameValue = otherTags.get("name");
|
||||||
if(pt.getNameTag() != null) {
|
if (pt.getNameTag() != null) {
|
||||||
nameValue = otherTags.get(pt.getNameTag());
|
nameValue = otherTags.get(pt.getNameTag());
|
||||||
}
|
}
|
||||||
boolean hasName = !Algorithms.isEmpty(nameValue);
|
boolean hasName = !Algorithms.isEmpty(nameValue);
|
||||||
if(!hasName && pt.isNameOnly()) {
|
if (!hasName && pt.isNameOnly()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(relation && !pt.isRelation()) {
|
if (relation && !pt.isRelation()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Amenity a = new Amenity();
|
Amenity a = new Amenity();
|
||||||
a.setType(pt.getCategory());
|
a.setType(pt.getCategory());
|
||||||
a.setSubType(pt.getKeyName());
|
a.setSubType(pt.getKeyName());
|
||||||
if(pt.getNameTag() != null) {
|
if (pt.getNameTag() != null) {
|
||||||
a.setName(nameValue);
|
a.setName(nameValue);
|
||||||
}
|
}
|
||||||
// additional info
|
// additional info
|
||||||
Iterator<Entry<String, String>> it = otherTags.entrySet().iterator();
|
Iterator<Entry<String, String>> it = otherTags.entrySet().iterator();
|
||||||
while(it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Entry<String, String> e = it.next();
|
Entry<String, String> e = it.next();
|
||||||
String otag = e.getKey();
|
String otag = e.getKey();
|
||||||
if(!otag.equals(tag) && !otag.equals("name")) {
|
if (!otag.equals(tag) && !otag.equals("name")) {
|
||||||
PoiType pat = poiTypesByTag.get(otag+"/"+e.getValue());
|
PoiType pat = poiTypesByTag.get(otag + "/" + e.getValue());
|
||||||
if(pat == null) {
|
if (pat == null) {
|
||||||
pat = poiTypesByTag.get(otag);
|
pat = poiTypesByTag.get(otag);
|
||||||
}
|
}
|
||||||
if(pat != null && pat.isAdditional()) {
|
if (pat != null && pat.isAdditional()) {
|
||||||
a.setAdditionalInfo(pat.getKeyName(), e.getValue());
|
a.setAdditionalInfo(pat.getKeyName(), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTextAdditionalInfo(String key, String value) {
|
public boolean isTextAdditionalInfo(String key, String value) {
|
||||||
if (key.startsWith("name:") || key.equals("name")) {
|
if (key.startsWith("name:") || key.equals("name")) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue