BinarySpatialOpTypeInfo binary = (BinarySpatialOpTypeInfo) spatialOps;
String propertyName = binary.getPropertyName().getValue();
if (binary.ifGeometry()) {
Geometry geometry = null;
WKTWriter writer = new WKTWriter();
GeometryFactory factory = new GeometryFactory();
AbstractGeometryInfo geom = binary.getGeometry();
geometry = toGeometry(factory, geom);
String wkt = writer.write(geometry);
if (binary instanceof ContainsInfo) {
return "CONTAINS(" + propertyName + "," + wkt + ")";
} else if (binary instanceof CrossesInfo) {
return "CROSSES(" + propertyName + "," + wkt + ")";
} else if (binary instanceof DisjointInfo) {
return "DISJOINT(" + propertyName + "," + wkt + ")";
} else if (binary instanceof EqualsInfo) {
return "EQUALS(" + propertyName + "," + wkt + ")";
} else if (binary instanceof IntersectsInfo) {
return "INTERSECTS(" + propertyName + "," + wkt + ")";
} else if (binary instanceof OverlapsInfo) {
return "OVERLAPS(" + propertyName + "," + wkt + ")";
} else if (binary instanceof TouchesInfo) {
return "TOUCHES(" + propertyName + "," + wkt + ")";
} else if (binary instanceof WithinInfo) {
return "WITHIN(" + propertyName + "," + wkt + ")";
}
} else if (spatialOps instanceof DistanceBufferTypeInfo) {
DistanceBufferTypeInfo distanceBuffer = (DistanceBufferTypeInfo) spatialOps;
AbstractGeometryInfo geom = distanceBuffer.getGeometry();
GeometryFactory factory = new GeometryFactory();
Geometry geometry = toGeometry(factory, geom);
WKTWriter writer = new WKTWriter();
String wkt = writer.write(geometry);
String units = distanceBuffer.getDistance().getUnits();
String distance = distanceBuffer.getDistance().getValue();