Improved type determination in processing of odvNameElems

This commit is contained in:
Andreas Schildbach 2013-08-29 15:46:40 +02:00
parent d2cd0b6603
commit b63b261f34

View file

@ -789,8 +789,8 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y); throw new IllegalStateException("unknown mapName=" + mapName + " x=" + x + " y=" + y);
} }
LocationType type; final LocationType type;
int id; final int id;
if ("stop".equals(anyType)) if ("stop".equals(anyType))
{ {
type = LocationType.STATION; type = LocationType.STATION;
@ -812,29 +812,36 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
type = LocationType.ADDRESS; type = LocationType.ADDRESS;
id = 0; id = 0;
} }
else if (stopIdStr != null) else if (anyType == null || "unknown".equals(anyType))
{ {
type = LocationType.STATION; if (stopIdStr != null)
id = Integer.parseInt(stopIdStr); {
} type = LocationType.STATION;
else if (poiIdStr != null) id = Integer.parseInt(stopIdStr);
{ }
type = LocationType.POI; else if (poiIdStr != null)
id = Integer.parseInt(poiIdStr); {
} type = LocationType.POI;
else if (stopIdStr == null && idStr == null && (lat != 0 || lon != 0)) id = Integer.parseInt(poiIdStr);
{ }
type = LocationType.ADDRESS; else if (streetIdStr != null)
id = 0; {
} type = LocationType.ADDRESS;
else if (streetIdStr != null) id = Integer.parseInt(streetIdStr);
{ }
type = LocationType.ADDRESS; else if (lat != 0 || lon != 0)
id = Integer.parseInt(streetIdStr); {
type = LocationType.ADDRESS;
id = 0;
}
else
{
throw new IllegalArgumentException("cannot substitute type");
}
} }
else else
{ {
throw new IllegalArgumentException("unknown type: " + anyType + " " + idStr + " " + stopIdStr); throw new IllegalArgumentException("unknown type: " + anyType);
} }
XmlPullUtil.enter(pp, "odvNameElem"); XmlPullUtil.enter(pp, "odvNameElem");