I have stored a route in ElasticSearch
as a Polygon. Now I have a circle (A point and a radius), I'am able to check the circle points intersects the polygon or not (Below is the code I used).
Question: How can I get the points in the route which intersects the circle ?
public Boolean isMatchingDoc(Long elasticDocId, Double latitude, Double longitude, Long radius) {
Coordinate origin = new Coordinate(latitude, longitude);
ShapeBuilder circleShapeBuilder = ShapeBuilder.newCircleBuilder().center(origin).radius(radius,
DistanceUnit.METERS);
GeoShapeQueryBuilder geoShapeQueryBuilder = QueryBuilders.geoShapeQuery("route", circleShapeBuilder);
SearchRequestBuilder finalQuery = client.prepareSearch(INDEX).setTypes(TYPE)
.setQuery(QueryBuilders.termQuery("_id", elasticDocId)).setPostFilter(geoShapeQueryBuilder);
SearchResponse searchResponse = finalQuery.execute().actionGet();
SearchHits searchHits = searchResponse.getHits();
if (searchHits.getTotalHits() > 0) {
return true;
}
return false;
}