use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class GeoFunctions method stOverlaps.
@SqlNullable
@Description("Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other")
@ScalarFunction("ST_Overlaps")
@SqlType(BOOLEAN)
public static Boolean stOverlaps(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
if (!envelopes(left, right, Envelope::intersect)) {
return false;
}
OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
verifySameSpatialReference(leftGeometry, rightGeometry);
return leftGeometry.overlaps(rightGeometry);
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class PagesRTreeIndex method findJoinPositions.
/**
* Returns an array of addresses from {@link PagesIndex#getValueAddresses()} corresponding
* to rows with matching geometries.
* <p>
* The caller is responsible for calling {@link #isJoinPositionEligible(int, int, Page)}
* for each of these addresses to apply additional join filters.
*/
@Override
public int[] findJoinPositions(int probePosition, Page probe, int probeGeometryChannel, Optional<Integer> probePartitionChannel) {
Block probeGeometryBlock = probe.getBlock(probeGeometryChannel);
if (probeGeometryBlock.isNull(probePosition)) {
return EMPTY_ADDRESSES;
}
int probePartition = probePartitionChannel.map(channel -> toIntExact(INTEGER.getLong(probe.getBlock(channel), probePosition))).orElse(-1);
Slice slice = probeGeometryBlock.getSlice(probePosition, 0, probeGeometryBlock.getSliceLength(probePosition));
OGCGeometry probeGeometry = deserialize(slice);
verify(probeGeometry != null);
if (probeGeometry.isEmpty()) {
return EMPTY_ADDRESSES;
}
IntArrayList matchingPositions = new IntArrayList();
Rectangle queryRectangle = getExtent(probeGeometry);
boolean probeIsPoint = queryRectangle.isPointlike();
rtree.findIntersections(queryRectangle, geometryWithPosition -> {
OGCGeometry buildGeometry = geometryWithPosition.getGeometry();
Rectangle buildEnvelope = geometryWithPosition.getExtent();
if (partitions.isEmpty() || (probePartition == geometryWithPosition.getPartition() && (probeIsPoint || buildEnvelope.isPointlike() || testReferencePoint(queryRectangle, buildEnvelope, probePartition)))) {
OptionalDouble radius = radiusChannel == -1 ? OptionalDouble.empty() : OptionalDouble.of(getRadius(geometryWithPosition.getPosition()));
if (spatialRelationshipTest.apply(buildGeometry, probeGeometry, radius)) {
matchingPositions.add(geometryWithPosition.getPosition());
}
}
});
return matchingPositions.toIntArray();
}
use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.
the class TestHelper method assertGeometryEqual.
public static void assertGeometryEqual(Object expected, Object test) {
OGCGeometry expected_geom = expected instanceof String ? OGCGeometry.fromText((String) expected) : OGCGeometry.fromBinary(ByteBuffer.wrap(((DataByteArray) expected).get()));
OGCGeometry test_geom = test instanceof String ? OGCGeometry.fromText((String) test) : OGCGeometry.fromBinary(ByteBuffer.wrap(((DataByteArray) test).get()));
if (expected_geom instanceof OGCGeometryCollection && test_geom instanceof OGCGeometryCollection) {
OGCGeometryCollection expected_coln = (OGCGeometryCollection) expected_geom;
OGCGeometryCollection test_coln = (OGCGeometryCollection) test_geom;
assertEquals(expected_coln.numGeometries(), test_coln.numGeometries());
Vector<OGCGeometry> expectedGeometries = new Vector<OGCGeometry>();
for (int i = 0; i < expected_coln.numGeometries(); i++) {
expectedGeometries.add(expected_coln.geometryN(i));
}
for (int i = 0; i < test_coln.numGeometries(); i++) {
OGCGeometry geom = test_coln.geometryN(i);
int j = 0;
while (j < expectedGeometries.size() && !geom.equals(expectedGeometries.get(j))) j++;
assertTrue(j < expectedGeometries.size());
expectedGeometries.remove(j++);
}
} else {
assertTrue("Exepcted geometry to be '" + expected + "' but found '" + test + "'", expected_geom.equals(test_geom));
}
}
use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.
the class TestGeometryParser method testShouldReturnNullOnNullInput.
public void testShouldReturnNullOnNullInput() throws Exception {
OGCGeometry parsed = geometry_parser.parseGeom(null);
assertNull(parsed);
}
use of com.esri.core.geometry.ogc.OGCGeometry in project pigeon by aseldawy.
the class TestGeometryParser method testShouldParseWKT.
public void testShouldParseWKT() throws Exception {
String wkt = polygon.asText();
OGCGeometry parsed = geometry_parser.parseGeom(wkt);
assertTrue(polygon.equals(parsed));
}
Aggregations