use of org.locationtech.jts.geom.IntersectionMatrix in project jena by apache.
the class RelateFF method exec.
@Override
public NodeValue exec(NodeValue v1, NodeValue v2, NodeValue v3) {
try {
GeometryWrapper geometry1 = GeometryWrapper.extract(v1, GeometryIndex.PRIMARY);
GeometryWrapper geometry2 = GeometryWrapper.extract(v2, GeometryIndex.SECONDARY);
if (!v3.isString()) {
throw new ExprEvalException("Not a String: " + FmtUtils.stringForNode(v3.asNode()));
}
String compareMatrix = v3.getString();
IntersectionMatrix matrix = geometry1.relate(geometry2);
boolean result = matrix.matches(compareMatrix);
return NodeValue.makeBoolean(result);
} catch (DatatypeFormatException ex) {
throw new ExprEvalException(ex.getMessage(), ex);
} catch (FactoryException | MismatchedDimensionException | TransformException ex) {
throw new ExprEvalException(ex.getMessage() + ": " + FmtUtils.stringForNode(v1.asNode()) + ", " + FmtUtils.stringForNode(v2.asNode()) + ", " + FmtUtils.stringForNode(v3.asNode()), ex);
}
}
Aggregations