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

The following examples show how to use com.esri.core.geometry.ogc.OGCGeometry#symDifference() . 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: ST_SymmetricDiff.java    From spatial-framework-for-hadoop with Apache License 2.0 5 votes vote down vote up
public BytesWritable evaluate(BytesWritable geometryref1, BytesWritable geometryref2)
{
	if (geometryref1 == null || geometryref2 == null ||
	    geometryref1.getLength() == 0 || geometryref2.getLength() == 0) {
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}
	
	if (!GeometryUtils.compareSpatialReferences(geometryref1, geometryref2)) {
		LogUtils.Log_SRIDMismatch(LOG, geometryref1, geometryref2);
		return null;
	}

	OGCGeometry ogcGeom1 = GeometryUtils.geometryFromEsriShape(geometryref1);
	OGCGeometry ogcGeom2 = GeometryUtils.geometryFromEsriShape(geometryref2);
	if (ogcGeom1 == null || ogcGeom2 == null){
		LogUtils.Log_ArgumentsNull(LOG);
		return null;
	}
	
	try {
		OGCGeometry diffGeometry = ogcGeom1.symDifference(ogcGeom2);
		return GeometryUtils.geometryToEsriShapeBytesWritable(diffGeometry);
	} catch (Exception e) {
	    LogUtils.Log_InternalError(LOG, "ST_SymmetricDiff: " + e);
	    return null;
	}
}
 
Example 2
Source File: TestOGC.java    From geometry-api-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testPointSymDif() {
	OGCGeometry g1 = OGCGeometry.fromText("POINT(1 2)");
	OGCGeometry g2 = OGCGeometry.fromText("POINT(3 4)");
	OGCGeometry gg = g1.symDifference(g2);
	assertTrue(gg.equals(OGCGeometry.fromText("MULTIPOINT(1 2, 3 4)")));

	OGCGeometry g3 = OGCGeometry.fromText("POINT(1 2)");
	OGCGeometry gg1 = g1.symDifference(g3);
	assertTrue(gg1 == null || gg1.isEmpty());

}