Fix map poi types
This commit is contained in:
parent
0849f7751e
commit
88a6d62080
1 changed files with 23 additions and 12 deletions
|
@ -29,6 +29,7 @@ import java.util.TreeSet;
|
||||||
|
|
||||||
|
|
||||||
public class MapPoiTypes {
|
public class MapPoiTypes {
|
||||||
|
private static final String OTHER_MAP_CATEGORY = "Other";
|
||||||
private static MapPoiTypes DEFAULT_INSTANCE = null;
|
private static MapPoiTypes DEFAULT_INSTANCE = null;
|
||||||
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
|
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
|
||||||
private String resourceName;
|
private String resourceName;
|
||||||
|
@ -96,7 +97,7 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
public PoiCategory getOtherMapCategory() {
|
public PoiCategory getOtherMapCategory() {
|
||||||
if (otherMapCategory == null) {
|
if (otherMapCategory == null) {
|
||||||
otherMapCategory = getPoiCategoryByName("Other", true);
|
otherMapCategory = getPoiCategoryByName(OTHER_MAP_CATEGORY, true);
|
||||||
}
|
}
|
||||||
return otherMapCategory;
|
return otherMapCategory;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +112,8 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
public List<AbstractPoiType> getTopVisibleFilters() {
|
public List<AbstractPoiType> getTopVisibleFilters() {
|
||||||
List<AbstractPoiType> lf = new ArrayList<AbstractPoiType>();
|
List<AbstractPoiType> lf = new ArrayList<AbstractPoiType>();
|
||||||
for (PoiCategory pc : categories) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory pc = categories.get(i);
|
||||||
if (pc.isTopVisible()) {
|
if (pc.isTopVisible()) {
|
||||||
lf.add(pc);
|
lf.add(pc);
|
||||||
}
|
}
|
||||||
|
@ -131,7 +133,8 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiCategory getOsmwiki() {
|
public PoiCategory getOsmwiki() {
|
||||||
for (PoiCategory category : categories) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory category = categories.get(i);
|
||||||
if (category.isWiki()) {
|
if (category.isWiki()) {
|
||||||
return category;
|
return category;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +170,8 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PoiType getPoiTypeByKey(String name) {
|
public PoiType getPoiTypeByKey(String name) {
|
||||||
for (PoiCategory pc : categories) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory pc = categories.get(i);
|
||||||
PoiType pt = pc.getPoiTypeByKeyName(name);
|
PoiType pt = pc.getPoiTypeByKeyName(name);
|
||||||
if (pt != null && !pt.isReference()) {
|
if (pt != null && !pt.isReference()) {
|
||||||
return pt;
|
return pt;
|
||||||
|
@ -184,7 +188,8 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractPoiType getAnyPoiTypeByKey(String name) {
|
public AbstractPoiType getAnyPoiTypeByKey(String name) {
|
||||||
for (PoiCategory pc : categories) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory pc = categories.get(i);
|
||||||
if (pc.getKeyName().equals(name)) {
|
if (pc.getKeyName().equals(name)) {
|
||||||
return pc;
|
return pc;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +208,8 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
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 (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory pc = categories.get(i);
|
||||||
if (skipNonEditable && pc.isNotEditableOsm()) {
|
if (skipNonEditable && pc.isNotEditableOsm()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +237,8 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
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 (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory pc = categories.get(i);
|
||||||
if (pc == otherMapCategory) {
|
if (pc == otherMapCategory) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +301,7 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
if (create) {
|
if (create) {
|
||||||
PoiCategory lastCategory = new PoiCategory(this, name, categories.size());
|
PoiCategory lastCategory = new PoiCategory(this, name, categories.size());
|
||||||
if (!lastCategory.getKeyName().equals("Other")) {
|
if (!lastCategory.getKeyName().equals(OTHER_MAP_CATEGORY)) {
|
||||||
lastCategory.setTopVisible(true);
|
lastCategory.setTopVisible(true);
|
||||||
}
|
}
|
||||||
addCategory(lastCategory);
|
addCategory(lastCategory);
|
||||||
|
@ -365,6 +372,8 @@ public class MapPoiTypes {
|
||||||
PoiType lastType = null;
|
PoiType lastType = null;
|
||||||
Set<String> lastTypePoiAdditionalsCategories = new TreeSet<String>();
|
Set<String> lastTypePoiAdditionalsCategories = new TreeSet<String>();
|
||||||
String lastPoiAdditionalCategory = null;
|
String lastPoiAdditionalCategory = null;
|
||||||
|
PoiCategory localOtherMapCategory = new PoiCategory(this, OTHER_MAP_CATEGORY, categoriesList.size());
|
||||||
|
categoriesList.add(localOtherMapCategory);
|
||||||
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||||
if (tok == XmlPullParser.START_TAG) {
|
if (tok == XmlPullParser.START_TAG) {
|
||||||
String name = parser.getName();
|
String name = parser.getName();
|
||||||
|
@ -404,7 +413,7 @@ 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 = localOtherMapCategory;
|
||||||
}
|
}
|
||||||
PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null, lastPoiAdditionalCategory);
|
PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null, lastPoiAdditionalCategory);
|
||||||
if ("true".equals(parser.getAttributeValue("", "lang"))) {
|
if ("true".equals(parser.getAttributeValue("", "lang"))) {
|
||||||
|
@ -433,7 +442,7 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
} else if (name.equals("poi_type")) {
|
} else if (name.equals("poi_type")) {
|
||||||
if (lastCategory == null) {
|
if (lastCategory == null) {
|
||||||
lastCategory = getOtherMapCategory();
|
lastCategory = localOtherMapCategory;
|
||||||
}
|
}
|
||||||
if(!Algorithms.isEmpty(parser.getAttributeValue("", "deprecated_of"))){
|
if(!Algorithms.isEmpty(parser.getAttributeValue("", "deprecated_of"))){
|
||||||
String vl = parser.getAttributeValue("", "name");
|
String vl = parser.getAttributeValue("", "name");
|
||||||
|
@ -705,7 +714,8 @@ public class MapPoiTypes {
|
||||||
|
|
||||||
public AbstractPoiType getAnyPoiAdditionalTypeByKey(String name) {
|
public AbstractPoiType getAnyPoiAdditionalTypeByKey(String name) {
|
||||||
PoiType add = null;
|
PoiType add = null;
|
||||||
for (PoiCategory pc : categories) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory pc = categories.get(i);
|
||||||
add = getPoiAdditionalByKey(pc, name);
|
add = getPoiAdditionalByKey(pc, name);
|
||||||
if (add != null) {
|
if (add != null) {
|
||||||
return add;
|
return add;
|
||||||
|
@ -811,7 +821,8 @@ public class MapPoiTypes {
|
||||||
if (!poiTypesByTag.isEmpty()) {
|
if (!poiTypesByTag.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (PoiCategory poic : categories) {
|
for (int i = 0; i < categories.size(); i++) {
|
||||||
|
PoiCategory poic = categories.get(i);
|
||||||
for (PoiType p : poic.getPoiTypes()) {
|
for (PoiType p : poic.getPoiTypes()) {
|
||||||
initPoiType(p);
|
initPoiType(p);
|
||||||
for (PoiType pts : p.getPoiAdditionals()) {
|
for (PoiType pts : p.getPoiAdditionals()) {
|
||||||
|
|
Loading…
Reference in a new issue