Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change object names in responses #119

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 89 additions & 89 deletions docs/endpoints.rst

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ private static ImmutablePair<List<String>, List<String[]>> createCsvResponseForE
columnNames.add(ratioGroupByResult.getGroupByObject() + "_value");
columnNames.add(ratioGroupByResult.getGroupByObject() + "_value2");
columnNames.add(ratioGroupByResult.getGroupByObject() + "_ratio");
for (int j = 0; j < ratioGroupByResult.getRatioResult().length; j++) {
RatioResult ratioResult = ratioGroupByResult.getRatioResult()[j];
for (int j = 0; j < ratioGroupByResult.getResult().length; j++) {
RatioResult ratioResult = ratioGroupByResult.getResult()[j];
if (i == 0) {
String[] row = new String[resultSet.length * 3 + 1];
row[0] = ratioResult.getTimestamp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ public class RatioGroupByBoundaryResponse implements Response {
private Feature[] features;
@ApiModelProperty(notes = "RatioGroupByResult array holding the respective objects "
+ "with their timestamp-value-value2-ratio values", required = true)
private RatioGroupByResult[] groupByBoundaryResult;
private RatioGroupByResult[] groupByResult;

public RatioGroupByBoundaryResponse(Attribution attribution, String apiVersion, Metadata metadata,
RatioGroupByResult[] groupByBoundaryResult) {
RatioGroupByResult[] groupByResult) {
this.attribution = attribution;
this.apiVersion = apiVersion;
this.metadata = metadata;
this.groupByBoundaryResult = groupByBoundaryResult;
this.groupByResult = groupByResult;
}

/** Static factory method returning the whole GeoJSON response. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class RatioGroupByResult extends GroupByObject {

@ApiModelProperty(notes = "RatioResult array holding timestamp, whole and part values",
required = true)
private RatioResult[] ratioResult;
private RatioResult[] result;

public RatioGroupByResult(Object groupByObject, RatioResult[] ratioResult) {
public RatioGroupByResult(Object groupByObject, RatioResult[] result) {
super(groupByObject);
this.ratioResult = ratioResult;
this.result = result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ public class RatioResponse implements Response {
@ApiModelProperty(notes = "Metadata describing the output")
private Metadata metadata;
@ApiModelProperty(notes = "ElementsResult for /ratio requests", required = true)
private RatioResult[] ratioResult;
private RatioResult[] result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ private static Feature[] generateRatioGroupByResultGeoJson(GroupByObject[] resul
int tstampCount) {
Feature[] features;
RatioGroupByResult[] groupByResults = (RatioGroupByResult[]) results;
int resultLength = groupByResults[0].getRatioResult().length;
int resultLength = groupByResults[0].getResult().length;
int featuresLength = groupByResultsLength * resultLength;
features = new Feature[featuresLength];
for (int i = 0; i < featuresLength; i++) {
RatioResult result = groupByResults[groupByResultCount].getRatioResult()[tstampCount];
RatioResult result = groupByResults[groupByResultCount].getResult()[tstampCount];
String tstamp = result.getTimestamp();
Feature feature = fillGeojsonFeature(results, groupByResultCount, tstamp);
feature.setProperty("value", result.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void getElementsCountRatioTest() {
+ "addr:housenumber=*",
JsonNode.class);
assertEquals(expectedValue,
response.getBody().get("ratioResult").get(0).get("ratio").asDouble(),
response.getBody().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand All @@ -248,10 +248,10 @@ public void getElementsCountRatioGroupByBoundaryTest() {
assertEquals(expectedValue, StreamSupport
.stream(
Spliterators.spliteratorUnknownSize(
response.getBody().get("groupByBoundaryResult").iterator(), Spliterator.ORDERED),
response.getBody().get("groupByResult").iterator(), Spliterator.ORDERED),
false)
.filter(jsonNode -> jsonNode.get("groupByObject").asText().equalsIgnoreCase("boundary1"))
.findFirst().get().get("ratioResult").get(0).get("ratio").asDouble(),
.findFirst().get().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand Down Expand Up @@ -440,7 +440,7 @@ public void getElementsLengthRatioTest() {
+ "&time=2011-12-13&&filter=type:way and highway=*&filter2=railway=*",
JsonNode.class);
assertEquals(expectedValue,
response.getBody().get("ratioResult").get(0).get("ratio").asDouble(),
response.getBody().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand All @@ -456,10 +456,10 @@ public void getElementsLengthRatioGroupByBoundaryTest() {
assertEquals(expectedValue, StreamSupport
.stream(
Spliterators.spliteratorUnknownSize(
response.getBody().get("groupByBoundaryResult").iterator(), Spliterator.ORDERED),
response.getBody().get("groupByResult").iterator(), Spliterator.ORDERED),
false)
.filter(jsonNode -> jsonNode.get("groupByObject").asText().equalsIgnoreCase("boundary1"))
.findFirst().get().get("ratioResult").get(0).get("ratio").asDouble(),
.findFirst().get().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand Down Expand Up @@ -1170,7 +1170,7 @@ public void areaRatioFilterTest() {
+ "2018-01-01&filter=building=* and type:way&filter2=building=* and type:relation",
JsonNode.class);
assertEquals(expectedValue,
response.getBody().get("ratioResult").get(0).get("ratio").asDouble(),
response.getBody().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand All @@ -1186,10 +1186,10 @@ public void ratioGroupByBoundaryFilterTest() {
assertEquals(expectedValue, StreamSupport
.stream(
Spliterators.spliteratorUnknownSize(
response.getBody().get("groupByBoundaryResult").iterator(), Spliterator.ORDERED),
response.getBody().get("groupByResult").iterator(), Spliterator.ORDERED),
false)
.filter(jsonNode -> jsonNode.get("groupByObject").asText().equalsIgnoreCase("b2"))
.findFirst().get().get("ratioResult").get(0).get("ratio").asDouble(),
.findFirst().get().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand All @@ -1202,7 +1202,7 @@ public void getElementsCountRatioEmptyFilterTest() {
+ "filter2=highway=*&time=2019-01-01",
JsonNode.class);
assertEquals(expectedValue,
response.getBody().get("ratioResult").get(0).get("ratio").asDouble(),
response.getBody().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public void elementsPerimeterRatioTest() {
ResponseEntity<JsonNode> response = restTemplate
.postForEntity(server + port + "/elements/perimeter/ratio", map, JsonNode.class);
assertEquals(expectedValue,
response.getBody().get("ratioResult").get(0).get("ratio").asDouble(),
response.getBody().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand All @@ -465,10 +465,10 @@ public void elementsPerimeterRatioGroupByBoundaryTest() {
assertEquals(expectedValue, StreamSupport
.stream(
Spliterators.spliteratorUnknownSize(
response.getBody().get("groupByBoundaryResult").iterator(), Spliterator.ORDERED),
response.getBody().get("groupByResult").iterator(), Spliterator.ORDERED),
false)
.filter(jsonNode -> jsonNode.get("groupByObject").asText().equalsIgnoreCase("Neuenheim"))
.findFirst().get().get("ratioResult").get(0).get("ratio").asDouble(),
.findFirst().get().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand Down Expand Up @@ -716,7 +716,7 @@ public void elementsAreaRatioTest() {
ResponseEntity<JsonNode> response =
restTemplate.postForEntity(server + port + "/elements/area/ratio", map, JsonNode.class);
assertEquals(expectedValue,
response.getBody().get("ratioResult").get(0).get("ratio").asDouble(),
response.getBody().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand All @@ -732,8 +732,8 @@ public void elementsAreaRatioGroupByBoundaryTest() {
map.add("filter2", "type:relation and building=*");
ResponseEntity<JsonNode> response = restTemplate.postForEntity(
server + port + "/elements/area/ratio/groupBy/boundary", map, JsonNode.class);
assertEquals(expectedValue, response.getBody().get("groupByBoundaryResult").get(1)
.get("ratioResult").get(0).get("ratio").asDouble(), expectedValue * deltaPercentage);
assertEquals(expectedValue, response.getBody().get("groupByResult").get(1)
.get("result").get(0).get("ratio").asDouble(), expectedValue * deltaPercentage);
}

@Test
Expand Down Expand Up @@ -850,7 +850,7 @@ public void elementsAreaRatioSimpleFeaturePolygonTest() {
ResponseEntity<JsonNode> response =
restTemplate.postForEntity(server + port + "/elements/area/ratio", map, JsonNode.class);
assertEquals(expectedValue,
response.getBody().get("ratioResult").get(0).get("ratio").asDouble(),
response.getBody().get("result").get(0).get("ratio").asDouble(),
expectedValue * deltaPercentage);
}

Expand Down