Query nearby stations by coordinate for Belgium

This commit is contained in:
Andreas Schildbach 2013-10-10 10:21:01 +02:00
parent 6dddd01b49
commit c74113709f

View file

@ -40,6 +40,7 @@ public class SncbProvider extends AbstractHafasProvider
super(API_BASE + "stboard.exe/nn", API_BASE + "ajax-getstop.exe/nny", API_BASE + "query.exe/nn", 16, null);
setJsonGetStopsEncoding(UTF_8);
setJsonNearbyStationsEncoding(UTF_8);
}
public NetworkId id()
@ -125,7 +126,21 @@ public class SncbProvider extends AbstractHafasProvider
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
{
if (location.type == LocationType.STATION && location.hasId())
if (location.hasLocation())
{
final StringBuilder uri = new StringBuilder(queryEndpoint);
uri.append('y');
uri.append("?performLocating=2&tpl=stop2json");
uri.append("&look_maxno=").append(maxStations != 0 ? maxStations : 200);
uri.append("&look_maxdist=").append(maxDistance != 0 ? maxDistance : 5000);
uri.append("&look_stopclass=").append(allProductsInt());
uri.append("&look_nv=get_stopweight|yes");
uri.append("&look_x=").append(location.lon);
uri.append("&look_y=").append(location.lat);
return jsonNearbyStations(uri.toString());
}
else if (location.type == LocationType.STATION && location.hasId())
{
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
uri.append("?near=Zoek");