mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 16:59:51 +00:00
Use common method for querying for nearby stations (Hafas).
This commit is contained in:
parent
fc91b8c7cb
commit
31b89f7ef8
26 changed files with 34 additions and 336 deletions
|
@ -2188,6 +2188,28 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return new Position(m.group(1));
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
protected final StringBuilder xmlNearbyStationsParameters(final String stationId)
|
||||
{
|
||||
final StringBuilder parameters = new StringBuilder();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue