diff --git a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java index 3a22556b06..73256ca461 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java @@ -275,24 +275,37 @@ public class MapPoiTypes { } public void init(String resourceName) { - InputStream is; - long time = System.currentTimeMillis(); - List referenceTypes = new ArrayList(); - final Map allTypes = new LinkedHashMap(); - final Map> categoryPoiAdditionalMap = new LinkedHashMap>(); - final Map> abstractTypeAdditionalCategories = new LinkedHashMap>(); - final Map additionalCategoryOriginMap = new LinkedHashMap(); if (resourceName != null) { this.resourceName = resourceName; } - this.categories.clear(); try { + InputStream is; if (this.resourceName == null) { is = MapPoiTypes.class.getResourceAsStream("poi_types.xml"); //$NON-NLS-1$ } else { 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 referenceTypes = new ArrayList(); + final Map allTypes = new LinkedHashMap(); + final Map> categoryPoiAdditionalMap = new LinkedHashMap>(); + final Map> abstractTypeAdditionalCategories = new LinkedHashMap>(); + this.categories.clear(); + try { XmlPullParser parser = PlatformUtil.newXMLPullParser(); int tok; parser.setInput(is, "UTF-8"); @@ -367,13 +380,6 @@ public class MapPoiTypes { if (!Algorithms.isEmpty(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")) {