mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-13 00:08:49 +00:00
Optionally disable sort by weight in JSON getstops (Hafas).
This commit is contained in:
parent
c11a23ba08
commit
8adf98b98e
4 changed files with 23 additions and 2 deletions
|
@ -89,6 +89,7 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
private String accessId;
|
||||
private String clientType;
|
||||
private Charset jsonGetStopsEncoding;
|
||||
private boolean jsonGetStopsUseWeight = true;
|
||||
private Charset jsonNearbyStationsEncoding;
|
||||
private boolean dominantPlanStopTime = false;
|
||||
private boolean useIso8601 = false;
|
||||
|
@ -183,6 +184,11 @@ public abstract class AbstractHafasProvider extends AbstractNetworkProvider
|
|||
this.jsonGetStopsEncoding = jsonGetStopsEncoding;
|
||||
}
|
||||
|
||||
protected void setJsonGetStopsUseWeight(final boolean jsonGetStopsUseWeight)
|
||||
{
|
||||
this.jsonGetStopsUseWeight = jsonGetStopsUseWeight;
|
||||
}
|
||||
|
||||
protected void setJsonNearbyStationsEncoding(final Charset jsonNearbyStationsEncoding)
|
||||
{
|
||||
this.jsonNearbyStationsEncoding = jsonNearbyStationsEncoding;
|
||||
|
@ -372,7 +378,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");
|
||||
final int weight = jsonGetStopsUseWeight ? suggestion.getInt("weight") : -i;
|
||||
String localId = null;
|
||||
final Matcher m = P_AJAX_GET_STOPS_ID.matcher(suggestion.getString("id"));
|
||||
if (m.matches())
|
||||
|
|
|
@ -63,6 +63,7 @@ public final class BvgProvider extends AbstractHafasProvider
|
|||
super(API_BASE + "stboard.bin/dn", API_BASE + "ajax-getstop.bin/dny", API_BASE + "query.bin/dn", 8, UTF_8);
|
||||
|
||||
setStyles(STYLES);
|
||||
setJsonGetStopsUseWeight(false);
|
||||
|
||||
this.additionalQueryParameter = additionalQueryParameter;
|
||||
}
|
||||
|
|
|
@ -155,7 +155,11 @@ public final class Location implements Serializable
|
|||
return this.id.equals(other.id);
|
||||
if (this.lat != 0 && this.lon != 0)
|
||||
return this.lat == other.lat && this.lon == other.lon;
|
||||
if (!nullSafeEquals(this.name, other.name)) // only discriminate by name if no ids are given
|
||||
|
||||
// only discriminate by name/place if no ids are given
|
||||
if (!nullSafeEquals(this.name, other.name))
|
||||
return false;
|
||||
if (!nullSafeEquals(this.place, other.place))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -100,6 +100,16 @@ public class BvgProviderLiveTest extends AbstractProviderLiveTest
|
|||
Assert.assertEquals("Güntzelstr. (U)", result.getLocations().get(0).name);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationsLocality() throws Exception
|
||||
{
|
||||
final SuggestLocationsResult result = provider.suggestLocations("seeling");
|
||||
|
||||
print(result);
|
||||
|
||||
Assert.assertEquals(new Location(LocationType.STATION, null, "Berlin", "Seelingstr."), result.getLocations().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suggestLocationsAddress() throws Exception
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue