mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 16:28:49 +00:00
nearby stations by coordinate for Austria
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@611 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
1a3548f831
commit
19cb46decc
2 changed files with 43 additions and 1 deletions
|
@ -38,6 +38,7 @@ import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
import de.schildbach.pte.dto.Line;
|
import de.schildbach.pte.dto.Line;
|
||||||
import de.schildbach.pte.dto.Location;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
@ -92,6 +93,30 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
return String.format(NEARBY_URI, ParserUtils.urlEncode(stationId));
|
return String.format(NEARBY_URI, ParserUtils.urlEncode(stationId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NearbyStationsResult nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
final StringBuilder uri = new StringBuilder(API_BASE);
|
||||||
|
|
||||||
|
if (lat != 0 || lon != 0)
|
||||||
|
{
|
||||||
|
uri.append("query.exe/dny");
|
||||||
|
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=2047");
|
||||||
|
uri.append("&look_x=").append(lon);
|
||||||
|
uri.append("&look_y=").append(lat);
|
||||||
|
|
||||||
|
return jsonNearbyStations(uri.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return super.nearbyStations(stationId, lat, lon, maxDistance, maxStations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<WalkSpeed, String>();
|
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<WalkSpeed, String>();
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.LocationType;
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -37,13 +38,29 @@ public class OebbProviderLiveTest
|
||||||
private static final String ALL_PRODUCTS = "IRSUTBFC";
|
private static final String ALL_PRODUCTS = "IRSUTBFC";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nearbyStation() throws Exception
|
public void nearbyStations() throws Exception
|
||||||
{
|
{
|
||||||
final NearbyStationsResult result = provider.nearbyStations("902006", 0, 0, 0, 0);
|
final NearbyStationsResult result = provider.nearbyStations("902006", 0, 0, 0, 0);
|
||||||
|
|
||||||
System.out.println(result.stations.size() + " " + result.stations);
|
System.out.println(result.stations.size() + " " + result.stations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void nearbyStationsByCoordinate() throws Exception
|
||||||
|
{
|
||||||
|
final NearbyStationsResult result = provider.nearbyStations(null, 48200239, 16370773, 0, 0);
|
||||||
|
|
||||||
|
System.out.println(result.stations.size() + " " + result.stations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void queryDepartures() throws Exception
|
||||||
|
{
|
||||||
|
final QueryDeparturesResult result = provider.queryDepartures("902006", 0, false);
|
||||||
|
|
||||||
|
System.out.println(result.stationDepartures);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shortConnection() throws Exception
|
public void shortConnection() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue