Skip to content

Commit

Permalink
fix: include transfers and fare properties only in PT responses (GISc…
Browse files Browse the repository at this point in the history
…ience#1586)

Co-authored-by: Julian Psotta <[email protected]>
  • Loading branch information
2 people authored and selimguvenc committed Apr 25, 2024
1 parent 71f31fc commit 77838dd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ RELEASING:
- YML configuration ([#1506](https://github.com/GIScience/openrouteservice/pull/1506))

### Changed
- include transfers and fare properties only in PT responses ([#1586](https://github.com/GIScience/openrouteservice/pull/1586))
- suppress empty legs property in routing JSON responses ([#1584](https://github.com/GIScience/openrouteservice/pull/1584))
- url_check.sh to support custom sleep and reporting intervals ([#1468](https://github.com/GIScience/openrouteservice/pull/1468))
- autogenerated API specification from Swagger 2.0 to OpenAPI 3.0 ([#1487](https://github.com/GIScience/openrouteservice/pull/1487))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import io.swagger.v3.oas.annotations.media.Schema;
import org.heigit.ors.routing.RouteResult;

import java.util.Objects;


@Schema(description = "Contains total sums of duration, route distance and actual distance of the route.")
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
Expand Down Expand Up @@ -54,28 +56,22 @@ public class JSONSummary {

@JsonProperty(value = "transfers")
@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
protected int transfers;
@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotMinusOne.class)
protected int transfers = -1;

public int getTransfers() {
return transfers;
}
@JsonProperty(value = "fare")
@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = NotMinusOne.class)
protected int fare = -1;

public void setTransfers(int transfers) {
this.transfers = transfers;
}

public int getFare() {
return fare;
}

public void setFare(int fare) {
this.fare = fare;
}

@JsonProperty(value = "fare")
@JsonFormat(shape = JsonFormat.Shape.NUMBER_INT)
protected int fare;

public JSONSummary(Double distance, Double duration) {
this.distance = distance;
this.duration = duration;
Expand Down Expand Up @@ -115,4 +111,11 @@ public Double getDescent() {
public Double getAscent() {
return ascent;
}

public static class NotMinusOne {
@Override
public boolean equals(Object other) {
return Objects.equals(other, -1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ void testGeoJsonExport() {
.body("features[0].containsKey('properties')", is(true))
.body("features[0].properties.containsKey('summary')", is(true))
.body("features[0].containsKey('bbox')", is(true))
.body("features[0].properties.containsKey('transfers')", is(false))
.body("features[0].properties.containsKey('fare')", is(false))
.body("features[0].properties.containsKey('way_points')", is(true))
.body("features[0].properties.containsKey('segments')", is(true))
.body("features[0].properties.containsKey('extras')", is(true))
Expand Down Expand Up @@ -780,6 +782,8 @@ void testSummary() { // waiting for elevation & turn restrictions
.body("routes[0].containsKey('segments')", is(true))
.body("routes[0].segments.size()", is(2))
.body("routes[0].containsKey('summary')", is(true))
.body("routes[0].summary.containsKey('transfers')", is(false))
.body("routes[0].summary.containsKey('fare')", is(false))
.body("routes[0].summary.containsKey('distance')", is(true))
.body("routes[0].summary.containsKey('duration')", is(true))
.body("routes[0].summary.containsKey('ascent')", is(true))
Expand Down Expand Up @@ -3768,6 +3772,7 @@ void testPTJSON() {
.body("any { it.key == 'routes' }", is(true))
.body("routes.size()", is(3))
.body("routes[0].summary.transfers", is(2))
.body("routes[0].summary.containsKey('fare')", is(true))
.body("routes[0].legs.size()", is(6))
.body("routes[0].legs[0].containsKey('arrival')", is(true))
.body("routes[0].legs[0].containsKey('departure')", is(true))
Expand Down Expand Up @@ -3811,6 +3816,7 @@ void testPTGeoJSON() {
.body("any { it.key == 'features' }", is(true))
.body("features.size()", is(3))
.body("features[0].properties.transfers", is(2))
.body("features[0].properties.containsKey('fare')", is(true))
.body("features[0].properties.legs.size()", is(6))
.body("features[0].properties.legs[0].containsKey('arrival')", is(true))
.body("features[0].properties.legs[0].containsKey('departure')", is(true))
Expand Down

0 comments on commit 77838dd

Please sign in to comment.