Search in sources :

Example 1 with RecordWithSpatialObject

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;
    }
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) IndexEntry(com.apple.foundationdb.record.IndexEntry) BiFunction(java.util.function.BiFunction) Coordinate(org.locationtech.jts.geom.Coordinate) RecordQueryPlan(com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan) SpatialObject(com.geophile.z.SpatialObject) PlanHashable(com.apple.foundationdb.record.PlanHashable) Tuple(com.apple.foundationdb.tuple.Tuple) ImmutableList(com.google.common.collect.ImmutableList) Attribute(com.apple.foundationdb.record.query.plan.temp.explain.Attribute) Map(java.util.Map) AliasMap(com.apple.foundationdb.record.query.plan.temp.AliasMap) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) DoubleValueOrParameter(com.apple.foundationdb.record.spatial.common.DoubleValueOrParameter) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) SpatialJoin(com.geophile.z.SpatialJoin) RecordWithSpatialObject(com.geophile.z.index.RecordWithSpatialObject) ImmutableMap(com.google.common.collect.ImmutableMap) ScanComparisons(com.apple.foundationdb.record.query.plan.ScanComparisons) QueriedValue(com.apple.foundationdb.record.query.predicates.QueriedValue) RelationalExpression(com.apple.foundationdb.record.query.plan.temp.RelationalExpression) Objects(java.util.Objects) Value(com.apple.foundationdb.record.query.predicates.Value) List(java.util.List) Point(com.geophile.z.spatialobject.d2.Point) EvaluationContext(com.apple.foundationdb.record.EvaluationContext) ObjectPlanHash(com.apple.foundationdb.record.ObjectPlanHash) Geometry(org.locationtech.jts.geom.Geometry) API(com.apple.foundationdb.annotation.API) PlannerGraph(com.apple.foundationdb.record.query.plan.temp.explain.PlannerGraph) NodeInfo(com.apple.foundationdb.record.query.plan.temp.explain.NodeInfo) AvailableFields(com.apple.foundationdb.record.query.plan.AvailableFields) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) Point(com.geophile.z.spatialobject.d2.Point) Nullable(javax.annotation.Nullable)

Aggregations

API (com.apple.foundationdb.annotation.API)1 EvaluationContext (com.apple.foundationdb.record.EvaluationContext)1 IndexEntry (com.apple.foundationdb.record.IndexEntry)1 ObjectPlanHash (com.apple.foundationdb.record.ObjectPlanHash)1 PlanHashable (com.apple.foundationdb.record.PlanHashable)1 AvailableFields (com.apple.foundationdb.record.query.plan.AvailableFields)1 ScanComparisons (com.apple.foundationdb.record.query.plan.ScanComparisons)1 RecordQueryPlan (com.apple.foundationdb.record.query.plan.plans.RecordQueryPlan)1 AliasMap (com.apple.foundationdb.record.query.plan.temp.AliasMap)1 RelationalExpression (com.apple.foundationdb.record.query.plan.temp.RelationalExpression)1 Attribute (com.apple.foundationdb.record.query.plan.temp.explain.Attribute)1 NodeInfo (com.apple.foundationdb.record.query.plan.temp.explain.NodeInfo)1 PlannerGraph (com.apple.foundationdb.record.query.plan.temp.explain.PlannerGraph)1 QueriedValue (com.apple.foundationdb.record.query.predicates.QueriedValue)1 Value (com.apple.foundationdb.record.query.predicates.Value)1 DoubleValueOrParameter (com.apple.foundationdb.record.spatial.common.DoubleValueOrParameter)1 Tuple (com.apple.foundationdb.tuple.Tuple)1 SpatialJoin (com.geophile.z.SpatialJoin)1 SpatialObject (com.geophile.z.SpatialObject)1 RecordWithSpatialObject (com.geophile.z.index.RecordWithSpatialObject)1