mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 08:49:51 +00:00
Sort suggested locations by hit quality.
This commit is contained in:
parent
e691e7c2fb
commit
68989ec451
24 changed files with 187 additions and 137 deletions
|
@ -19,14 +19,12 @@ package de.schildbach.pte;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Currency;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
@ -65,6 +63,7 @@ import de.schildbach.pte.dto.ResultHeader;
|
|||
import de.schildbach.pte.dto.StationDepartures;
|
||||
import de.schildbach.pte.dto.Stop;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
import de.schildbach.pte.dto.SuggestedLocation;
|
||||
import de.schildbach.pte.dto.Trip;
|
||||
import de.schildbach.pte.exception.InvalidDataException;
|
||||
import de.schildbach.pte.exception.ParserException;
|
||||
|
@ -252,7 +251,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
|
||||
try
|
||||
{
|
||||
final List<Location> locations = new ArrayList<Location>();
|
||||
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
||||
|
||||
final JSONObject head = new JSONObject(page.toString());
|
||||
final JSONObject stopFinder = head.optJSONObject("stopFinder");
|
||||
|
@ -267,7 +266,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
if (points != null)
|
||||
{
|
||||
final JSONObject stop = points.getJSONObject("point");
|
||||
final Location location = parseJsonStop(stop);
|
||||
final SuggestedLocation location = parseJsonStop(stop);
|
||||
locations.add(location);
|
||||
return new SuggestLocationsResult(header, locations);
|
||||
}
|
||||
|
@ -280,7 +279,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
for (int i = 0; i < nStops; i++)
|
||||
{
|
||||
final JSONObject stop = stops.optJSONObject(i);
|
||||
final Location location = parseJsonStop(stop);
|
||||
final SuggestedLocation location = parseJsonStop(stop);
|
||||
locations.add(location);
|
||||
}
|
||||
|
||||
|
@ -292,12 +291,13 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
private Location parseJsonStop(final JSONObject stop) throws JSONException
|
||||
private SuggestedLocation parseJsonStop(final JSONObject stop) throws JSONException
|
||||
{
|
||||
String type = stop.getString("type");
|
||||
if ("any".equals(type))
|
||||
type = stop.getString("anyType");
|
||||
final String name = normalizeLocationName(stop.getString("object"));
|
||||
final int quality = stop.getInt("quality");
|
||||
final JSONObject ref = stop.getJSONObject("ref");
|
||||
String place = ref.getString("place");
|
||||
if (place != null && place.length() == 0)
|
||||
|
@ -317,16 +317,19 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
lon = 0;
|
||||
}
|
||||
|
||||
final Location location;
|
||||
if ("stop".equals(type))
|
||||
return new Location(LocationType.STATION, stop.getString("stateless"), lat, lon, place, name);
|
||||
location = new Location(LocationType.STATION, stop.getString("stateless"), lat, lon, place, name);
|
||||
else if ("poi".equals(type))
|
||||
return new Location(LocationType.POI, null, lat, lon, place, name);
|
||||
location = new Location(LocationType.POI, null, lat, lon, place, name);
|
||||
else if ("crossing".equals(type))
|
||||
return new Location(LocationType.ADDRESS, null, lat, lon, place, name);
|
||||
location = new Location(LocationType.ADDRESS, null, lat, lon, place, name);
|
||||
else if ("street".equals(type) || "address".equals(type) || "singlehouse".equals(type) || "buildingname".equals(type))
|
||||
return new Location(LocationType.ADDRESS, null, lat, lon, place, normalizeLocationName(stop.getString("name")));
|
||||
location = new Location(LocationType.ADDRESS, null, lat, lon, place, normalizeLocationName(stop.getString("name")));
|
||||
else
|
||||
throw new JSONException("unknown type: " + type);
|
||||
|
||||
return new SuggestedLocation(location, quality);
|
||||
}
|
||||
|
||||
private StringBuilder stopfinderRequestParameters(final Location constraint, final String outputFormat)
|
||||
|
@ -374,7 +377,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
pp.setInput(is, null);
|
||||
final ResultHeader header = enterItdRequest(pp);
|
||||
|
||||
final List<Location> locations = new ArrayList<Location>();
|
||||
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
||||
|
||||
XmlPullUtil.enter(pp, "itdStopFinderRequest");
|
||||
|
||||
|
@ -396,7 +399,11 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
if ("identified".equals(nameState) || "list".equals(nameState))
|
||||
{
|
||||
while (XmlPullUtil.test(pp, "odvNameElem"))
|
||||
locations.add(processOdvNameElem(pp, null));
|
||||
{
|
||||
final int matchQuality = XmlPullUtil.intAttr(pp, "matchQuality");
|
||||
final Location location = processOdvNameElem(pp, null);
|
||||
locations.add(new SuggestedLocation(location, matchQuality));
|
||||
}
|
||||
}
|
||||
else if ("notidentified".equals(nameState))
|
||||
{
|
||||
|
@ -426,57 +433,6 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
}
|
||||
}
|
||||
|
||||
private class LocationAndQuality implements Serializable, Comparable<LocationAndQuality>
|
||||
{
|
||||
public final Location location;
|
||||
public final int quality;
|
||||
|
||||
public LocationAndQuality(final Location location, final int quality)
|
||||
{
|
||||
this.location = location;
|
||||
this.quality = quality;
|
||||
}
|
||||
|
||||
public int compareTo(final LocationAndQuality other)
|
||||
{
|
||||
// prefer quality
|
||||
if (this.quality > other.quality)
|
||||
return -1;
|
||||
else if (this.quality < other.quality)
|
||||
return 1;
|
||||
|
||||
// prefer stations
|
||||
final int compareLocationType = this.location.type.compareTo(other.location.type);
|
||||
if (compareLocationType != 0)
|
||||
return compareLocationType;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o)
|
||||
{
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof LocationAndQuality))
|
||||
return false;
|
||||
final LocationAndQuality other = (LocationAndQuality) o;
|
||||
return location.equals(other.location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return location.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return quality + ":" + location;
|
||||
}
|
||||
}
|
||||
|
||||
protected SuggestLocationsResult mobileStopfinderRequest(final Location constraint) throws IOException
|
||||
{
|
||||
final StringBuilder parameters = stopfinderRequestParameters(constraint, "XML");
|
||||
|
@ -500,7 +456,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
pp.setInput(is, null);
|
||||
final ResultHeader header = enterEfa(pp);
|
||||
|
||||
final List<LocationAndQuality> locations = new ArrayList<LocationAndQuality>();
|
||||
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
||||
|
||||
XmlPullUtil.require(pp, "sf");
|
||||
if (!pp.isEmptyElementTag())
|
||||
|
@ -548,7 +504,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
|
||||
final Location location = new Location(type, type == LocationType.STATION ? id : null, coord != null ? coord.lat : 0,
|
||||
coord != null ? coord.lon : 0, place, name);
|
||||
final LocationAndQuality locationAndQuality = new LocationAndQuality(location, quality);
|
||||
final SuggestedLocation locationAndQuality = new SuggestedLocation(location, quality);
|
||||
locations.add(locationAndQuality);
|
||||
}
|
||||
|
||||
|
@ -559,13 +515,7 @@ public abstract class AbstractEfaProvider extends AbstractNetworkProvider
|
|||
XmlPullUtil.next(pp);
|
||||
}
|
||||
|
||||
Collections.sort(locations);
|
||||
|
||||
final List<Location> results = new ArrayList<Location>(locations.size());
|
||||
for (final LocationAndQuality location : locations)
|
||||
results.add(location.location);
|
||||
|
||||
return new SuggestLocationsResult(header, results);
|
||||
return new SuggestLocationsResult(header, locations);
|
||||
}
|
||||
catch (final XmlPullParserException x)
|
||||
{
|
||||
|
|
|
@ -64,6 +64,7 @@ import de.schildbach.pte.dto.ResultHeader;
|
|||
import de.schildbach.pte.dto.StationDepartures;
|
||||
import de.schildbach.pte.dto.Stop;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
import de.schildbach.pte.dto.SuggestedLocation;
|
||||
import de.schildbach.pte.dto.Trip;
|
||||
import de.schildbach.pte.exception.ParserException;
|
||||
import de.schildbach.pte.exception.SessionExpiredException;
|
||||
|
@ -342,7 +343,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
if (mJson.matches())
|
||||
{
|
||||
final String json = mJson.group(1);
|
||||
final List<Location> locations = new ArrayList<Location>();
|
||||
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -358,6 +359,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
final String value = suggestion.getString("value");
|
||||
final int lat = suggestion.optInt("ycoord");
|
||||
final int lon = suggestion.optInt("xcoord");
|
||||
final int weight = suggestion.getInt("weight");
|
||||
String localId = null;
|
||||
final Matcher m = P_AJAX_GET_STOPS_ID.matcher(suggestion.getString("id"));
|
||||
if (m.matches())
|
||||
|
@ -366,16 +368,19 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
if (type == 1) // station
|
||||
{
|
||||
final String[] placeAndName = splitPlaceAndName(value);
|
||||
locations.add(new Location(LocationType.STATION, localId, lat, lon, placeAndName[0], placeAndName[1]));
|
||||
final Location location = new Location(LocationType.STATION, localId, lat, lon, placeAndName[0], placeAndName[1]);
|
||||
locations.add(new SuggestedLocation(location, weight));
|
||||
}
|
||||
else if (type == 2) // address
|
||||
{
|
||||
final String[] placeAndName = splitPlaceAndName(value);
|
||||
locations.add(new Location(LocationType.ADDRESS, null, lat, lon, placeAndName[0], placeAndName[1]));
|
||||
final Location location = new Location(LocationType.ADDRESS, null, lat, lon, placeAndName[0], placeAndName[1]);
|
||||
locations.add(new SuggestedLocation(location, weight));
|
||||
}
|
||||
else if (type == 4) // poi
|
||||
{
|
||||
locations.add(new Location(LocationType.POI, localId, lat, lon, null, value));
|
||||
final Location location = new Location(LocationType.POI, localId, lat, lon, null, value);
|
||||
locations.add(new SuggestedLocation(location, weight));
|
||||
}
|
||||
else if (type == 71) // strange (VBN)
|
||||
{
|
||||
|
@ -747,7 +752,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
if (!from.isIdentified())
|
||||
{
|
||||
final List<Location> locations = suggestLocations(from.name).locations;
|
||||
final List<Location> locations = suggestLocations(from.name).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO
|
||||
if (locations.size() > 1)
|
||||
|
@ -757,7 +762,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
if (via != null && !via.isIdentified())
|
||||
{
|
||||
final List<Location> locations = suggestLocations(via.name).locations;
|
||||
final List<Location> locations = suggestLocations(via.name).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO
|
||||
if (locations.size() > 1)
|
||||
|
@ -767,7 +772,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
if (!to.isIdentified())
|
||||
{
|
||||
final List<Location> locations = suggestLocations(to.name).locations;
|
||||
final List<Location> locations = suggestLocations(to.name).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO
|
||||
if (locations.size() > 1)
|
||||
|
@ -1366,7 +1371,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
if (!from.isIdentified())
|
||||
{
|
||||
final List<Location> locations = suggestLocations(from.name).locations;
|
||||
final List<Location> locations = suggestLocations(from.name).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO
|
||||
if (locations.size() > 1)
|
||||
|
@ -1376,7 +1381,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
if (via != null && !via.isIdentified())
|
||||
{
|
||||
final List<Location> locations = suggestLocations(via.name).locations;
|
||||
final List<Location> locations = suggestLocations(via.name).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO
|
||||
if (locations.size() > 1)
|
||||
|
@ -1386,7 +1391,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
|
||||
if (!to.isIdentified())
|
||||
{
|
||||
final List<Location> locations = suggestLocations(to.name).locations;
|
||||
final List<Location> locations = suggestLocations(to.name).getLocations();
|
||||
if (locations.isEmpty())
|
||||
return new QueryTripsResult(header, QueryTripsResult.Status.NO_TRIPS); // TODO
|
||||
if (locations.size() > 1)
|
||||
|
|
|
@ -49,6 +49,7 @@ import de.schildbach.pte.dto.QueryTripsResult;
|
|||
import de.schildbach.pte.dto.ResultHeader;
|
||||
import de.schildbach.pte.dto.Stop;
|
||||
import de.schildbach.pte.dto.SuggestLocationsResult;
|
||||
import de.schildbach.pte.dto.SuggestedLocation;
|
||||
import de.schildbach.pte.dto.Trip;
|
||||
import de.schildbach.pte.exception.ParserException;
|
||||
import de.schildbach.pte.util.ParserUtils;
|
||||
|
@ -198,7 +199,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
|
|||
final CharSequence page = ParserUtils.scrape(uri.toString(), null, UTF_8, null, 3);
|
||||
try
|
||||
{
|
||||
final List<Location> locations = new ArrayList<Location>();
|
||||
final List<SuggestedLocation> locations = new ArrayList<SuggestedLocation>();
|
||||
final JSONObject head = new JSONObject(page.toString());
|
||||
|
||||
int status = head.getInt("StatusCode");
|
||||
|
@ -214,7 +215,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
|
|||
|
||||
if (location.isIdentified()) // make sure the location is really identified
|
||||
// some addresses may not contain coordinates, we ignore them
|
||||
locations.add(location);
|
||||
locations.add(new SuggestedLocation(location));
|
||||
}
|
||||
|
||||
return new SuggestLocationsResult(HEADER, locations);
|
||||
|
@ -267,7 +268,7 @@ public abstract class AbstractTsiProvider extends AbstractNetworkProvider
|
|||
if (location.isIdentified())
|
||||
return Collections.singletonList(location);
|
||||
|
||||
final List<Location> locations = suggestLocations(location.uniqueShortName()).locations;
|
||||
final List<Location> locations = suggestLocations(location.uniqueShortName()).getLocations();
|
||||
if (locations == null)
|
||||
return new ArrayList<Location>(0);
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
package de.schildbach.pte.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -32,20 +34,20 @@ public final class SuggestLocationsResult implements Serializable
|
|||
|
||||
public final ResultHeader header;
|
||||
public final Status status;
|
||||
public final List<Location> locations;
|
||||
private final List<SuggestedLocation> suggestedLocations;
|
||||
|
||||
public SuggestLocationsResult(final ResultHeader header, final List<Location> locations)
|
||||
public SuggestLocationsResult(final ResultHeader header, final List<SuggestedLocation> suggestedLocations)
|
||||
{
|
||||
this.header = header;
|
||||
this.status = Status.OK;
|
||||
this.locations = locations;
|
||||
this.suggestedLocations = suggestedLocations;
|
||||
}
|
||||
|
||||
public SuggestLocationsResult(final ResultHeader header, final Status status)
|
||||
{
|
||||
this.header = header;
|
||||
this.status = status;
|
||||
this.locations = null;
|
||||
this.suggestedLocations = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,8 +55,19 @@ public final class SuggestLocationsResult implements Serializable
|
|||
{
|
||||
final StringBuilder builder = new StringBuilder(getClass().getName());
|
||||
builder.append("[").append(this.status);
|
||||
builder.append(" ").append(locations);
|
||||
builder.append(" ").append(suggestedLocations);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public List<Location> getLocations()
|
||||
{
|
||||
Collections.sort(suggestedLocations);
|
||||
|
||||
final List<Location> locations = new ArrayList<Location>(suggestedLocations.size());
|
||||
for (final SuggestedLocation location : suggestedLocations)
|
||||
locations.add(location.location);
|
||||
|
||||
return locations;
|
||||
}
|
||||
}
|
||||
|
|
79
enabler/src/de/schildbach/pte/dto/SuggestedLocation.java
Normal file
79
enabler/src/de/schildbach/pte/dto/SuggestedLocation.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright 2013-2014 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
*/
|
||||
public final class SuggestedLocation implements Serializable, Comparable<SuggestedLocation>
|
||||
{
|
||||
public final Location location;
|
||||
public final int priority;
|
||||
|
||||
public SuggestedLocation(final Location location, final int priority)
|
||||
{
|
||||
this.location = location;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public SuggestedLocation(final Location location)
|
||||
{
|
||||
this(location, 0);
|
||||
}
|
||||
|
||||
public int compareTo(final SuggestedLocation other)
|
||||
{
|
||||
// prefer quality
|
||||
if (this.priority > other.priority)
|
||||
return -1;
|
||||
else if (this.priority < other.priority)
|
||||
return 1;
|
||||
|
||||
// prefer stations
|
||||
final int compareLocationType = this.location.type.compareTo(other.location.type);
|
||||
if (compareLocationType != 0)
|
||||
return compareLocationType;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o)
|
||||
{
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof SuggestedLocation))
|
||||
return false;
|
||||
final SuggestedLocation other = (SuggestedLocation) o;
|
||||
return location.equals(other.location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return location.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return priority + ":" + location;
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ package de.schildbach.pte.live;
|
|||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import de.schildbach.pte.NetworkProvider;
|
||||
import de.schildbach.pte.NetworkProvider.Accessibility;
|
||||
|
@ -61,8 +62,9 @@ public abstract class AbstractProviderLiveTest
|
|||
|
||||
protected final void print(final SuggestLocationsResult result)
|
||||
{
|
||||
System.out.print(result.locations.size() + " ");
|
||||
for (final Location location : result.locations)
|
||||
final List<Location> locations = result.getLocations();
|
||||
System.out.print(locations.size() + " ");
|
||||
for (final Location location : locations)
|
||||
System.out.print(location + " ");
|
||||
System.out.println();
|
||||
}
|
||||
|
|
|
@ -75,17 +75,17 @@ public class BahnProviderLiveTest extends AbstractProviderLiveTest
|
|||
|
||||
print(result);
|
||||
|
||||
assertEquals("Güntzelstr. (U), Berlin", result.locations.get(0).name);
|
||||
assertEquals("Güntzelstr. (U), Berlin", result.getLocations().get(0).name);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationsIncomplete() throws Exception
|
||||
{
|
||||
final SuggestLocationsResult result = provider.suggestLocations("Landungsbr");
|
||||
final SuggestLocationsResult result = provider.suggestLocations("Dammt");
|
||||
|
||||
print(result);
|
||||
|
||||
assertEquals("Hamburg Landungsbrücken", result.locations.get(0).name);
|
||||
assertEquals("Hamburg Dammtor", result.getLocations().get(0).name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -101,13 +101,13 @@ public class BayernProviderLiveTest extends AbstractProviderLiveTest
|
|||
public void suggestLocationsLocal() throws Exception
|
||||
{
|
||||
final SuggestLocationsResult regensburgResult = provider.suggestLocations("Regensburg");
|
||||
assertEquals("80001083", regensburgResult.locations.iterator().next().id);
|
||||
assertEquals("80001083", regensburgResult.getLocations().iterator().next().id);
|
||||
|
||||
final SuggestLocationsResult munichResult = provider.suggestLocations("München");
|
||||
assertEquals("80000689", munichResult.locations.iterator().next().id);
|
||||
assertEquals("80000689", munichResult.getLocations().iterator().next().id);
|
||||
|
||||
final SuggestLocationsResult nurembergResult = provider.suggestLocations("Nürnberg");
|
||||
assertEquals("80001020", nurembergResult.locations.iterator().next().id);
|
||||
assertEquals("80001020", nurembergResult.getLocations().iterator().next().id);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -92,7 +92,7 @@ public class BsvagProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult braunschweigResult = provider.suggestLocations("Braunschweig Rhönweg");
|
||||
print(braunschweigResult);
|
||||
assertThat(braunschweigResult.locations, hasItem(new Location(LocationType.STATION, "26000351")));
|
||||
assertThat(braunschweigResult.getLocations(), hasItem(new Location(LocationType.STATION, "26000351")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -97,7 +97,7 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest
|
|||
|
||||
print(result);
|
||||
|
||||
Assert.assertEquals("Güntzelstr. (U)", result.locations.get(0).name);
|
||||
Assert.assertEquals("Güntzelstr. (U)", result.getLocations().get(0).name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -107,7 +107,7 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest
|
|||
|
||||
print(result);
|
||||
|
||||
Assert.assertEquals("Sophienstr. 24", result.locations.get(0).name);
|
||||
Assert.assertEquals("Sophienstr. 24", result.getLocations().get(0).name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -92,19 +92,19 @@ public class MvgProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult luedenscheidResult = provider.suggestLocations("Lüdenscheid Freibad");
|
||||
print(luedenscheidResult);
|
||||
assertThat(luedenscheidResult.locations, hasItem(new Location(LocationType.STATION, "24200153")));
|
||||
assertThat(luedenscheidResult.getLocations(), hasItem(new Location(LocationType.STATION, "24200153")));
|
||||
|
||||
final SuggestLocationsResult iserlohnResult = provider.suggestLocations("Iserlohn Rathaus");
|
||||
print(iserlohnResult);
|
||||
assertThat(iserlohnResult.locations, hasItem(new Location(LocationType.STATION, "24200764")));
|
||||
assertThat(iserlohnResult.getLocations(), hasItem(new Location(LocationType.STATION, "24200764")));
|
||||
|
||||
final SuggestLocationsResult plettenbergResult = provider.suggestLocations("Plettenberg Friedhof");
|
||||
print(plettenbergResult);
|
||||
assertThat(plettenbergResult.locations, hasItem(new Location(LocationType.STATION, "24202864")));
|
||||
assertThat(plettenbergResult.getLocations(), hasItem(new Location(LocationType.STATION, "24202864")));
|
||||
|
||||
final SuggestLocationsResult mendenResult = provider.suggestLocations("Menden Am Gillfeld");
|
||||
print(mendenResult);
|
||||
assertThat(mendenResult.locations, hasItem(new Location(LocationType.STATION, "24202193")));
|
||||
assertThat(mendenResult.getLocations(), hasItem(new Location(LocationType.STATION, "24202193")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -99,16 +99,16 @@ public class MvvProviderLiveTest extends AbstractProviderLiveTest
|
|||
public void suggestLocationsLocal() throws Exception
|
||||
{
|
||||
final SuggestLocationsResult fraunhoferStrResult = provider.suggestLocations("fraunhofer");
|
||||
assertThat(fraunhoferStrResult.locations, hasItem(new Location(LocationType.STATION, "1000150")));
|
||||
assertThat(fraunhoferStrResult.getLocations(), hasItem(new Location(LocationType.STATION, "1000150")));
|
||||
|
||||
final SuggestLocationsResult hirschgartenResult = provider.suggestLocations("Hirschgarten");
|
||||
assertEquals("München", hirschgartenResult.locations.get(0).place);
|
||||
assertEquals("München", hirschgartenResult.getLocations().get(0).place);
|
||||
|
||||
final SuggestLocationsResult ostbahnhofResult = provider.suggestLocations("Ostbahnhof");
|
||||
assertEquals("München", ostbahnhofResult.locations.get(0).place);
|
||||
assertEquals("München", ostbahnhofResult.getLocations().get(0).place);
|
||||
|
||||
final SuggestLocationsResult marienplatzResult = provider.suggestLocations("Marienplatz");
|
||||
assertEquals("München", marienplatzResult.locations.get(0).place);
|
||||
assertEquals("München", marienplatzResult.getLocations().get(0).place);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -92,15 +92,15 @@ public class NvbwProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult freiburgResult = provider.suggestLocations("Freiburg Hauptbahnhof");
|
||||
print(freiburgResult);
|
||||
assertThat(freiburgResult.locations, hasItem(new Location(LocationType.STATION, "6906508")));
|
||||
assertThat(freiburgResult.getLocations(), hasItem(new Location(LocationType.STATION, "6906508")));
|
||||
|
||||
final SuggestLocationsResult baselResult = provider.suggestLocations("Basel");
|
||||
print(baselResult);
|
||||
assertThat(baselResult.locations, hasItem(new Location(LocationType.STATION, "51000007")));
|
||||
assertThat(baselResult.getLocations(), hasItem(new Location(LocationType.STATION, "51000007")));
|
||||
|
||||
final SuggestLocationsResult constanceResult = provider.suggestLocations("Konstanz");
|
||||
print(constanceResult);
|
||||
assertThat(constanceResult.locations, hasItem(new Location(LocationType.STATION, "8706554")));
|
||||
assertThat(constanceResult.getLocations(), hasItem(new Location(LocationType.STATION, "8706554")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -87,7 +87,7 @@ public class OebbProviderLiveTest extends AbstractProviderLiveTest
|
|||
final SuggestLocationsResult result = provider.suggestLocations("Wien");
|
||||
|
||||
print(result);
|
||||
assertTrue(result.locations.size() > 0);
|
||||
assertTrue(result.getLocations().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -96,7 +96,7 @@ public class RtProviderLiveTest extends AbstractProviderLiveTest
|
|||
public void suggestLocationsEncoding() throws Exception
|
||||
{
|
||||
final SuggestLocationsResult result = provider.suggestLocations("Dorfstrasse 1, Schäftland");
|
||||
assertEquals("Schöftland, Dorfstrasse", result.locations.get(0).name);
|
||||
assertEquals("Schöftland, Dorfstrasse", result.getLocations().get(0).name);
|
||||
print(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,23 +92,23 @@ public class StvProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult grazResult = provider.suggestLocations("Graz Brauhaus");
|
||||
print(grazResult);
|
||||
assertThat(grazResult.locations, hasItem(new Location(LocationType.STATION, "63203044")));
|
||||
assertThat(grazResult.getLocations(), hasItem(new Location(LocationType.STATION, "63203044")));
|
||||
|
||||
final SuggestLocationsResult leobenResult = provider.suggestLocations("Leoben Blockhäuser");
|
||||
print(leobenResult);
|
||||
assertThat(leobenResult.locations, hasItem(new Location(LocationType.STATION, "63206224")));
|
||||
assertThat(leobenResult.getLocations(), hasItem(new Location(LocationType.STATION, "63206224")));
|
||||
|
||||
final SuggestLocationsResult bruckResult = provider.suggestLocations("Bruck Hauptplatz");
|
||||
print(bruckResult);
|
||||
assertThat(bruckResult.locations, hasItem(new Location(LocationType.STATION, "63202063")));
|
||||
assertThat(bruckResult.getLocations(), hasItem(new Location(LocationType.STATION, "63202063")));
|
||||
|
||||
final SuggestLocationsResult kindbergResult = provider.suggestLocations("Kindberg Friedhof");
|
||||
print(kindbergResult);
|
||||
assertThat(kindbergResult.locations, hasItem(new Location(LocationType.STATION, "63208877")));
|
||||
assertThat(kindbergResult.getLocations(), hasItem(new Location(LocationType.STATION, "63208877")));
|
||||
|
||||
final SuggestLocationsResult mariborResult = provider.suggestLocations("Maribor Dravograjska Sokolska");
|
||||
print(mariborResult);
|
||||
assertThat(mariborResult.locations, hasItem(new Location(LocationType.STATION, "63300136")));
|
||||
assertThat(mariborResult.getLocations(), hasItem(new Location(LocationType.STATION, "63300136")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -84,19 +84,19 @@ public class SvvProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult salzburgResult = provider.suggestLocations("Salzburg Süd");
|
||||
print(salzburgResult);
|
||||
assertThat(salzburgResult.locations, hasItem(new Location(LocationType.STATION, "60650458")));
|
||||
assertThat(salzburgResult.getLocations(), hasItem(new Location(LocationType.STATION, "60650458")));
|
||||
|
||||
final SuggestLocationsResult strasswalchenResult = provider.suggestLocations("Straßwalchen West");
|
||||
print(strasswalchenResult);
|
||||
assertThat(strasswalchenResult.locations, hasItem(new Location(LocationType.STATION, "60656483")));
|
||||
assertThat(strasswalchenResult.getLocations(), hasItem(new Location(LocationType.STATION, "60656483")));
|
||||
|
||||
final SuggestLocationsResult schwarzachResult = provider.suggestLocations("Schwarzach Abtsdorf");
|
||||
print(schwarzachResult);
|
||||
assertThat(schwarzachResult.locations, hasItem(new Location(LocationType.STATION, "60656614")));
|
||||
assertThat(schwarzachResult.getLocations(), hasItem(new Location(LocationType.STATION, "60656614")));
|
||||
|
||||
final SuggestLocationsResult trimmelkamResult = provider.suggestLocations("Trimmelkam");
|
||||
print(trimmelkamResult);
|
||||
assertThat(trimmelkamResult.locations, hasItem(new Location(LocationType.STATION, "60640776")));
|
||||
assertThat(trimmelkamResult.getLocations(), hasItem(new Location(LocationType.STATION, "60640776")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -84,7 +84,7 @@ public class VagfrProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult freiburgResult = provider.suggestLocations("Betzenhauser Torplatz");
|
||||
print(freiburgResult);
|
||||
assertThat(freiburgResult.locations, hasItem(new Location(LocationType.STATION, "6930503")));
|
||||
assertThat(freiburgResult.getLocations(), hasItem(new Location(LocationType.STATION, "6930503")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -93,7 +93,7 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest
|
|||
|
||||
print(result);
|
||||
|
||||
Assert.assertEquals("Güntzelstr. (U)", result.locations.get(0).name);
|
||||
Assert.assertEquals("Güntzelstr. (U)", result.getLocations().get(0).name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -103,7 +103,7 @@ public class VbbProviderLiveTest extends AbstractProviderLiveTest
|
|||
|
||||
print(result);
|
||||
|
||||
Assert.assertEquals("Sophienstr. 24", result.locations.get(0).name);
|
||||
Assert.assertEquals("Sophienstr. 24", result.getLocations().get(0).name);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -91,7 +91,7 @@ public class VbnProviderLiveTest extends AbstractProviderLiveTest
|
|||
|
||||
print(result);
|
||||
|
||||
assertEquals("Göttingen", result.locations.get(0).place);
|
||||
assertEquals("Göttingen", result.getLocations().get(0).place);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -92,11 +92,11 @@ public class VorProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult huetteldorfResult = provider.suggestLocations("Hütteldorf");
|
||||
print(huetteldorfResult);
|
||||
assertThat(huetteldorfResult.locations, hasItem(new Location(LocationType.STATION, "60200560")));
|
||||
assertThat(huetteldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "60200560")));
|
||||
|
||||
final SuggestLocationsResult wienerNeustadtResult = provider.suggestLocations("Wiener Neustadt Nord");
|
||||
print(wienerNeustadtResult);
|
||||
assertThat(wienerNeustadtResult.locations, hasItem(new Location(LocationType.STATION, "60205223")));
|
||||
assertThat(wienerNeustadtResult.getLocations(), hasItem(new Location(LocationType.STATION, "60205223")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -116,23 +116,23 @@ public class VrrProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult cologneResult = provider.suggestLocations("Köln Ebertplatz");
|
||||
print(cologneResult);
|
||||
assertThat(cologneResult.locations, hasItem(new Location(LocationType.STATION, "22000035")));
|
||||
assertThat(cologneResult.getLocations(), hasItem(new Location(LocationType.STATION, "22000035")));
|
||||
|
||||
final SuggestLocationsResult dortmundResult = provider.suggestLocations("Dortmund Zugstraße");
|
||||
print(dortmundResult);
|
||||
assertThat(dortmundResult.locations, hasItem(new Location(LocationType.STATION, "20000524")));
|
||||
assertThat(dortmundResult.getLocations(), hasItem(new Location(LocationType.STATION, "20000524")));
|
||||
|
||||
final SuggestLocationsResult duesseldorfResult = provider.suggestLocations("Düsseldorf Sternstraße");
|
||||
print(duesseldorfResult);
|
||||
assertThat(duesseldorfResult.locations, hasItem(new Location(LocationType.STATION, "20018017")));
|
||||
assertThat(duesseldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "20018017")));
|
||||
|
||||
final SuggestLocationsResult muensterResult = provider.suggestLocations("Münster Vennheideweg");
|
||||
print(muensterResult);
|
||||
assertThat(muensterResult.locations, hasItem(new Location(LocationType.STATION, "24047291")));
|
||||
assertThat(muensterResult.getLocations(), hasItem(new Location(LocationType.STATION, "24047291")));
|
||||
|
||||
final SuggestLocationsResult aachenResult = provider.suggestLocations("Aachen Elisenbrunnen");
|
||||
print(aachenResult);
|
||||
assertThat(aachenResult.locations, hasItem(new Location(LocationType.STATION, "21001029")));
|
||||
assertThat(aachenResult.getLocations(), hasItem(new Location(LocationType.STATION, "21001029")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -92,7 +92,7 @@ public class VvoProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult dresdenResult = provider.suggestLocations("Dresden Postplatz");
|
||||
print(dresdenResult);
|
||||
assertThat(dresdenResult.locations, hasItem(new Location(LocationType.STATION, "33000037")));
|
||||
assertThat(dresdenResult.getLocations(), hasItem(new Location(LocationType.STATION, "33000037")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -92,11 +92,11 @@ public class WienProviderLiveTest extends AbstractProviderLiveTest
|
|||
{
|
||||
final SuggestLocationsResult huetteldorfResult = provider.suggestLocations("Wien Hütteldorf");
|
||||
print(huetteldorfResult);
|
||||
assertThat(huetteldorfResult.locations, hasItem(new Location(LocationType.STATION, "60200560")));
|
||||
assertThat(huetteldorfResult.getLocations(), hasItem(new Location(LocationType.STATION, "60200560")));
|
||||
|
||||
final SuggestLocationsResult wienerNeustadtResult = provider.suggestLocations("Wiener Neustadt Nord");
|
||||
print(wienerNeustadtResult);
|
||||
assertThat(wienerNeustadtResult.locations, hasItem(new Location(LocationType.STATION, "60205223")));
|
||||
assertThat(wienerNeustadtResult.getLocations(), hasItem(new Location(LocationType.STATION, "60205223")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue