Skip to content

Commit

Permalink
Decreasing min size for small LineString aggregation.
Browse files Browse the repository at this point in the history
Fixes output type for LineString aggregation
  • Loading branch information
Clément Tourrière committed Mar 20, 2015
1 parent 5f93587 commit 4731b9d
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit 4731b9d

Please sign in to comment.