From 4731b9d6ee39ee330e129a4157d1a3f3c921656a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Tourri=C3=A8re?= Date: Fri, 20 Mar 2015 17:31:51 +0100 Subject: [PATCH] Decreasing min size for small LineString aggregation. Fixes output type for LineString aggregation --- .../rest/action/geo/RestGeoAction.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/opendatasoft/elasticsearch/rest/action/geo/RestGeoAction.java b/src/main/java/com/opendatasoft/elasticsearch/rest/action/geo/RestGeoAction.java index 11feff7..ff1e8c0 100644 --- a/src/main/java/com/opendatasoft/elasticsearch/rest/action/geo/RestGeoAction.java +++ b/src/main/java/com/opendatasoft/elasticsearch/rest/action/geo/RestGeoAction.java @@ -33,8 +33,14 @@ import org.elasticsearch.index.query.*; import org.elasticsearch.rest.*; import org.elasticsearch.rest.action.search.RestSearchAction; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.SearchHitField; import org.elasticsearch.search.aggregations.bucket.SingleBucketAggregation; import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder; +import org.elasticsearch.search.aggregations.metrics.tophits.TopHits; +import org.elasticsearch.search.aggregations.metrics.tophits.TopHitsBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.geotools.geojson.geom.GeometryJSON; import org.geotools.geometry.jts.JTS; @@ -169,6 +175,9 @@ protected void handleRequest(final RestRequest request, final RestChannel channe +// GeoShapeBuilder samallLineStringFirstHit = new GeoShapeBuilder("small_line_string_top_hit").field(geoFieldWKB).zoom(zoom).simplifyShape(true).outputFormat(outputFormat).size(1); +// GeoHashClusteringBuilder smallLineStringGrid = new GeoHashClusteringBuilder("small_line_string_agg").field(geoFieldCentroid).zoom(zoom).distance(1).subAggregation(samallLineStringFirstHit); + GeoHashClusteringBuilder smallLineStringGrid = new GeoHashClusteringBuilder("small_line_string_agg").field(geoFieldCentroid).zoom(zoom).distance(1); FilterAggregationBuilder smallLineStringFilter = new FilterAggregationBuilder("small_line_string_filter"). filter(new RangeFilterBuilder(geoFieldArea).lt(lineStringLimit)).subAggregation(smallLineStringGrid); @@ -354,7 +363,7 @@ public void onResponse(SearchResponse response) { Geometry jtsPoint = geometryFactory.createPoint(new Coordinate(pointHash.lon(), pointHash.lat())); double bufferSize = GeoPluginUtils.getShapeLimit(zoom, jtsPoint.getCoordinate().y); - Geometry geom = jtsPoint.buffer(bufferSize, 4, BufferParameters.CAP_SQUARE); + Geometry geom = jtsPoint.buffer(bufferSize / 3, 4, BufferParameters.CAP_SQUARE); if (mustProject) { geom = JTS.transform(geom, transform); @@ -368,7 +377,7 @@ public void onResponse(SearchResponse response) { builder.field("shape", geoString); // builder.field("digest", bucket.getHash()); - builder.field("type", "Polygon"); + builder.field("type", "LineString"); builder.field("doc_count", bucketGrid.getDocCount()); builder.field("cluster_count", bucketGrid.getDocCount()); builder.field("grid", bucketGrid.getKey());