mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-07 18:48:49 +00:00
Location and LocationType belong together
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@247 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
875bd1d651
commit
19c9c269e2
27 changed files with 177 additions and 143 deletions
|
@ -34,10 +34,11 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
@ -54,14 +55,14 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
{
|
{
|
||||||
protected abstract String autocompleteUri(final CharSequence constraint);
|
protected abstract String autocompleteUri(final CharSequence constraint);
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = autocompleteUri(constraint);
|
final String uri = autocompleteUri(constraint);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
final List<Autocomplete> results = new ArrayList<Autocomplete>();
|
final List<Location> results = new ArrayList<Location>();
|
||||||
|
|
||||||
final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
|
final XmlPullParserFactory factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
|
||||||
final XmlPullParser pp = factory.newPullParser();
|
final XmlPullParser pp = factory.newPullParser();
|
||||||
|
@ -85,7 +86,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
final int id = Integer.parseInt(pp.getAttributeValue(null, "stopID"));
|
final int id = Integer.parseInt(pp.getAttributeValue(null, "stopID"));
|
||||||
final String name = normalizeLocationName(pp.getAttributeValue(null, "nameWithPlace"));
|
final String name = normalizeLocationName(pp.getAttributeValue(null, "nameWithPlace"));
|
||||||
|
|
||||||
final Autocomplete autocomplete = new Autocomplete(LocationType.STATION, id, name);
|
final Location autocomplete = new Location(LocationType.STATION, id, name);
|
||||||
if (!results.contains(autocomplete))
|
if (!results.contains(autocomplete))
|
||||||
results.add(autocomplete);
|
results.add(autocomplete);
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processOdvNameElem(final List<Autocomplete> results, final XmlPullParser pp) throws XmlPullParserException, IOException
|
private void processOdvNameElem(final List<Location> results, final XmlPullParser pp) throws XmlPullParserException, IOException
|
||||||
{
|
{
|
||||||
while (XmlPullUtil.nextStartTagInsideTree(pp, null, "odvNameElem"))
|
while (XmlPullUtil.nextStartTagInsideTree(pp, null, "odvNameElem"))
|
||||||
{
|
{
|
||||||
|
@ -110,7 +111,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
id = 0;
|
id = 0;
|
||||||
final String name = normalizeLocationName(pp.nextText());
|
final String name = normalizeLocationName(pp.nextText());
|
||||||
results.add(new Autocomplete(type(type), id, name));
|
results.add(new Location(type(type), id, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +640,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
final String sessionId = pp.getAttributeValue(null, "sessionID");
|
final String sessionId = pp.getAttributeValue(null, "sessionID");
|
||||||
|
|
||||||
// parse odv name elements
|
// parse odv name elements
|
||||||
List<Autocomplete> ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null;
|
List<Location> ambiguousFrom = null, ambiguousTo = null, ambiguousVia = null;
|
||||||
String from = null, to = null;
|
String from = null, to = null;
|
||||||
|
|
||||||
XmlPullUtil.jumpToStartTag(pp, null, "itdOdv");
|
XmlPullUtil.jumpToStartTag(pp, null, "itdOdv");
|
||||||
|
@ -649,7 +650,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
final String originState = pp.getAttributeValue(null, "state");
|
final String originState = pp.getAttributeValue(null, "state");
|
||||||
if ("list".equals(originState))
|
if ("list".equals(originState))
|
||||||
{
|
{
|
||||||
ambiguousFrom = new ArrayList<Autocomplete>();
|
ambiguousFrom = new ArrayList<Location>();
|
||||||
processOdvNameElem(ambiguousFrom, pp);
|
processOdvNameElem(ambiguousFrom, pp);
|
||||||
}
|
}
|
||||||
else if ("identified".equals(originState))
|
else if ("identified".equals(originState))
|
||||||
|
@ -665,7 +666,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
final String destinationState = pp.getAttributeValue(null, "state");
|
final String destinationState = pp.getAttributeValue(null, "state");
|
||||||
if ("list".equals(destinationState))
|
if ("list".equals(destinationState))
|
||||||
{
|
{
|
||||||
ambiguousTo = new ArrayList<Autocomplete>();
|
ambiguousTo = new ArrayList<Location>();
|
||||||
processOdvNameElem(ambiguousTo, pp);
|
processOdvNameElem(ambiguousTo, pp);
|
||||||
}
|
}
|
||||||
else if ("identified".equals(destinationState))
|
else if ("identified".equals(destinationState))
|
||||||
|
@ -681,7 +682,7 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
final String viaState = pp.getAttributeValue(null, "state");
|
final String viaState = pp.getAttributeValue(null, "state");
|
||||||
if ("list".equals(viaState))
|
if ("list".equals(viaState))
|
||||||
{
|
{
|
||||||
ambiguousVia = new ArrayList<Autocomplete>();
|
ambiguousVia = new ArrayList<Location>();
|
||||||
processOdvNameElem(ambiguousVia, pp);
|
processOdvNameElem(ambiguousVia, pp);
|
||||||
}
|
}
|
||||||
else if ("identified".equals(viaState))
|
else if ("identified".equals(viaState))
|
||||||
|
|
|
@ -30,10 +30,11 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
@ -65,22 +66,22 @@ public final class BahnProvider implements NetworkProvider
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<option value=\".+?#(\\d+)\">(.+?)</option>", Pattern.DOTALL);
|
private static final Pattern P_MULTI_NAME = Pattern.compile("<option value=\".+?#(\\d+)\">(.+?)</option>", Pattern.DOTALL);
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final CharSequence page = ParserUtils.scrape(NAME_URL + ParserUtils.urlEncode(constraint.toString()));
|
final CharSequence page = ParserUtils.scrape(NAME_URL + ParserUtils.urlEncode(constraint.toString()));
|
||||||
|
|
||||||
final List<Autocomplete> results = new ArrayList<Autocomplete>();
|
final List<Location> results = new ArrayList<Location>();
|
||||||
|
|
||||||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||||
if (mSingle.matches())
|
if (mSingle.matches())
|
||||||
{
|
{
|
||||||
results.add(new Autocomplete(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||||
while (mMulti.find())
|
while (mMulti.find())
|
||||||
results.add(new Autocomplete(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
@ -187,9 +188,9 @@ public final class BahnProvider implements NetworkProvider
|
||||||
return QueryConnectionsResult.INVALID_DATE;
|
return QueryConnectionsResult.INVALID_DATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Autocomplete> fromAddresses = null;
|
List<Location> fromAddresses = null;
|
||||||
List<Autocomplete> viaAddresses = null;
|
List<Location> viaAddresses = null;
|
||||||
List<Autocomplete> toAddresses = null;
|
List<Location> toAddresses = null;
|
||||||
|
|
||||||
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
||||||
while (mPreAddress.find())
|
while (mPreAddress.find())
|
||||||
|
@ -198,12 +199,12 @@ public final class BahnProvider implements NetworkProvider
|
||||||
final String options = mPreAddress.group(2);
|
final String options = mPreAddress.group(2);
|
||||||
|
|
||||||
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
||||||
final List<Autocomplete> addresses = new ArrayList<Autocomplete>();
|
final List<Location> addresses = new ArrayList<Location>();
|
||||||
while (mAddresses.find())
|
while (mAddresses.find())
|
||||||
{
|
{
|
||||||
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
||||||
if (!addresses.contains(address))
|
if (!addresses.contains(address))
|
||||||
addresses.add(new Autocomplete(LocationType.ANY, 0, address));
|
addresses.add(new Location(LocationType.ANY, 0, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals("REQ0JourneyStopsS0K"))
|
if (type.equals("REQ0JourneyStopsS0K"))
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,9 +30,10 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.Station;
|
import de.schildbach.pte.dto.Station;
|
||||||
|
@ -74,12 +75,12 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = autocompleteUri(constraint);
|
final String uri = autocompleteUri(constraint);
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
|
|
||||||
final List<Autocomplete> results = new ArrayList<Autocomplete>();
|
final List<Location> results = new ArrayList<Location>();
|
||||||
|
|
||||||
final Matcher mAutocompleteCoarse = P_AUTOCOMPLETE_COARSE.matcher(page);
|
final Matcher mAutocompleteCoarse = P_AUTOCOMPLETE_COARSE.matcher(page);
|
||||||
while (mAutocompleteCoarse.find())
|
while (mAutocompleteCoarse.find())
|
||||||
|
@ -92,13 +93,13 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
final int locationId = Integer.parseInt(mAutocompleteFine.group(3));
|
final int locationId = Integer.parseInt(mAutocompleteFine.group(3));
|
||||||
|
|
||||||
if (type.equals("stop"))
|
if (type.equals("stop"))
|
||||||
results.add(new Autocomplete(LocationType.STATION, locationId, location));
|
results.add(new Location(LocationType.STATION, locationId, location));
|
||||||
else if (type.equals("street"))
|
else if (type.equals("street"))
|
||||||
results.add(new Autocomplete(LocationType.ADDRESS, 0, location));
|
results.add(new Location(LocationType.ADDRESS, 0, location));
|
||||||
else if (type.equals("singlehouse"))
|
else if (type.equals("singlehouse"))
|
||||||
results.add(new Autocomplete(LocationType.ADDRESS, 0, location));
|
results.add(new Location(LocationType.ADDRESS, 0, location));
|
||||||
else if (type.equals("poi"))
|
else if (type.equals("poi"))
|
||||||
results.add(new Autocomplete(LocationType.POI, 0, location));
|
results.add(new Location(LocationType.POI, 0, location));
|
||||||
else
|
else
|
||||||
throw new IllegalStateException("unknown type " + type + " on " + uri);
|
throw new IllegalStateException("unknown type " + type + " on " + uri);
|
||||||
}
|
}
|
||||||
|
@ -347,9 +348,9 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
return QueryConnectionsResult.NO_CONNECTIONS;
|
return QueryConnectionsResult.NO_CONNECTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Autocomplete> fromAddresses = null;
|
List<Location> fromAddresses = null;
|
||||||
List<Autocomplete> viaAddresses = null;
|
List<Location> viaAddresses = null;
|
||||||
List<Autocomplete> toAddresses = null;
|
List<Location> toAddresses = null;
|
||||||
|
|
||||||
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
||||||
while (mPreAddress.find())
|
while (mPreAddress.find())
|
||||||
|
@ -358,12 +359,12 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
final String options = mPreAddress.group(2);
|
final String options = mPreAddress.group(2);
|
||||||
|
|
||||||
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
||||||
final List<Autocomplete> addresses = new ArrayList<Autocomplete>();
|
final List<Location> addresses = new ArrayList<Location>();
|
||||||
while (mAddresses.find())
|
while (mAddresses.find())
|
||||||
{
|
{
|
||||||
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
||||||
if (!addresses.contains(address))
|
if (!addresses.contains(address))
|
||||||
addresses.add(new Autocomplete(LocationType.ANY, 0, address));
|
addresses.add(new Location(LocationType.ANY, 0, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals("name_origin"))
|
if (type.equals("name_origin"))
|
||||||
|
|
|
@ -28,9 +28,10 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
@ -55,7 +56,7 @@ public class NasaProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,9 @@ import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.Location;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
@ -39,11 +40,6 @@ public interface NetworkProvider
|
||||||
NEARBY_STATIONS, DEPARTURES, CONNECTIONS, LOCATION_WGS84, LOCATION_STATION_ID
|
NEARBY_STATIONS, DEPARTURES, CONNECTIONS, LOCATION_WGS84, LOCATION_STATION_ID
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum LocationType
|
|
||||||
{
|
|
||||||
ANY, STATION, WGS84, ADDRESS, POI
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum WalkSpeed
|
public enum WalkSpeed
|
||||||
{
|
{
|
||||||
SLOW, NORMAL, FAST
|
SLOW, NORMAL, FAST
|
||||||
|
@ -59,7 +55,7 @@ public interface NetworkProvider
|
||||||
* @return auto-complete suggestions
|
* @return auto-complete suggestions
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
List<Autocomplete> autocompleteStations(CharSequence constraint) throws IOException;
|
List<Location> autocompleteStations(CharSequence constraint) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine stations near to given location. At least one of stationId or lat/lon pair must be given.
|
* Determine stations near to given location. At least one of stationId or lat/lon pair must be given.
|
||||||
|
|
|
@ -32,10 +32,11 @@ import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
@ -62,7 +63,7 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
private static final Pattern P_AUTOCOMPLETE_JSON = Pattern.compile("SLs\\.sls=(.*?);SLs\\.showSuggestion\\(\\);", Pattern.DOTALL);
|
private static final Pattern P_AUTOCOMPLETE_JSON = Pattern.compile("SLs\\.sls=(.*?);SLs\\.showSuggestion\\(\\);", Pattern.DOTALL);
|
||||||
private static final Pattern P_AUTOCOMPLETE_ID = Pattern.compile(".*?@L=(\\d+)@.*?");
|
private static final Pattern P_AUTOCOMPLETE_ID = Pattern.compile(".*?@L=(\\d+)@.*?");
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
final String uri = String.format(AUTOCOMPLETE_URI, ParserUtils.urlEncode(constraint.toString(), ENCODING));
|
||||||
final CharSequence page = ParserUtils.scrape(uri);
|
final CharSequence page = ParserUtils.scrape(uri);
|
||||||
|
@ -71,7 +72,7 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
if (mJson.matches())
|
if (mJson.matches())
|
||||||
{
|
{
|
||||||
final String json = mJson.group(1);
|
final String json = mJson.group(1);
|
||||||
final List<Autocomplete> results = new ArrayList<Autocomplete>();
|
final List<Location> results = new ArrayList<Location>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -93,7 +94,7 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
if (m.matches())
|
if (m.matches())
|
||||||
{
|
{
|
||||||
final int localId = Integer.parseInt(m.group(1));
|
final int localId = Integer.parseInt(m.group(1));
|
||||||
results.add(new Autocomplete(LocationType.STATION, localId, value));
|
results.add(new Location(LocationType.STATION, localId, value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -102,11 +103,11 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
}
|
}
|
||||||
else if (type == 2) // address
|
else if (type == 2) // address
|
||||||
{
|
{
|
||||||
results.add(new Autocomplete(LocationType.ADDRESS, 0, value));
|
results.add(new Location(LocationType.ADDRESS, 0, value));
|
||||||
}
|
}
|
||||||
else if (type == 4) // poi
|
else if (type == 4) // poi
|
||||||
{
|
{
|
||||||
results.add(new Autocomplete(LocationType.ANY, 0, value));
|
results.add(new Location(LocationType.ANY, 0, value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -247,9 +248,9 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
throw new SessionExpiredException();
|
throw new SessionExpiredException();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Autocomplete> fromAddresses = null;
|
List<Location> fromAddresses = null;
|
||||||
List<Autocomplete> viaAddresses = null;
|
List<Location> viaAddresses = null;
|
||||||
List<Autocomplete> toAddresses = null;
|
List<Location> toAddresses = null;
|
||||||
|
|
||||||
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
||||||
while (mPreAddress.find())
|
while (mPreAddress.find())
|
||||||
|
@ -258,12 +259,12 @@ public class OebbProvider extends AbstractHafasProvider
|
||||||
final String options = mPreAddress.group(2);
|
final String options = mPreAddress.group(2);
|
||||||
|
|
||||||
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
||||||
final List<Autocomplete> addresses = new ArrayList<Autocomplete>();
|
final List<Location> addresses = new ArrayList<Location>();
|
||||||
while (mAddresses.find())
|
while (mAddresses.find())
|
||||||
{
|
{
|
||||||
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
||||||
if (!addresses.contains(address))
|
if (!addresses.contains(address))
|
||||||
addresses.add(new Autocomplete(LocationType.ANY, 0, address));
|
addresses.add(new Location(LocationType.ANY, 0, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals("REQ0JourneyStopsS0K"))
|
if (type.equals("REQ0JourneyStopsS0K"))
|
||||||
|
|
|
@ -30,10 +30,11 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
@ -65,22 +66,22 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
private static final Pattern P_MULTI_NAME = Pattern.compile("<a href=\"/auskunft/bin/jp/stboard.exe/dox.*?input=(\\d+)&.*?\">\\s*(.*?)\\s*</a>",
|
private static final Pattern P_MULTI_NAME = Pattern.compile("<a href=\"/auskunft/bin/jp/stboard.exe/dox.*?input=(\\d+)&.*?\">\\s*(.*?)\\s*</a>",
|
||||||
Pattern.DOTALL);
|
Pattern.DOTALL);
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final CharSequence page = ParserUtils.scrape(NAME_URL + ParserUtils.urlEncode(constraint.toString()));
|
final CharSequence page = ParserUtils.scrape(NAME_URL + ParserUtils.urlEncode(constraint.toString()));
|
||||||
|
|
||||||
final List<Autocomplete> results = new ArrayList<Autocomplete>();
|
final List<Location> results = new ArrayList<Location>();
|
||||||
|
|
||||||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||||
if (mSingle.matches())
|
if (mSingle.matches())
|
||||||
{
|
{
|
||||||
results.add(new Autocomplete(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||||
while (mMulti.find())
|
while (mMulti.find())
|
||||||
results.add(new Autocomplete(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
@ -186,9 +187,9 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
return QueryConnectionsResult.INVALID_DATE;
|
return QueryConnectionsResult.INVALID_DATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Autocomplete> fromAddresses = null;
|
List<Location> fromAddresses = null;
|
||||||
List<Autocomplete> viaAddresses = null;
|
List<Location> viaAddresses = null;
|
||||||
List<Autocomplete> toAddresses = null;
|
List<Location> toAddresses = null;
|
||||||
|
|
||||||
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
||||||
while (mPreAddress.find())
|
while (mPreAddress.find())
|
||||||
|
@ -196,12 +197,12 @@ public class RmvProvider extends AbstractHafasProvider
|
||||||
final String type = mPreAddress.group(1);
|
final String type = mPreAddress.group(1);
|
||||||
|
|
||||||
final Matcher mAddresses = P_ADDRESSES.matcher(page);
|
final Matcher mAddresses = P_ADDRESSES.matcher(page);
|
||||||
final List<Autocomplete> addresses = new ArrayList<Autocomplete>();
|
final List<Location> addresses = new ArrayList<Location>();
|
||||||
while (mAddresses.find())
|
while (mAddresses.find())
|
||||||
{
|
{
|
||||||
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
||||||
if (!addresses.contains(address))
|
if (!addresses.contains(address))
|
||||||
addresses.add(new Autocomplete(LocationType.ANY, 0, address));
|
addresses.add(new Location(LocationType.ANY, 0, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
|
|
|
@ -28,10 +28,11 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
@ -62,22 +63,22 @@ public class SbbProvider extends AbstractHafasProvider
|
||||||
+ "(.*?)\n?" //
|
+ "(.*?)\n?" //
|
||||||
+ "</a>", Pattern.DOTALL);
|
+ "</a>", Pattern.DOTALL);
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final CharSequence page = ParserUtils.scrape(NAME_URL + ParserUtils.urlEncode(constraint.toString()));
|
final CharSequence page = ParserUtils.scrape(NAME_URL + ParserUtils.urlEncode(constraint.toString()));
|
||||||
|
|
||||||
final List<Autocomplete> results = new ArrayList<Autocomplete>();
|
final List<Location> results = new ArrayList<Location>();
|
||||||
|
|
||||||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||||
if (mSingle.matches())
|
if (mSingle.matches())
|
||||||
{
|
{
|
||||||
results.add(new Autocomplete(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
results.add(new Location(LocationType.STATION, Integer.parseInt(mSingle.group(2)), ParserUtils.resolveEntities(mSingle.group(1))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||||
while (mMulti.find())
|
while (mMulti.find())
|
||||||
results.add(new Autocomplete(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils.resolveEntities(mMulti.group(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
@ -162,9 +163,9 @@ public class SbbProvider extends AbstractHafasProvider
|
||||||
return QueryConnectionsResult.INVALID_DATE;
|
return QueryConnectionsResult.INVALID_DATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Autocomplete> fromAddresses = null;
|
List<Location> fromAddresses = null;
|
||||||
List<Autocomplete> viaAddresses = null;
|
List<Location> viaAddresses = null;
|
||||||
List<Autocomplete> toAddresses = null;
|
List<Location> toAddresses = null;
|
||||||
|
|
||||||
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
final Matcher mPreAddress = P_PRE_ADDRESS.matcher(page);
|
||||||
while (mPreAddress.find())
|
while (mPreAddress.find())
|
||||||
|
@ -173,12 +174,12 @@ public class SbbProvider extends AbstractHafasProvider
|
||||||
final String options = mPreAddress.group(2);
|
final String options = mPreAddress.group(2);
|
||||||
|
|
||||||
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
final Matcher mAddresses = P_ADDRESSES.matcher(options);
|
||||||
final List<Autocomplete> addresses = new ArrayList<Autocomplete>();
|
final List<Location> addresses = new ArrayList<Location>();
|
||||||
while (mAddresses.find())
|
while (mAddresses.find())
|
||||||
{
|
{
|
||||||
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
final String address = ParserUtils.resolveEntities(mAddresses.group(1)).trim();
|
||||||
if (!addresses.contains(address))
|
if (!addresses.contains(address))
|
||||||
addresses.add(new Autocomplete(LocationType.ANY, 0, address));
|
addresses.add(new Location(LocationType.ANY, 0, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.equals("REQ0JourneyStopsS0K"))
|
if (type.equals("REQ0JourneyStopsS0K"))
|
||||||
|
|
|
@ -26,9 +26,10 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
@ -52,7 +53,7 @@ public class SncbProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,10 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
@ -48,7 +49,7 @@ public class TflProvider implements NetworkProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,11 @@ import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
@ -71,9 +72,9 @@ public final class VbbProvider implements NetworkProvider
|
||||||
private static final String AUTOCOMPLETE_MASTID_URL = "http://mobil.bvg.de/IstAbfahrtzeiten/index/mobil?input=";
|
private static final String AUTOCOMPLETE_MASTID_URL = "http://mobil.bvg.de/IstAbfahrtzeiten/index/mobil?input=";
|
||||||
private static final Pattern P_SINGLE_MASTID = Pattern.compile(".*Ist-Abfahrtzeiten.*?<strong>(.*?)</strong>.*", Pattern.DOTALL);
|
private static final Pattern P_SINGLE_MASTID = Pattern.compile(".*Ist-Abfahrtzeiten.*?<strong>(.*?)</strong>.*", Pattern.DOTALL);
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(final CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(final CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
final List<Autocomplete> results = new ArrayList<Autocomplete>();
|
final List<Location> results = new ArrayList<Location>();
|
||||||
|
|
||||||
if (P_AUTOCOMPLETE_IS_MAST.matcher(constraint).matches())
|
if (P_AUTOCOMPLETE_IS_MAST.matcher(constraint).matches())
|
||||||
{
|
{
|
||||||
|
@ -82,7 +83,7 @@ public final class VbbProvider implements NetworkProvider
|
||||||
final Matcher mSingle = P_SINGLE_MASTID.matcher(page);
|
final Matcher mSingle = P_SINGLE_MASTID.matcher(page);
|
||||||
if (mSingle.matches())
|
if (mSingle.matches())
|
||||||
{
|
{
|
||||||
results.add(new Autocomplete(LocationType.ANY, 0 /* TODO */, ParserUtils.resolveEntities(mSingle.group(1))));
|
results.add(new Location(LocationType.ANY, 0 /* TODO */, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -92,13 +93,13 @@ public final class VbbProvider implements NetworkProvider
|
||||||
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
final Matcher mSingle = P_SINGLE_NAME.matcher(page);
|
||||||
if (mSingle.matches())
|
if (mSingle.matches())
|
||||||
{
|
{
|
||||||
results.add(new Autocomplete(LocationType.ANY, 0 /* TODO */, ParserUtils.resolveEntities(mSingle.group(1))));
|
results.add(new Location(LocationType.ANY, 0 /* TODO */, ParserUtils.resolveEntities(mSingle.group(1))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
final Matcher mMulti = P_MULTI_NAME.matcher(page);
|
||||||
while (mMulti.find())
|
while (mMulti.find())
|
||||||
results.add(new Autocomplete(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils
|
results.add(new Location(LocationType.STATION, Integer.parseInt(mMulti.group(1)), ParserUtils
|
||||||
.resolveEntities(mMulti.group(2))));
|
.resolveEntities(mMulti.group(2))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,12 +239,12 @@ public final class VbbProvider implements NetworkProvider
|
||||||
|
|
||||||
final Matcher mAddress = P_CHECK_ADDRESS.matcher(page);
|
final Matcher mAddress = P_CHECK_ADDRESS.matcher(page);
|
||||||
|
|
||||||
final List<Autocomplete> addresses = new ArrayList<Autocomplete>();
|
final List<Location> addresses = new ArrayList<Location>();
|
||||||
while (mAddress.find())
|
while (mAddress.find())
|
||||||
{
|
{
|
||||||
final String address = ParserUtils.resolveEntities(mAddress.group(1));
|
final String address = ParserUtils.resolveEntities(mAddress.group(1));
|
||||||
if (!addresses.contains(address))
|
if (!addresses.contains(address))
|
||||||
addresses.add(new Autocomplete(LocationType.ANY, 0, address));
|
addresses.add(new Location(LocationType.ANY, 0, address));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addresses.isEmpty())
|
if (addresses.isEmpty())
|
||||||
|
|
|
@ -28,9 +28,10 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.Departure;
|
import de.schildbach.pte.dto.Departure;
|
||||||
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
import de.schildbach.pte.dto.GetConnectionDetailsResult;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
import de.schildbach.pte.dto.QueryDeparturesResult.Status;
|
||||||
|
@ -55,7 +56,7 @@ public class VgsProvider extends AbstractHafasProvider
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Autocomplete> autocompleteStations(CharSequence constraint) throws IOException
|
public List<Location> autocompleteStations(CharSequence constraint) throws IOException
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.util.ParserUtils;
|
import de.schildbach.pte.util.ParserUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,33 +16,31 @@
|
||||||
*/
|
*/
|
||||||
package de.schildbach.pte.dto;
|
package de.schildbach.pte.dto;
|
||||||
|
|
||||||
import de.schildbach.pte.NetworkProvider.LocationType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
*/
|
*/
|
||||||
public final class Autocomplete
|
public final class Location
|
||||||
{
|
{
|
||||||
public final LocationType locationType;
|
public final LocationType type;
|
||||||
public final int locationId;
|
public final int id;
|
||||||
public final String location;
|
public final String name;
|
||||||
|
|
||||||
public Autocomplete(final LocationType locationType, final int locationId, final String location)
|
public Location(final LocationType type, final int id, final String name)
|
||||||
{
|
{
|
||||||
this.locationType = locationType;
|
this.type = type;
|
||||||
this.locationId = locationId;
|
this.id = id;
|
||||||
this.location = location;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return location; // invoked by AutoCompleteTextView in landscape orientation
|
return name; // invoked by AutoCompleteTextView in landscape orientation
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toDebugString()
|
public String toDebugString()
|
||||||
{
|
{
|
||||||
return "[" + locationType + " " + locationId + " '" + location + "']";
|
return "[" + type + " " + id + " '" + name + "']";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,21 +48,21 @@ public final class Autocomplete
|
||||||
{
|
{
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (!(o instanceof Autocomplete))
|
if (!(o instanceof Location))
|
||||||
return false;
|
return false;
|
||||||
final Autocomplete other = (Autocomplete) o;
|
final Location other = (Location) o;
|
||||||
if (this.locationType != other.locationType)
|
if (this.type != other.type)
|
||||||
return false;
|
return false;
|
||||||
if (this.locationId != other.locationId)
|
if (this.id != other.id)
|
||||||
return false;
|
return false;
|
||||||
if (this.locationId != 0)
|
if (this.id != 0)
|
||||||
return true;
|
return true;
|
||||||
return this.location.equals(other.location);
|
return this.name.equals(other.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return locationType.hashCode(); // FIXME not very discriminative
|
return type.hashCode(); // FIXME not very discriminative
|
||||||
}
|
}
|
||||||
}
|
}
|
25
src/de/schildbach/pte/dto/LocationType.java
Normal file
25
src/de/schildbach/pte/dto/LocationType.java
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* 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.dto;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andreas Schildbach
|
||||||
|
*/
|
||||||
|
public enum LocationType
|
||||||
|
{
|
||||||
|
ANY, STATION, WGS84, ADDRESS, POI
|
||||||
|
}
|
|
@ -37,9 +37,9 @@ public final class QueryConnectionsResult implements Serializable
|
||||||
|
|
||||||
public final Status status;
|
public final Status status;
|
||||||
|
|
||||||
public final List<Autocomplete> ambiguousFrom;
|
public final List<Location> ambiguousFrom;
|
||||||
public final List<Autocomplete> ambiguousVia;
|
public final List<Location> ambiguousVia;
|
||||||
public final List<Autocomplete> ambiguousTo;
|
public final List<Location> ambiguousTo;
|
||||||
|
|
||||||
public final String queryUri;
|
public final String queryUri;
|
||||||
public final String from;
|
public final String from;
|
||||||
|
@ -66,7 +66,7 @@ public final class QueryConnectionsResult implements Serializable
|
||||||
this.ambiguousTo = null;
|
this.ambiguousTo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryConnectionsResult(final List<Autocomplete> ambiguousFrom, final List<Autocomplete> ambiguousVia, final List<Autocomplete> ambiguousTo)
|
public QueryConnectionsResult(final List<Location> ambiguousFrom, final List<Location> ambiguousVia, final List<Location> ambiguousTo)
|
||||||
{
|
{
|
||||||
this.status = Status.AMBIGUOUS;
|
this.status = Status.AMBIGUOUS;
|
||||||
this.ambiguousFrom = ambiguousFrom;
|
this.ambiguousFrom = ambiguousFrom;
|
||||||
|
|
|
@ -22,9 +22,9 @@ import java.util.Date;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.BahnProvider;
|
import de.schildbach.pte.BahnProvider;
|
||||||
import de.schildbach.pte.NetworkProvider.LocationType;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
import de.schildbach.pte.dto.Connection;
|
import de.schildbach.pte.dto.Connection;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.GvhProvider;
|
import de.schildbach.pte.GvhProvider;
|
||||||
import de.schildbach.pte.NetworkProvider.LocationType;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public class GvhProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIncomplete() throws Exception
|
public void autocompleteIncomplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Kur");
|
final List<Location> autocompletes = provider.autocompleteStations("Kur");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class GvhProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIdentified() throws Exception
|
public void autocompleteIdentified() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Hannover, Hannoversche Straße");
|
final List<Location> autocompletes = provider.autocompleteStations("Hannover, Hannoversche Straße");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -55,15 +55,15 @@ public class GvhProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteCity() throws Exception
|
public void autocompleteCity() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Hannover");
|
final List<Location> autocompletes = provider.autocompleteStations("Hannover");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list(final List<Autocomplete> autocompletes)
|
private void list(final List<Location> autocompletes)
|
||||||
{
|
{
|
||||||
System.out.print(autocompletes.size() + " ");
|
System.out.print(autocompletes.size() + " ");
|
||||||
for (final Autocomplete autocomplete : autocompletes)
|
for (final Location autocomplete : autocompletes)
|
||||||
System.out.print(autocomplete.toDebugString() + " ");
|
System.out.print(autocomplete.toDebugString() + " ");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public class GvhProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocomplete() throws Exception
|
public void autocomplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> results = provider.autocompleteStations("Hannover");
|
final List<Location> results = provider.autocompleteStations("Hannover");
|
||||||
|
|
||||||
System.out.println(results.size() + " " + results);
|
System.out.println(results.size() + " " + results);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,9 @@ import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.LinzProvider;
|
import de.schildbach.pte.LinzProvider;
|
||||||
import de.schildbach.pte.NetworkProvider.LocationType;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class LinzProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIncomplete() throws Exception
|
public void autocompleteIncomplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Linz, H");
|
final List<Location> autocompletes = provider.autocompleteStations("Linz, H");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class LinzProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIdentified() throws Exception
|
public void autocompleteIdentified() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Leonding, Haag");
|
final List<Location> autocompletes = provider.autocompleteStations("Leonding, Haag");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -56,15 +56,15 @@ public class LinzProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteCity() throws Exception
|
public void autocompleteCity() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Linz");
|
final List<Location> autocompletes = provider.autocompleteStations("Linz");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list(final List<Autocomplete> autocompletes)
|
private void list(final List<Location> autocompletes)
|
||||||
{
|
{
|
||||||
System.out.print(autocompletes.size() + " ");
|
System.out.print(autocompletes.size() + " ");
|
||||||
for (final Autocomplete autocomplete : autocompletes)
|
for (final Location autocomplete : autocompletes)
|
||||||
System.out.print(autocomplete.toDebugString() + " ");
|
System.out.print(autocomplete.toDebugString() + " ");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ import java.util.Date;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.MvvProvider;
|
import de.schildbach.pte.MvvProvider;
|
||||||
import de.schildbach.pte.NetworkProvider.LocationType;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,8 +22,8 @@ import java.util.Date;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.OebbProvider;
|
import de.schildbach.pte.OebbProvider;
|
||||||
import de.schildbach.pte.NetworkProvider.LocationType;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.SbbProvider;
|
import de.schildbach.pte.SbbProvider;
|
||||||
import de.schildbach.pte.NetworkProvider.LocationType;
|
|
||||||
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
import de.schildbach.pte.NetworkProvider.WalkSpeed;
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
|
import de.schildbach.pte.dto.LocationType;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryConnectionsResult;
|
import de.schildbach.pte.dto.QueryConnectionsResult;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class SbbProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autoComplete() throws Exception
|
public void autoComplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> result = provider.autocompleteStations("haupt");
|
final List<Location> result = provider.autocompleteStations("haupt");
|
||||||
System.out.println(result);
|
System.out.println(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.VrnProvider;
|
import de.schildbach.pte.VrnProvider;
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public class VrnProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIncomplete() throws Exception
|
public void autocompleteIncomplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Kur");
|
final List<Location> autocompletes = provider.autocompleteStations("Kur");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class VrnProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIdentified() throws Exception
|
public void autocompleteIdentified() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Bremen, KUR");
|
final List<Location> autocompletes = provider.autocompleteStations("Bremen, KUR");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class VrnProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteLocality() throws Exception
|
public void autocompleteLocality() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Bremen");
|
final List<Location> autocompletes = provider.autocompleteStations("Bremen");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -59,15 +59,15 @@ public class VrnProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteCity() throws Exception
|
public void autocompleteCity() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Mannheim");
|
final List<Location> autocompletes = provider.autocompleteStations("Mannheim");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list(final List<Autocomplete> autocompletes)
|
private void list(final List<Location> autocompletes)
|
||||||
{
|
{
|
||||||
System.out.print(autocompletes.size() + " ");
|
System.out.print(autocompletes.size() + " ");
|
||||||
for (final Autocomplete autocomplete : autocompletes)
|
for (final Location autocomplete : autocompletes)
|
||||||
System.out.print(autocomplete.toDebugString() + " ");
|
System.out.print(autocomplete.toDebugString() + " ");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.schildbach.pte.VrrProvider;
|
import de.schildbach.pte.VrrProvider;
|
||||||
import de.schildbach.pte.dto.Autocomplete;
|
import de.schildbach.pte.dto.Location;
|
||||||
import de.schildbach.pte.dto.NearbyStationsResult;
|
import de.schildbach.pte.dto.NearbyStationsResult;
|
||||||
import de.schildbach.pte.dto.QueryDeparturesResult;
|
import de.schildbach.pte.dto.QueryDeparturesResult;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public class VrrProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIncomplete() throws Exception
|
public void autocompleteIncomplete() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Kur");
|
final List<Location> autocompletes = provider.autocompleteStations("Kur");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class VrrProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteIdentified() throws Exception
|
public void autocompleteIdentified() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Düsseldorf, Am Frohnhof");
|
final List<Location> autocompletes = provider.autocompleteStations("Düsseldorf, Am Frohnhof");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
@ -51,15 +51,15 @@ public class VrrProviderLiveTest
|
||||||
@Test
|
@Test
|
||||||
public void autocompleteCity() throws Exception
|
public void autocompleteCity() throws Exception
|
||||||
{
|
{
|
||||||
final List<Autocomplete> autocompletes = provider.autocompleteStations("Düsseldorf");
|
final List<Location> autocompletes = provider.autocompleteStations("Düsseldorf");
|
||||||
|
|
||||||
list(autocompletes);
|
list(autocompletes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list(final List<Autocomplete> autocompletes)
|
private void list(final List<Location> autocompletes)
|
||||||
{
|
{
|
||||||
System.out.print(autocompletes.size() + " ");
|
System.out.print(autocompletes.size() + " ");
|
||||||
for (final Autocomplete autocomplete : autocompletes)
|
for (final Location autocomplete : autocompletes)
|
||||||
System.out.print(autocomplete.toDebugString() + " ");
|
System.out.print(autocomplete.toDebugString() + " ");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue