diff --git a/README.md b/README.md index 44f5149c..8b50b10c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Copy the `secrets.properties.template` file to `secrets.properties` like so: $ cp test/de/schildbach/pte/live/secrets.properties.template test/de/schildbach/pte/live/secrets.properties -You need to request the secrets directly from the provider. For Navitia based providers, you can [request a secret here](https://www.navitia.io/register). +You need to request the secrets directly from the provider. How to run live tests? ---------------------- @@ -25,7 +25,7 @@ If you prefer to run tests from the command line, you can comment out the test e [build.gradle](https://github.com/schildbach/public-transport-enabler/blob/master/build.gradle#L30) and use this command to only execute a test for a single provider: - $ gradle -Dtest.single=ParisProviderLive test + $ gradle -Dtest.single=BvgProviderLive test -This uses the `ParisProvider` as an example. +This uses the `BvgProvider` as an example. Just replace it with the provider you want to test. diff --git a/src/de/schildbach/pte/AbstractNavitiaProvider.java b/src/de/schildbach/pte/AbstractNavitiaProvider.java deleted file mode 100644 index 73c12732..00000000 --- a/src/de/schildbach/pte/AbstractNavitiaProvider.java +++ /dev/null @@ -1,1148 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.io.IOException; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.EnumSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import javax.annotation.Nullable; - -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; - -import com.google.common.base.Strings; - -import de.schildbach.pte.dto.Departure; -import de.schildbach.pte.dto.Line; -import de.schildbach.pte.dto.LineDestination; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.NearbyLocationsResult; -import de.schildbach.pte.dto.NearbyLocationsResult.Status; -import de.schildbach.pte.dto.Point; -import de.schildbach.pte.dto.Position; -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.QueryDeparturesResult; -import de.schildbach.pte.dto.QueryTripsContext; -import de.schildbach.pte.dto.QueryTripsResult; -import de.schildbach.pte.dto.ResultHeader; -import de.schildbach.pte.dto.StationDepartures; -import de.schildbach.pte.dto.Stop; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.Style.Shape; -import de.schildbach.pte.dto.SuggestLocationsResult; -import de.schildbach.pte.dto.SuggestedLocation; -import de.schildbach.pte.dto.Trip; -import de.schildbach.pte.dto.Trip.Individual; -import de.schildbach.pte.dto.Trip.Leg; -import de.schildbach.pte.dto.Trip.Public; -import de.schildbach.pte.dto.TripOptions; -import de.schildbach.pte.exception.NotFoundException; -import de.schildbach.pte.exception.ParserException; - -import okhttp3.HttpUrl; - -/** - * @author Antonio El Khoury - * @author Andreas Schildbach - * @author Torsten Grote - */ -public abstract class AbstractNavitiaProvider extends AbstractNetworkProvider { - protected final static String SERVER_PRODUCT = "navitia"; - protected final static String SERVER_VERSION = "v1"; - - private final List CAPABILITIES = Arrays.asList( - Capability.SUGGEST_LOCATIONS, - Capability.NEARBY_LOCATIONS, - Capability.DEPARTURES, - Capability.TRIPS - ); - - protected HttpUrl apiBase = HttpUrl.parse("https://api.navitia.io/").newBuilder().addPathSegment(SERVER_VERSION) - .build(); - - private enum PlaceType { - ADDRESS, ADMINISTRATIVE_REGION, POI, STOP_POINT, STOP_AREA - } - - private enum SectionType { - CROW_FLY, PUBLIC_TRANSPORT, STREET_NETWORK, TRANSFER, WAITING, STAY_IN, ON_DEMAND_TRANSPORT, BSS_RENT, BSS_PUT_BACK, BOARDING, LANDING - } - - private enum TransferType { - BIKE, WALKING - } - - private enum PhysicalMode { - AIR, BOAT, BUS, BUSRAPIDTRANSIT, COACH, FERRY, FUNICULAR, LOCALTRAIN, LONGDISTANCETRAIN, METRO, RAPIDTRANSIT, SHUTTLE, TAXI, TRAIN, TRAMWAY, TRAM, VAL, RAILSHUTTLE, OTHER - } - - @SuppressWarnings("serial") - private static class Context implements QueryTripsContext { - private final Location from; - private final Location to; - private final String prevQueryUri; - private final String nextQueryUri; - - private Context(final Location from, final Location to, final String prevQueryUri, final String nextQueryUri) { - this.from = from; - this.to = to; - this.prevQueryUri = prevQueryUri; - this.nextQueryUri = nextQueryUri; - } - - @Override - public boolean canQueryLater() { - return (from != null && to != null && nextQueryUri != null); - } - - @Override - public boolean canQueryEarlier() { - return (from != null && to != null && prevQueryUri != null); - } - - @Override - public String toString() { - return getClass().getName() + "[" + from + "|" + to + "|" + prevQueryUri + "|" + nextQueryUri + "]"; - } - } - - public AbstractNavitiaProvider(final NetworkId network, final HttpUrl apiBase, final String authorization) { - this(network, authorization); - - this.apiBase = apiBase; - } - - public AbstractNavitiaProvider(final NetworkId network, final String authorization) { - super(network); - - if (authorization != null) - httpClient.setHeader("Authorization", authorization); - } - - protected abstract String region(); - - protected int computeForegroundColor(final String lineColor) { - int bgColor = Style.parseColor(lineColor); - return Style.deriveForegroundColor(bgColor); - } - - protected Style getLineStyle(final String network, final Product product, final String code, final String color) { - return getLineStyle(network, product, code, color, null); - } - - protected Style getLineStyle(final String network, final Product product, final String code, - final String backgroundColor, final String foregroundColor) { - if (backgroundColor != null) { - if (foregroundColor == null) - return new Style(Shape.RECT, Style.parseColor(backgroundColor), - computeForegroundColor(backgroundColor)); - return new Style(Shape.RECT, Style.parseColor(backgroundColor), Style.parseColor(foregroundColor)); - } else { - final Style defaultStyle = Standard.STYLES.get(product); - return new Style(Shape.RECT, defaultStyle.backgroundColor, defaultStyle.backgroundColor2, - defaultStyle.foregroundColor, defaultStyle.borderColor); - } - } - - private HttpUrl.Builder url() { - return apiBase.newBuilder().addPathSegment("coverage").addPathSegment(region()); - } - - private Point parseCoord(final JSONObject coord) throws IOException { - try { - final double lat = coord.getDouble("lat"); - final double lon = coord.getDouble("lon"); - return Point.fromDouble(lat, lon); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private LocationType getLocationType(PlaceType placeType) { - switch (placeType) { - case STOP_POINT: { - return LocationType.STATION; - } - case STOP_AREA: { - return LocationType.STATION; - } - case ADDRESS: { - return LocationType.ADDRESS; - } - case POI: { - return LocationType.POI; - } - default: - throw new IllegalArgumentException("Unhandled place type: " + placeType); - } - } - - /** - * Some Navitia providers return location names with wrong case. This method can be used to fix the name - * when locations are parsed. - * - * @param name - * The name of the location - * @return the fixed name of the location - */ - protected String getLocationName(String name) { - return name; - } - - /** - * Navitia always formats the address label in the French way. - * This method can be used to display addresses in a localized way. - * It defaults to putting the house number behind the street name. - * - * @param name The name of the address. Usually a street name. - * @param houseNumber The house number of the address. - * @return the localized name of the address location - */ - protected String getAddressName(final String name, final String houseNumber) { - return name + " " + houseNumber; - } - - private Location parsePlace(JSONObject location, PlaceType placeType) throws IOException { - try { - final LocationType type = getLocationType(placeType); - String id = null; - if (placeType != PlaceType.ADDRESS && placeType != PlaceType.POI) - id = location.getString("id"); - final JSONObject coord = location.getJSONObject("coord"); - final Point point = parseCoord(coord); - final String placeName = location.getString("name"); - String name; - if (placeType == PlaceType.ADDRESS) { - final String houseNumber = location.optString("house_number", "0"); - name = houseNumber.equals("0") ? placeName : getAddressName(placeName, houseNumber); - } else { - name = getLocationName(placeName); - } - String place = null; - if (location.has("administrative_regions")) { - JSONArray admin = location.getJSONArray("administrative_regions"); - if (admin.length() > 0) - place = Strings.emptyToNull(admin.getJSONObject(0).optString("name")); - } - Set products = null; - if (location.has("stop_area") && location.getJSONObject("stop_area").has("physical_modes")) { - products = EnumSet.noneOf(Product.class); - JSONArray physicalModes = location.getJSONObject("stop_area").getJSONArray("physical_modes"); - for (int i = 0; i < physicalModes.length(); i++) { - JSONObject mode = physicalModes.getJSONObject(i); - Product product = parseLineProductFromMode(mode.getString("id")); - if (product != null) - products.add(product); - } - } - return new Location(type, id, point, place, name, products); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private Location parseAdministrativeRegion(final JSONObject j) throws IOException { - try { - final JSONObject coord = j.getJSONObject("coord"); - final Point point = parseCoord(coord); - final String name = j.getString("name"); - return new Location(LocationType.POI, null, point, null, name); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private Location parseLocation(final JSONObject j) throws IOException { - try { - final String type = j.getString("embedded_type"); - final PlaceType placeType = PlaceType.valueOf(type.toUpperCase()); - JSONObject location; - - switch (placeType) { - case STOP_POINT: { - location = j.getJSONObject("stop_point"); - break; - } - case STOP_AREA: { - location = j.getJSONObject("stop_area"); - break; - } - case ADDRESS: { - location = j.getJSONObject("address"); - break; - } - case POI: { - location = j.getJSONObject("poi"); - break; - } - case ADMINISTRATIVE_REGION: { - return parseAdministrativeRegion(j.getJSONObject("administrative_region")); - } - default: - throw new IllegalArgumentException("Unhandled place type: " + type); - } - return parsePlace(location, placeType); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private String printLocation(final Location location) { - if (location.hasId()) - return location.id; - else if (location.hasCoord()) - return location.getLonAsDouble() + ";" + location.getLatAsDouble(); - else - return ""; - } - - private Date parseDate(final String dateString) throws ParseException { - DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss"); - format.setTimeZone(timeZone); - return format.parse(dateString); - } - - private String printDate(final Date date) { - DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss"); - format.setTimeZone(timeZone); - return format.format(date); - } - - private LinkedList parsePath(final JSONArray coordinates) throws IOException { - LinkedList path = new LinkedList<>(); - - for (int i = 0; i < coordinates.length(); ++i) { - try { - final JSONArray jsonPoint = coordinates.getJSONArray(i); - final double lon = jsonPoint.getDouble(0); - final double lat = jsonPoint.getDouble(1); - final Point point = Point.fromDouble(lat, lon); - path.add(point); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - return path; - } - - private static class LegInfo { - public final Location departure; - public final Date departureTime; - public final Location arrival; - public final Date arrivalTime; - public final List path; - public final int distance; - public final int min; - - public LegInfo(final Location departure, final Date departureTime, final Location arrival, - final Date arrivalTime, final List path, final int distance, final int min) { - this.departure = departure; - this.departureTime = departureTime; - this.arrival = arrival; - this.arrivalTime = arrivalTime; - this.path = path; - this.distance = distance; - this.min = min; - } - } - - private LegInfo parseLegInfo(final JSONObject section) throws IOException { - try { - final String type = section.getString("type"); - - if (!type.equals("waiting")) { - // Build departure location. - final JSONObject sectionFrom = section.getJSONObject("from"); - final Location departure = parseLocation(sectionFrom); - - // Build departure time. - final String departureDateTime = section.getString("departure_date_time"); - final Date departureTime = parseDate(departureDateTime); - - // Build arrival location. - final JSONObject sectionTo = section.getJSONObject("to"); - final Location arrival = parseLocation(sectionTo); - - // Build arrival time. - final String arrivalDateTime = section.getString("arrival_date_time"); - final Date arrivalTime = parseDate(arrivalDateTime); - - // Build path and distance. Check first that geojson - // object exists. - LinkedList path = null; - int distance = 0; - if (section.has("geojson")) { - final JSONObject jsonPath = section.getJSONObject("geojson"); - final JSONArray coordinates = jsonPath.getJSONArray("coordinates"); - path = parsePath(coordinates); - - final JSONArray properties = jsonPath.getJSONArray("properties"); - for (int i = 0; i < properties.length(); ++i) { - final JSONObject property = properties.getJSONObject(i); - if (property.has("length")) { - distance = property.getInt("length"); - break; - } - } - } - - // Build duration in min. - final int min = section.getInt("duration") / 60; - - return new LegInfo(departure, departureTime, arrival, arrivalTime, path, distance, min); - } else { - return null; - } - } catch (final JSONException | ParseException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private Line parseLineFromSection(final JSONObject section, final SectionType type) throws IOException { - try { - final JSONArray links = section.getJSONArray("links"); - String lineId = null; - String modeId = null; - for (int i = 0; i < links.length(); ++i) { - final JSONObject link = links.getJSONObject(i); - final String linkType = link.getString("type"); - if (linkType.equals("line")) - lineId = link.getString("id"); - else if (linkType.equals("physical_mode")) - modeId = link.getString("id"); - } - - final Product product = type == SectionType.ON_DEMAND_TRANSPORT ? Product.ON_DEMAND - : parseLineProductFromMode(modeId); - final JSONObject displayInfo = section.getJSONObject("display_informations"); - final String network = Strings.emptyToNull(displayInfo.optString("network")); - final String code = displayInfo.getString("code"); - final String color = Strings.emptyToNull(displayInfo.getString("color")); - final String name = Strings.emptyToNull(displayInfo.optString("headsign")); - final Style lineStyle = getLineStyle(network, product, code, color != null ? "#" + color : null); - - return new Line(lineId, network, product, code, name, lineStyle); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private Stop parseStop(final JSONObject stopDateTime) throws IOException { - try { - // Build location. - final JSONObject stopPoint = stopDateTime.getJSONObject("stop_point"); - final Location location = parsePlace(stopPoint, PlaceType.STOP_POINT); - - // Build planned arrival time. - final Date plannedArrivalTime = parseDate(stopDateTime.getString("arrival_date_time")); - - // Build planned arrival position. - final Position plannedArrivalPosition = null; - - // Build planned departure time. - final Date plannedDepartureTime = parseDate(stopDateTime.getString("departure_date_time")); - - // Build planned departure position. - final Position plannedDeparturePosition = null; - - return new Stop(location, plannedArrivalTime, plannedArrivalPosition, plannedDepartureTime, - plannedDeparturePosition); - } catch (final JSONException | ParseException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private Leg parseLeg(final JSONObject section) throws IOException { - try { - // Build common leg info. - final LegInfo legInfo = parseLegInfo(section); - if (legInfo == null) - return null; - - final String type = section.getString("type"); - final SectionType sectionType = SectionType.valueOf(type.toUpperCase()); - - switch (sectionType) { - case CROW_FLY: { - // Return null leg if duration is 0. - if (legInfo.min == 0) - return null; - - // Build type. - final Individual.Type individualType = Individual.Type.WALK; - - return new Individual(individualType, legInfo.departure, legInfo.departureTime, legInfo.arrival, - legInfo.arrivalTime, legInfo.path, legInfo.distance); - } - case ON_DEMAND_TRANSPORT: - case PUBLIC_TRANSPORT: { - // Build line. - final Line line = parseLineFromSection(section, sectionType); - - // Build destination. - final JSONObject displayInfo = section.getJSONObject("display_informations"); - final String direction = displayInfo.getString("direction"); - final Location destination = new Location(LocationType.ANY, null, null, getLocationName(direction)); - - final JSONArray stopDateTimes = section.getJSONArray("stop_date_times"); - final int nbStopDateTime = stopDateTimes.length(); - - // Build departure stop. - final Stop departureStop = parseStop(stopDateTimes.getJSONObject(0)); - - // Build arrival stop. - final Stop arrivalStop = parseStop(stopDateTimes.getJSONObject(nbStopDateTime - 1)); - - // Build intermediate stops. - final LinkedList intermediateStops = new LinkedList<>(); - for (int i = 1; i < nbStopDateTime - 1; ++i) { - final Stop intermediateStop = parseStop(stopDateTimes.getJSONObject(i)); - intermediateStops.add(intermediateStop); - } - - // Build message. - final String message = null; - - return new Public(line, destination, departureStop, arrivalStop, intermediateStops, legInfo.path, - message); - } - case STREET_NETWORK: { - final String modeType = section.getString("mode"); - final TransferType transferType = TransferType.valueOf(modeType.toUpperCase()); - - // Build type. - final Individual.Type individualType; - switch (transferType) { - case BIKE: - individualType = Individual.Type.BIKE; - break; - case WALKING: - individualType = Individual.Type.WALK; - break; - default: - throw new IllegalArgumentException("Unhandled transfer type: " + modeType); - } - - return new Individual(individualType, legInfo.departure, legInfo.departureTime, legInfo.arrival, - legInfo.arrivalTime, legInfo.path, legInfo.distance); - } - case TRANSFER: { - // Build type. - final Individual.Type individualType = Individual.Type.WALK; - - return new Individual(individualType, legInfo.departure, legInfo.departureTime, legInfo.arrival, - legInfo.arrivalTime, legInfo.path, legInfo.distance); - } - case WAITING: { - return null; - // Do not add leg in case of waiting on the peer. - } - default: - throw new IllegalArgumentException("Unhandled leg type: " + type); - } - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private void parseQueryTripsResult(final JSONObject head, final Location from, final Location to, - final QueryTripsResult result) throws IOException { - try { - // Fill trips. - final JSONArray journeys = head.getJSONArray("journeys"); - for (int i = 0; i < journeys.length(); ++i) { - final JSONObject journey = journeys.getJSONObject(i); - final int changeCount = journey.getInt("nb_transfers"); - - // Build leg list. - final List legs = new LinkedList<>(); - final JSONArray sections = journey.getJSONArray("sections"); - - for (int j = 0; j < sections.length(); ++j) { - final JSONObject section = sections.getJSONObject(j); - final Leg leg = parseLeg(section); - if (leg != null) - legs.add(leg); - } - - result.trips.add(new Trip(null, from, to, legs, null, null, changeCount)); - } - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private Line parseLine(final JSONObject jsonRoute) throws IOException { - try { - final JSONObject jsonLine = jsonRoute.getJSONObject("line"); - final String lineId = jsonLine.getString("id"); - String network = null; - if (jsonLine.has("network")) - network = Strings.emptyToNull(jsonLine.getJSONObject("network").optString("name")); - final JSONObject mode = jsonRoute.getJSONArray("physical_modes").getJSONObject(0); - final String modeId = mode.getString("id"); - final Product product = parseLineProductFromMode(modeId); - final String code = jsonLine.getString("code"); - final String name = Strings.emptyToNull(jsonLine.optString("name")); - final String color = Strings.emptyToNull(jsonLine.getString("color")); - final String textColor = Strings.emptyToNull(jsonLine.optString("text_color")); - final Style lineStyle = getLineStyle(network, product, code, color != null ? "#" + color : null, - textColor != null ? "#" + textColor : null); - - return new Line(lineId, network, product, code, name, lineStyle); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private @Nullable Product parseLineProductFromMode(final String modeId) { - final String modeType = modeId.replace("physical_mode:", ""); - final PhysicalMode physicalMode = PhysicalMode.valueOf(modeType.toUpperCase()); - - switch (physicalMode) { - case BUS: - case BUSRAPIDTRANSIT: - case COACH: - case SHUTTLE: - return Product.BUS; - case RAPIDTRANSIT: - case TRAIN: - case LOCALTRAIN: - case LONGDISTANCETRAIN: - case VAL: - case RAILSHUTTLE: - return Product.SUBURBAN_TRAIN; - case TRAMWAY: - case TRAM: - return Product.TRAM; - case METRO: - return Product.SUBWAY; - case FERRY: - return Product.FERRY; - case FUNICULAR: - return Product.CABLECAR; - case TAXI: - return Product.ON_DEMAND; - case OTHER: - return null; - default: - throw new IllegalArgumentException("Unhandled physical mode: " + modeId); - } - } - - private LineDestination getStationLine(final Line line, final JSONObject jsonDeparture) throws IOException { - try { - final JSONObject route = jsonDeparture.getJSONObject("route"); - final JSONObject direction = route.getJSONObject("direction"); - final Location destination = parseLocation(direction); - - return new LineDestination(line, destination); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - private String getStopAreaId(final String stopPointId) throws IOException { - final HttpUrl.Builder url = url().addPathSegment("stop_points").addPathSegment(stopPointId); - url.addQueryParameter("depth", "1"); - final CharSequence page = httpClient.get(url.build()); - - try { - final JSONObject head = new JSONObject(page.toString()); - final JSONArray stopPoints = head.getJSONArray("stop_points"); - final JSONObject stopPoint = stopPoints.getJSONObject(0); - final JSONObject stopArea = stopPoint.getJSONObject("stop_area"); - return stopArea.getString("id"); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - // this should be overridden by networks not providing one of the default capabilities - @Override - protected boolean hasCapability(final Capability capability) { - return CAPABILITIES.contains(capability); - } - - @Override - public NearbyLocationsResult queryNearbyLocations(final Set types, final Location location, - int maxDistance, final int maxLocations) throws IOException { - final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null); - - // Build url depending of location type. - final HttpUrl.Builder url = url(); - if (location.hasCoord()) { - final double lon = location.getLonAsDouble(); - final double lat = location.getLatAsDouble(); - url.addPathSegment("coords").addPathSegment(lon + ";" + lat); - } else if (location.type == LocationType.STATION) { - if (!location.isIdentified()) - throw new IllegalArgumentException(); - url.addPathSegment("stop_points").addPathSegment(location.id); - } else if (location.type == LocationType.POI) { - if (!location.isIdentified()) - throw new IllegalArgumentException(); - url.addPathSegment("pois").addPathSegment(location.id); - } else { - throw new IllegalArgumentException("Unhandled location type: " + location.type); - } - url.addPathSegment("places_nearby"); - url.addQueryParameter("type[]", "stop_point"); - url.addQueryParameter("distance", Integer.toString(maxDistance == 0 ? 50000 : maxDistance)); - if (maxLocations > 0) - url.addQueryParameter("count", Integer.toString(maxLocations)); - url.addQueryParameter("depth", "3"); - final CharSequence page = httpClient.get(url.build()); - - try { - final JSONObject head = new JSONObject(page.toString()); - - final JSONObject pagination = head.getJSONObject("pagination"); - final int nbResults = pagination.getInt("total_result"); - // If no result is available, location id must be - // faulty. - if (nbResults == 0) { - return new NearbyLocationsResult(resultHeader, Status.INVALID_ID); - } else { - final List stations = new ArrayList<>(); - - final JSONArray places = head.getJSONArray("places_nearby"); - - // Cycle through nearby stations. - for (int i = 0; i < places.length(); ++i) { - final JSONObject place = places.getJSONObject(i); - - // Add location to station list only if - // station is active, i.e. at least one - // departure exists within one hour. - final Location nearbyLocation = parseLocation(place); - stations.add(nearbyLocation); - } - - return new NearbyLocationsResult(resultHeader, stations); - } - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - @Override - public QueryDeparturesResult queryDepartures(final String stationId, final @Nullable Date time, - final int maxDepartures, final boolean equivs) throws IOException { - checkNotNull(Strings.emptyToNull(stationId)); - - final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null); - - try { - final QueryDeparturesResult result = new QueryDeparturesResult(resultHeader, - QueryDeparturesResult.Status.OK); - - // If equivs is equal to true, get stop_area corresponding - // to stop_point and query departures. - final HttpUrl.Builder url = url(); - final String header = stationId.substring(0, stationId.indexOf(":")); - if (equivs && header.equals("stop_point")) { - final String stopAreaId = getStopAreaId(stationId); - url.addPathSegment("stop_areas"); - url.addPathSegment(stopAreaId); - } else if (header.equals("stop_area")) { - url.addPathSegment("stop_areas"); - url.addPathSegment(stationId); - } else { - url.addPathSegment("stop_points"); - url.addPathSegment(stationId); - } - url.addPathSegment("departures"); - url.addQueryParameter("from_datetime", printDate(time)); - url.addQueryParameter("count", Integer.toString(maxDepartures)); - url.addQueryParameter("duration", "86400"); - url.addQueryParameter("depth", "0"); - - final CharSequence page = httpClient.get(url.build()); - - final JSONObject head = new JSONObject(page.toString()); - - final JSONArray departures = head.getJSONArray("departures"); - - // Fill departures in StationDepartures. - for (int i = 0; i < departures.length(); ++i) { - final JSONObject jsonDeparture = departures.getJSONObject(i); - - // Build departure date. - final JSONObject stopDateTime = jsonDeparture.getJSONObject("stop_date_time"); - final String departureDateTime = stopDateTime.getString("departure_date_time"); - final Date plannedTime = parseDate(departureDateTime); - - // Build line. - final JSONObject route = jsonDeparture.getJSONObject("route"); - final Line line = parseLine(route); - - final JSONObject stopPoint = jsonDeparture.getJSONObject("stop_point"); - final Location location = parsePlace(stopPoint, PlaceType.STOP_POINT); - - // If stop point has already been added, retrieve it from result, - // otherwise add it and add station lines. - StationDepartures stationDepartures = result.findStationDepartures(location.id); - if (stationDepartures == null) { - stationDepartures = new StationDepartures(location, new LinkedList(), - new LinkedList()); - result.stationDepartures.add(stationDepartures); - } - final LineDestination lineDestination = getStationLine(line, jsonDeparture); - final List lines = stationDepartures.lines; - if (lines != null && !lines.contains(lineDestination)) - lines.add(lineDestination); - final Location destination = lineDestination.destination; - - // Add departure to list. - final Departure departure = new Departure(plannedTime, null, line, null, destination, null, null); - stationDepartures.departures.add(departure); - } - - return result; - } catch (final JSONException | ParseException jsonExc) { - throw new ParserException(jsonExc); - } catch (final NotFoundException fnfExc) { - try { - final JSONObject head = new JSONObject(fnfExc.getBodyPeek().toString()); - final JSONObject error = head.getJSONObject("error"); - final String id = error.getString("id"); - - if (id.equals("unknown_object")) - return new QueryDeparturesResult(resultHeader, QueryDeparturesResult.Status.INVALID_STATION); - else - throw new IllegalArgumentException("Unhandled error id: " + id); - } catch (final JSONException jsonExc) { - throw new ParserException("Cannot parse error content, original exception linked", fnfExc); - } - } - } - - @Override - public SuggestLocationsResult suggestLocations(final CharSequence constraint, - final @Nullable Set types, final int maxLocations) throws IOException { - final String nameCstr = constraint.toString(); - - final HttpUrl.Builder url = url().addPathSegment("places"); - url.addQueryParameter("q", nameCstr); - if (types == null || types.contains(LocationType.ANY) || types.contains(LocationType.STATION)) - url.addQueryParameter("type[]", "stop_area"); - if (types == null || types.contains(LocationType.ANY) || types.contains(LocationType.ADDRESS)) - url.addQueryParameter("type[]", "address"); - if (types == null || types.contains(LocationType.ANY) || types.contains(LocationType.POI)) - url.addQueryParameter("type[]", "poi"); - url.addQueryParameter("type[]", "administrative_region"); - url.addQueryParameter("depth", "1"); - final CharSequence page = httpClient.get(url.build()); - - try { - final List locations = new ArrayList<>(); - - final JSONObject head = new JSONObject(page.toString()); - - if (head.has("places")) { - final JSONArray places = head.getJSONArray("places"); - final int numPlaces = places.length(); - - for (int i = 0; i < numPlaces; ++i) { - final JSONObject place = places.getJSONObject(i); - final int priority = numPlaces - i; // "quality" found in JSON is deprecated, only sort order matters - - // Add location to station list. - final Location location = parseLocation(place); - locations.add(new SuggestedLocation(location, priority)); - } - } - - final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null); - return new SuggestLocationsResult(resultHeader, locations); - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - @Override - public QueryTripsResult queryTrips(final Location from, final @Nullable Location via, final Location to, - final Date date, final boolean dep, @Nullable TripOptions options) throws IOException { - final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null); - - try { - if (from != null && from.isIdentified() && to != null && to.isIdentified()) { - final HttpUrl.Builder url = url().addPathSegment("journeys"); - url.addQueryParameter("from", printLocation(from)); - url.addQueryParameter("to", printLocation(to)); - url.addQueryParameter("datetime", printDate(date)); - url.addQueryParameter("datetime_represents", dep ? "departure" : "arrival"); - url.addQueryParameter("min_nb_journeys", Integer.toString(this.numTripsRequested)); - url.addQueryParameter("depth", "0"); - - if (options == null) - options = new TripOptions(); - - // Set walking speed. - if (options.walkSpeed != null) { - final double walkingSpeed; - switch (options.walkSpeed) { - case SLOW: - walkingSpeed = 1.12 * 0.8; - break; - case FAST: - walkingSpeed = 1.12 * 1.2; - break; - case NORMAL: - default: - walkingSpeed = 1.12; - break; - } - - url.addQueryParameter("walking_speed", Double.toString(walkingSpeed)); - } - - if (options.flags != null && options.flags.contains(TripFlag.BIKE)) { - url.addQueryParameter("first_section_mode", "bike"); - url.addQueryParameter("last_section_mode", "bike"); - } - - // Set forbidden physical modes. - if (options.products != null && !options.products.equals(Product.ALL)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Air"); - url.addQueryParameter("forbidden_uris[]", "physical_mode:Boat"); - if (!options.products.contains(Product.REGIONAL_TRAIN)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Localdistancetrain"); - url.addQueryParameter("forbidden_uris[]", "physical_mode:Train"); - } - if (!options.products.contains(Product.SUBURBAN_TRAIN)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Localtrain"); - url.addQueryParameter("forbidden_uris[]", "physical_mode:Train"); - url.addQueryParameter("forbidden_uris[]", "physical_mode:Rapidtransit"); - } - if (!options.products.contains(Product.SUBWAY)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Metro"); - } - if (!options.products.contains(Product.TRAM)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Tramway"); - } - if (!options.products.contains(Product.BUS)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Bus"); - url.addQueryParameter("forbidden_uris[]", "physical_mode:Busrapidtransit"); - url.addQueryParameter("forbidden_uris[]", "physical_mode:Coach"); - url.addQueryParameter("forbidden_uris[]", "physical_mode:Shuttle"); - } - if (!options.products.contains(Product.FERRY)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Ferry"); - } - if (!options.products.contains(Product.CABLECAR)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Funicular"); - } - if (!options.products.contains(Product.ON_DEMAND)) { - url.addQueryParameter("forbidden_uris[]", "physical_mode:Taxi"); - } - } - - final CharSequence page = httpClient.get(url.build()); - - try { - final JSONObject head = new JSONObject(page.toString()); - - if (head.has("error")) { - final JSONObject error = head.getJSONObject("error"); - final String id = error.getString("id"); - - if (id.equals("no_solution")) - return new QueryTripsResult(resultHeader, QueryTripsResult.Status.NO_TRIPS); - else - throw new IllegalArgumentException("Unhandled error id: " + id); - } else { - // Fill context. - HttpUrl prevQueryUrl = null; - HttpUrl nextQueryUrl = null; - final JSONArray links = head.getJSONArray("links"); - for (int i = 0; i < links.length(); ++i) { - final JSONObject link = links.getJSONObject(i); - final String type = link.getString("type"); - if (type.equals("prev")) { - prevQueryUrl = HttpUrl.parse(link.getString("href")); - } else if (type.equals("next")) { - nextQueryUrl = HttpUrl.parse(link.getString("href")); - } - } - - String prevQueryUrlString = prevQueryUrl != null ? prevQueryUrl.toString() : null; - String nextQueryUrlString = nextQueryUrl != null ? nextQueryUrl.toString() : null; - - final QueryTripsResult result = new QueryTripsResult(resultHeader, url.build().toString(), from, - null, to, new Context(from, to, prevQueryUrlString, nextQueryUrlString), - new LinkedList()); - - parseQueryTripsResult(head, from, to, result); - - return result; - } - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } else if (from != null && to != null) { - List ambiguousFrom = null, ambiguousTo = null; - Location newFrom = null, newTo = null; - - if (!from.isIdentified() && from.hasName()) { - ambiguousFrom = suggestLocations(from.name, null, 0).getLocations(); - if (ambiguousFrom.isEmpty()) - return new QueryTripsResult(resultHeader, QueryTripsResult.Status.UNKNOWN_FROM); - if (ambiguousFrom.size() == 1 && ambiguousFrom.get(0).isIdentified()) - newFrom = ambiguousFrom.get(0); - } - - if (!to.isIdentified() && to.hasName()) { - ambiguousTo = suggestLocations(to.name, null, 0).getLocations(); - if (ambiguousTo.isEmpty()) - return new QueryTripsResult(resultHeader, QueryTripsResult.Status.UNKNOWN_TO); - if (ambiguousTo.size() == 1 && ambiguousTo.get(0).isIdentified()) - newTo = ambiguousTo.get(0); - } - - if (newTo != null && newFrom != null) - return queryTrips(newFrom, via, newTo, date, dep, options); - - if (ambiguousFrom != null || ambiguousTo != null) - return new QueryTripsResult(resultHeader, ambiguousFrom, null, ambiguousTo); - } - return new QueryTripsResult(resultHeader, QueryTripsResult.Status.NO_TRIPS); - } catch (final NotFoundException fnfExc) { - try { - final JSONObject head = new JSONObject(fnfExc.getBodyPeek().toString()); - final JSONObject error = head.getJSONObject("error"); - final String id = error.getString("id"); - - if (id.equals("unknown_object")) { - // Identify unknown object. - final String fromString = printLocation(from); - final String toString = printLocation(to); - - final String message = error.getString("message"); - if (message.contains(fromString)) - return new QueryTripsResult(resultHeader, QueryTripsResult.Status.UNKNOWN_FROM); - else if (message.contains(toString)) - return new QueryTripsResult(resultHeader, QueryTripsResult.Status.UNKNOWN_TO); - else - throw new IllegalArgumentException("Unhandled error message: " + message); - } else if (id.equals("date_out_of_bounds")) { - return new QueryTripsResult(resultHeader, QueryTripsResult.Status.INVALID_DATE); - } else { - throw new IllegalArgumentException("Unhandled error id: " + id); - } - } catch (final JSONException jsonExc) { - throw new ParserException("Cannot parse error content, original exception linked", fnfExc); - } - } - } - - @Override - public QueryTripsResult queryMoreTrips(final QueryTripsContext contextObj, final boolean later) throws IOException { - final ResultHeader resultHeader = new ResultHeader(network, SERVER_PRODUCT, SERVER_VERSION, null, 0, null); - - final Context context = (Context) contextObj; - final Location from = context.from; - final Location to = context.to; - final HttpUrl queryUrl = HttpUrl.parse(later ? context.nextQueryUri : context.prevQueryUri); - final CharSequence page = httpClient.get(queryUrl); - - try { - if (from.isIdentified() && to.isIdentified()) { - final JSONObject head = new JSONObject(page.toString()); - - // Fill context. - final JSONArray links = head.getJSONArray("links"); - final JSONObject prev = links.getJSONObject(0); - final HttpUrl prevQueryUrl = HttpUrl.parse(prev.getString("href")); - final JSONObject next = links.getJSONObject(1); - final HttpUrl nextQueryUrl = HttpUrl.parse(next.getString("href")); - - final QueryTripsResult result = new QueryTripsResult(resultHeader, queryUrl.toString(), from, null, to, - new Context(from, to, prevQueryUrl.toString(), nextQueryUrl.toString()), - new LinkedList()); - - parseQueryTripsResult(head, from, to, result); - - return result; - } else { - return new QueryTripsResult(null, QueryTripsResult.Status.NO_TRIPS); - } - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } - - @Override - public Point[] getArea() throws IOException { - final HttpUrl.Builder url = url(); - final CharSequence page = httpClient.get(url.build()); - - try { - // Get shape string. - final JSONObject head = new JSONObject(page.toString()); - final JSONArray regions = head.getJSONArray("regions"); - final JSONObject regionInfo = regions.getJSONObject(0); - final String shape = regionInfo.getString("shape"); - - // Parse string using JSON tokenizer for coordinates. - List pointList = new ArrayList<>(); - final JSONTokener shapeTokener = new JSONTokener(shape); - shapeTokener.skipTo('('); - shapeTokener.next(); - shapeTokener.next(); - char c = shapeTokener.next(); - while (c != ')') { - // Navitia coordinates are in (longitude, latitude) order. - final String lonString = shapeTokener.nextTo(' '); - shapeTokener.next(); - final String latString = shapeTokener.nextTo(",)"); - c = shapeTokener.next(); - - // Append new point with (latitude, longitude) order. - final double lat = Double.parseDouble(latString); - final double lon = Double.parseDouble(lonString); - pointList.add(Point.fromDouble(lat, lon)); - } - - // Fill point array. - final Point[] pointArray = new Point[pointList.size()]; - for (int i = 0; i < pointList.size(); ++i) - pointArray[i] = pointList.get(i); - - return pointArray; - } catch (final JSONException jsonExc) { - throw new ParserException(jsonExc); - } - } -} diff --git a/src/de/schildbach/pte/AustraliaProvider.java b/src/de/schildbach/pte/AustraliaProvider.java deleted file mode 100644 index 26242ef6..00000000 --- a/src/de/schildbach/pte/AustraliaProvider.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import java.util.HashMap; -import java.util.Map; - -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; - -import okhttp3.HttpUrl; - -public class AustraliaProvider extends AbstractNavitiaProvider { - - public static final String NETWORK_PTV = "PTV - Public Transport Victoria"; - public static final String NETWORK_TAS = "Metro Tasmania"; - public static final String NETWORK_QLD = "TransLink"; - public static final String NETWORK_SA = "Adelaide Metro"; - public static final String NETWORK_WA = "Transperth"; - - private static final Map STYLES = new HashMap<>(); - - static { - // Melbourne train networks. - // https://static.ptv.vic.gov.au/Maps/1482457134/PTV_Train-Network-Map_2017.pdf - STYLES.put(NETWORK_PTV + "|SBelgrave", new Style(Style.Shape.RECT, Style.parseColor("#094B8D"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SLilydale", new Style(Style.Shape.RECT, Style.parseColor("#094B8D"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SAlamein", new Style(Style.Shape.RECT, Style.parseColor("#094B8D"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SGlen Waverly", - new Style(Style.Shape.RECT, Style.parseColor("#094B8D"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SSunbury", new Style(Style.Shape.RECT, Style.parseColor("#FFB531"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|SCraigieburn", - new Style(Style.Shape.RECT, Style.parseColor("#FFB531"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|SUpfield", new Style(Style.Shape.RECT, Style.parseColor("#FFB531"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|SSouth Morang", - new Style(Style.Shape.RECT, Style.parseColor("#E42B23"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SHurstbridge", - new Style(Style.Shape.RECT, Style.parseColor("#E42B23"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SPakenham", new Style(Style.Shape.RECT, Style.parseColor("#16B4E8"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SCranbourne", new Style(Style.Shape.RECT, Style.parseColor("#16B4E8"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SFrankston", new Style(Style.Shape.RECT, Style.parseColor("#149943"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SWerribee", new Style(Style.Shape.RECT, Style.parseColor("#149943"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|SWilliamstown", - new Style(Style.Shape.RECT, Style.parseColor("#149943"), Style.WHITE)); - - // Truncated version of "Sandringham". Not sure if this is a bug/limitation in either Navitia or the - // GTFS feed from PTV. - STYLES.put(NETWORK_PTV + "|SSandringha", new Style(Style.Shape.RECT, Style.parseColor("#FC7EBB"), Style.BLACK)); - - // Difficult to test this, because the line is open only for select periods of the year (e.g. for the - // Melbourne Show in September) and at time of writing, the GTFS feed did not have data up until then. - STYLES.put(NETWORK_PTV + "|SFlemington Racecourse", - new Style(Style.Shape.RECT, Style.parseColor("#9A9B9F"), Style.BLACK)); - - // Melbourne Trams. - // https://static.ptv.vic.gov.au/Maps/1493356745/PTV_Tram-Network-Map_2017.pdf - STYLES.put(NETWORK_PTV + "|T1", new Style(Style.Shape.RECT, Style.parseColor("#B8C53A"), Style.BLACK)); - - // The GTFS feed seems to combine 3 + 3a like this, but for completeness we include 3 and 3a - // separately too. - STYLES.put(NETWORK_PTV + "|T3", new Style(Style.Shape.RECT, Style.parseColor("#87D9F2"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T3a", new Style(Style.Shape.RECT, Style.parseColor("#87D9F2"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T3/3a", new Style(Style.Shape.RECT, Style.parseColor("#87D9F2"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T5", new Style(Style.Shape.RECT, Style.parseColor("#F44131"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T6", new Style(Style.Shape.RECT, Style.parseColor("#004969"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T11", new Style(Style.Shape.RECT, Style.parseColor("#7ECBA4"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T12", new Style(Style.Shape.RECT, Style.parseColor("#008A99"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T16", new Style(Style.Shape.RECT, Style.parseColor("#FFD86C"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T19", new Style(Style.Shape.RECT, Style.parseColor("#87457A"), Style.WHITE)); // Night - STYLES.put(NETWORK_PTV + "|T30", new Style(Style.Shape.RECT, Style.parseColor("#3343A3"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T35", new Style(Style.Shape.RECT, Style.parseColor("#6E351C"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T48", new Style(Style.Shape.RECT, Style.parseColor("#45474C"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T57", new Style(Style.Shape.RECT, Style.parseColor("#45C6CE"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T58", new Style(Style.Shape.RECT, Style.parseColor("#878E94"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T59", new Style(Style.Shape.RECT, Style.parseColor("#438459"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T64", new Style(Style.Shape.RECT, Style.parseColor("#2EB070"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T67", new Style(Style.Shape.RECT, Style.parseColor("#B47962"), Style.WHITE)); // Night - STYLES.put(NETWORK_PTV + "|T70", new Style(Style.Shape.RECT, Style.parseColor("#FC8BC1"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T72", new Style(Style.Shape.RECT, Style.parseColor("#97BAA6"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T75", new Style(Style.Shape.RECT, Style.parseColor("#00A8DF"), Style.WHITE)); // Night - STYLES.put(NETWORK_PTV + "|T78", new Style(Style.Shape.RECT, Style.parseColor("#7B7EC0"), Style.WHITE)); - STYLES.put(NETWORK_PTV + "|T82", new Style(Style.Shape.RECT, Style.parseColor("#BCD649"), Style.BLACK)); - STYLES.put(NETWORK_PTV + "|T86", new Style(Style.Shape.RECT, Style.parseColor("#FFB730"), Style.BLACK)); // Night - STYLES.put(NETWORK_PTV + "|T96", new Style(Style.Shape.RECT, Style.parseColor("#F2428F"), Style.WHITE)); // Night - STYLES.put(NETWORK_PTV + "|T109", new Style(Style.Shape.RECT, Style.parseColor("#FF7B24"), Style.WHITE)); // Night - - STYLES.put(NETWORK_PTV + "|B", new Style(Style.Shape.RECT, Style.parseColor("#EA8D1E"), Style.WHITE)); - - // NOTE: This is a work around for poor GTFS data. We should instead say "All REGIONAL_TRAINs are - // purple", but the GTFS feed from Navitia instead returns rural trains as SUBURBAN_TRAINs. Given we - // have already provided colours for all suburban trains above, this more general statement about - // suburban trains results in all regional trains being coloured purple, as intented. - STYLES.put(NETWORK_PTV + "|S", new Style(Style.Shape.RECT, Style.parseColor("#782F9A"), Style.WHITE)); - - // Sydney train networks. - // http://www.sydneytrains.info/stations/pdf/suburban_map.pdf - // Navitia is not returning enough info in "display_informations" to colourise correctly. - // Specifically, they are not returning "code" which usually is the display name of the line. - // At any rate, the EFA provider for Sydney is likely going to be better than this Navitia provider - // anyway. - - // Adelaide train/tram networks. - // These are already colourised correctly by the GTFS data given to Navitia. - // But for reference, the map is available at https://www.adelaidemetro.com.au/Timetables-Maps/Maps. - - // Brisbane train/tram/bus/ferry networks. - // These are already colourised correctly by the GTFS data given to Navitia. - // But for reference, the maps are available at https://translink.com.au/plan-your-journey/maps. - - // Perth train/bus/ferry networks. - // These are already colourised correctly by the GTFS data given to Navitia. - // The styles do not include "display_informations" with a proper "code" though, so the names are not - // displayed. But for reference, the maps are available at - // http://www.transperth.wa.gov.au/Journey-Planner/Network-Maps. - - // Tasmania bus networks. - // Somewhat colourised in Navitia (e.g. Launceston has green buses), but it is incorrect (e.g. - // Launceston should have all sorts of different coloured buses). Maps are available at - // https://www.metrotas.com.au/timetables/. - } - - public AustraliaProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.AUSTRALIA, apiBase, authorization); - - setTimeZone("Australia/Melbourne"); - setStyles(STYLES); - } - - public AustraliaProvider(final String authorization) { - super(NetworkId.AUSTRALIA, authorization); - - setTimeZone("Australia/Melbourne"); - setStyles(STYLES); - } - - @Override - public String region() { - return "au"; - } - - @Override - protected Style getLineStyle(String network, Product product, String code, String backgroundColor, - String foregroundColor) { - final Style overridenStyle = lineStyle(network, product, code); - if (overridenStyle != Standard.STYLES.get(product)) - return overridenStyle; - else - return super.getLineStyle(network, product, code, backgroundColor, foregroundColor); - } -} diff --git a/src/de/schildbach/pte/BrazilProvider.java b/src/de/schildbach/pte/BrazilProvider.java deleted file mode 100644 index af249fdc..00000000 --- a/src/de/schildbach/pte/BrazilProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.Style.Shape; - -/** - * @author Torsten Grote - */ -public class BrazilProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "br"; - - public BrazilProvider(final String authorization) { - super(NetworkId.BRAZIL, authorization); - setTimeZone("America/Sao_Paulo"); - } - - @Override - public String region() { - return API_REGION; - } - - @Override - protected Style getLineStyle(final String network, final Product product, final String code, final String color) { - final Style defaultStyle = Standard.STYLES.get(product); - int bc = defaultStyle.backgroundColor; - int fc = defaultStyle.foregroundColor; - if (color != null) { - bc = Style.parseColor(color); - fc = computeForegroundColor(color); - } - - switch (product) { - case SUBURBAN_TRAIN: { - return new Style(Shape.CIRCLE, bc, fc); - } - case SUBWAY: { - return new Style(Shape.CIRCLE, bc, fc); - } - case TRAM: { - return new Style(Shape.RECT, bc, fc); - } - case BUS: { - return new Style(Shape.RECT, bc, fc); - } - default: - return new Style(bc, fc); - } - } -} diff --git a/src/de/schildbach/pte/BritishColumbiaProvider.java b/src/de/schildbach/pte/BritishColumbiaProvider.java deleted file mode 100644 index 455973f4..00000000 --- a/src/de/schildbach/pte/BritishColumbiaProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -/** - * @author Stephane Berube - */ -public class BritishColumbiaProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "ca-bc"; - - public BritishColumbiaProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.BRITISHCOLUMBIA, apiBase, authorization); - setTimeZone("America/Vancouver"); - } - - public BritishColumbiaProvider(final String authorization) { - super(NetworkId.BRITISHCOLUMBIA, authorization); - setTimeZone("America/Vancouver"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/CzechRepublicProvider.java b/src/de/schildbach/pte/CzechRepublicProvider.java deleted file mode 100644 index c5623172..00000000 --- a/src/de/schildbach/pte/CzechRepublicProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -/** - * @author Filip Hejsek - */ -public class CzechRepublicProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "cz"; - - public CzechRepublicProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.CZECH_REPUBLIC, apiBase, authorization); - setTimeZone("Europe/Prague"); - } - - public CzechRepublicProvider(final String authorization) { - super(NetworkId.CZECH_REPUBLIC, authorization); - setTimeZone("Europe/Prague"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/FinlandProvider.java b/src/de/schildbach/pte/FinlandProvider.java deleted file mode 100644 index 6178dc24..00000000 --- a/src/de/schildbach/pte/FinlandProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import de.schildbach.pte.util.WordUtils; - -import okhttp3.HttpUrl; - -/** - * @author Adrian Perez de Castro - */ -public class FinlandProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "fi"; - - public FinlandProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.FINLAND, apiBase, authorization); - setTimeZone("Europe/Helsinki"); - } - - public FinlandProvider(final String authorization) { - super(NetworkId.FINLAND, authorization); - setTimeZone("Europe/Helsinki"); - } - - @Override - public String region() { - return API_REGION; - } - - @Override - protected String getLocationName(final String name) { - return WordUtils.capitalizeFully(name); - } -} diff --git a/src/de/schildbach/pte/FranceNorthEastProvider.java b/src/de/schildbach/pte/FranceNorthEastProvider.java deleted file mode 100644 index 72e72ee9..00000000 --- a/src/de/schildbach/pte/FranceNorthEastProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2016 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.Style.Shape; - -import okhttp3.HttpUrl; - -/** - * @author Nicolas Derive - * @author Stéphane Guillou - */ -public class FranceNorthEastProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "fr-ne"; - // dataset available at: https://navitia.opendatasoft.com/explore/dataset/fr-ne/ - - public FranceNorthEastProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.FRANCENORTHEAST, apiBase, authorization); - - setTimeZone("Europe/Paris"); - } - - public FranceNorthEastProvider(final String authorization) { - super(NetworkId.FRANCENORTHEAST, authorization); - - setTimeZone("Europe/Paris"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/FranceNorthWestProvider.java b/src/de/schildbach/pte/FranceNorthWestProvider.java deleted file mode 100644 index 53ad9b5a..00000000 --- a/src/de/schildbach/pte/FranceNorthWestProvider.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2016 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -/** - * @author Patrick Kanzler - */ -public class FranceNorthWestProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "fr-nw"; - - public FranceNorthWestProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.FRANCENORTHWEST, apiBase, authorization); - - setTimeZone("Europe/Paris"); - } - - public FranceNorthWestProvider(final String authorization) { - super(NetworkId.FRANCENORTHWEST, authorization); - - setTimeZone("Europe/Paris"); - } - - @Override - public String region() { - return API_REGION; - } - - @Override - protected String getAddressName(final String name, final String houseNumber) { - return houseNumber + " " + name; - } -} diff --git a/src/de/schildbach/pte/FranceSouthEastProvider.java b/src/de/schildbach/pte/FranceSouthEastProvider.java deleted file mode 100644 index d224c488..00000000 --- a/src/de/schildbach/pte/FranceSouthEastProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2016 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.Style.Shape; - -import okhttp3.HttpUrl; - -/** - * @author Anthony Chaput - */ -public class FranceSouthEastProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "fr-se"; - - public FranceSouthEastProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.FRANCESOUTHEAST, apiBase, authorization); - - setTimeZone("Europe/Paris"); - } - - public FranceSouthEastProvider(final String authorization) { - super(NetworkId.FRANCESOUTHEAST, authorization); - - setTimeZone("Europe/Paris"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/FranceSouthWestProvider.java b/src/de/schildbach/pte/FranceSouthWestProvider.java deleted file mode 100644 index 1e0597af..00000000 --- a/src/de/schildbach/pte/FranceSouthWestProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.Style.Shape; - -import okhttp3.HttpUrl; - -/** - * @author Nicolas Derive - */ -public class FranceSouthWestProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "fr-sw"; - - public FranceSouthWestProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.FRANCESOUTHWEST, apiBase, authorization); - - setTimeZone("Europe/Paris"); - } - - public FranceSouthWestProvider(final String authorization) { - super(NetworkId.FRANCESOUTHWEST, authorization); - - setTimeZone("Europe/Paris"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/GhanaProvider.java b/src/de/schildbach/pte/GhanaProvider.java deleted file mode 100644 index e1f151aa..00000000 --- a/src/de/schildbach/pte/GhanaProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -public class GhanaProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "gh"; - - public GhanaProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.GHANA, apiBase, authorization); - setTimeZone("UTC"); - } - - public GhanaProvider(final String authorization) { - super(NetworkId.GHANA, authorization); - setTimeZone("UTC"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/ItalyProvider.java b/src/de/schildbach/pte/ItalyProvider.java deleted file mode 100644 index 982be3a8..00000000 --- a/src/de/schildbach/pte/ItalyProvider.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import de.schildbach.pte.util.WordUtils; - -import okhttp3.HttpUrl; - -/** - * @author Antonio El Khoury - */ -public class ItalyProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "it"; - - public ItalyProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.IT, apiBase, authorization); - - setTimeZone("Europe/Rome"); - } - - public ItalyProvider(final String authorization) { - super(NetworkId.IT, authorization); - - setTimeZone("Europe/Rome"); - } - - @Override - public String region() { - return API_REGION; - } - - @Override - protected String getLocationName(String name) { - return WordUtils.capitalizeFully(name); - } -} diff --git a/src/de/schildbach/pte/MassachusettsProvider.java b/src/de/schildbach/pte/MassachusettsProvider.java deleted file mode 100644 index c5615146..00000000 --- a/src/de/schildbach/pte/MassachusettsProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2018 Erik Uhlmann. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -/** - * @author Erik Uhlmann - */ -public class MassachusettsProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "us-ma"; - - public MassachusettsProvider(HttpUrl apiBase, String authorization) { - super(NetworkId.MASSACHUSETTS, apiBase, authorization); - setTimeZone("America/New_York"); - } - - public MassachusettsProvider(final String authorization) { - super(NetworkId.MASSACHUSETTS, authorization); - setTimeZone("America/New_York"); - } - - @Override - protected String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/NetworkId.java b/src/de/schildbach/pte/NetworkId.java index c194c1a3..f5282d24 100644 --- a/src/de/schildbach/pte/NetworkId.java +++ b/src/de/schildbach/pte/NetworkId.java @@ -30,18 +30,9 @@ public enum NetworkId { // Austria OEBB, VAO, VOR, WIEN, OOEVV, LINZ, SVV, VVT, STV, VMOBIL, - // Czech Republic - CZECH_REPUBLIC, - // Switzerland VBL, ZVV, - // France - PARIS, FRANCESOUTHWEST, FRANCESOUTHEAST, FRANCENORTHWEST, FRANCENORTHEAST, - - // Spain - SPAIN, - // Netherlands NS, NEGENTWEE, @@ -51,9 +42,6 @@ public enum NetworkId { // Sweden SE, - // Finland - FINLAND, - // Luxembourg LU, @@ -64,32 +52,14 @@ public enum NetworkId { EIREANN, // Poland - PL, PLNAVITIA, - - // Italy - IT, + PL, // United Arab Emirates DUB, // United States - BART, RTACHICAGO, OREGON, MASSACHUSETTS, CMTA, - - // Canada - ONTARIO, QUEBEC, BRITISHCOLUMBIA, + BART, RTACHICAGO, CMTA, // Australia - SYDNEY, AUSTRALIA, - - // New Zealand - NZ, - - // Africa - GHANA, - - // Nicaragua - NICARAGUA, - - // Brazil - BRAZIL, + SYDNEY, } diff --git a/src/de/schildbach/pte/NicaraguaProvider.java b/src/de/schildbach/pte/NicaraguaProvider.java deleted file mode 100644 index 78508eec..00000000 --- a/src/de/schildbach/pte/NicaraguaProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -/** - * @author ialokim - */ -public class NicaraguaProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "ni"; - - public NicaraguaProvider(final String authorization) { - super(NetworkId.NICARAGUA, authorization); - setTimeZone("America/Managua"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/NzProvider.java b/src/de/schildbach/pte/NzProvider.java deleted file mode 100644 index 631ca049..00000000 --- a/src/de/schildbach/pte/NzProvider.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2014-2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import java.util.HashMap; -import java.util.Map; - -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.Style.Shape; - -/** - * @author Torsten Grote - */ -public class NzProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "nz"; - - public NzProvider(final String authorization) { - super(NetworkId.NZ, authorization); - setTimeZone("Pacific/Auckland"); - setStyles(STYLES); - } - - @Override - public String region() { - return API_REGION; - } - - @Override - protected Style getLineStyle(final String network, final Product product, final String code, final String color) { - if (color != null) { - return lineStyle(this.network.name(), product, code); - } else { - return super.getLineStyle(network, product, code, null); - } - } - - private static final Map STYLES = new HashMap<>(); - static { - // Wellington buses - STYLES.put("B1", new Style(Shape.ROUNDED, Style.parseColor("#A10082"), Style.WHITE)); - STYLES.put("B2", new Style(Shape.ROUNDED, Style.parseColor("#cf142b"), Style.WHITE)); - STYLES.put("B3", new Style(Shape.ROUNDED, Style.parseColor("#61bf1a"), Style.WHITE)); - STYLES.put("B4", new Style(Shape.ROUNDED, Style.parseColor("#52006b"), Style.WHITE)); - STYLES.put("B5", new Style(Shape.ROUNDED, Style.parseColor("#f54029"), Style.WHITE)); - STYLES.put("B6", new Style(Shape.ROUNDED, Style.parseColor("#009970"), Style.WHITE)); - STYLES.put("B7", new Style(Shape.ROUNDED, Style.parseColor("#b35408"), Style.WHITE)); - STYLES.put("B8", new Style(Shape.ROUNDED, Style.parseColor("#703824"), Style.WHITE)); - STYLES.put("B9", new Style(Shape.ROUNDED, Style.parseColor("#d42e12"), Style.WHITE)); - STYLES.put("B10", new Style(Shape.ROUNDED, Style.parseColor("#703824"), Style.WHITE)); - STYLES.put("B11", new Style(Shape.ROUNDED, Style.parseColor("#b35408"), Style.WHITE)); - STYLES.put("B13", new Style(Shape.ROUNDED, Style.parseColor("#974e18"), Style.WHITE)); - STYLES.put("B14", new Style(Shape.ROUNDED, Style.parseColor("#8599a8"), Style.WHITE)); - STYLES.put("B17", new Style(Shape.ROUNDED, Style.parseColor("#61bf1a"), Style.WHITE)); - STYLES.put("B18", new Style(Shape.ROUNDED, Style.parseColor("#00b8e0"), Style.WHITE)); - STYLES.put("B20", new Style(Shape.ROUNDED, Style.parseColor("#f266b5"), Style.WHITE)); - STYLES.put("B21", new Style(Shape.ROUNDED, Style.parseColor("#70752b"), Style.WHITE)); - STYLES.put("B22", new Style(Shape.ROUNDED, Style.parseColor("#d97300"), Style.WHITE)); - STYLES.put("B23", new Style(Shape.ROUNDED, Style.parseColor("#e6b012"), Style.WHITE)); - STYLES.put("B24", new Style(Shape.ROUNDED, Style.parseColor("#214230"), Style.WHITE)); - STYLES.put("B25", new Style(Shape.ROUNDED, Style.parseColor("#002a42"), Style.WHITE)); - STYLES.put("B28", new Style(Shape.ROUNDED, Style.parseColor("#bd9065"), Style.WHITE)); - STYLES.put("B29", new Style(Shape.ROUNDED, Style.parseColor("#006973"), Style.WHITE)); - STYLES.put("B30", new Style(Shape.ROUNDED, Style.parseColor("#703824"), Style.WHITE)); - STYLES.put("B31", new Style(Shape.ROUNDED, Style.parseColor("#cf142b"), Style.WHITE)); - STYLES.put("B32", new Style(Shape.ROUNDED, Style.parseColor("#a10082"), Style.WHITE)); - STYLES.put("B43", new Style(Shape.ROUNDED, Style.parseColor("#8599a8"), Style.WHITE)); - STYLES.put("B44", new Style(Shape.ROUNDED, Style.parseColor("#57b5e0"), Style.WHITE)); - STYLES.put("B45", new Style(Shape.ROUNDED, Style.parseColor("#00b0c7"), Style.WHITE)); - STYLES.put("B46", new Style(Shape.ROUNDED, Style.parseColor("#005ec4"), Style.WHITE)); - STYLES.put("B47", new Style(Shape.ROUNDED, Style.parseColor("#9F6614"), Style.WHITE)); - STYLES.put("B50", new Style(Shape.ROUNDED, Style.parseColor("#008542"), Style.WHITE)); - STYLES.put("B52", new Style(Shape.ROUNDED, Style.parseColor("#4f8c0d"), Style.WHITE)); - STYLES.put("B53", new Style(Shape.ROUNDED, Style.parseColor("#c25e03"), Style.WHITE)); - STYLES.put("B54", new Style(Shape.ROUNDED, Style.parseColor("#a8034f"), Style.WHITE)); - STYLES.put("B55", new Style(Shape.ROUNDED, Style.parseColor("#703824"), Style.WHITE)); - STYLES.put("B56", new Style(Shape.ROUNDED, Style.parseColor("#f58025"), Style.WHITE)); - STYLES.put("B57", new Style(Shape.ROUNDED, Style.parseColor("#eba96b"), Style.WHITE)); - STYLES.put("B58", new Style(Shape.ROUNDED, Style.parseColor("#a8034f"), Style.WHITE)); - STYLES.put("B80", new Style(Shape.ROUNDED, Style.parseColor("#002b45"), Style.WHITE)); - STYLES.put("B81", new Style(Shape.ROUNDED, Style.parseColor("#5c2624"), Style.WHITE)); - STYLES.put("B83", new Style(Shape.ROUNDED, Style.parseColor("#ad2624"), Style.WHITE)); - STYLES.put("B84", new Style(Shape.ROUNDED, Style.parseColor("#f27d00"), Style.WHITE)); - STYLES.put("B85", new Style(Shape.ROUNDED, Style.parseColor("#781496"), Style.WHITE)); - STYLES.put("B90", new Style(Shape.ROUNDED, Style.parseColor("#9278d1"), Style.WHITE)); - STYLES.put("B91", new Style(Shape.ROUNDED, Style.parseColor("#f27d00"), Style.WHITE)); - STYLES.put("B92", new Style(Shape.ROUNDED, Style.parseColor("#6e0a78"), Style.WHITE)); - STYLES.put("B93", new Style(Shape.ROUNDED, Style.parseColor("#a87cb6"), Style.WHITE)); - STYLES.put("B110", new Style(Shape.ROUNDED, Style.parseColor("#9c1a87"), Style.WHITE)); - STYLES.put("B111", new Style(Shape.ROUNDED, Style.parseColor("#00599c"), Style.WHITE)); - STYLES.put("B112", new Style(Shape.ROUNDED, Style.parseColor("#85c7e3"), Style.WHITE)); - STYLES.put("B114", new Style(Shape.ROUNDED, Style.parseColor("#9eab05"), Style.WHITE)); - STYLES.put("B115", new Style(Shape.ROUNDED, Style.parseColor("#006647"), Style.WHITE)); - STYLES.put("B120", new Style(Shape.ROUNDED, Style.parseColor("#0db02b"), Style.WHITE)); - STYLES.put("B121", new Style(Shape.ROUNDED, Style.parseColor("#00599c"), Style.WHITE)); - STYLES.put("B130", new Style(Shape.ROUNDED, Style.parseColor("#00a6d6"), Style.WHITE)); - STYLES.put("B145", new Style(Shape.ROUNDED, Style.parseColor("#2ec7d6"), Style.WHITE)); - STYLES.put("B150", new Style(Shape.ROUNDED, Style.parseColor("#8f2140"), Style.WHITE)); - STYLES.put("B154", new Style(Shape.ROUNDED, Style.parseColor("#e0457a"), Style.WHITE)); - STYLES.put("B160", new Style(Shape.ROUNDED, Style.parseColor("#cf142b"), Style.WHITE)); - STYLES.put("B170", new Style(Shape.ROUNDED, Style.parseColor("#7d7805"), Style.WHITE)); - STYLES.put("B200", new Style(Shape.ROUNDED, Style.parseColor("#e0457a"), Style.WHITE)); - STYLES.put("B201", new Style(Shape.ROUNDED, Style.parseColor("#007073"), Style.WHITE)); - STYLES.put("B202", new Style(Shape.ROUNDED, Style.parseColor("#e6b012"), Style.WHITE)); - STYLES.put("B203", new Style(Shape.ROUNDED, Style.parseColor("#9c70cc"), Style.WHITE)); - STYLES.put("B204", new Style(Shape.ROUNDED, Style.parseColor("#b3c98c"), Style.WHITE)); - STYLES.put("B205", new Style(Shape.ROUNDED, Style.parseColor("#85c7e3"), Style.WHITE)); - STYLES.put("B206", new Style(Shape.ROUNDED, Style.parseColor("#DD0A61"), Style.WHITE)); - STYLES.put("B210", new Style(Shape.ROUNDED, Style.parseColor("#7A1600"), Style.WHITE)); - STYLES.put("B211", new Style(Shape.ROUNDED, Style.parseColor("#F47836"), Style.WHITE)); - STYLES.put("B220", new Style(Shape.ROUNDED, Style.parseColor("#008952"), Style.WHITE)); - STYLES.put("B226", new Style(Shape.ROUNDED, Style.parseColor("#007FB1"), Style.WHITE)); - STYLES.put("B230", new Style(Shape.ROUNDED, Style.parseColor("#D31145"), Style.WHITE)); - STYLES.put("B236", new Style(Shape.ROUNDED, Style.parseColor("#862175"), Style.WHITE)); - STYLES.put("B250", new Style(Shape.ROUNDED, Style.parseColor("#00679D"), Style.WHITE)); - STYLES.put("B260", new Style(Shape.ROUNDED, Style.parseColor("#570861"), Style.WHITE)); - STYLES.put("B261", new Style(Shape.ROUNDED, Style.parseColor("#ED1C24"), Style.WHITE)); - STYLES.put("B262", new Style(Shape.ROUNDED, Style.parseColor("#5D9732"), Style.WHITE)); - STYLES.put("B270", new Style(Shape.ROUNDED, Style.parseColor("#d95121"), Style.WHITE)); - STYLES.put("B280", new Style(Shape.ROUNDED, Style.parseColor("#2526a9"), Style.WHITE)); - STYLES.put("B289", new Style(Shape.ROUNDED, Style.parseColor("#2526a9"), Style.WHITE)); - STYLES.put("B290", new Style(Shape.ROUNDED, Style.parseColor("#00a6de"), Style.WHITE)); - - // Wellington suburban trains - STYLES.put("SHVL", new Style(Shape.ROUNDED, Style.parseColor("#de7008"), Style.WHITE)); - STYLES.put("SWRL", new Style(Shape.ROUNDED, Style.parseColor("#003f8d"), Style.WHITE)); - STYLES.put("SJVL", new Style(Shape.ROUNDED, Style.parseColor("#29c2ce"), Style.WHITE)); - STYLES.put("SKPL", new Style(Shape.ROUNDED, Style.parseColor("#d4d152"), Style.WHITE)); - STYLES.put("SMEL", new Style(Shape.ROUNDED, Style.parseColor("#00885f"), Style.WHITE)); - STYLES.put("SNEX", new Style(Shape.ROUNDED, Style.parseColor("#00354d"), Style.WHITE)); - STYLES.put("SPNL", new Style(Shape.ROUNDED, Style.parseColor("#00354d"), Style.WHITE)); - - // Wellington other - STYLES.put("CCCL", new Style(Shape.ROUNDED, Style.parseColor("#CC0000"), Style.WHITE)); - STYLES.put("FWHF", new Style(Shape.ROUNDED, Style.parseColor("#004b38"), Style.WHITE)); - } -} diff --git a/src/de/schildbach/pte/OntarioProvider.java b/src/de/schildbach/pte/OntarioProvider.java deleted file mode 100644 index b27bf347..00000000 --- a/src/de/schildbach/pte/OntarioProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -/** - * @author Stephane Berube - */ -public class OntarioProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "ca-on"; - - public OntarioProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.ONTARIO, apiBase, authorization); - - setTimeZone("America/Toronto"); - } - - public OntarioProvider(final String authorization) { - super(NetworkId.ONTARIO, authorization); - - setTimeZone("America/Toronto"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/OregonProvider.java b/src/de/schildbach/pte/OregonProvider.java deleted file mode 100644 index 5808cfbd..00000000 --- a/src/de/schildbach/pte/OregonProvider.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2016 Clayton Craft. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -public class OregonProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "us-or"; - - public OregonProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.OREGON, apiBase, authorization); - - setTimeZone("America/Los_Angeles"); - } - - public OregonProvider(final String authorization) { - super(NetworkId.OREGON, authorization); - - setTimeZone("America/Los_Angeles"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/ParisProvider.java b/src/de/schildbach/pte/ParisProvider.java deleted file mode 100644 index c58e5f78..00000000 --- a/src/de/schildbach/pte/ParisProvider.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2014-2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.Style; -import de.schildbach.pte.dto.Style.Shape; -import de.schildbach.pte.util.WordUtils; - -import okhttp3.HttpUrl; - -/** - * @author Antonio El Khoury - */ -public class ParisProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "fr-idf"; - - public ParisProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.PARIS, apiBase, authorization); - - setTimeZone("Europe/Paris"); - } - - public ParisProvider(final String authorization) { - super(NetworkId.PARIS, authorization); - - setTimeZone("Europe/Paris"); - } - - @Override - public String region() { - return API_REGION; - } - - @Override - protected Style getLineStyle(final String network, final Product product, final String code, final String color) { - switch (product) { - case SUBURBAN_TRAIN: { - // RER - if (code.compareTo("F") < 0) { - return new Style(Shape.CIRCLE, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color)); - } - // Transilien - else { - return new Style(Shape.ROUNDED, Style.TRANSPARENT, Style.parseColor(color), Style.parseColor(color)); - } - } - case REGIONAL_TRAIN: { - // TER + Intercités - return new Style(Style.parseColor(color), computeForegroundColor(color)); - } - case SUBWAY: { - // Metro - return new Style(Shape.CIRCLE, Style.parseColor(color), computeForegroundColor(color)); - } - case TRAM: { - // Tram - return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color)); - } - case BUS: { - // Bus + Noctilien - return new Style(Shape.RECT, Style.parseColor(color), computeForegroundColor(color)); - } - case CABLECAR: { - // Orlyval - return new Style(Shape.ROUNDED, Style.parseColor(color), computeForegroundColor(color)); - } - default: - return super.getLineStyle(network, product, code, color); - } - } - - @Override - protected String getLocationName(String name) { - return WordUtils.capitalizeFully(name); - } - - @Override - protected String getAddressName(final String name, final String houseNumber) { - return houseNumber + " " + name; - } - -} diff --git a/src/de/schildbach/pte/PlNavitiaProvider.java b/src/de/schildbach/pte/PlNavitiaProvider.java deleted file mode 100644 index f454c6e5..00000000 --- a/src/de/schildbach/pte/PlNavitiaProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2018 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -/** - * @author Michel Le Bihan - */ -public class PlNavitiaProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "pl"; - - public PlNavitiaProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.PLNAVITIA, apiBase, authorization); - - setTimeZone("Europe/Warsaw"); - } - - public PlNavitiaProvider(final String authorization) { - super(NetworkId.PLNAVITIA, authorization); - - setTimeZone("Europe/Warsaw"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/QuebecProvider.java b/src/de/schildbach/pte/QuebecProvider.java deleted file mode 100644 index 327b289a..00000000 --- a/src/de/schildbach/pte/QuebecProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -import okhttp3.HttpUrl; - -/** - * @author Stephane Berube - */ -public class QuebecProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "ca-qc"; - - public QuebecProvider(final HttpUrl apiBase, final String authorization) { - super(NetworkId.QUEBEC, apiBase, authorization); - - setTimeZone("America/Montreal"); - } - - public QuebecProvider(final String authorization) { - super(NetworkId.QUEBEC, authorization); - - setTimeZone("America/Montreal"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/src/de/schildbach/pte/SpainProvider.java b/src/de/schildbach/pte/SpainProvider.java deleted file mode 100644 index 5f503587..00000000 --- a/src/de/schildbach/pte/SpainProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2014-2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte; - -public class SpainProvider extends AbstractNavitiaProvider { - private static final String API_REGION = "es"; - - public SpainProvider(final String authorization) { - super(NetworkId.SPAIN, authorization); - setTimeZone("Europe/Spain"); - } - - @Override - public String region() { - return API_REGION; - } -} diff --git a/test/de/schildbach/pte/live/AbstractNavitiaProviderLiveTest.java b/test/de/schildbach/pte/live/AbstractNavitiaProviderLiveTest.java deleted file mode 100644 index 62e1723f..00000000 --- a/test/de/schildbach/pte/live/AbstractNavitiaProviderLiveTest.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.Date; -import java.util.EnumSet; -import java.util.List; - -import de.schildbach.pte.NetworkProvider; -import de.schildbach.pte.NetworkProvider.Accessibility; -import de.schildbach.pte.NetworkProvider.WalkSpeed; -import de.schildbach.pte.dto.LineDestination; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.NearbyLocationsResult; -import de.schildbach.pte.dto.Product; -import de.schildbach.pte.dto.QueryDeparturesResult; -import de.schildbach.pte.dto.QueryTripsContext; -import de.schildbach.pte.dto.QueryTripsResult; -import de.schildbach.pte.dto.StationDepartures; -import de.schildbach.pte.dto.SuggestLocationsResult; -import de.schildbach.pte.dto.TripOptions; - -/** - * @author Antonio El Khoury - */ -public abstract class AbstractNavitiaProviderLiveTest extends AbstractProviderLiveTest { - public AbstractNavitiaProviderLiveTest(final NetworkProvider provider) { - super(provider); - } - - protected final void nearbyStationsAddress(final int lat, final int lon) throws IOException { - final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), - Location.coord(lat, lon), 700, 10); - assertEquals(NearbyLocationsResult.Status.OK, result.status); - print(result); - } - - protected final void nearbyStationsStation(final String stationId) throws IOException { - final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), - new Location(LocationType.STATION, stationId), 700, 10); - assertEquals(NearbyLocationsResult.Status.OK, result.status); - print(result); - } - - protected final void nearbyStationsPoi(final String poiId) throws IOException { - final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), - new Location(LocationType.POI, poiId), 700, 10); - assertEquals(NearbyLocationsResult.Status.OK, result.status); - print(result); - } - - protected final void nearbyStationsAny(final int lat, final int lon) throws IOException { - final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), - Location.coord(lat, lon), 700, 10); - assertEquals(NearbyLocationsResult.Status.OK, result.status); - print(result); - } - - protected final void nearbyStationsStationDistance(final String stationId) throws IOException { - final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), - new Location(LocationType.STATION, stationId), 0, 10); - assertEquals(NearbyLocationsResult.Status.OK, result.status); - assertTrue(result.locations.size() > 1); - print(result); - } - - protected final void nearbyStationsInvalidStation(final String stationId) throws IOException { - final NearbyLocationsResult result = queryNearbyLocations(EnumSet.of(LocationType.STATION), - new Location(LocationType.STATION, stationId), 700, 10); - assertEquals(NearbyLocationsResult.Status.INVALID_ID, result.status); - print(result); - } - - protected final void queryDeparturesEquivsFalse(final String stationId) throws IOException { - final int maxDepartures = 5; - final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, false); - assertEquals(QueryDeparturesResult.Status.OK, result.status); - assertEquals(1, result.stationDepartures.size()); - assertTrue(result.stationDepartures.get(0).departures.size() <= maxDepartures); - final List lines = result.stationDepartures.get(0).lines; - assertNotNull(lines); - assertTrue(lines.size() >= 1); - print(result); - } - - protected final void queryDeparturesStopArea(final String stationId) throws IOException { - final int maxDepartures = 5; - final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, true); - assertEquals(QueryDeparturesResult.Status.OK, result.status); - assertTrue(result.stationDepartures.size() > 1); - int nbDepartures = 0; - int nbLines = 0; - for (final StationDepartures stationDepartures : result.stationDepartures) { - nbDepartures += stationDepartures.departures.size(); - final List lines = stationDepartures.lines; - if (lines != null) - nbLines += lines.size(); - } - assertTrue(nbDepartures <= maxDepartures); - assertTrue(nbLines >= 2); - print(result); - } - - protected final void queryDeparturesEquivsTrue(final String stationId) throws IOException { - final int maxDepartures = 5; - final QueryDeparturesResult result = queryDepartures(stationId, maxDepartures, true); - assertEquals(QueryDeparturesResult.Status.OK, result.status); - assertTrue(result.stationDepartures.size() > 1); - int nbDepartures = 0; - int nbLines = 0; - for (StationDepartures stationDepartures : result.stationDepartures) { - nbDepartures += stationDepartures.departures.size(); - final List lines = stationDepartures.lines; - assertNotNull(lines); - nbLines += lines.size(); - } - assertTrue(nbDepartures <= maxDepartures); - assertTrue(nbLines >= 2); - print(result); - } - - protected final void queryDeparturesInvalidStation(final String stationId) throws IOException { - final QueryDeparturesResult result = queryDepartures(stationId, false); - assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status); - } - - protected final void suggestLocationsFromName(final CharSequence constraint) throws IOException { - final SuggestLocationsResult result = suggestLocations(constraint); - assertTrue(result.getLocations().size() > 0); - print(result); - } - - protected final void suggestLocationsFromAddress(final CharSequence constraint) throws IOException { - final SuggestLocationsResult result = suggestLocations(constraint); - assertTrue(result.getLocations().size() > 0); - print(result); - } - - protected final void suggestLocationsNoLocation(final CharSequence constraint) throws IOException { - final SuggestLocationsResult result = suggestLocations(constraint); - assertEquals(result.getLocations().size(), 0); - print(result); - } - - protected final void queryTrip(final CharSequence from, final CharSequence to) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - - final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, - toResult.getLocations().get(0), new Date(), true, null); - assertEquals(QueryTripsResult.Status.OK, result.status); - print(result); - } - - protected final void queryTripNoSolution(final CharSequence from, final CharSequence to) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - - final TripOptions options = new TripOptions(EnumSet.noneOf(Product.class), null, WalkSpeed.NORMAL, - Accessibility.NEUTRAL, null); - final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, - toResult.getLocations().get(0), new Date(), true, options); - assertEquals(QueryTripsResult.Status.NO_TRIPS, result.status); - print(result); - } - - protected final void queryTripUnknownFrom(final CharSequence to) throws IOException { - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - - final QueryTripsResult result = queryTrips(new Location(LocationType.STATION, "stop_area:RTP:SA:999999"), null, - toResult.getLocations().get(0), new Date(), true, null); - assertEquals(QueryTripsResult.Status.UNKNOWN_FROM, result.status); - print(result); - } - - protected final void queryTripUnknownTo(final CharSequence from) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - - final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, - new Location(LocationType.STATION, "stop_area:RTP:SA:999999"), new Date(), true, null); - assertEquals(QueryTripsResult.Status.UNKNOWN_TO, result.status); - print(result); - } - - protected final void queryTripAmbiguousFrom(final Location from, final CharSequence to) throws IOException { - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - - final QueryTripsResult result = queryTrips(from, null, toResult.getLocations().get(0), new Date(), true, null); - assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status); - assertTrue(result.ambiguousFrom != null); - assertTrue(result.ambiguousFrom.size() > 0); - print(result); - } - - protected final void queryTripAmbiguousTo(final CharSequence from, final Location to) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - - final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, to, new Date(), true, null); - assertEquals(QueryTripsResult.Status.AMBIGUOUS, result.status); - assertTrue(result.ambiguousTo != null); - assertTrue(result.ambiguousTo.size() > 0); - print(result); - } - - protected final void queryTripSlowWalk(final CharSequence from, final CharSequence to) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - - final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.SLOW, Accessibility.NEUTRAL, null); - final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, - toResult.getLocations().get(0), new Date(), true, options); - assertEquals(QueryTripsResult.Status.OK, result.status); - print(result); - } - - protected final void queryTripFastWalk(final CharSequence from, final CharSequence to) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - - final TripOptions options = new TripOptions(Product.ALL, null, WalkSpeed.FAST, Accessibility.NEUTRAL, null); - final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, - toResult.getLocations().get(0), new Date(), true, options); - assertEquals(QueryTripsResult.Status.OK, result.status); - print(result); - } - - protected final void queryTripFromAdminToPoi(final CharSequence from, final CharSequence to) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - Location fromLocation = fromResult.getLocations().get(0); - assertEquals(fromLocation.type, LocationType.POI); - print(fromResult); - - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - Location toLocation = toResult.getLocations().get(0); - assertEquals(toLocation.type, LocationType.POI); - print(toResult); - - final QueryTripsResult tripsResult = queryTrips(fromLocation, null, toLocation, new Date(), true, null); - assertEquals(QueryTripsResult.Status.OK, tripsResult.status); - print(tripsResult); - } - - protected final void queryMoreTrips(final CharSequence from, final CharSequence to) throws IOException { - final SuggestLocationsResult fromResult = suggestLocations(from); - assertTrue(fromResult.getLocations().size() > 0); - final SuggestLocationsResult toResult = suggestLocations(to); - assertTrue(toResult.getLocations().size() > 0); - - final QueryTripsResult result = queryTrips(fromResult.getLocations().get(0), null, - toResult.getLocations().get(0), new Date(), true, null); - assertEquals(QueryTripsResult.Status.OK, result.status); - final QueryTripsContext context = result.context; - - final QueryTripsResult nextResult = queryMoreTrips(context, true); - assertEquals(QueryTripsResult.Status.OK, nextResult.status); - print(nextResult); - - final QueryTripsResult prevResult = queryMoreTrips(context, false); - assertEquals(QueryTripsResult.Status.OK, prevResult.status); - print(prevResult); - } -} diff --git a/test/de/schildbach/pte/live/AustraliaProviderLiveTest.java b/test/de/schildbach/pte/live/AustraliaProviderLiveTest.java deleted file mode 100644 index c912fbbd..00000000 --- a/test/de/schildbach/pte/live/AustraliaProviderLiveTest.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; - -import java.io.IOException; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; - -import org.junit.Ignore; -import org.junit.Test; - -import de.schildbach.pte.AustraliaProvider; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.QueryTripsResult; -import de.schildbach.pte.dto.SuggestLocationsResult; -import de.schildbach.pte.dto.Trip; - -/** - * Test basic from/to directions for each mode of transport, in each state of Australia supported by Navitia. - * This is mainly to test whether or not the coverage is still in date or not. For example, at time of writing - * Cambera, Alice Springs, and Darwin were all present on Navitia, but out of date so were unable to provide - * journey planning. - * - * These tests work by taking the next Monday at 08:45 (a random peak hour time where you'd expect there to be - * a lot of public transport available). If they are unable to find a route for a specific mode of transport, - * then you should further investigate to see if the data is out of date or not in Navitia. - * - * Note that by default, only Melbourne is tested comprehensively to prevent running into API limits - * ({@see #RUN_EXPENSIVE_TESTS}). - */ -public class AustraliaProviderLiveTest extends AbstractNavitiaProviderLiveTest { - - /** - * If enabled, the entire set of tests will run, resulting in over 30 API calls to Navitia. Given this - * test may or may not be run under, e.g. continuous integration, or run frequently while working on the - * Australian API, it could end up using up your API limit unneccesarily. Thus, the default value is to - * only perform a proper test of Melbourne, and the rest of the coverage is disabled until this flag is - * true. - */ - private static final boolean RUN_EXPENSIVE_TESTS = false; - - public AustraliaProviderLiveTest() { - super(new AustraliaProvider(secretProperty("navitia.authorization"))); - } - - /** - * Ensures that each of the suburban/rural trains, trams, and buses are represented in the journey - * planning and location suggestion API. Based on travelling around the Camberwell area: - * http://www.openstreetmap.org/#map=15/-37.8195/145.0586&layers=T - */ - @Test - public void melbourne() throws IOException { - final Location suburbanTrainStation = assertAndGetLocation("Camberwell Railway Station (Camberwell)"); - final Location ruralTrainStation = assertAndGetLocation("Geelong Railway Station (Geelong)"); - assertJourneyExists(AustraliaProvider.NETWORK_PTV, new String[] { "Lilydale", "Belgrave", "Alamein" }, - suburbanTrainStation, ruralTrainStation); - - final Location tramStop = assertAndGetLocation("70-Cotham Rd/Burke Rd (Kew)"); - assertJourneyExists(AustraliaProvider.NETWORK_PTV, "72", suburbanTrainStation, tramStop); - - final Location busStop = assertAndGetLocation("Lawrence St/Burke Rd (Kew East)"); - assertJourneyExists(AustraliaProvider.NETWORK_PTV, "548", tramStop, busStop); - } - - @Test - public void adelaideRail() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location railwayStation = assertAndGetLocation("Woodville Park Railway Station"); - final Location railwayStation2 = assertAndGetLocation("Unley Park Railway Station"); - assertJourneyExists(AustraliaProvider.NETWORK_SA, new String[] { "GRNG", "BEL", "OUTHA" }, railwayStation, - railwayStation2); - } - - @Test - public void adelaideBus() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location busStation = assertAndGetLocation("Stop 137 Portrush Rd - East side"); - final Location busStation2 = assertAndGetLocation("Stop 144 Portrush Rd - East side"); - assertJourneyExists(AustraliaProvider.NETWORK_SA, "300", busStation, busStation2); - } - - @Test - public void adelaideTram() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location tramStation = assertAndGetLocation("Stop 15 Dunbar Tce - Brighton Rd"); - final Location tramStation2 = assertAndGetLocation("Stop 5 Black Forest"); - assertJourneyExists(AustraliaProvider.NETWORK_SA, "Tram", tramStation, tramStation2); - } - - @Test - public void perthTrain() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location railwayStation = assertAndGetLocation("Kenwick Stn"); - final Location railwayStation2 = assertAndGetLocation("Warwick Stn"); - assertJourneyExists(AustraliaProvider.NETWORK_WA, "", railwayStation, railwayStation2); - } - - @Test - public void perthBus() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location bus = assertAndGetLocation("Curtin University"); - final Location bus2 = assertAndGetLocation("Murdoch Stn"); - assertJourneyExists(AustraliaProvider.NETWORK_WA, "", bus, bus2); - } - - @Test - public void perthFerry() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location ferry = assertAndGetLocation("Elizabeth Quay Stn"); - final Location ferry2 = assertAndGetLocation("Ferry Route Mends St Jetty"); - assertJourneyExists(AustraliaProvider.NETWORK_WA, "", ferry, ferry2); - } - - @Test - public void brisbaneRail() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location railwayStation = assertAndGetLocation("Beenleigh station"); - final Location railwayStation2 = assertAndGetLocation("Ipswich station"); - assertJourneyExists(AustraliaProvider.NETWORK_QLD, "BNFG", railwayStation, railwayStation2); - } - - @Test - public void brisbaneFerry() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location ferry = assertAndGetLocation("Broadbeach South"); - final Location ferry2 = assertAndGetLocation("Southport"); - assertJourneyExists(AustraliaProvider.NETWORK_QLD, "GLKN", ferry, ferry2); - } - - @Test - public void brisbaneTram() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location tram = assertAndGetLocation("South Bank 2 ferry terminal"); - final Location tram2 = assertAndGetLocation("Guyatt Park ferry terminal"); - assertJourneyExists(AustraliaProvider.NETWORK_QLD, "UQSL", tram, tram2); - } - - @Test - public void hobartBus() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location bus = assertAndGetLocation("Stop 15, No.237 New Town Rd"); - final Location bus2 = assertAndGetLocation("Stop 2, No.131 Elizabeth St"); - assertJourneyExists(AustraliaProvider.NETWORK_TAS, "504", bus, bus2); - } - - @Test - public void launcestonBus() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location bus = assertAndGetLocation("Riverside Dr / Rannoch Ave"); - final Location bus2 = assertAndGetLocation("Trevallyn Shops"); - assertJourneyExists(AustraliaProvider.NETWORK_TAS, "90", bus, bus2); - } - - @Test - public void bernieBus() throws IOException { - assumeTrue(RUN_EXPENSIVE_TESTS); - - final Location bus = assertAndGetLocation("Stop 31, 197 Mount St"); - final Location bus2 = assertAndGetLocation("Burnie Park opposite 55 West Park Gr"); - assertJourneyExists(AustraliaProvider.NETWORK_TAS, "12", bus, bus2); - } - - // Although Navitia has a GTFS feed for ACT, Darwin, and Alice Springs, they were out of date at time of - // writing. - @Test - @Ignore - public void act() { - } - - @Test - @Ignore - public void darwin() { - } - - @Test - @Ignore - public void aliceSprings() { - } - - /** - * Suggests locations similar to {@param locationName}, but then ensures that one matches exactly and then - * returns it. Try not to use an ambiguous name such as "Central Station", because it may exist in several - * datasets on Navitia. - */ - private Location assertAndGetLocation(String locationName) throws IOException { - SuggestLocationsResult locations = suggestLocations(locationName); - assertEquals(SuggestLocationsResult.Status.OK, locations.status); - assertTrue(locations.getLocations().size() > 0); - - StringBuilder nonMatching = new StringBuilder(); - for (Location location : locations.getLocations()) { - if (locationName.equals(location.name)) { - return location; - } - - nonMatching.append('[').append(location.name).append("] "); - } - - throw new AssertionError( - "suggestLocations() did not find \"" + locationName + "\". Options were: " + nonMatching); - } - - /** - * @see #assertJourneyExists(String, String[], Location, Location) - */ - private void assertJourneyExists(String network, String eligibleLine, Location from, Location to) - throws IOException { - assertJourneyExists(network, new String[] { eligibleLine }, from, to); - } - - private Date getNextMondayMorning() { - Calendar date = Calendar.getInstance(); - date.setTime(new Date()); - date.set(Calendar.HOUR_OF_DAY, 8); - date.set(Calendar.MINUTE, 45); - while (date.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { - date.add(Calendar.DATE, 1); - } - - return date.getTime(); - } - - private void assertJourneyExists(String network, String[] eligibleLines, Location from, Location to) - throws IOException { - QueryTripsResult trips = queryTrips(from, null, to, getNextMondayMorning(), true, null); - assertNull(trips.ambiguousFrom); - assertNull(trips.ambiguousTo); - assertEquals(QueryTripsResult.Status.OK, trips.status); - assertNotNull(trips.trips); - assertTrue(trips.trips.size() > 0); - - Set eligibleLineSet = new HashSet<>(); - Collections.addAll(eligibleLineSet, eligibleLines); - - for (Trip trip : trips.trips) { - boolean hasPublicTransport = false; - boolean matchesCode = false; - for (Trip.Leg leg : trip.legs) { - if (leg instanceof Trip.Public) { - hasPublicTransport = true; - - Trip.Public publicLeg = (Trip.Public) leg; - assertEquals(network, publicLeg.line.network); - - if (eligibleLineSet.contains(publicLeg.line.label)) { - matchesCode = true; - } - } - } - - if (hasPublicTransport && matchesCode) { - return; - } - } - - StringBuilder sb = new StringBuilder(); - for (Trip trip : trips.trips) { - sb.append("\n "); - for (Trip.Leg leg : trip.legs) { - String via = leg instanceof Trip.Public ? " (via " + ((Trip.Public) leg).line.label + ") " : " -> "; - sb.append('[').append(leg.arrival.name).append(']').append(via).append('[').append(leg.departure.name) - .append(']').append(" ... "); - } - } - - fail("No public trip found between [" + from.name + "] and [" + to.name - + "] using appropriate line. Found trips:" + sb); - } -} diff --git a/test/de/schildbach/pte/live/BrazilProviderLiveTest.java b/test/de/schildbach/pte/live/BrazilProviderLiveTest.java deleted file mode 100644 index 1bf6b258..00000000 --- a/test/de/schildbach/pte/live/BrazilProviderLiveTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import de.schildbach.pte.BrazilProvider; -import de.schildbach.pte.dto.Point; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * @author Torsten Grote - */ -public class BrazilProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public BrazilProviderLiveTest() { - super(new BrazilProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - // Sao Paulo - nearbyStationsAddress(-23547900, -46635200); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - // Rio de Janeiro - nearbyStationsAddress(-22905300, -43179500); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:OIO:SP:18255914"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:OIO:SPX:18255914"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:OSA:SP:800016608"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:OWX:SP:6911"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("Republica"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Benjamim Constant", "Avenida Paulista"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("Republica", "Avenida Paulista"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/BritishColumbiaProviderLiveTest.java b/test/de/schildbach/pte/live/BritishColumbiaProviderLiveTest.java deleted file mode 100644 index 7025f90f..00000000 --- a/test/de/schildbach/pte/live/BritishColumbiaProviderLiveTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import org.junit.Test; - -import de.schildbach.pte.BritishColumbiaProvider; -import de.schildbach.pte.dto.Location; - -/** - * @author Stephane Berube - */ -public class BritishColumbiaProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public BritishColumbiaProviderLiveTest() { - super(new BritishColumbiaProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:VTA:SP:100084"); - } - - @Test - public void nearbyStationsByCoordinate() throws Exception { - queryNearbyStations(Location.coord(48428611, -123365556)); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDepartures("stop_point:VTA:SP:xxxxxx", false); - } - - @Test - public void queryDepartures() throws Exception { - queryDepartures("VTA:SP:100084", false); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocations("Airport"); - } -} diff --git a/test/de/schildbach/pte/live/CzechRepublicProviderLiveTest.java b/test/de/schildbach/pte/live/CzechRepublicProviderLiveTest.java deleted file mode 100644 index c389957e..00000000 --- a/test/de/schildbach/pte/live/CzechRepublicProviderLiveTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 2019 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.CzechRepublicProvider; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.Point; - -/** - * @author Filip Hejsek - */ -public class CzechRepublicProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public CzechRepublicProviderLiveTest() { - super(new CzechRepublicProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - nearbyStationsAddress(50062956, 14430641); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - nearbyStationsAddress(50083373, 14423001); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:OCZPRA:U527Z102P"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - nearbyStationsPoi("poi:osm:way:141756627"); - } - - @Test - public void nearbyStationsAny() throws Exception { - nearbyStationsAny(50062956, 14430641); - } - - @Test - public void nearbyStationsDistance() throws Exception { - nearbyStationsStationDistance("stop_point:OCZPRA:U527Z102P"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:RTP:SP:392"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:OCZPRA:U1072Z121P"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - queryDeparturesStopArea("stop_area:OCZPRA:U527S1"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - queryDeparturesEquivsTrue("stop_point:OCZPRA:U527Z101P"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:RTP:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("Vyšehr"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - suggestLocationsFromAddress("This doesn't work"); - // Address search doesn't work for Czech Republic in Navitia - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - suggestLocationsNoLocation("bellevilleadasdjkaskd"); - } - - @Test - public void queryTripAddresses() throws Exception { - queryTrip("This doesn't work", "This doesn't work"); - // Address search doesn't work for Czech Republic in Navitia - } - - @Test - public void queryTripAddressStation() throws Exception { - queryTrip("This doesn't work", "Muzeum"); - // Address search doesn't work for Czech Republic in Navitia - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Vyšehrad", "Muzeum"); - } - - @Test - public void queryTripStations2() throws Exception { - queryTrip("Sídliště Písnice", "Modřanská rokle"); - } - - @Test - public void queryTripStations3() throws Exception { - queryTrip("Modřanská rokle", "Českomoravská"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - queryTripUnknownFrom("Muzeum"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - queryTripUnknownTo("Vyšehrad"); - } - - @Test - public void queryTripAmbiguousFrom() throws Exception { - queryTripAmbiguousFrom(new Location(LocationType.ANY, null, null, "Sídliště"), "Muzeum"); - } - - @Test - public void queryTripAmbiguousTo() throws Exception { - queryTripAmbiguousTo("Vyšehrad", new Location(LocationType.ANY, null, null, "Sídliště")); - } - - @Test - public void queryTripSlowWalk() throws Exception { - queryTripSlowWalk("Nemocnice Krč", "Budějovická"); - } - - @Test - public void queryTripFastWalk() throws Exception { - queryTripFastWalk("Nemocnice Krč", "Budějovická"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("Nemocnice Krč", "Budějovická"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/FinlandProviderLiveTest.java b/test/de/schildbach/pte/live/FinlandProviderLiveTest.java deleted file mode 100644 index 874b5b50..00000000 --- a/test/de/schildbach/pte/live/FinlandProviderLiveTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.FinlandProvider; -import de.schildbach.pte.dto.Point; - -/** - * @author Adrian Perez de Castro - */ -public class FinlandProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public FinlandProviderLiveTest() { - super(new FinlandProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - nearbyStationsAddress(60160920, 24941870); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:OFI:SP:1050412"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - nearbyStationsPoi("poi:osm:way:29071686"); - } - - @Test - public void nearbyStationsAny() throws Exception { - nearbyStationsAny(60160920, 24941870); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:9999999999"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - queryDeparturesStopArea("stop_area:OFI:SA:1000201"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:OFI:SP:1050412"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - queryDeparturesEquivsTrue("stop_area:OFI:SA:1000201"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:OFI:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("postitalo"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - suggestLocationsFromAddress("10 yrjönkatu"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - suggestLocationsNoLocation("fontana di trevi blah blah"); - } - - @Test - public void queryTripAddresses() throws Exception { - queryTrip("Yrjönkatu, 10, Helsinki", "Kolmas Linja, 5, Helsinki"); - } - - @Test - public void queryTripAddressStation() throws Exception { - queryTrip("Viides Linja, 3, Helsinki", "Kapylän asema"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Kapylän asema", "Päärautatieasema"); - } - - @Test - public void queryTripNoSolution() throws Exception { - queryTripNoSolution("Steissi, Helsinki", "Keskuskatu 1, Kuopio"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - queryTripUnknownFrom("Rautatieasema"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - queryTripUnknownTo("Rautatieasema"); - } - - @Test - public void queryTripSlowWalk() throws Exception { - queryTripSlowWalk("Rautatieasema", "Postitalo"); - } - - @Test - public void queryTripFastWalk() throws Exception { - queryTripFastWalk("Rautatieasema", "Postitalo"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("Steissi", "Töölöntori"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/FranceNorthEastProviderLiveTest.java b/test/de/schildbach/pte/live/FranceNorthEastProviderLiveTest.java deleted file mode 100644 index e15beea9..00000000 --- a/test/de/schildbach/pte/live/FranceNorthEastProviderLiveTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2015-2016 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.FranceNorthEastProvider; -import de.schildbach.pte.dto.Point; - -/** - * @author Nicolas Derive - * @author Stéphane Guillou - */ -public class FranceNorthEastProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public FranceNorthEastProviderLiveTest() { - super(new FranceNorthEastProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - // stations close to those coordinates (lat, lon) - // no decimal point, has to include 6 decimal places - nearbyStationsAddress(48573410, 7752110); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - // different test case for stations close to coordinates (lat, lon) - // no decimal point, has to include 6 decimal places - nearbyStationsAddress(48598480, 7761790); - } - - @Test - public void nearbyStationsStation() throws Exception { - // station to find other stations around - // look in NTFS file for a stop_id (that contains "SP") and apend to "stop_point:" - nearbyStationsStation("stop_point:OST:SP:HOFER_11"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - // POI to find stations around - // search OSM for a node, use identifier after - // "https://www.openstreetmap.org/node/" and apend it to "poi:n" - nearbyStationsPoi("poi:n39224822"); - } - - @Test - public void nearbyStationsAny() throws Exception { - // coordinates to find stations around - nearbyStationsAny(48573410, 7752110); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - // station that does not exist? - nearbyStationsInvalidStation("stop_point:RTP:SP:392"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - // what is it for?? - queryDeparturesEquivsFalse("stop_point:OST:SP:HOFER_11"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - // what is it for?? - // has to be an existing stop area (i.e. ID contains "SA") - queryDeparturesStopArea("stop_area:OST:SA:CTPHOFER_04"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - // what is it for?? - // can be the same to queryDeparturesEquivsFalse - queryDeparturesEquivsTrue("stop_point:OST:SP:HOFER_11"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - // station that does not exist - queryDeparturesInvalidStation("stop_point:OBO:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - // start of a place name that should return something - suggestLocationsFromName("Observat"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - // start of an address that should return something - suggestLocationsFromAddress("16 quai Saint"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - // fake place that will not return results - suggestLocationsNoLocation("quinconcesadasdjkaskd"); - } - - @Test - public void queryTripAddresses() throws Exception { - // two existing addresses to define a trip - queryTrip("16 quai Saint-Nicolas Strasbourg", "37 rue Voltaire Vendenheim"); - } - - @Test - public void queryTripAddressStation() throws Exception { - // one existing address and one existing station to define a trip - queryTrip("16 quai Saint-Nicolas Strasbourg", "Illkirch Lixenbuhl"); - } - - @Test - public void queryTripStations() throws Exception { - // two existing stops to define a trip - queryTrip("Mathieu Zell", "Illkirch Lixenbuhl"); - } - - @Test - public void queryTripStations2() throws Exception { - // two existing stations for a trip, second test case - queryTrip("Homme de Fer", "Général Lejeune"); - } - - @Test - public void queryTripStations3() throws Exception { - // two existing stations for a trip, third test case - queryTrip("Eurofret", "Gare aux Marchandises"); - } - - @Test - public void queryTripStationsRapidTransit() throws Exception { - // two existing stations for "rapid transit"... ? - queryTrip("Observatoire Strasbourg", "Porte de l'Hôpital Strasbourg"); - } - - @Test - public void queryTripNoSolution() throws Exception { - // two existing stations that are not connected - queryTripNoSolution("Homme de Fer Strasbourg", "Villers Mairie Villers-Les-Nancy"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - // existing station for end of trip, don't know where from - queryTripUnknownFrom("Homme de Fer Strasbourg"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - // existing station to start from, don't know where to - queryTripUnknownTo("Homme de Fer Strasbourg"); - } - - @Test - public void queryTripSlowWalk() throws Exception { - // two addresses for a "slow walk" - queryTripSlowWalk("16 quai Saint-Nicolas Strasbourg", "5 rue du Travail Strasbourg"); - } - - @Test - public void queryTripFastWalk() throws Exception { - // two addresses for a "fast walk", can be same as above - queryTripFastWalk("16 quai Saint-Nicolas Strasbourg", "5 rue du Travail Strasbourg"); - } - - @Test - public void queryMoreTrips() throws Exception { - // two addresses to show more trip options, can be same as above - queryMoreTrips("16 quai Saint-Nicolas Strasbourg", "5 rue du Travail Strasbourg"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/FranceNorthWestProviderLiveTest.java b/test/de/schildbach/pte/live/FranceNorthWestProviderLiveTest.java deleted file mode 100644 index b0bfa40d..00000000 --- a/test/de/schildbach/pte/live/FranceNorthWestProviderLiveTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2010-2016 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.FranceNorthWestProvider; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.NearbyLocationsResult; -import de.schildbach.pte.dto.Point; -import de.schildbach.pte.dto.QueryDeparturesResult; -import de.schildbach.pte.dto.SuggestLocationsResult; - -/** - * @author Patrick Kanzler - */ -public class FranceNorthWestProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public FranceNorthWestProviderLiveTest() { - super(new FranceNorthWestProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStations() throws Exception { - final NearbyLocationsResult result = queryNearbyStations( - new Location(LocationType.STATION, "stop_point:ORE:SP:1016")); - print(result); - } - - @Test - public void nearbyStationsByCoordinate() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(Location.coord(48109710, -16793391)); - print(result); - } - - @Test - public void queryDepartures() throws Exception { - final QueryDeparturesResult result = queryDepartures("stop_point:ORE:SP:1016", 10, false); - print(result); - } - - @Test - public void suggestLocations() throws Exception { - final SuggestLocationsResult result = suggestLocations("Anne"); - print(result); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/FranceSouthEastProviderLiveTest.java b/test/de/schildbach/pte/live/FranceSouthEastProviderLiveTest.java deleted file mode 100644 index b50918b7..00000000 --- a/test/de/schildbach/pte/live/FranceSouthEastProviderLiveTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2016 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import org.junit.Assert; -import org.junit.Test; - -import de.schildbach.pte.FranceSouthEastProvider; -import de.schildbach.pte.dto.Point; - -/** - * @author Anthony Chaput - */ -public class FranceSouthEastProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public FranceSouthEastProviderLiveTest() { - super(new FranceSouthEastProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - nearbyStationsAddress(45185260, 5737800); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - nearbyStationsAddress(45184620, 5779780); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:OGR:SP:2021"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - nearbyStationsPoi("poi:n1245491811"); - } - - @Test - public void nearbyStationsAny() throws Exception { - nearbyStationsAny(45184630, 5779790); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:OGR:SP:S99999"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:OGR:SP:2021"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - queryDeparturesStopArea("stop_area:OGR:SA:S3105"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - queryDeparturesEquivsTrue("stop_point:OGR:SP:2021"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:OBO:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("condil"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - suggestLocationsFromAddress("360 rue des res"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - suggestLocationsNoLocation("quinconcesadasdjkaskd"); - } - - @Test - public void queryTripAddresses() throws Exception { - queryTrip("360 rue des résidences", "2 rue Charles Michels"); - } - - @Test - public void queryTripAddressStation() throws Exception { - queryTrip("78 Quai Pierre Scize", "Bellecour"); - } - - @Test - public void queryTripTowns() throws Exception { - queryTrip("Annecy", "Lyon"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Victor Hugo", "Les Bauches"); - } - - @Test - public void queryTripStations2() throws Exception { - queryTrip("Chavant", "Louise Michel"); - } - - @Test - public void queryTripStations3() throws Exception { - queryTrip("Fontaine", "Vallier Libération"); - } - - @Test - public void queryTripStationsRapidTransit() throws Exception { - queryTrip("Alsace-Lorraine", "Vallier Libération"); - } - - @Test - public void queryTripNoSolution() throws Exception { - queryTripNoSolution("Robespierre", "Les Bauches"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - queryTripUnknownFrom("Chavant"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - queryTripUnknownTo("Chavant"); - } - - @Test - public void queryTripSlowWalk() throws Exception { - queryTripSlowWalk("360 rue des résidences", "15 rue de la chimie"); - } - - @Test - public void queryTripFastWalk() throws Exception { - queryTripFastWalk("360 rue des résidences", "15 rue de la chimie"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("360 rue des résidences", "15 rue de la chimie"); - } - - @Test - public void getArea() throws Exception { - Point[] polygon = this.provider.getArea(); - Assert.assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/FranceSouthWestProviderLiveTest.java b/test/de/schildbach/pte/live/FranceSouthWestProviderLiveTest.java deleted file mode 100644 index 2ab412f2..00000000 --- a/test/de/schildbach/pte/live/FranceSouthWestProviderLiveTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.FranceSouthWestProvider; -import de.schildbach.pte.dto.Point; - -/** - * @author Nicolas Derive - */ -public class FranceSouthWestProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public FranceSouthWestProviderLiveTest() { - super(new FranceSouthWestProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - nearbyStationsAddress(44826434, -557312); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - nearbyStationsAddress(44841225, -580036); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:STE:SP:OCETrainTER-87581538"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - nearbyStationsPoi("poi:n849494949"); - } - - @Test - public void nearbyStationsAny() throws Exception { - nearbyStationsAny(44826434, -557312); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:OBO:SP:7"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:OBO:SP:732"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - queryDeparturesStopArea("stop_area:OBO:SA:AEROG"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - queryDeparturesEquivsTrue("stop_point:OBO:SP:732"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:OBO:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("quinco"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - suggestLocationsFromAddress("78 rue cam"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - suggestLocationsNoLocation("quinconcesadasdjkaskd"); - } - - @Test - public void queryTripAddresses() throws Exception { - queryTrip("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux"); - } - - @Test - public void queryTripAddressStation() throws Exception { - queryTrip("98, rue Jean-Renaud Dandicolle Bordeaux", "Saint-Augustin"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Hôpital Pellegrin", "Avenue de l'Université"); - } - - @Test - public void queryTripStations2() throws Exception { - queryTrip("Pelletan", "Barrière de Pessac"); - } - - @Test - public void queryTripStations3() throws Exception { - queryTrip("Barrière de Pessac", "Hôpital Pellegrin"); - } - - @Test - public void queryTripStationsRapidTransit() throws Exception { - queryTrip("Gaviniès Bordeaux", "Saint-Augustin Bordeaux"); - } - - @Test - public void queryTripNoSolution() throws Exception { - queryTripNoSolution("Patinoire Mériadeck Bordeaux", "Mérignac Centre"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - queryTripUnknownFrom("Patinoire Mériadeck Bordeaux"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - queryTripUnknownTo("Patinoire Mériadeck Bordeaux"); - } - - @Test - public void queryTripSlowWalk() throws Exception { - queryTripSlowWalk("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux"); - } - - @Test - public void queryTripFastWalk() throws Exception { - queryTripFastWalk("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("98 rue Jean-Renaud Dandicolle Bordeaux", "78 rue Camena d'Almeida Bordeaux"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/GhanaProviderLiveTest.java b/test/de/schildbach/pte/live/GhanaProviderLiveTest.java deleted file mode 100644 index 37d665f7..00000000 --- a/test/de/schildbach/pte/live/GhanaProviderLiveTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.GhanaProvider; -import de.schildbach.pte.dto.Point; - -public class GhanaProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public GhanaProviderLiveTest() { - super(new GhanaProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - nearbyStationsAddress(5553473, -190438); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_area:SA4980974759"); - } - - @Test - public void nearbyStationsDistance() throws Exception { - nearbyStationsStationDistance("stop_area:SA5036738888"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_area:SC5031328601"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:5005030178"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - queryDeparturesStopArea("stop_area:SA5031328607"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - queryDeparturesEquivsTrue("stop_area:SA5031328607"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:RTP:5005030178"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("mark"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - suggestLocationsNoLocation("bellevilleadasdjkaskd"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("College", "Market"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - queryTripUnknownFrom("Market"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - queryTripUnknownTo("Market"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("College", "Market"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/ItalyProviderLiveTest.java b/test/de/schildbach/pte/live/ItalyProviderLiveTest.java deleted file mode 100644 index 01eae3c4..00000000 --- a/test/de/schildbach/pte/live/ItalyProviderLiveTest.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.ItalyProvider; -import de.schildbach.pte.dto.Point; - -/** - * @author Antonio El Khoury - */ -public class ItalyProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public ItalyProviderLiveTest() { - super(new ItalyProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - nearbyStationsAddress(38143607, 13336346); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:OPO:SP:100"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - nearbyStationsPoi("poi:w300581846"); - } - - @Test - public void nearbyStationsAny() throws Exception { - nearbyStationsAny(38096070, 13400204); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:9999999999"); - } - - @Test - public void queryDeparturesEquivsFalsePalermo() throws Exception { - queryDeparturesEquivsFalse("stop_point:OTO:SP:54673002"); - } - - @Test - public void queryDeparturesStopAreaPalermo() throws Exception { - queryDeparturesStopArea("stop_area:OPO:SA:1974"); - } - - @Test - public void queryDeparturesEquivsTruePalermo() throws Exception { - queryDeparturesEquivsTrue("stop_point:OTO:SP:54673002"); - } - - @Test - public void queryDeparturesEquivsFalseRome() throws Exception { - queryDeparturesEquivsFalse("stop_point:ORA:SP:AD10"); - } - - @Test - public void queryDeparturesStopAreaRome() throws Exception { - queryDeparturesStopArea("stop_area:ORA:SA:50003"); - } - - @Test - public void queryDeparturesEquivsTrueRome() throws Exception { - queryDeparturesEquivsTrue("stop_point:ORA:SP:AD10"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:RTP:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("fontana trevi"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - suggestLocationsFromAddress("12 via ferrata"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - suggestLocationsNoLocation("bellevilleadasdjkaskd"); - } - - @Test - public void queryTripAddressesPalermo() throws Exception { - queryTrip("Via Giuseppe Lanza di Scalea, 2703, 90147 Palermo", "Via Eugenio Montale, 12, Palermo"); - } - - @Test - public void queryTripAddressStationPalermo() throws Exception { - queryTrip("Via Giuseppe Lanza di Scalea, 2703, 90147 Palermo", "Galletti - Zita"); - } - - @Test - public void queryTripStationsPalermo() throws Exception { - queryTrip("Palermo Centrale", "Galletti Zita"); - } - - @Test - public void queryTripAddressesRome() throws Exception { - queryTrip("Via Anton Giulio Barrili, 44-46, Roma", "Via delle Cave di Pietralata, 103, Roma"); - } - - @Test - public void queryTripAddressStationRome() throws Exception { - queryTrip("Via Anton Giulio Barrili, 44-46, Roma", "Policlinico"); - } - - @Test - public void queryTripStationsRome() throws Exception { - queryTrip("Ottaviano", "Policlinico"); - } - - @Test - public void queryTripNoSolution() throws Exception { - queryTripNoSolution("Palermo Centrale", "Galletti Zita"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - queryTripUnknownFrom("Palermo Centrale"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - queryTripUnknownTo("Palermo Centrale"); - } - - @Test - public void queryTripSlowWalkPalermo() throws Exception { - queryTripSlowWalk("Palermo Centrale", "Galletti Zita"); - } - - @Test - public void queryTripFastWalkPalermo() throws Exception { - queryTripFastWalk("Palermo Centrale", "Galletti Zita"); - } - - @Test - public void queryMoreTripsPalermo() throws Exception { - queryMoreTrips("Palermo Centrale", "Galletti Zita"); - } - - @Test - public void queryTripSlowWalkRome() throws Exception { - queryTripSlowWalk("Ottaviano", "Policlinico"); - } - - @Test - public void queryTripFastWalkRome() throws Exception { - queryTripFastWalk("Ottaviano", "Policlinico"); - } - - @Test - public void queryMoreTripsRome() throws Exception { - queryMoreTrips("Ottaviano", "Policlinico"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/MassachusettsProviderLiveTest.java b/test/de/schildbach/pte/live/MassachusettsProviderLiveTest.java deleted file mode 100644 index b01b8eb2..00000000 --- a/test/de/schildbach/pte/live/MassachusettsProviderLiveTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2018 Erik Uhlmann. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import org.junit.Test; - -import de.schildbach.pte.MassachusettsProvider; - -/** - * @author Erik Uhlmann - */ -public class MassachusettsProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public MassachusettsProviderLiveTest() { - super(new MassachusettsProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStations() throws Exception { - nearbyStationsStation("stop_point:OUB:SP:70243"); - } - - @Test - public void nearbyStationsByCoordinate() throws Exception { - nearbyStationsAny(42353187, -71067045); - } - - @Test - public void queryDepartures() throws Exception { - queryDeparturesEquivsFalse("stop_point:OUB:SP:70198"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:OUB:SP:xxxx"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("Airport"); - } -} diff --git a/test/de/schildbach/pte/live/NicaraguaProviderLiveTest.java b/test/de/schildbach/pte/live/NicaraguaProviderLiveTest.java deleted file mode 100644 index c0fc4ea4..00000000 --- a/test/de/schildbach/pte/live/NicaraguaProviderLiveTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.NicaraguaProvider; -import de.schildbach.pte.dto.Point; - -public class NicaraguaProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public NicaraguaProviderLiveTest() { - super(new NicaraguaProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - // Managua - nearbyStationsAddress(13090080, -86356250); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - // Esteli - nearbyStationsAddress(12146120, -86274660); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:MNI:SP:node3230617621"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:MNIX:SP:node3230617621"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:MNI:SP:node3230617621"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:MNIX:SP:node3230617621"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("Hospital"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("27 de Mayo", "San Miguel Arcángel"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("Hospital", "Super Las Segovias"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/NzProviderLiveTest.java b/test/de/schildbach/pte/live/NzProviderLiveTest.java deleted file mode 100644 index d9c9efe0..00000000 --- a/test/de/schildbach/pte/live/NzProviderLiveTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2014-2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.NzProvider; -import de.schildbach.pte.dto.Point; - -/** - * @author Torsten Grote - */ -public class NzProviderLiveTest extends AbstractNavitiaProviderLiveTest { - - public NzProviderLiveTest() { - super(new NzProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - // Auckland - nearbyStationsAddress(-36852200, 174763000); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - // Wellington - nearbyStationsAddress(-41292500, 174777000); - } - - @Test - public void nearbyStationsStation() throws Exception { - // Ghuznee Street at Cuba Street (Wellington) - nearbyStationsStation("stop_point:OWT:SP:6909"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:OWX:SP:6909"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:OWT:SP:6911"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:OWX:SP:6911"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("Cuba St"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Cuba Street at Weltec", "Petone"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("Manners Street", "Lower Hutt"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/OntarioProviderLiveTest.java b/test/de/schildbach/pte/live/OntarioProviderLiveTest.java deleted file mode 100644 index 8f7ed49d..00000000 --- a/test/de/schildbach/pte/live/OntarioProviderLiveTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2010-2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import de.schildbach.pte.OntarioProvider; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.NearbyLocationsResult; -import de.schildbach.pte.dto.QueryDeparturesResult; -import de.schildbach.pte.dto.SuggestLocationsResult; - -/** - * @author Stephane Berube - */ -public class OntarioProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public OntarioProviderLiveTest() { - super(new OntarioProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStations() throws Exception { - final NearbyLocationsResult result = queryNearbyStations( - new Location(LocationType.STATION, "stop_point:OAW:SP:CH240")); - print(result); - } - - @Test - public void nearbyStationsByCoordinate() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(Location.coord(45416667, -75683333)); - print(result); - } - - @Test - public void queryDepartures() throws Exception { - final QueryDeparturesResult result = queryDepartures("OAW:SP:CH240", false); - print(result); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - final QueryDeparturesResult result = queryDepartures("OAW:SP:CHxxx", false); - assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status); - } - - @Test - public void suggestLocations() throws Exception { - final SuggestLocationsResult result = suggestLocations("Airport"); - print(result); - } -} diff --git a/test/de/schildbach/pte/live/OregonProviderLiveTest.java b/test/de/schildbach/pte/live/OregonProviderLiveTest.java deleted file mode 100644 index 36223a45..00000000 --- a/test/de/schildbach/pte/live/OregonProviderLiveTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2016 Clayton Craft. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -import de.schildbach.pte.OregonProvider; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.NearbyLocationsResult; -import de.schildbach.pte.dto.QueryDeparturesResult; -import de.schildbach.pte.dto.SuggestLocationsResult; - -/** - * @author Stephane Berube - */ -public class OregonProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public OregonProviderLiveTest() { - super(new OregonProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStations() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(new Location(LocationType.STATION, "OTP:SP:5017")); - print(result); - } - - @Test - public void nearbyStationsByCoordinate() throws Exception { - final NearbyLocationsResult result = queryNearbyStations(Location.coord(45514998, -122673334)); - print(result); - } - - @Test - public void queryDepartures() throws Exception { - final QueryDeparturesResult result = queryDepartures("OTP:SP:5017", false); - print(result); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - final QueryDeparturesResult result = queryDepartures("OTP:SP:xxxx", false); - assertEquals(QueryDeparturesResult.Status.INVALID_STATION, result.status); - } - - @Test - public void suggestLocations() throws Exception { - final SuggestLocationsResult result = suggestLocations("Airport"); - print(result); - } -} diff --git a/test/de/schildbach/pte/live/ParisProviderLiveTest.java b/test/de/schildbach/pte/live/ParisProviderLiveTest.java deleted file mode 100644 index 2134b147..00000000 --- a/test/de/schildbach/pte/live/ParisProviderLiveTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2014-2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.ParisProvider; -import de.schildbach.pte.dto.Location; -import de.schildbach.pte.dto.LocationType; -import de.schildbach.pte.dto.Point; - -/** - * @author Antonio El Khoury - */ -public class ParisProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public ParisProviderLiveTest() { - super(new ParisProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - nearbyStationsAddress(48877523, 2378353); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - nearbyStationsAddress(48785420, 2212050); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:OIF:SP:59:5657291"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - nearbyStationsPoi("poi:n668579722"); - } - - @Test - public void nearbyStationsAny() throws Exception { - nearbyStationsAny(48877523, 2378353); - } - - @Test - public void nearbyStationsDistance() throws Exception { - nearbyStationsStationDistance("stop_point:OIF:SP:80:137"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:RTP:SP:392"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:OIF:SP:59:5657291"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - queryDeparturesStopArea("stop_area:OIF:SA:59864"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - queryDeparturesEquivsTrue("stop_point:OIF:SP:59:5657291"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:RTP:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("bellevi"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - suggestLocationsFromAddress("13 rue man"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - suggestLocationsNoLocation("bellevilleadasdjkaskd"); - } - - @Test - public void queryTripAddresses() throws Exception { - queryTrip("5 rue Manin Paris", "10 rue Elanger Paris"); - } - - @Test - public void queryTripAddressStation() throws Exception { - queryTrip("155 bd hopital paris", "Gare St-Lazare"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Campo Formio", "Gare St-Lazare"); - } - - @Test - public void queryTripCablecar() throws Exception { - queryTrip("Campo Formio", "Aéroport Orly Sud"); - } - - @Test - public void queryTripStations2() throws Exception { - queryTrip("Tour Eiffel", "Orsay Ville"); - } - - @Test - public void queryTripStations3() throws Exception { - queryTrip("Tour Eiffel", "Campo Formio"); - } - - @Test - public void queryTripStationsOrlyval() throws Exception { - queryTrip("Orly Sud", "Gare De Lyon"); - } - - @Test - public void queryTripStationsRapidTransit() throws Exception { - queryTrip("Luxembourg Paris", "Antony Antony"); - } - - @Test - public void queryTripFromAdministrativeRegionToPoi() throws Exception { - queryTripFromAdminToPoi("Paris 10e Arrondissement", "Paris Tour Eiffel"); - } - - @Test - public void queryTripNoSolution() throws Exception { - queryTripNoSolution("secretan buttes chaumont paris", "Antony Antony"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - queryTripUnknownFrom("secretan buttes chaumont paris"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - queryTripUnknownTo("secretan buttes chaumont paris"); - } - - @Test - public void queryTripAmbiguousFrom() throws Exception { - queryTripAmbiguousFrom(new Location(LocationType.ANY, "ambiguous", null, "Eiffel"), "Gare St-Lazare"); - } - - @Test - public void queryTripAmbiguousTo() throws Exception { - queryTripAmbiguousTo("Gare St-Lazare", new Location(LocationType.ANY, "ambiguous", null, "Eiffel")); - } - - @Test - public void queryTripSlowWalk() throws Exception { - queryTripSlowWalk("5 rue manin paris", "10 rue marcel dassault velizy"); - } - - @Test - public void queryTripFastWalk() throws Exception { - queryTripFastWalk("5 rue manin paris", "10 rue marcel dassault velizy"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("5 rue manin paris", "10 rue marcel dassault velizy"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/PlNavitiaProviderLiveTest.java b/test/de/schildbach/pte/live/PlNavitiaProviderLiveTest.java deleted file mode 100644 index 76ba298f..00000000 --- a/test/de/schildbach/pte/live/PlNavitiaProviderLiveTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2018 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.PlNavitiaProvider; -import de.schildbach.pte.dto.Point; - -/** - * @author Michel Le Bihan - */ -public class PlNavitiaProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public PlNavitiaProviderLiveTest() { - super(new PlNavitiaProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - // stations close to those coordinates (lat, lon) - // no decimal point, has to include 6 decimal places - nearbyStationsAddress(52231160, 21010740); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - // different test case for stations close to coordinates (lat, lon) - // no decimal point, has to include 6 decimal places - nearbyStationsAddress(52244700, 21001260); - } - - @Test - public void nearbyStationsStation() throws Exception { - // station to find other stations around - // look in NTFS file for a stop_id (that contains "SP") and append to "stop_point:" - nearbyStationsStation("stop_point:OWW:SP:ctr"); - } - - @Test - public void nearbyStationsPoi() throws Exception { - // POI to find stations around - // search OSM for a node, use identifier after - // "https://www.openstreetmap.org/node/" and append it to "poi:n" - nearbyStationsPoi("poi:n35121252"); - } - - @Test - public void nearbyStationsAny() throws Exception { - // coordinates to find stations around - nearbyStationsAny(52231160, 21010740); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - // station that does not exist? - nearbyStationsInvalidStation("stop_point:RTP:SP:392"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - // what is it for?? - queryDeparturesEquivsFalse("stop_point:OWW:SP:ctr"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - // what is it for?? - // has to be an existing stop area (i.e. ID contains "SA") - queryDeparturesStopArea("stop_area:OWW:SA:709003"); - } - - @Test - public void queryDeparturesEquivsTrue() throws Exception { - // what is it for?? - // can be the same to queryDeparturesEquivsFalse - queryDeparturesEquivsTrue("stop_point:OWW:SP:709003"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - // station that does not exist - queryDeparturesInvalidStation("stop_point:OBO:SP:999999"); - } - - @Test - public void suggestLocations() throws Exception { - // start of a place name that should return something - suggestLocationsFromName("Pałac"); - } - - @Test - public void suggestLocationsFromAddress() throws Exception { - // start of an address that should return something - suggestLocationsFromAddress("Radarowa 1"); - } - - @Test - public void suggestLocationsNoLocation() throws Exception { - // fake place that will not return results - suggestLocationsNoLocation("quinconcesadasdjkaskd"); - } - - @Test - public void queryTripAddresses() throws Exception { - // two existing addresses to define a trip - queryTrip("Radarowa 1, Warszawa", "Nowowiejska 37a, Warszawa"); - } - - @Test - public void queryTripAddressStation() throws Exception { - // one existing address and one existing station to define a trip - queryTrip("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa"); - } - - @Test - public void queryTripStations() throws Exception { - // two existing stops to define a trip - queryTrip("Radarowa 01", "Centrum 01"); - } - - @Test - public void queryTripStations2() throws Exception { - // two existing stations for a trip, second test case - queryTrip("Ratuszowa - ZOO 01", "Nowowiejska 01"); - } - - @Test - public void queryTripStations3() throws Exception { - // two existing stations for a trip, third test case - queryTrip("Warszawa Zoo", "Politechnika"); - } - - @Test - public void queryTripStationsRapidTransit() throws Exception { - // two existing stations for "rapid transit"... ? - queryTrip("Politechnika", "Centrum"); - } - - @Test - public void queryTripNoSolution() throws Exception { - // two existing stations that are not connected - queryTripNoSolution("Centrum", "Sródmiescie SKM"); - } - - @Test - public void queryTripUnknownFrom() throws Exception { - // existing station for end of trip, don't know where from - queryTripUnknownFrom("Centrum"); - } - - @Test - public void queryTripUnknownTo() throws Exception { - // existing station to start from, don't know where to - queryTripUnknownTo("Politechnika"); - } - - @Test - public void queryTripSlowWalk() throws Exception { - // two addresses for a "slow walk" - queryTripSlowWalk("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa"); - } - - @Test - public void queryTripFastWalk() throws Exception { - // two addresses for a "fast walk", can be same as above - queryTripFastWalk("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa"); - } - - @Test - public void queryMoreTrips() throws Exception { - // two addresses to show more trip options, can be same as above - queryMoreTrips("Nowowiejska 37a, Warszawa", "Centrum 01, Warszawa"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/QuebecProviderLiveTest.java b/test/de/schildbach/pte/live/QuebecProviderLiveTest.java deleted file mode 100644 index e77001b4..00000000 --- a/test/de/schildbach/pte/live/QuebecProviderLiveTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2010-2015 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import org.junit.Test; - -import de.schildbach.pte.QuebecProvider; - -/** - * @author Stephane Berube - */ -public class QuebecProviderLiveTest extends AbstractNavitiaProviderLiveTest { - public QuebecProviderLiveTest() { - super(new QuebecProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_area:OML:SA:CTP3102842"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_area:OML:SA:CTPxxxxxxx"); - } - - @Test - public void queryDeparturesStopArea() throws Exception { - queryDeparturesStopArea("stop_area:OML:SA:CTP3102842"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocations("Airport"); - } -} diff --git a/test/de/schildbach/pte/live/SpainProviderLiveTest.java b/test/de/schildbach/pte/live/SpainProviderLiveTest.java deleted file mode 100644 index 9e6e0b18..00000000 --- a/test/de/schildbach/pte/live/SpainProviderLiveTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2015-2016 the original author or authors. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package de.schildbach.pte.live; - -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import de.schildbach.pte.SpainProvider; -import de.schildbach.pte.dto.Point; - -public class SpainProviderLiveTest extends AbstractNavitiaProviderLiveTest { - - public SpainProviderLiveTest() { - super(new SpainProvider(secretProperty("navitia.authorization"))); - } - - @Test - public void nearbyStationsAddress() throws Exception { - // Valencia - nearbyStationsAddress(39473600, -371100); - } - - @Test - public void nearbyStationsAddress2() throws Exception { - // Madrid - nearbyStationsAddress(40410400, -3702400); - } - - @Test - public void nearbyStationsStation() throws Exception { - nearbyStationsStation("stop_point:E38:SP:2223"); - } - - @Test - public void nearbyStationsInvalidStation() throws Exception { - nearbyStationsInvalidStation("stop_point:EX38:SP:2223"); - } - - @Test - public void queryDeparturesEquivsFalse() throws Exception { - queryDeparturesEquivsFalse("stop_point:E38:SP:2223"); - } - - @Test - public void queryDeparturesInvalidStation() throws Exception { - queryDeparturesInvalidStation("stop_point:OWX:SP:6911"); - } - - @Test - public void suggestLocations() throws Exception { - suggestLocationsFromName("Turia"); - } - - @Test - public void queryTripStations() throws Exception { - queryTrip("Benimaclet", "Nou d'Octubre"); - } - - @Test - public void queryMoreTrips() throws Exception { - queryMoreTrips("Valencia Sud", "Faitanar"); - } - - @Test - public void getArea() throws Exception { - final Point[] polygon = provider.getArea(); - assertTrue(polygon.length > 0); - } -} diff --git a/test/de/schildbach/pte/live/secrets.properties.template b/test/de/schildbach/pte/live/secrets.properties.template index f8093f9d..8557cdd3 100644 --- a/test/de/schildbach/pte/live/secrets.properties.template +++ b/test/de/schildbach/pte/live/secrets.properties.template @@ -1,5 +1,4 @@ # Secrets are needed to run some of the live tests. -navitia.authorization = hci.salt_encryption_key = db.api_authorization = db.encrypted_salt =