From e48a68a2404afdf327c0b8f07f6b51456fcf4388 Mon Sep 17 00:00:00 2001 From: Andreas Schildbach Date: Fri, 28 Oct 2016 16:46:55 +0200 Subject: [PATCH] EFA: Silently ignore coordinates on other systems than WGS84. --- .../schildbach/pte/AbstractEfaProvider.java | 57 ++++++++++--------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java index 5d6e19ad..31cb9cb8 100644 --- a/enabler/src/de/schildbach/pte/AbstractEfaProvider.java +++ b/enabler/src/de/schildbach/pte/AbstractEfaProvider.java @@ -554,7 +554,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { XmlPullUtil.enter(pp, "coordInfoItem"); // FIXME this is always only one coordinate - final Point coord = processItdPathCoordinates(pp).get(0); + final List path = processItdPathCoordinates(pp); + final Point coord = path != null ? path.get(0) : null; XmlPullUtil.skipExit(pp, "coordInfoItem"); @@ -2828,20 +2829,23 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { } } } - final String coord = intermediateParts[4]; + final String coordPart = intermediateParts[4]; - final Location location; - if (!"::".equals(coord)) { - final String[] coordParts = coord.split(":"); - if (!"WGS84".equals(coordParts[2])) - throw new IllegalStateException("unknown map name: " + coordParts[2]); - final double lat = Double.parseDouble(coordParts[1]); - final double lon = Double.parseDouble(coordParts[0]); - location = new Location(LocationType.STATION, id, Point.fromDouble(lat, lon), - null, name); + final Point coords; + if (!"::".equals(coordPart)) { + final String[] coordParts = coordPart.split(":"); + if ("WGS84".equals(coordParts[2])) { + final double lat = Double.parseDouble(coordParts[1]); + final double lon = Double.parseDouble(coordParts[0]); + coords = Point.fromDouble(lat, lon); + } else { + coords = null; + } } else { - location = new Location(LocationType.STATION, id, null, name); + coords = null; } + final Location location = new Location(LocationType.STATION, id, coords, null, + name); final Date plannedTime = plannedTimeCal.isSet(Calendar.HOUR_OF_DAY) ? plannedTimeCal.getTime() : null; @@ -2933,26 +2937,25 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { private List processItdPathCoordinates(final XmlPullParser pp) throws XmlPullParserException, IOException { XmlPullUtil.enter(pp, "itdPathCoordinates"); + final List path; final String ellipsoid = XmlPullUtil.valueTag(pp, "coordEllipsoid"); - if (!"WGS84".equals(ellipsoid)) - throw new IllegalStateException("unknown ellipsoid: " + ellipsoid); - - final String type = XmlPullUtil.valueTag(pp, "coordType"); - if (!"GEO_DECIMAL".equals(type)) - throw new IllegalStateException("unknown type: " + type); - - final List path; - if (XmlPullUtil.test(pp, "itdCoordinateString")) { - path = processCoordinateStrings(pp, "itdCoordinateString"); - } else if (XmlPullUtil.test(pp, "itdCoordinateBaseElemList")) { - path = processCoordinateBaseElems(pp); + if ("WGS84".equals(ellipsoid)) { + final String type = XmlPullUtil.valueTag(pp, "coordType"); + if (!"GEO_DECIMAL".equals(type)) + throw new IllegalStateException("unknown type: " + type); + if (XmlPullUtil.test(pp, "itdCoordinateString")) { + path = processCoordinateStrings(pp, "itdCoordinateString"); + } else if (XmlPullUtil.test(pp, "itdCoordinateBaseElemList")) { + path = processCoordinateBaseElems(pp); + } else { + throw new IllegalStateException(pp.getPositionDescription()); + } } else { - throw new IllegalStateException(pp.getPositionDescription()); + return null; } XmlPullUtil.skipExit(pp, "itdPathCoordinates"); - return path; } @@ -3006,7 +3009,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider { return null; if (!"WGS84".equals(mapName)) - throw new IllegalStateException("unknown mapName=" + mapName); + return null; return new Point(y, x); }