Skip to content

Commit

Permalink
fix timestamp format in ratio/groupBy/boundary endpoint, closes #318
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrasd committed Nov 23, 2023
1 parent 88b7167 commit 560909a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ Changelog

## 1.11.0-SNAPSHOT (current master)

### Bug Fixes
* Fix inconsistent timestamp format in `/elements/(aggregation)/ratio/groupBy/boundary` request responses ([#318])

[#318]: https://github.com/GIScience/ohsome-api/issues/318


## 1.10.1

* Fix performance degradation in previous release (version 1.10.0) which made data extractions very slow for medium to large query areas ([oshdb#516])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,9 +923,10 @@ public static <P extends Geometry & Polygonal> Response aggregateBasicFiltersRat
resultValues2[matchesBothCount] = resultValues2[matchesBothCount]
+ Double.parseDouble(df.format(innerEntry.getValue().doubleValue()));
if (!timeArrayFilled) {
String time = innerEntry.getKey().getFirstIndex().toString();
String time = TimestampFormatter.getInstance().isoDateTime(
innerEntry.getKey().getFirstIndex());
if (matchesBothCount == 0 || !timeArray[timeArrayCount - 1].equals(time)) {
timeArray[timeArrayCount] = innerEntry.getKey().getFirstIndex().toString();
timeArray[timeArrayCount] = time;
timeArrayCount++;
}
}
Expand Down Expand Up @@ -1083,9 +1084,10 @@ public static <P extends Geometry & Polygonal> Response aggregateRatioGroupByBou
resultValues2[matchesBothCount] = resultValues2[matchesBothCount]
+ Double.parseDouble(df.format(innerEntry.getValue().doubleValue()));
if (!timeArrayFilled) {
String time = innerEntry.getKey().getFirstIndex().toString();
String time = TimestampFormatter.getInstance().isoDateTime(
innerEntry.getKey().getFirstIndex());
if (matchesBothCount == 0 || !timeArray[timeArrayCount - 1].equals(time)) {
timeArray[timeArrayCount] = innerEntry.getKey().getFirstIndex().toString();
timeArray[timeArrayCount] = time;
timeArrayCount++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ public void elementsAreaRatioGroupByBoundaryTest() {
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("2017-01-01T00:00:00Z", response.getBody().get("groupByBoundaryResult").get(1)
.get("ratioResult").get(0).get("timestamp").asText());
}

@Test
Expand Down

0 comments on commit 560909a

Please sign in to comment.