mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 16:40:30 +00:00
Use common method for querying for nearby stations (Hafas).
This commit is contained in:
parent
fc91b8c7cb
commit
31b89f7ef8
26 changed files with 34 additions and 336 deletions
|
@ -2188,6 +2188,28 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
return new Position(m.group(1));
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
protected final StringBuilder xmlNearbyStationsParameters(final String stationId)
|
||||
{
|
||||
final StringBuilder parameters = new StringBuilder();
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -128,28 +124,6 @@ public final class BahnProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -175,6 +175,7 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
private final static Pattern P_NEARBY_FINE_LOCATION = Pattern.compile("input=(\\d+)&[^\"]*\">([^<]*)<");
|
||||
private static final Pattern P_NEARBY_ERRORS = Pattern.compile("(Haltestellen in der Umgebung anzeigen)");
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
|
|
@ -17,12 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -131,28 +127,6 @@ public class DsbProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: '" + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -26,8 +26,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
|
@ -98,28 +96,6 @@ public class EireannProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendCustomTripsQueryBinaryUri(final StringBuilder uri)
|
||||
{
|
||||
|
|
|
@ -101,6 +101,7 @@ public class InvgProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
|
|
|
@ -105,6 +105,7 @@ public class JetProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -137,28 +132,6 @@ public class LuProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char normalizeType(final String type)
|
||||
{
|
||||
|
|
|
@ -126,6 +126,7 @@ public class NasaProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
|
|
@ -23,8 +23,6 @@ import java.util.Date;
|
|||
import java.util.Set;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.QueryTripsContext;
|
||||
import de.schildbach.pte.dto.QueryTripsResult;
|
||||
|
@ -133,28 +131,6 @@ public class NriProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -114,6 +114,7 @@ public class NsProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
|
|
|
@ -148,6 +148,7 @@ public class NvvProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
|
|
@ -138,6 +138,7 @@ public class OebbProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
|
|
@ -17,12 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.util.StringReplaceReader;
|
||||
|
||||
|
@ -130,28 +126,6 @@ public class PlProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addCustomReplaces(final StringReplaceReader reader)
|
||||
{
|
||||
|
|
|
@ -17,12 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -98,28 +94,6 @@ public class RtProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -17,12 +17,8 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -119,28 +115,6 @@ public class SbbProvider extends AbstractHafasProvider
|
|||
}
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -17,15 +17,11 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -148,28 +144,6 @@ public class SeProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -119,6 +119,7 @@ public class SeptaProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
|
|
|
@ -155,6 +155,7 @@ public class ShProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
|
|
|
@ -122,6 +122,7 @@ public class SncbProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
|
|
@ -17,16 +17,12 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.Style.Shape;
|
||||
|
@ -136,28 +132,6 @@ public class StockholmProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void appendCustomTripsQueryBinaryUri(final StringBuilder uri)
|
||||
{
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -25,9 +24,6 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -146,28 +142,6 @@ public class VbbProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: '" + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Product> defaultProducts()
|
||||
{
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
|
||||
/**
|
||||
|
@ -112,28 +107,6 @@ public class VbnProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected char normalizeType(final String type)
|
||||
{
|
||||
|
|
|
@ -113,6 +113,7 @@ public class VgsProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
|
|
|
@ -138,6 +138,7 @@ public class VsnProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.type == LocationType.STATION && location.hasId())
|
||||
|
|
|
@ -17,15 +17,11 @@
|
|||
|
||||
package de.schildbach.pte;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import de.schildbach.pte.dto.Line;
|
||||
import de.schildbach.pte.dto.Location;
|
||||
import de.schildbach.pte.dto.LocationType;
|
||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||
import de.schildbach.pte.dto.Product;
|
||||
import de.schildbach.pte.dto.Style;
|
||||
import de.schildbach.pte.dto.Style.Shape;
|
||||
|
@ -160,28 +156,6 @@ public class ZvvProvider extends AbstractHafasProvider
|
|||
return super.splitPlaceAndName(name);
|
||||
}
|
||||
|
||||
public NearbyStationsResult queryNearbyStations(final Location location, final int maxDistance, final int maxStations) throws IOException
|
||||
{
|
||||
if (location.hasLocation())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(queryEndpoint);
|
||||
uri.append(jsonNearbyStationsParameters(location, maxDistance, maxStations));
|
||||
|
||||
return jsonNearbyStations(uri.toString());
|
||||
}
|
||||
else if (location.type == LocationType.STATION && location.hasId())
|
||||
{
|
||||
final StringBuilder uri = new StringBuilder(stationBoardEndpoint);
|
||||
uri.append(xmlNearbyStationsParameters(location.id));
|
||||
|
||||
return xmlNearbyStations(uri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("cannot handle: " + location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Line parseLineAndType(final String lineAndType)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue