Negentwee: Use full trip fares instead of per leg.

This commit is contained in:
full-duplex 2020-01-02 20:51:13 +01:00 committed by Andreas Schildbach
parent f19004c31a
commit 82c6761097

View file

@ -485,15 +485,17 @@ public class NegentweeProvider extends AbstractNetworkProvider {
// Get journey fares // Get journey fares
JSONObject fareInfo = trip.getJSONObject("fareInfo"); JSONObject fareInfo = trip.getJSONObject("fareInfo");
JSONArray fareLegs = fareInfo.getJSONArray("legs");
Fare[] foundFares = new Fare[fareLegs.length()]; List<Fare> tripFares = null;
for (int i = 0; i < fareLegs.length(); i++) { if (fareInfo.getBoolean("complete")) {
foundFares[i] = fareFromJSONObject(fareLegs.getJSONObject(i)); tripFares = Arrays.asList(
new Fare("Full-price", Fare.Type.ADULT, Currency.getInstance("EUR"),
fareInfo.getInt("fullPriceCents") / 100, null, null),
new Fare("Reduced-price", Fare.Type.ADULT, Currency.getInstance("EUR"),
fareInfo.getInt("reducedPriceCents") / 100, null, null));
} }
return new Trip(trip.getString("id"), from, to, foundLegs, Arrays.asList(foundFares), null, return new Trip(trip.getString("id"), from, to, foundLegs, tripFares, null, trip.getInt("numberOfChanges"));
trip.getInt("numberOfChanges"));
} }
private Stop stopFromJSONObject(JSONObject stop) throws JSONException { private Stop stopFromJSONObject(JSONObject stop) throws JSONException {