Changed init of MapPoiTypes
This commit is contained in:
parent
2cfdbf9a9b
commit
93101c5573
1 changed files with 22 additions and 16 deletions
|
@ -275,24 +275,37 @@ public class MapPoiTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(String resourceName) {
|
public void init(String resourceName) {
|
||||||
InputStream is;
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
List<PoiType> referenceTypes = new ArrayList<PoiType>();
|
|
||||||
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
|
||||||
final Map<String, List<PoiType>> categoryPoiAdditionalMap = new LinkedHashMap<String, List<PoiType>>();
|
|
||||||
final Map<AbstractPoiType, Set<String>> abstractTypeAdditionalCategories = new LinkedHashMap<AbstractPoiType, Set<String>>();
|
|
||||||
final Map<String, AbstractPoiType> additionalCategoryOriginMap = new LinkedHashMap<String, AbstractPoiType>();
|
|
||||||
if (resourceName != null) {
|
if (resourceName != null) {
|
||||||
this.resourceName = resourceName;
|
this.resourceName = resourceName;
|
||||||
}
|
}
|
||||||
this.categories.clear();
|
|
||||||
try {
|
try {
|
||||||
|
InputStream is;
|
||||||
if (this.resourceName == null) {
|
if (this.resourceName == null) {
|
||||||
is = MapPoiTypes.class.getResourceAsStream("poi_types.xml"); //$NON-NLS-1$
|
is = MapPoiTypes.class.getResourceAsStream("poi_types.xml"); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
is = new FileInputStream(this.resourceName);
|
is = new FileInputStream(this.resourceName);
|
||||||
}
|
}
|
||||||
time = System.currentTimeMillis();
|
initFromInputStream(is);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Unexpected error", e); //$NON-NLS-1$
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
log.error("Unexpected error", e); //$NON-NLS-1$
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initFromInputStream(InputStream is) {
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
List<PoiType> referenceTypes = new ArrayList<PoiType>();
|
||||||
|
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
||||||
|
final Map<String, List<PoiType>> categoryPoiAdditionalMap = new LinkedHashMap<String, List<PoiType>>();
|
||||||
|
final Map<AbstractPoiType, Set<String>> abstractTypeAdditionalCategories = new LinkedHashMap<AbstractPoiType, Set<String>>();
|
||||||
|
this.categories.clear();
|
||||||
|
try {
|
||||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||||
int tok;
|
int tok;
|
||||||
parser.setInput(is, "UTF-8");
|
parser.setInput(is, "UTF-8");
|
||||||
|
@ -367,13 +380,6 @@ public class MapPoiTypes {
|
||||||
if (!Algorithms.isEmpty(icon)) {
|
if (!Algorithms.isEmpty(icon)) {
|
||||||
poiAdditionalCategoryIcons.put(lastPoiAdditionalCategory, icon);
|
poiAdditionalCategoryIcons.put(lastPoiAdditionalCategory, icon);
|
||||||
}
|
}
|
||||||
if (lastType != null) {
|
|
||||||
additionalCategoryOriginMap.put(lastPoiAdditionalCategory, lastType);
|
|
||||||
} else if (lastFilter != null) {
|
|
||||||
additionalCategoryOriginMap.put(lastPoiAdditionalCategory, lastFilter);
|
|
||||||
} else if (lastCategory != null) {
|
|
||||||
additionalCategoryOriginMap.put(lastPoiAdditionalCategory, lastCategory);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (name.equals("poi_type")) {
|
} else if (name.equals("poi_type")) {
|
||||||
|
|
Loading…
Reference in a new issue