From b63b261f34b9ad2247b0be4418fd5e91318dbada Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Thu, 29 Aug 2013 15:46:40 +0200 Subject: [PATCH] Improved type determination in processing of odvNameElems --- .../schildbach/pte/AbstractEfaProvider.java | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index ea958c50..9dfbf5e6 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -789,8 +789,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y); } - LocationType type; - int id; + final LocationType type; + final int id; if ("stop".equals(anyType)) { type = LocationType.STATION; @@ -812,29 +812,36 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider type = LocationType.ADDRESS; id = 0; } - else if (stopIdStr != null) + else if (anyType == null || "unknown".equals(anyType)) { - type = LocationType.STATION; - id = Integer.parseInt(stopIdStr); - } - else if (poiIdStr != null) - { - type = LocationType.POI; - id = Integer.parseInt(poiIdStr); - } - else if (stopIdStr == null && idStr == null && (lat != 0 || lon != 0)) - { - type = LocationType.ADDRESS; - id = 0; - } - else if (streetIdStr != null) - { - type = LocationType.ADDRESS; - id = Integer.parseInt(streetIdStr); + if (stopIdStr != null) + { + type = LocationType.STATION; + id = Integer.parseInt(stopIdStr); + } + else if (poiIdStr != null) + { + type = LocationType.POI; + id = Integer.parseInt(poiIdStr); + } + else if (streetIdStr != null) + { + type = LocationType.ADDRESS; + id = Integer.parseInt(streetIdStr); + } + else if (lat != 0 || lon != 0) + { + type = LocationType.ADDRESS; + id = 0; + } + else + { + throw new IllegalArgumentException("cannot substitute type"); + } } else { - throw new IllegalArgumentException("unknown type: " + anyType + " " + idStr + " " + stopIdStr); + throw new IllegalArgumentException("unknown type: " + anyType); } XmlPullUtil.enter(pp, "odvNameElem");