Skip to content

Commit

Permalink
Return all buckets of a tiled geoaggregate request
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedHamouGisaia committed Feb 5, 2020
1 parent acb7276 commit 97abe66
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,22 +358,16 @@ private FeatureCollection toGeoJson(AggregationResponse aggregationResponse, Agg
FeatureCollection fc = new FeatureCollection();
ObjectMapper mapper = new ObjectMapper();
List<AggregationResponse> elements = aggregationResponse.elements;
if (geohash.isPresent() && precision.isPresent()) {
if (geohash.get().length() < precision.get()) {
elements = aggregationResponse.elements.stream()
.filter(element -> element.keyAsString.toString().startsWith(geohash.get())).collect(Collectors.toList());
} else {
elements = aggregationResponse.elements.stream()
.filter(element -> element.keyAsString.toString().equals(geohash.get().substring(0, precision.get()))).collect(Collectors.toList());
}
}
if (elements != null && elements.size() > 0) {
for (AggregationResponse element : elements) {
Feature feature = new Feature();
Map<String, Object> properties = new HashMap<>();
properties.put("count", element.count);
if (mainAggregationType == AggregationTypeEnum.geohash) {
properties.put("geohash", element.keyAsString);
if (geohash.isPresent()) {
properties.put("parent_geohash", geohash.get());
}
} else {
properties.put("key", element.keyAsString);
}
Expand Down

0 comments on commit 97abe66

Please sign in to comment.