Skip to content

Commit

Permalink
Merge pull request #600 from gisaia/feature/not_filtering_geoaggregat…
Browse files Browse the repository at this point in the history
…e_buckets

Return all buckets of a tiled geoaggregate request
  • Loading branch information
MohamedHamouGisaia authored Feb 5, 2020
2 parents acb7276 + fee932a commit 3e66d8d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 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
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ public void testGeohashTile() throws Exception {

}

@Test
public void testNoMatchingGeohashTile() throws Exception {
handleNotMatchingGeohashTile(geohashTileGet("geohash:geo_params.centroid:interval-3", "ar"));
}


//----------------------------------------------------------------
//---------------------- SPECIFIC BEHAVIORS ----------------------
Expand All @@ -75,8 +72,6 @@ public void testNoMatchingGeohashTile() throws Exception {

protected abstract void handleGeohashTileDisjointFromPwithin(ValidatableResponse then) throws Exception;

protected abstract void handleNotMatchingGeohashTile(ValidatableResponse then) throws Exception;

private ValidatableResponse geohashTileGet(Object paramValue, String geohash) {
return given().param("agg", paramValue)
.when().get(getGeohashUrlPath("geodata", geohash))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,6 @@ protected void handleGeohashTileDisjointFromPwithin(ValidatableResponse then) th
.body("features", equalTo(null));
}

@Override
protected void handleNotMatchingGeohashTile(ValidatableResponse then) {
then.statusCode(200)
.body("features", equalTo(null));
}

//----------------------------------------------------------------
//----------------------- FORM PART ------------------------------
//----------------------------------------------------------------
Expand Down

0 comments on commit 3e66d8d

Please sign in to comment.