mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 14:58:49 +00:00
try to preserve full addresses in connection queries
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@684 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
b8592a1740
commit
8b79adddc6
2 changed files with 17 additions and 3 deletions
|
@ -162,7 +162,7 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
||||||
throw new IllegalStateException("cannot handle: " + type);
|
throw new IllegalStateException("cannot handle: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Location parseAddress(final XmlPullParser pp)
|
private final Location parseAddress(final XmlPullParser pp)
|
||||||
{
|
{
|
||||||
final String type = pp.getName();
|
final String type = pp.getName();
|
||||||
if ("Address".equals(type))
|
if ("Address".equals(type))
|
||||||
|
@ -172,7 +172,9 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
||||||
name = null;
|
name = null;
|
||||||
final int x = Integer.parseInt(pp.getAttributeValue(null, "x"));
|
final int x = Integer.parseInt(pp.getAttributeValue(null, "x"));
|
||||||
final int y = Integer.parseInt(pp.getAttributeValue(null, "y"));
|
final int y = Integer.parseInt(pp.getAttributeValue(null, "y"));
|
||||||
return new Location(LocationType.ADDRESS, 0, y, x, null, name);
|
|
||||||
|
final String[] placeAndName = splitPlaceAndName(name);
|
||||||
|
return new Location(LocationType.ADDRESS, 0, y, x, placeAndName[0], placeAndName[1]);
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("cannot handle: " + type);
|
throw new IllegalStateException("cannot handle: " + type);
|
||||||
}
|
}
|
||||||
|
@ -1030,7 +1032,8 @@ public abstract class AbstractHafasProvider implements NetworkProvider
|
||||||
if (location.type == LocationType.POI && location.hasLocation())
|
if (location.type == LocationType.POI && location.hasLocation())
|
||||||
return "<Poi type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" />";
|
return "<Poi type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" />";
|
||||||
if (location.type == LocationType.ADDRESS && location.hasLocation())
|
if (location.type == LocationType.ADDRESS && location.hasLocation())
|
||||||
return "<Address type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" />";
|
return "<Address type=\"WGS84\" x=\"" + location.lon + "\" y=\"" + location.lat + "\" name=\""
|
||||||
|
+ (location.place != null ? location.place + ", " : "") + location.name + "\" />";
|
||||||
|
|
||||||
throw new IllegalArgumentException("cannot handle: " + location.toDebugString());
|
throw new IllegalArgumentException("cannot handle: " + location.toDebugString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,4 +79,15 @@ public class NasaProviderLiveTest
|
||||||
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
|
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
|
||||||
System.out.println(moreResult);
|
System.out.println(moreResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addressConnection() throws Exception
|
||||||
|
{
|
||||||
|
final QueryConnectionsResult result = provider.queryConnections(new Location(LocationType.ADDRESS, 0, 51334078, 12478331,
|
||||||
|
"04319 Leipzig-Engelsdorf", "August-Bebel-Platz"), null, new Location(LocationType.STATION, 8010205, null, "Leipzig Hbf"),
|
||||||
|
new Date(), true, ALL_PRODUCTS, WalkSpeed.NORMAL);
|
||||||
|
System.out.println(result);
|
||||||
|
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.context);
|
||||||
|
System.out.println(moreResult);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue