use of com.geophile.z.SpatialObject in project fdb-record-layer by FoundationDB.
the class GeophileSpatialObjectQueryPlan method executeEntries.
@Nonnull
@Override
public <M extends Message> RecordCursor<IndexEntry> executeEntries(@Nonnull FDBRecordStoreBase<M> store, @Nonnull EvaluationContext context, @Nullable byte[] continuation, @Nonnull ExecuteProperties executeProperties) {
if (continuation != null) {
throw new RecordCoreException("continuations are not yet supported");
}
final SpatialObject spatialObject = getSpatialObject(context);
if (spatialObject == null) {
return RecordCursor.empty();
}
final SpatialJoin spatialJoin = SpatialJoin.newSpatialJoin(SpatialJoin.Duplicates.INCLUDE, getFilter(context));
final GeophileSpatialJoin geophileSpatialJoin = new GeophileSpatialJoin(spatialJoin, store.getUntypedRecordStore(), context);
final SpatialIndex<GeophileRecordImpl> spatialIndex = geophileSpatialJoin.getSpatialIndex(indexName, prefixComparisons, getRecordFunction());
return geophileSpatialJoin.recordCursor(spatialObject, spatialIndex);
}
use of com.geophile.z.SpatialObject 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;
}
}
use of com.geophile.z.SpatialObject in project fdb-record-layer by FoundationDB.
the class GeophileSpatialFunctionKeyExpression method evaluateFunction.
@Nonnull
@Override
public <M extends Message> List<Key.Evaluated> evaluateFunction(@Nullable FDBRecord<M> record, @Nullable Message message, @Nonnull Key.Evaluated arguments) {
SpatialObject spatialObject;
try {
spatialObject = parseSpatialObject(arguments);
} catch (ParseException ex) {
throw new RecordCoreException(ex);
}
if (spatialObject == null) {
return Collections.singletonList(Key.Evaluated.NULL);
}
long[] zs = new long[spatialObject.maxZ()];
GeophileSpatial.shuffle(space, spatialObject, zs);
List<Key.Evaluated> result = new ArrayList<>(zs.length);
for (long z : zs) {
if (z == Space.Z_NULL) {
break;
}
result.add(Key.Evaluated.scalar(z));
}
return result;
}
Aggregations