mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 08:49:58 +00:00
scanning by coordinates doesn't seem to work any more
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@243 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
1a269d808a
commit
124e1d2186
1 changed files with 0 additions and 47 deletions
|
@ -34,10 +34,8 @@ import de.schildbach.pte.dto.Autocomplete;
|
|||
import de.schildbach.pte.dto.Connection;
|
||||
import de.schildbach.pte.dto.Departure;
|
||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||
import de.schildbach.pte.dto.Station;
|
||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||
import de.schildbach.pte.util.ParserUtils;
|
||||
|
||||
|
@ -88,9 +86,6 @@ public class RmvProvider extends AbstractHafasProvider
|
|||
return results;
|
||||
}
|
||||
|
||||
private final static Pattern P_NEARBY_STATIONS = Pattern.compile("<a href=\"/auskunft/bin/jp/stboard.exe/dox.+?input=(\\d+).*?\">\\n"
|
||||
+ "(.+?)\\s*\\((\\d+) m/[A-Z]+\\)\\n</a>", Pattern.DOTALL);
|
||||
|
||||
private final String NEARBY_URI = API_BASE + "stboard.exe/dn?L=vs_rmv&distance=50&near&input=%s";
|
||||
|
||||
@Override
|
||||
|
@ -99,48 +94,6 @@ public class RmvProvider extends AbstractHafasProvider
|
|||
return String.format(NEARBY_URI, stationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
if (lat != 0 || lon != 0)
|
||||
{
|
||||
final String uri = API_BASE + "dox?input=" + latLonToDouble(lat) + "%20" + latLonToDouble(lon);
|
||||
final CharSequence page = ParserUtils.scrape(uri);
|
||||
|
||||
final List<Station> stations = new ArrayList<Station>();
|
||||
|
||||
final Matcher m = P_NEARBY_STATIONS.matcher(page);
|
||||
while (m.find())
|
||||
{
|
||||
final int sId = Integer.parseInt(m.group(1));
|
||||
final String sName = ParserUtils.resolveEntities(m.group(2));
|
||||
final int sDist = Integer.parseInt(m.group(3));
|
||||
|
||||
final Station station = new Station(sId, sName, 0, 0, sDist, null, null);
|
||||
stations.add(station);
|
||||
}
|
||||
|
||||
if (maxStations == 0 || maxStations >= stations.size())
|
||||
return new NearbyStationsResult(uri, stations);
|
||||
else
|
||||
return new NearbyStationsResult(uri, stations.subList(0, maxStations));
|
||||
}
|
||||
else if (stationId != null)
|
||||
{
|
||||
return super.nearbyStations(stationId, 0, 0, maxDistance, maxStations);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("at least one of stationId or lat/lon must be given");
|
||||
}
|
||||
}
|
||||
|
||||
private static double latLonToDouble(int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
private static final Map<WalkSpeed, String> WALKSPEED_MAP = new HashMap<WalkSpeed, String>();
|
||||
static
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue