diff --git a/docs/endpoints.rst b/docs/endpoints.rst index 8a6de4e3..b48bfc5e 100644 --- a/docs/endpoints.rst +++ b/docs/endpoints.rst @@ -414,23 +414,23 @@ How often information about the roof of buildings is present? }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : "remainder", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 23225.0 - } ], - "groupByObject" : "remainder" + } ] }, { + "groupByObject" : "building:roof", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1418.0 - } ], - "groupByObject" : "building:roof" + } ] }, { + "groupByObject" : "building:roof:colour", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1178.0 - } ], - "groupByObject" : "building:roof:colour" + } ] } ] } @@ -443,23 +443,23 @@ How often information about the roof of buildings is present? }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : "remainder", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 23225.0 - } ], - "groupByObject" : "remainder" + } ] }, { + "groupByObject" : "building:roof", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1418.0 - } ], - "groupByObject" : "building:roof" + } ] }, { + "groupByObject" : "building:roof:colour", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1178.0 - } ], - "groupByObject" : "building:roof:colour" + } ] } ] } @@ -472,23 +472,23 @@ How often information about the roof of buildings is present? }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : "remainder", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 23225.0 - } ], - "groupByObject" : "remainder" + } ] }, { + "groupByObject" : "building:roof", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1418.0 - } ], - "groupByObject" : "building:roof" + } ] }, { + "groupByObject" : "building:roof:colour", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1178.0 - } ], - "groupByObject" : "building:roof:colour" + } ] } ] } @@ -501,23 +501,23 @@ How often information about the roof of buildings is present? }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : "remainder", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 23225.0 - } ], - "groupByObject" : "remainder" + } ] }, { + "groupByObject" : "building:roof", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1418.0 - } ], - "groupByObject" : "building:roof" + } ] }, { + "groupByObject" : "building:roof:colour", "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1178.0 - } ], - "groupByObject" : "building:roof:colour" + } ] } ] } @@ -584,53 +584,53 @@ Compare length of different types of streets for two or more regions. }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : [ "Heidelberg", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1650245.08 - } ], - "groupByObject" : [ "Heidelberg", "remainder" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 48637.96 - } ], - "groupByObject" : [ "Heidelberg", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 29114.72 - } ], - "groupByObject" : [ "Heidelberg", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 35297.95 - } ], - "groupByObject" : [ "Heidelberg", "highway=primary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 56493.26 - } ], - "groupByObject" : [ "Plankstadt", "remainder" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 3399.22 - } ], - "groupByObject" : [ "Plankstadt", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 954.7 - } ], - "groupByObject" : [ "Plankstadt", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 0.0 - } ], - "groupByObject" : [ "Plankstadt", "highway=primary" ] + } ] } ] } @@ -643,53 +643,53 @@ Compare length of different types of streets for two or more regions. }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : [ "Heidelberg", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1650245.08 - } ], - "groupByObject" : [ "Heidelberg", "remainder" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 48637.96 - } ], - "groupByObject" : [ "Heidelberg", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 29114.72 - } ], - "groupByObject" : [ "Heidelberg", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 35297.95 - } ], - "groupByObject" : [ "Heidelberg", "highway=primary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 56493.26 - } ], - "groupByObject" : [ "Plankstadt", "remainder" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 3399.22 - } ], - "groupByObject" : [ "Plankstadt", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 954.7 - } ], - "groupByObject" : [ "Plankstadt", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 0.0 - } ], - "groupByObject" : [ "Plankstadt", "highway=primary" ] + } ] } ] } @@ -702,112 +702,112 @@ Compare length of different types of streets for two or more regions. }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : [ "Heidelberg", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1650245.08 - } ], - "groupByObject" : [ "Heidelberg", "remainder" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 48637.96 - } ], - "groupByObject" : [ "Heidelberg", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 29114.72 - } ], - "groupByObject" : [ "Heidelberg", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 35297.95 - } ], - "groupByObject" : [ "Heidelberg", "highway=primary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 56493.26 - } ], - "groupByObject" : [ "Plankstadt", "remainder" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 3399.22 - } ], - "groupByObject" : [ "Plankstadt", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 954.7 - } ], - "groupByObject" : [ "Plankstadt", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 0.0 - } ], - "groupByObject" : [ "Plankstadt", "highway=primary" ] + } ] } ] } .. code-tab:: json R - { + { "attribution" : { "url" : "https://ohsome.org/copyrights", "text" : "© OpenStreetMap contributors" }, "apiVersion" : "1.5.0", "groupByResult" : [ { + "groupByObject" : [ "Heidelberg", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 1650245.08 - } ], - "groupByObject" : [ "Heidelberg", "remainder" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 48637.96 - } ], - "groupByObject" : [ "Heidelberg", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 29114.72 - } ], - "groupByObject" : [ "Heidelberg", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Heidelberg", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 35297.95 - } ], - "groupByObject" : [ "Heidelberg", "highway=primary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "remainder" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 56493.26 - } ], - "groupByObject" : [ "Plankstadt", "remainder" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=tertiary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 3399.22 - } ], - "groupByObject" : [ "Plankstadt", "highway=tertiary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=secondary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 954.7 - } ], - "groupByObject" : [ "Plankstadt", "highway=secondary" ] + } ] }, { + "groupByObject" : [ "Plankstadt", "highway=primary" ], "result" : [ { "timestamp" : "2018-01-01T00:00:00Z", "value" : 0.0 - } ], - "groupByObject" : [ "Plankstadt", "highway=primary" ] + } ] } ] } diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ExecutionUtils.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ExecutionUtils.java index bb22cd05..db5de744 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ExecutionUtils.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ExecutionUtils.java @@ -782,8 +782,8 @@ private static ImmutablePair, List> 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(); diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByBoundaryResponse.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByBoundaryResponse.java index da80a526..02e7f337 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByBoundaryResponse.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByBoundaryResponse.java @@ -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. */ diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByResult.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByResult.java index bd84b2aa..8ea92c55 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByResult.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioGroupByResult.java @@ -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; } } diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioResponse.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioResponse.java index 3185d4c5..cbdb98cc 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioResponse.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/output/ratio/RatioResponse.java @@ -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; } diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/utils/GroupByBoundaryGeoJsonGenerator.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/utils/GroupByBoundaryGeoJsonGenerator.java index 15daa8ea..e8363bd5 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/utils/GroupByBoundaryGeoJsonGenerator.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/utils/GroupByBoundaryGeoJsonGenerator.java @@ -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()); diff --git a/src/test/java/org/heigit/ohsome/ohsomeapi/controller/GetControllerTest.java b/src/test/java/org/heigit/ohsome/ohsomeapi/controller/GetControllerTest.java index 425cc9f7..33238658 100644 --- a/src/test/java/org/heigit/ohsome/ohsomeapi/controller/GetControllerTest.java +++ b/src/test/java/org/heigit/ohsome/ohsomeapi/controller/GetControllerTest.java @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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); } @@ -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); } diff --git a/src/test/java/org/heigit/ohsome/ohsomeapi/controller/PostControllerTest.java b/src/test/java/org/heigit/ohsome/ohsomeapi/controller/PostControllerTest.java index 144fd09c..fc21aebb 100644 --- a/src/test/java/org/heigit/ohsome/ohsomeapi/controller/PostControllerTest.java +++ b/src/test/java/org/heigit/ohsome/ohsomeapi/controller/PostControllerTest.java @@ -446,7 +446,7 @@ public void elementsPerimeterRatioTest() { ResponseEntity 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); } @@ -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); } @@ -716,7 +716,7 @@ public void elementsAreaRatioTest() { ResponseEntity 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); } @@ -732,8 +732,8 @@ public void elementsAreaRatioGroupByBoundaryTest() { map.add("filter2", "type:relation and building=*"); ResponseEntity 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 @@ -850,7 +850,7 @@ public void elementsAreaRatioSimpleFeaturePolygonTest() { ResponseEntity 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); }