mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-18 00:09:55 +00:00
VRS: Avoid endless queryMoreTrips() loop by not allowing earlier or later trips if current arrival or departure query found only one trip.
This commit is contained in:
parent
154085da1d
commit
bc9679310a
1 changed files with 21 additions and 2 deletions
|
@ -79,6 +79,8 @@ public class VrsProvider extends AbstractNetworkProvider
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private static class Context implements QueryTripsContext
|
private static class Context implements QueryTripsContext
|
||||||
{
|
{
|
||||||
|
private boolean canQueryLater = true;
|
||||||
|
private boolean canQueryEarlier = true;
|
||||||
private Date lastDeparture = null;
|
private Date lastDeparture = null;
|
||||||
private Date firstArrival = null;
|
private Date firstArrival = null;
|
||||||
public Location from;
|
public Location from;
|
||||||
|
@ -92,12 +94,12 @@ public class VrsProvider extends AbstractNetworkProvider
|
||||||
|
|
||||||
public boolean canQueryLater()
|
public boolean canQueryLater()
|
||||||
{
|
{
|
||||||
return true;
|
return this.canQueryLater;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canQueryEarlier()
|
public boolean canQueryEarlier()
|
||||||
{
|
{
|
||||||
return true;
|
return this.canQueryEarlier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void departure(Date departure)
|
public void departure(Date departure)
|
||||||
|
@ -125,6 +127,16 @@ public class VrsProvider extends AbstractNetworkProvider
|
||||||
{
|
{
|
||||||
return this.firstArrival;
|
return this.firstArrival;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void disableEarlier()
|
||||||
|
{
|
||||||
|
this.canQueryEarlier = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableLater()
|
||||||
|
{
|
||||||
|
this.canQueryLater = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LocationWithPosition
|
private static class LocationWithPosition
|
||||||
|
@ -948,6 +960,13 @@ public class VrsProvider extends AbstractNetworkProvider
|
||||||
context.to = to;
|
context.to = to;
|
||||||
context.via = via;
|
context.via = via;
|
||||||
context.products = products;
|
context.products = products;
|
||||||
|
if (trips.size() == 1)
|
||||||
|
{
|
||||||
|
if (dep)
|
||||||
|
context.disableLater();
|
||||||
|
else
|
||||||
|
context.disableEarlier();
|
||||||
|
}
|
||||||
return new QueryTripsResult(header, uri.toString(), from, via, to, context, trips);
|
return new QueryTripsResult(header, uri.toString(), from, via, to, context, trips);
|
||||||
}
|
}
|
||||||
catch (final JSONException x)
|
catch (final JSONException x)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue