Fix map poi types

This commit is contained in:
Victor Shcherb 2020-05-22 14:57:55 +02:00
parent 0849f7751e
commit 88a6d62080

View file

@ -29,6 +29,7 @@ import java.util.TreeSet;
public class MapPoiTypes {
private static final String OTHER_MAP_CATEGORY = "Other";
private static MapPoiTypes DEFAULT_INSTANCE = null;
private static final Log log = PlatformUtil.getLog(MapRenderingTypes.class);
private String resourceName;
@ -96,7 +97,7 @@ public class MapPoiTypes {
public PoiCategory getOtherMapCategory() {
if (otherMapCategory == null) {
otherMapCategory = getPoiCategoryByName("Other", true);
otherMapCategory = getPoiCategoryByName(OTHER_MAP_CATEGORY, true);
}
return otherMapCategory;
}
@ -111,7 +112,8 @@ public class MapPoiTypes {
public List<AbstractPoiType> getTopVisibleFilters() {
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()) {
lf.add(pc);
}
@ -131,7 +133,8 @@ public class MapPoiTypes {
}
public PoiCategory getOsmwiki() {
for (PoiCategory category : categories) {
for (int i = 0; i < categories.size(); i++) {
PoiCategory category = categories.get(i);
if (category.isWiki()) {
return category;
}
@ -167,7 +170,8 @@ public class MapPoiTypes {
}
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);
if (pt != null && !pt.isReference()) {
return pt;
@ -184,7 +188,8 @@ public class MapPoiTypes {
}
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)) {
return pc;
}
@ -203,7 +208,8 @@ public class MapPoiTypes {
public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) {
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()) {
continue;
}
@ -231,7 +237,8 @@ public class MapPoiTypes {
public List<AbstractPoiType> getAllTypesTranslatedNames(StringMatcher matcher) {
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) {
continue;
}
@ -294,7 +301,7 @@ public class MapPoiTypes {
}
if (create) {
PoiCategory lastCategory = new PoiCategory(this, name, categories.size());
if (!lastCategory.getKeyName().equals("Other")) {
if (!lastCategory.getKeyName().equals(OTHER_MAP_CATEGORY)) {
lastCategory.setTopVisible(true);
}
addCategory(lastCategory);
@ -365,6 +372,8 @@ public class MapPoiTypes {
PoiType lastType = null;
Set<String> lastTypePoiAdditionalsCategories = new TreeSet<String>();
String lastPoiAdditionalCategory = null;
PoiCategory localOtherMapCategory = new PoiCategory(this, OTHER_MAP_CATEGORY, categoriesList.size());
categoriesList.add(localOtherMapCategory);
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
if (tok == XmlPullParser.START_TAG) {
String name = parser.getName();
@ -404,7 +413,7 @@ public class MapPoiTypes {
lastCategory.addPoiType(tp);
} else if (name.equals("poi_additional")) {
if (lastCategory == null) {
lastCategory = getOtherMapCategory();
lastCategory = localOtherMapCategory;
}
PoiType baseType = parsePoiAdditional(parser, lastCategory, lastFilter, lastType, null, null, lastPoiAdditionalCategory);
if ("true".equals(parser.getAttributeValue("", "lang"))) {
@ -433,7 +442,7 @@ public class MapPoiTypes {
} else if (name.equals("poi_type")) {
if (lastCategory == null) {
lastCategory = getOtherMapCategory();
lastCategory = localOtherMapCategory;
}
if(!Algorithms.isEmpty(parser.getAttributeValue("", "deprecated_of"))){
String vl = parser.getAttributeValue("", "name");
@ -705,7 +714,8 @@ public class MapPoiTypes {
public AbstractPoiType getAnyPoiAdditionalTypeByKey(String name) {
PoiType add = null;
for (PoiCategory pc : categories) {
for (int i = 0; i < categories.size(); i++) {
PoiCategory pc = categories.get(i);
add = getPoiAdditionalByKey(pc, name);
if (add != null) {
return add;
@ -811,7 +821,8 @@ public class MapPoiTypes {
if (!poiTypesByTag.isEmpty()) {
return;
}
for (PoiCategory poic : categories) {
for (int i = 0; i < categories.size(); i++) {
PoiCategory poic = categories.get(i);
for (PoiType p : poic.getPoiTypes()) {
initPoiType(p);
for (PoiType pts : p.getPoiAdditionals()) {