use of com.esri.core.geometry.Envelope in project presto by prestodb.
the class TestSpatialPartitioningInternalAggregation method getSpatialPartitioning.
private String getSpatialPartitioning(List<OGCGeometry> geometries, int partitionCount) {
ImmutableList.Builder<Rectangle> rectangles = ImmutableList.builder();
for (OGCGeometry geometry : geometries) {
Envelope envelope = new Envelope();
geometry.getEsriGeometry().queryEnvelope(envelope);
rectangles.add(new Rectangle(envelope.getXMin(), envelope.getYMin(), envelope.getXMax(), envelope.getYMax()));
}
return KdbTreeUtils.toJson(buildKdbTree(roundToInt(geometries.size() * 1.0 / partitionCount, CEILING), rectangles.build()));
}
use of com.esri.core.geometry.Envelope in project presto by prestodb.
the class GeoFunctions method spatialPartitions.
@ScalarFunction
@SqlNullable
@Description("Returns an array of spatial partition IDs for a geometry representing a set of points within specified distance from the input geometry")
@SqlType("array(int)")
public static Block spatialPartitions(@SqlType(KdbTreeType.NAME) Object kdbTree, @SqlType(GEOMETRY_TYPE_NAME) Slice geometry, @SqlType(DOUBLE) double distance) {
if (isNaN(distance)) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is NaN");
}
if (isInfinite(distance)) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is infinite");
}
if (distance < 0) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "distance is negative");
}
Envelope envelope = deserializeEnvelope(geometry);
if (envelope.isEmpty()) {
return null;
}
Rectangle expandedEnvelope2D = new Rectangle(envelope.getXMin() - distance, envelope.getYMin() - distance, envelope.getXMax() + distance, envelope.getYMax() + distance);
return spatialPartitions((KdbTree) kdbTree, expandedEnvelope2D);
}
use of com.esri.core.geometry.Envelope in project calcite by apache.
the class GeoFunctions method envelope.
private static Envelope envelope(Geometry g) {
final Envelope env = new Envelope();
g.queryEnvelope(env);
return env;
}
Aggregations