Java Code Examples for com.esri.core.geometry.ogc.OGCGeometry#intersects()

The following examples show how to use com.esri.core.geometry.ogc.OGCGeometry#intersects() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserDefinedGeoJsonSpatialFilter.java    From bboxdb with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a real filter based on the geometry of the data
 */
@Override
public boolean filterTuple(final Tuple tuple, final byte[] customData) {
	
	// No custom geometry is passed
	if(customData == null) { 
		return true;
	}
	
	// Cache the custom geometry between method calls
	if(customGeomety == null) {
		final String customString = new String(customData);
		customGeomety = geoJoinToGeomety(customString);
	}
	
	final String geoJsonString = new String(tuple.getDataBytes());
	final OGCGeometry geometry = extractGeometry(geoJsonString);

       return geometry.intersects(customGeomety);
}
 
Example 2
Source File: UserDefinedGeoJsonSpatialFilter.java    From bboxdb with Apache License 2.0 6 votes vote down vote up
/**
 * Perform a real join based on the geometry of the data
 */
@Override
public boolean filterJoinCandidate(final Tuple tuple1, final Tuple tuple2, final byte[] customData) {
	
	final String geoJsonString1 = new String(tuple1.getDataBytes());
	final String geoJsonString2 = new String(tuple2.getDataBytes());

	// Full text search on string (if provided)
	if(customData != null) {
		final String customDataString = new String(customData);
		if(! geoJsonString1.contains(customDataString) && 
				! geoJsonString2.contains(customDataString)) {
			return false;
		}
	}
	
	final OGCGeometry geometry1 = extractGeometry(geoJsonString1);
	final OGCGeometry geometry2 = extractGeometry(geoJsonString2);
	
	if(geometry1 instanceof OGCPoint) {
		final double geometryDistrance = geometry1.distance(geometry2);
		return geometryDistrance < MAX_OVERLAPPING_POINT_DISTANCE;
	} else {
	    return geometry1.intersects(geometry2);
	}
}
 
Example 3
Source File: GeoFunctions.java    From presto with Apache License 2.0 5 votes vote down vote up
@SqlNullable
@Description("Returns TRUE if the Geometries spatially intersect in 2D - (share any portion of space) and FALSE if they don't (they are Disjoint)")
@ScalarFunction("ST_Intersects")
@SqlType(BOOLEAN)
public static Boolean stIntersects(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right)
{
    if (!envelopes(left, right, Envelope::intersect)) {
        return false;
    }
    OGCGeometry leftGeometry = deserialize(left);
    OGCGeometry rightGeometry = deserialize(right);
    verifySameSpatialReference(leftGeometry, rightGeometry);
    return leftGeometry.intersects(rightGeometry);
}