EFA: Silently ignore coordinates on other systems than WGS84.

This commit is contained in:
Andreas Schildbach 2016-10-28 16:46:55 +02:00
parent 40763ef6f6
commit e48a68a240

View file

@ -554,7 +554,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
XmlPullUtil.enter(pp, "coordInfoItem"); XmlPullUtil.enter(pp, "coordInfoItem");
// FIXME this is always only one coordinate // FIXME this is always only one coordinate
final Point coord = processItdPathCoordinates(pp).get(0); final List<Point> path = processItdPathCoordinates(pp);
final Point coord = path != null ? path.get(0) : null;
XmlPullUtil.skipExit(pp, "coordInfoItem"); 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; final Point coords;
if (!"::".equals(coord)) { if (!"::".equals(coordPart)) {
final String[] coordParts = coord.split(":"); final String[] coordParts = coordPart.split(":");
if (!"WGS84".equals(coordParts[2])) if ("WGS84".equals(coordParts[2])) {
throw new IllegalStateException("unknown map name: " + coordParts[2]);
final double lat = Double.parseDouble(coordParts[1]); final double lat = Double.parseDouble(coordParts[1]);
final double lon = Double.parseDouble(coordParts[0]); final double lon = Double.parseDouble(coordParts[0]);
location = new Location(LocationType.STATION, id, Point.fromDouble(lat, lon), coords = Point.fromDouble(lat, lon);
null, name);
} else { } else {
location = new Location(LocationType.STATION, id, null, name); coords = null;
} }
} else {
coords = null;
}
final Location location = new Location(LocationType.STATION, id, coords, null,
name);
final Date plannedTime = plannedTimeCal.isSet(Calendar.HOUR_OF_DAY) final Date plannedTime = plannedTimeCal.isSet(Calendar.HOUR_OF_DAY)
? plannedTimeCal.getTime() : null; ? plannedTimeCal.getTime() : null;
@ -2933,16 +2937,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
private List<Point> processItdPathCoordinates(final XmlPullParser pp) throws XmlPullParserException, IOException { private List<Point> processItdPathCoordinates(final XmlPullParser pp) throws XmlPullParserException, IOException {
XmlPullUtil.enter(pp, "itdPathCoordinates"); XmlPullUtil.enter(pp, "itdPathCoordinates");
final List<Point> path;
final String ellipsoid = XmlPullUtil.valueTag(pp, "coordEllipsoid"); final String ellipsoid = XmlPullUtil.valueTag(pp, "coordEllipsoid");
if (!"WGS84".equals(ellipsoid)) if ("WGS84".equals(ellipsoid)) {
throw new IllegalStateException("unknown ellipsoid: " + ellipsoid);
final String type = XmlPullUtil.valueTag(pp, "coordType"); final String type = XmlPullUtil.valueTag(pp, "coordType");
if (!"GEO_DECIMAL".equals(type)) if (!"GEO_DECIMAL".equals(type))
throw new IllegalStateException("unknown type: " + type); throw new IllegalStateException("unknown type: " + type);
final List<Point> path;
if (XmlPullUtil.test(pp, "itdCoordinateString")) { if (XmlPullUtil.test(pp, "itdCoordinateString")) {
path = processCoordinateStrings(pp, "itdCoordinateString"); path = processCoordinateStrings(pp, "itdCoordinateString");
} else if (XmlPullUtil.test(pp, "itdCoordinateBaseElemList")) { } else if (XmlPullUtil.test(pp, "itdCoordinateBaseElemList")) {
@ -2950,9 +2951,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
} else { } else {
throw new IllegalStateException(pp.getPositionDescription()); throw new IllegalStateException(pp.getPositionDescription());
} }
} else {
return null;
}
XmlPullUtil.skipExit(pp, "itdPathCoordinates"); XmlPullUtil.skipExit(pp, "itdPathCoordinates");
return path; return path;
} }
@ -3006,7 +3009,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider {
return null; return null;
if (!"WGS84".equals(mapName)) if (!"WGS84".equals(mapName))
throw new IllegalStateException("unknown mapName=" + mapName); return null;
return new Point(y, x); return new Point(y, x);
} }