use ID parameters for connection queries, rather than A and G

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@321 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-10-24 17:44:05 +00:00
parent f3c0a54272
commit 5711f7ea3a
4 changed files with 65 additions and 117 deletions

View file

@ -547,7 +547,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
throw new IllegalArgumentException("cannot parse duration: " + str);
}
private final String location(final Location location)
private static final String location(final Location location)
{
if (location.type == LocationType.STATION && location.id != 0)
return "<Station externalId=\"" + location.id + "\" />";
@ -559,6 +559,34 @@ public abstract class AbstractHafasProvider implements NetworkProvider
throw new IllegalArgumentException("cannot handle: " + location.toDebugString());
}
protected static final String locationId(final Location location)
{
final StringBuilder builder = new StringBuilder();
builder.append("A=").append(locationType(location));
if (location.lat != 0 || location.lon != 0)
builder.append("@X=" + location.lon + "@Y=" + location.lat);
if (location.name != null)
builder.append("@G=" + location.name);
if (location.type == LocationType.STATION && location.id != 0)
builder.append("@L=").append(location.id);
return builder.toString();
}
protected static final int locationType(final Location location)
{
if (location.type == LocationType.STATION)
return 1;
if (location.type == LocationType.POI)
return 4;
if (location.type == LocationType.ADDRESS && (location.lat != 0 || location.lon != 0))
return 16;
if (location.type == LocationType.ADDRESS && location.name != null)
return 2;
if (location.type == LocationType.ANY)
return 255;
throw new IllegalArgumentException(location.type.toString());
}
private static final Pattern P_LINE_S = Pattern.compile("SN?\\d+");
private final String _normalizeLine(final String type, final String name, final String longCategory)