mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 19:28:49 +00:00
refactor pte to use int,int for coordinates
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@219 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
135b07f59e
commit
9af8c00ede
17 changed files with 69 additions and 106 deletions
|
@ -79,11 +79,11 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
+ "|distance=\"(\\d+)\" [^>]*? nameWithPlace=\"([^\"]*)\" [^>]*? stopID=\"(\\d+)\" [^>]*? x=\"(\\d+)\" y=\"(\\d+)\"" //
|
||||
+ ")");
|
||||
|
||||
protected abstract String nearbyLatLonUri(double lat, double lon);
|
||||
protected abstract String nearbyLatLonUri(int lat, int lon);
|
||||
|
||||
protected abstract String nearbyStationUri(String stationId);
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
String uri = null;
|
||||
|
@ -103,8 +103,8 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
{
|
||||
final boolean firstSyntax = mNearby.group(1) != null;
|
||||
final int sId = Integer.parseInt(mNearby.group(firstSyntax ? 1 : 8));
|
||||
final double sLon = latLonToDouble(Integer.parseInt(mNearby.group(firstSyntax ? 2 : 9)));
|
||||
final double sLat = latLonToDouble(Integer.parseInt(mNearby.group(firstSyntax ? 3 : 10)));
|
||||
final int sLon = Integer.parseInt(mNearby.group(firstSyntax ? 2 : 9));
|
||||
final int sLat = Integer.parseInt(mNearby.group(firstSyntax ? 3 : 10));
|
||||
final String sName = mNearby.group(firstSyntax ? 4 : 7).trim();
|
||||
final int sDist = Integer.parseInt(mNearby.group(firstSyntax ? 5 : 6));
|
||||
|
||||
|
@ -118,11 +118,6 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
return stations.subList(0, maxStations);
|
||||
}
|
||||
|
||||
private static double latLonToDouble(final int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
private static final Pattern P_LINE_RE = Pattern.compile("RE\\d+");
|
||||
private static final Pattern P_LINE_RB = Pattern.compile("RB\\d+");
|
||||
private static final Pattern P_LINE_U = Pattern.compile("U\\d+");
|
||||
|
@ -423,4 +418,9 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
{
|
||||
return P_STATION_NAME_WHITESPACE.matcher(name).replaceAll(" ");
|
||||
}
|
||||
|
||||
protected static double latLonToDouble(final int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public final class BahnProvider implements NetworkProvider
|
|||
private final static Pattern P_NEARBY_STATIONS = Pattern
|
||||
.compile("<a class=\"uLine\" href=\".+?!X=(\\d+)!Y=(\\d+)!id=(\\d+)!dist=(\\d+).*?\">(.+?)</a>");
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
if (lat == 0 && lon == 0)
|
||||
|
@ -87,7 +87,7 @@ public final class BahnProvider implements NetworkProvider
|
|||
final List<Station> stations = new ArrayList<Station>();
|
||||
|
||||
final String url = API_BASE + "query.exe/dox" + "?performLocating=2&tpl=stopsnear&look_maxdist=" + (maxDistance > 0 ? maxDistance : 5000)
|
||||
+ "&look_stopclass=1023" + "&look_x=" + latLonToInt(lon) + "&look_y=" + latLonToInt(lat);
|
||||
+ "&look_stopclass=1023" + "&look_x=" + lon + "&look_y=" + lat;
|
||||
final CharSequence page = ParserUtils.scrape(url);
|
||||
|
||||
final Matcher m = P_NEARBY_STATIONS.matcher(page);
|
||||
|
@ -95,8 +95,8 @@ public final class BahnProvider implements NetworkProvider
|
|||
{
|
||||
final int sId = Integer.parseInt(m.group(3));
|
||||
|
||||
final double sLon = latLonToDouble(Integer.parseInt(m.group(1)));
|
||||
final double sLat = latLonToDouble(Integer.parseInt(m.group(2)));
|
||||
final int sLon = Integer.parseInt(m.group(1));
|
||||
final int sLat = Integer.parseInt(m.group(2));
|
||||
final int sDist = Integer.parseInt(m.group(4));
|
||||
final String sName = ParserUtils.resolveEntities(m.group(5).trim());
|
||||
|
||||
|
@ -110,16 +110,6 @@ public final class BahnProvider implements NetworkProvider
|
|||
return stations.subList(0, maxStations);
|
||||
}
|
||||
|
||||
private static int latLonToInt(double value)
|
||||
{
|
||||
return (int) (value * 1000000);
|
||||
}
|
||||
|
||||
private static double latLonToDouble(int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
public StationLocationResult stationLocation(final String stationId) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -143,10 +143,10 @@ public final class Connection implements Serializable
|
|||
final public String departure;
|
||||
final public int arrivalId;
|
||||
final public String arrival;
|
||||
final public double arrivalLat, arrivalLon;
|
||||
final public int arrivalLat, arrivalLon;
|
||||
|
||||
public Footway(final int min, final int departureId, final String departure, final int arrivalId, final String arrival,
|
||||
final double arrivalLat, final double arrivalLon)
|
||||
public Footway(final int min, final int departureId, final String departure, final int arrivalId, final String arrival, final int arrivalLat,
|
||||
final int arrivalLon)
|
||||
{
|
||||
this.min = min;
|
||||
this.departureId = departureId;
|
||||
|
|
|
@ -59,7 +59,7 @@ public class GvhProvider extends AbstractEfaProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String nearbyLatLonUri(final double lat, final double lon)
|
||||
protected String nearbyLatLonUri(final int lat, final int lon)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -55,9 +55,9 @@ public class LinzProvider extends AbstractEfaProvider
|
|||
+ "?outputFormat=XML&mode=direct&coordOutputFormat=WGS84&mergeDep=1&useAllStops=1&name_dm=%2.6f:%2.6f:WGS84&type_dm=coord&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&excludedMeans=checkbox";
|
||||
|
||||
@Override
|
||||
protected String nearbyLatLonUri(final double lat, final double lon)
|
||||
protected String nearbyLatLonUri(final int lat, final int lon)
|
||||
{
|
||||
return String.format(NEARBY_LATLON_URI, lon, lat);
|
||||
return String.format(NEARBY_LATLON_URI, latLonToDouble(lon), latLonToDouble(lat));
|
||||
}
|
||||
|
||||
private static final String NEARBY_STATION_URI = API_BASE
|
||||
|
|
|
@ -105,9 +105,9 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
+ "?mode=direct&coordOutputFormat=WGS84&mergeDep=1&useAllStops=1&name_dm=%2.6f:%2.6f:WGS84&type_dm=coord&itOptionsActive=1&ptOptionsActive=1&useProxFootSearch=1&excludedMeans=checkbox";
|
||||
|
||||
@Override
|
||||
protected String nearbyLatLonUri(final double lat, final double lon)
|
||||
protected String nearbyLatLonUri(final int lat, final int lon)
|
||||
{
|
||||
return String.format(NEARBY_LATLON_URI, lon, lat);
|
||||
return String.format(NEARBY_LATLON_URI, latLonToDouble(lon), latLonToDouble(lat));
|
||||
}
|
||||
|
||||
private static final String NEARBY_STATION_URI = "http://efa.mvv-muenchen.de/ultralite/XML_DM_REQUEST"
|
||||
|
@ -123,7 +123,7 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
private static final Pattern P_NEARBY_FINE = Pattern.compile(".*?<n>(.*?)</n>.*?<r>.*?<id>(.*?)</id>.*?</r>.*?(?:<c>(\\d+),(\\d+)</c>.*?)?");
|
||||
|
||||
@Override
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
String uri;
|
||||
|
@ -146,8 +146,8 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
{
|
||||
final String sName = mNearbyFine.group(1).trim();
|
||||
final int sId = Integer.parseInt(mNearbyFine.group(2));
|
||||
final double sLon = mNearbyFine.group(3) != null ? latLonToDouble(Integer.parseInt(mNearbyFine.group(3))) : 0;
|
||||
final double sLat = mNearbyFine.group(4) != null ? latLonToDouble(Integer.parseInt(mNearbyFine.group(4))) : 0;
|
||||
final int sLon = mNearbyFine.group(3) != null ? Integer.parseInt(mNearbyFine.group(3)) : 0;
|
||||
final int sLat = mNearbyFine.group(4) != null ? Integer.parseInt(mNearbyFine.group(4)) : 0;
|
||||
|
||||
final Station station = new Station(sId, sName, sLat, sLon, 0, null, null);
|
||||
stations.add(station);
|
||||
|
@ -164,11 +164,6 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
return stations.subList(0, maxStations);
|
||||
}
|
||||
|
||||
private static double latLonToDouble(int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
public StationLocationResult stationLocation(final String stationId) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -219,9 +214,9 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
if (fromType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = from.split(",\\s*", 2);
|
||||
final double lat = Double.parseDouble(parts[0]);
|
||||
final double lon = Double.parseDouble(parts[1]);
|
||||
uri.append("&nameInfo_origin=").append(String.format("%2.5f:%2.5f", lon, lat)).append(":WGS84[DD.ddddd]");
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&nameInfo_origin=").append(String.format("%2.5f:%2.5f", lon / 1E6, lat / 1E6)).append(":WGS84[DD.ddddd]");
|
||||
uri.append("&typeInfo_origin=coord");
|
||||
}
|
||||
else
|
||||
|
@ -244,9 +239,9 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
if (toType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = to.split(",\\s*", 2);
|
||||
final double lat = Double.parseDouble(parts[0]);
|
||||
final double lon = Double.parseDouble(parts[1]);
|
||||
uri.append("&nameInfo_destination=").append(String.format("%2.5f:%2.5f", lon, lat)).append(":WGS84[DD.ddddd]");
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&nameInfo_destination=").append(String.format("%2.5f:%2.5f", lon / 1E6, lat / 1E6)).append(":WGS84[DD.ddddd]");
|
||||
uri.append("&typeInfo_destination=coord");
|
||||
}
|
||||
else
|
||||
|
@ -271,9 +266,9 @@ public class MvvProvider extends AbstractEfaProvider
|
|||
if (viaType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = via.split(",\\s*", 2);
|
||||
final double lat = Double.parseDouble(parts[0]);
|
||||
final double lon = Double.parseDouble(parts[1]);
|
||||
uri.append("&nameInfo_via=").append(String.format("%2.5f:%2.5f", lon, lat)).append(":WGS84[DD.ddddd]");
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&nameInfo_via=").append(String.format("%2.5f:%2.5f", lon / 1E6, lat / 1E6)).append(":WGS84[DD.ddddd]");
|
||||
uri.append("&typeInfo_via=coord");
|
||||
}
|
||||
else
|
||||
|
|
|
@ -71,7 +71,7 @@ public interface NetworkProvider
|
|||
* @return nearby stations
|
||||
* @throws IOException
|
||||
*/
|
||||
List<Station> nearbyStations(String stationId, double lat, double lon, int maxDistance, int maxStations) throws IOException;
|
||||
List<Station> nearbyStations(String stationId, int lat, int lon, int maxDistance, int maxStations) throws IOException;
|
||||
|
||||
/**
|
||||
* Look up location of station.
|
||||
|
|
|
@ -125,7 +125,7 @@ public class OebbProvider implements NetworkProvider
|
|||
private final static Pattern P_NEARBY_COARSE = Pattern.compile("<tr class=\"zebracol-\\d\">(.*?)</tr>", Pattern.DOTALL);
|
||||
private final static Pattern P_NEARBY_FINE = Pattern.compile(".*?stboard\\.exe/.*?&input=.*?%23(\\d+)&.*?>(.*?)</a>.*?", Pattern.DOTALL);
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
if (stationId == null)
|
||||
|
|
|
@ -87,14 +87,14 @@ public class RmvProvider implements NetworkProvider
|
|||
+ "&REQMapRoute0\\.Location0\\.X=(-?\\d+)&REQMapRoute0\\.Location0\\.Y=(-?\\d+)" //
|
||||
+ "&REQMapRoute0\\.Location0\\.Name=(.*?)\">.*?", Pattern.DOTALL);
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
final List<Station> stations = new ArrayList<Station>();
|
||||
|
||||
if (lat != 0 || lon != 0)
|
||||
{
|
||||
final String url = "http://www.rmv.de/auskunft/bin/jp/stboard.exe/dox?input=" + lat + "%20" + lon;
|
||||
final String url = "http://www.rmv.de/auskunft/bin/jp/stboard.exe/dox?input=" + latLonToDouble(lat) + "%20" + latLonToDouble(lon);
|
||||
final CharSequence page = ParserUtils.scrape(url);
|
||||
|
||||
final Matcher m = P_NEARBY_STATIONS.matcher(page);
|
||||
|
@ -121,8 +121,8 @@ public class RmvProvider implements NetworkProvider
|
|||
if (mFine.matches())
|
||||
{
|
||||
final int parsedId = Integer.parseInt(mFine.group(1));
|
||||
final double parsedLon = latLonToDouble(Integer.parseInt(mFine.group(2)));
|
||||
final double parsedLat = latLonToDouble(Integer.parseInt(mFine.group(3)));
|
||||
final int parsedLon = Integer.parseInt(mFine.group(2));
|
||||
final int parsedLat = Integer.parseInt(mFine.group(3));
|
||||
final String parsedName = ParserUtils.resolveEntities(mFine.group(4));
|
||||
|
||||
final Station station = new Station(parsedId, parsedName, parsedLat, parsedLon, 0, null, null);
|
||||
|
@ -158,8 +158,8 @@ public class RmvProvider implements NetworkProvider
|
|||
final Matcher m = P_STATION_LOCATION.matcher(page);
|
||||
if (m.find())
|
||||
{
|
||||
final double lon = latLonToDouble(Integer.parseInt(m.group(1)));
|
||||
final double lat = latLonToDouble(Integer.parseInt(m.group(2)));
|
||||
final int lon = Integer.parseInt(m.group(1));
|
||||
final int lat = Integer.parseInt(m.group(2));
|
||||
final String name = ParserUtils.resolveEntities(m.group(3));
|
||||
|
||||
return new StationLocationResult(lat, lon, name);
|
||||
|
|
|
@ -83,7 +83,7 @@ public class SbbProvider implements NetworkProvider
|
|||
private final static Pattern P_NEARBY_FINE = Pattern.compile(".*?&REQMapRoute0\\.Location0\\.X=(-?\\d+)&REQMapRoute0\\.Location0\\.Y=(-?\\d+)"
|
||||
+ "&REQMapRoute0\\.Location0\\.Name=(.*?)&sturl=.*?dn\\?input=(\\d+).*?", Pattern.DOTALL);
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
if (stationId == null)
|
||||
|
@ -100,8 +100,8 @@ public class SbbProvider implements NetworkProvider
|
|||
final Matcher mFine = P_NEARBY_FINE.matcher(mCoarse.group(1));
|
||||
if (mFine.matches())
|
||||
{
|
||||
final double parsedLon = latLonToDouble(Integer.parseInt(mFine.group(1)));
|
||||
final double parsedLat = latLonToDouble(Integer.parseInt(mFine.group(2)));
|
||||
final int parsedLon = Integer.parseInt(mFine.group(1));
|
||||
final int parsedLat = Integer.parseInt(mFine.group(2));
|
||||
final String parsedName = ParserUtils.resolveEntities(mFine.group(3));
|
||||
final int parsedId = Integer.parseInt(mFine.group(4));
|
||||
|
||||
|
@ -120,11 +120,6 @@ public class SbbProvider implements NetworkProvider
|
|||
return stations.subList(0, maxStations);
|
||||
}
|
||||
|
||||
private static double latLonToDouble(int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
public StationLocationResult stationLocation(final String stationId) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -38,7 +38,7 @@ public class SncbProvider implements NetworkProvider
|
|||
private final static Pattern P_NEARBY_FINE = Pattern.compile(".*?&REQMapRoute0\\.Location0\\.X=(-?\\d+)&REQMapRoute0\\.Location0\\.Y=(-?\\d+)"
|
||||
+ "&REQMapRoute0\\.Location0\\.Name=(.*?)\">.*?en\\?input=(\\d+).*?", Pattern.DOTALL);
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
if (stationId == null)
|
||||
|
@ -55,8 +55,8 @@ public class SncbProvider implements NetworkProvider
|
|||
final Matcher mFine = P_NEARBY_FINE.matcher(mCoarse.group(1));
|
||||
if (mFine.matches())
|
||||
{
|
||||
final double parsedLon = latLonToDouble(Integer.parseInt(mFine.group(1)));
|
||||
final double parsedLat = latLonToDouble(Integer.parseInt(mFine.group(2)));
|
||||
final int parsedLon = Integer.parseInt(mFine.group(1));
|
||||
final int parsedLat = Integer.parseInt(mFine.group(2));
|
||||
final String parsedName = ParserUtils.resolveEntities(mFine.group(3));
|
||||
final int parsedId = Integer.parseInt(mFine.group(4));
|
||||
|
||||
|
@ -75,11 +75,6 @@ public class SncbProvider implements NetworkProvider
|
|||
return stations.subList(0, maxStations);
|
||||
}
|
||||
|
||||
private static double latLonToDouble(int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
public StationLocationResult stationLocation(final String stationId) throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
|
@ -26,12 +25,12 @@ public final class Station
|
|||
// data
|
||||
public final int id;
|
||||
public final String name;
|
||||
public final double latitude, longitude;
|
||||
public final int latitude, longitude;
|
||||
public float distance;
|
||||
public final String[] lines;
|
||||
public final int[][] lineColors;
|
||||
|
||||
public Station(final int id, final String name, final double latitude, final double longitude, final float distance, final String[] lines,
|
||||
public Station(final int id, final String name, final int latitude, final int longitude, final float distance, final String[] lines,
|
||||
final int[][] lineColors)
|
||||
{
|
||||
this.id = id;
|
||||
|
|
|
@ -25,7 +25,7 @@ public final class StationLocationResult
|
|||
public final double lat, lon;
|
||||
public final String name;
|
||||
|
||||
public StationLocationResult(final double lat, final double lon, final String name)
|
||||
public StationLocationResult(final int lat, final int lon, final String name)
|
||||
{
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TflProvider implements NetworkProvider
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -97,7 +97,7 @@ public final class VbbProvider implements NetworkProvider
|
|||
return results;
|
||||
}
|
||||
|
||||
public List<Station> nearbyStations(final String stationId, final double lat, final double lon, final int maxDistance, final int maxStations)
|
||||
public List<Station> nearbyStations(final String stationId, final int lat, final int lon, final int maxDistance, final int maxStations)
|
||||
throws IOException
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -138,8 +138,8 @@ public final class VbbProvider implements NetworkProvider
|
|||
if (m.find())
|
||||
{
|
||||
final String name = ParserUtils.resolveEntities(m.group(1));
|
||||
final double lon = latLonToDouble(Integer.parseInt(m.group(2)));
|
||||
final double lat = latLonToDouble(Integer.parseInt(m.group(3)));
|
||||
final int lon = Integer.parseInt(m.group(2));
|
||||
final int lat = Integer.parseInt(m.group(3));
|
||||
|
||||
return new StationLocationResult(lat, lon, name);
|
||||
}
|
||||
|
@ -149,11 +149,6 @@ public final class VbbProvider implements NetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
private static double latLonToDouble(int value)
|
||||
{
|
||||
return (double) value / 1000000;
|
||||
}
|
||||
|
||||
public static final String STATION_URL_CONNECTION = "http://mobil.bvg.de/Fahrinfo/bin/query.bin/dox";
|
||||
|
||||
private String connectionsQueryUri(final LocationType fromType, final String from, final LocationType viaType, final String via,
|
||||
|
@ -170,9 +165,9 @@ public final class VbbProvider implements NetworkProvider
|
|||
if (fromType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = from.split(",\\s*", 2);
|
||||
final double lat = Double.parseDouble(parts[0]);
|
||||
final double lon = Double.parseDouble(parts[1]);
|
||||
uri.append("&SID=").append(ParserUtils.urlEncode("A=16@X=" + latLonToInt(lon) + "@Y=" + latLonToInt(lat)));
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&SID=").append(ParserUtils.urlEncode("A=16@X=" + lon + "@Y=" + lat));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -203,9 +198,9 @@ public final class VbbProvider implements NetworkProvider
|
|||
if (toType == LocationType.WGS84)
|
||||
{
|
||||
final String[] parts = to.split(",\\s*", 2);
|
||||
final double lat = Double.parseDouble(parts[0]);
|
||||
final double lon = Double.parseDouble(parts[1]);
|
||||
uri.append("&ZID=").append(ParserUtils.urlEncode("A=16@X=" + latLonToInt(lon) + "@Y=" + latLonToInt(lat)));
|
||||
final int lat = Integer.parseInt(parts[0]);
|
||||
final int lon = Integer.parseInt(parts[1]);
|
||||
uri.append("&ZID=").append(ParserUtils.urlEncode("A=16@X=" + lon + "@Y=" + lat));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,11 +229,6 @@ public final class VbbProvider implements NetworkProvider
|
|||
throw new IllegalArgumentException(locationType.toString());
|
||||
}
|
||||
|
||||
private static int latLonToInt(final double value)
|
||||
{
|
||||
return (int) (value * 1000000);
|
||||
}
|
||||
|
||||
private static final Pattern P_CHECK_ADDRESS = Pattern.compile("<option[^>]*>\\s*(.*?)\\s*</option>", Pattern.DOTALL);
|
||||
private static final Pattern P_CHECK_FROM = Pattern.compile("Von:");
|
||||
private static final Pattern P_CHECK_TO = Pattern.compile("Nach:");
|
||||
|
@ -461,9 +451,9 @@ public final class VbbProvider implements NetworkProvider
|
|||
final String arrival = ParserUtils.resolveEntities(ParserUtils.selectNotNull(mDetFine.group(13), mDetFine.group(16), mDetFine
|
||||
.group(17)));
|
||||
|
||||
final double arrivalLon = mDetFine.group(14) != null ? latLonToDouble(Integer.parseInt(mDetFine.group(14))) : 0;
|
||||
final int arrivalLon = mDetFine.group(14) != null ? Integer.parseInt(mDetFine.group(14)) : 0;
|
||||
|
||||
final double arrivalLat = mDetFine.group(15) != null ? latLonToDouble(Integer.parseInt(mDetFine.group(15))) : 0;
|
||||
final int arrivalLat = mDetFine.group(15) != null ? Integer.parseInt(mDetFine.group(15)) : 0;
|
||||
|
||||
if (parts.size() > 0 && parts.get(parts.size() - 1) instanceof Connection.Footway)
|
||||
{
|
||||
|
|
|
@ -64,17 +64,16 @@ public class LinzProviderLiveTest
|
|||
@Test
|
||||
public void connectionBetweenCoordinates() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48.165238,11.577473", null, null, LocationType.WGS84,
|
||||
"47.987199,11.326532", new Date(), true, WalkSpeed.NORMAL);
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48165238,11577473", null, null, LocationType.WGS84,
|
||||
"47987199,11326532", new Date(), true, WalkSpeed.NORMAL);
|
||||
System.out.println(result);
|
||||
// final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
|
||||
// System.out.println(moreResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void connectionBetweenCoordinateAndStation() throws Exception
|
||||
@Test public void connectionBetweenCoordinateAndStation() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48.238341,11.478230", null, null, LocationType.ANY,
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48238341,11478230", null, null, LocationType.ANY,
|
||||
"Ostbahnhof", new Date(), true, WalkSpeed.NORMAL);
|
||||
System.out.println(result);
|
||||
// final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
|
||||
|
|
|
@ -55,8 +55,8 @@ public class MvvProviderLiveTest
|
|||
@Test
|
||||
public void connectionBetweenCoordinates() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48.165238,11.577473", null, null, LocationType.WGS84,
|
||||
"47.987199,11.326532", new Date(), true, WalkSpeed.NORMAL);
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48165238,11577473", null, null, LocationType.WGS84,
|
||||
"47987199,11326532", new Date(), true, WalkSpeed.NORMAL);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
|
||||
System.out.println(moreResult);
|
||||
|
@ -65,7 +65,7 @@ public class MvvProviderLiveTest
|
|||
@Test
|
||||
public void connectionBetweenCoordinateAndStation() throws Exception
|
||||
{
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48.238341,11.478230", null, null, LocationType.ANY,
|
||||
final QueryConnectionsResult result = provider.queryConnections(LocationType.WGS84, "48238341,11478230", null, null, LocationType.ANY,
|
||||
"Ostbahnhof", new Date(), true, WalkSpeed.NORMAL);
|
||||
System.out.println(result);
|
||||
final QueryConnectionsResult moreResult = provider.queryMoreConnections(result.linkLater);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue