use of com.geophile.z.index.RecordWithSpatialObject in project fdb-record-layer by FoundationDB.
the class GeophilePointWithinDistanceQueryPlan method getFilter.
@Nullable
@Override
protected SpatialJoin.Filter<RecordWithSpatialObject, GeophileRecordImpl> getFilter(@Nonnull EvaluationContext context) {
if (covering) {
Double distanceValue = distance.getValue(context);
Double centerLatitudeValue = centerLatitude.getValue(context);
Double centerLongitudeValue = centerLongitude.getValue(context);
if (distanceValue == null || centerLatitudeValue == null || centerLongitudeValue == null) {
return null;
}
final GeometryFactory geometryFactory = new GeometryFactory();
final Geometry center = geometryFactory.createPoint(new Coordinate(centerLatitudeValue, centerLongitudeValue));
return (spatialObject, record) -> {
Point point = (Point) record.spatialObject();
Geometry geometry = geometryFactory.createPoint(new Coordinate(point.x(), point.y()));
return geometry.isWithinDistance(center, distanceValue);
};
} else {
return null;
}
}
Aggregations