From 89da3a9bbafc69a47e8713f6983f17908f8bffdd Mon Sep 17 00:00:00 2001 From: "andreas.schildbach" Date: Tue, 5 Oct 2010 11:23:51 +0000 Subject: [PATCH] fixed own station parsing git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@240 0924bc21-9374-b0fa-ee44-9ff1593b38f0 --- .../schildbach/pte/AbstractEfaProvider.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/de/schildbach/pte/AbstractEfaProvider.java b/src/de/schildbach/pte/AbstractEfaProvider.java index 04e43068..31604494 100644 --- a/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/src/de/schildbach/pte/AbstractEfaProvider.java @@ -117,20 +117,25 @@ public abstract class AbstractEfaProvider implements NetworkProvider { final List stations = new ArrayList(); + Station ownStation = null; XmlPullUtil.jumpToStartTag(pp, null, "odvNameElem"); - final String parsedOwnLocationIdStr = pp.getAttributeValue(null, "stopID"); + String parsedOwnLocationIdStr = pp.getAttributeValue(null, "stopID"); + if (parsedOwnLocationIdStr == null) + parsedOwnLocationIdStr = pp.getAttributeValue(null, "id"); if (parsedOwnLocationIdStr != null) { final int parsedOwnLocationId = Integer.parseInt(parsedOwnLocationIdStr); - final String parsedOwnMapName = pp.getAttributeValue(null, "mapName"); - if (parsedOwnMapName != null) + int parsedOwnLat = 0, parsedOwnLon = 0; + final String mapName = pp.getAttributeValue(null, "mapName"); + if (mapName != null) { - if (!"WGS84".equals(parsedOwnMapName)) - throw new IllegalStateException("unknown mapName: " + parsedOwnMapName); - final int parsedOwnLon = Integer.parseInt(pp.getAttributeValue(null, "x")); - final int parsedOwnLat = Integer.parseInt(pp.getAttributeValue(null, "y")); - stations.add(new Station(parsedOwnLocationId, null, parsedOwnLat, parsedOwnLon, 0, null, null)); + if (!"WGS84".equals(mapName)) + throw new IllegalStateException("unknown mapName: " + mapName); + parsedOwnLon = Integer.parseInt(pp.getAttributeValue(null, "x")); + parsedOwnLat = Integer.parseInt(pp.getAttributeValue(null, "y")); } + final String parsedOwnLocation = normalizeLocationName(pp.nextText()); // FIXME evtl. nur optional? + ownStation = new Station(parsedOwnLocationId, parsedOwnLocation, parsedOwnLat, parsedOwnLon, 0, null, null); } if (XmlPullUtil.jumpToStartTag(pp, null, "itdOdvAssignedStops")) @@ -150,13 +155,18 @@ public abstract class AbstractEfaProvider implements NetworkProvider final String parsedDistStr = pp.getAttributeValue(null, "distance"); final int parsedDist = parsedDistStr != null ? Integer.parseInt(parsedDistStr) : 0; - stations.add(new Station(parsedLocationId, parsedName, parsedLat, parsedLon, parsedDist, null, null)); + final Station newStation = new Station(parsedLocationId, parsedName, parsedLat, parsedLon, parsedDist, null, null); + if (!stations.contains(newStation)) + stations.add(newStation); XmlPullUtil.skipRestOfTree(pp); } } } + if (ownStation != null && !stations.contains(ownStation)) + stations.add(ownStation); + if (maxStations == 0 || maxStations >= stations.size()) return new NearbyStationsResult(uri, stations); else