mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-19 16:59:51 +00:00

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@237 0924bc21-9374-b0fa-ee44-9ff1593b38f0
169 lines
5.2 KiB
Java
169 lines
5.2 KiB
Java
/*
|
|
* Copyright 2010 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package de.schildbach.pte;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
import de.schildbach.pte.dto.Autocomplete;
|
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
|
import de.schildbach.pte.dto.StationLocationResult;
|
|
|
|
/**
|
|
* Interface to be implemented by providers of transportation networks
|
|
*
|
|
* @author Andreas Schildbach
|
|
*/
|
|
public interface NetworkProvider
|
|
{
|
|
public enum Capability
|
|
{
|
|
NEARBY_STATIONS, DEPARTURES, CONNECTIONS, LOCATION_WGS84, LOCATION_STATION_ID
|
|
}
|
|
|
|
public enum LocationType
|
|
{
|
|
ANY, STATION, WGS84, ADDRESS, POI
|
|
}
|
|
|
|
public enum WalkSpeed
|
|
{
|
|
SLOW, NORMAL, FAST
|
|
}
|
|
|
|
boolean hasCapabilities(Capability... capabilities);
|
|
|
|
/**
|
|
* Meant for auto-completion of station names, like in an {@link android.widget.AutoCompleteTextView}
|
|
*
|
|
* @param constraint
|
|
* input by user so far
|
|
* @return auto-complete suggestions
|
|
* @throws IOException
|
|
*/
|
|
List<Autocomplete> autocompleteStations(CharSequence constraint) throws IOException;
|
|
|
|
/**
|
|
* Determine stations near to given location. At least one of stationId or lat/lon pair must be given.
|
|
*
|
|
* @param stationId
|
|
* id of station to look up nearby stations (optional)
|
|
* @param lat
|
|
* latitude (optional)
|
|
* @param lon
|
|
* longitude (optional)
|
|
* @param maxDistance
|
|
* maximum distance in meters, or {@code 0}
|
|
* @param maxStations
|
|
* maximum number of stations, or {@code 0}
|
|
* @return nearby stations
|
|
* @throws IOException
|
|
*/
|
|
NearbyStationsResult nearbyStations(String stationId, int lat, int lon, int maxDistance, int maxStations) throws IOException;
|
|
|
|
/**
|
|
* Look up location of station.
|
|
*
|
|
* @param stationId
|
|
* id of station to look up
|
|
* @return location
|
|
* @throws IOException
|
|
*/
|
|
StationLocationResult stationLocation(String stationId) throws IOException;
|
|
|
|
/**
|
|
* Query connections, asking for any ambiguousnesses
|
|
*
|
|
* @param fromType
|
|
* type of location to route from, mandatory
|
|
* @param from
|
|
* location to route from, mandatory
|
|
* @param viaType
|
|
* type of location to route via, may be {@code null}
|
|
* @param via
|
|
* location to route via, may be {@code null}
|
|
* @param toType
|
|
* type of location to route to, mandatory
|
|
* @param to
|
|
* location to route to, mandatory
|
|
* @param date
|
|
* desired date for departing, mandatory
|
|
* @param dep
|
|
* date is departure date? {@code true} for departure, {@code false} for arrival
|
|
* @param walkSpeed
|
|
* how fast can you walk?
|
|
* @return result object that can contain alternatives to clear up ambiguousnesses, or contains possible connections
|
|
* @throws IOException
|
|
*/
|
|
QueryConnectionsResult queryConnections(LocationType fromType, String from, LocationType viaType, String via, LocationType toType, String to,
|
|
Date date, boolean dep, WalkSpeed walkSpeed) throws IOException;
|
|
|
|
/**
|
|
* Query more connections (e.g. earlier or later)
|
|
*
|
|
* @param uri
|
|
* uri to query more connections from
|
|
* @return result object that contains possible connections
|
|
* @throws IOException
|
|
*/
|
|
QueryConnectionsResult queryMoreConnections(String uri) throws IOException;
|
|
|
|
/**
|
|
* Get details about a connection
|
|
*
|
|
* @param connectionUri
|
|
* uri returned via {@link NetworkProvider#queryConnections}
|
|
* @return result object containing the details of the connection
|
|
* @throws IOException
|
|
*/
|
|
GetConnectionDetailsResult getConnectionDetails(String connectionUri) throws IOException;
|
|
|
|
/**
|
|
* Construct an Uri for getting departures
|
|
*
|
|
* @param stationId
|
|
* id of the station
|
|
* @param maxDepartures
|
|
* maximum number of departures to get or {@code 0}
|
|
* @return uri for getting departures
|
|
*/
|
|
String departuresQueryUri(String stationId, int maxDepartures);
|
|
|
|
/**
|
|
* Get departures at a given station, probably live
|
|
*
|
|
* @param queryUri
|
|
* uri constructed by {@link NetworkProvider#departuresQueryUri}
|
|
* @return result object containing the departures
|
|
* @throws IOException
|
|
*/
|
|
QueryDeparturesResult queryDepartures(String queryUri) throws IOException;
|
|
|
|
/**
|
|
* Get colors of line
|
|
*
|
|
* @param line
|
|
* line to get color of
|
|
* @return array containing background, foreground and border (optional) colors
|
|
*/
|
|
int[] lineColors(String line);
|
|
}
|