mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-15 17:10:30 +00:00
Query nearby stations by coordinate for Leipzig
This commit is contained in:
parent
75be137e40
commit
89219d7d19
2 changed files with 30 additions and 1 deletions
|
@ -42,6 +42,8 @@ public class NasaProvider extends AbstractHafasProvider
|
||||||
public NasaProvider()
|
public NasaProvider()
|
||||||
{
|
{
|
||||||
super(API_BASE + "stboard.exe/dn", null, API_BASE + "query.exe/dn", 8, null);
|
super(API_BASE + "stboard.exe/dn", null, API_BASE + "query.exe/dn", 8, null);
|
||||||
|
|
||||||
|
setJsonNearbyStationsEncoding(UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkId id()
|
public NetworkId id()
|
||||||
|
@ -134,7 +136,21 @@ public class NasaProvider extends AbstractHafasProvider
|
||||||
|
|
||||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
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);
|
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||||
uri.append("?near=Anzeigen");
|
uri.append("?near=Anzeigen");
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
|
|
||||||
package de.schildbach.pte.live;
|
package de.schildbach.pte.live;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -50,6 +53,16 @@ public class NasaProviderLiveTest extends AbstractProviderLiveTest
|
||||||
print(result);
|
print(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nearbyStationsByCoordinate() throws Exception
|
||||||
|
{
|
||||||
|
final NearbyStationsResult result = provider.queryNearbyStations(new Location(LocationType.ADDRESS, 51346546, 12383333), 0, 0);
|
||||||
|
|
||||||
|
print(result);
|
||||||
|
assertEquals(NearbyStationsResult.Status.OK, result.status);
|
||||||
|
assertTrue(result.stations.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void queryDepartures() throws Exception
|
public void queryDepartures() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue