use of org.opengis.util.FactoryException in project jena by apache.
the class IntersectionFF method exec.
@Override
public NodeValue exec(NodeValue v1, NodeValue v2) {
try {
GeometryWrapper geometry1 = GeometryWrapper.extract(v1, GeometryIndex.PRIMARY);
GeometryWrapper geometry2 = GeometryWrapper.extract(v2, GeometryIndex.SECONDARY);
GeometryWrapper intersection = geometry1.intersection(geometry2);
return intersection.asNodeValue();
} 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()), ex);
}
}
use of org.opengis.util.FactoryException 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);
}
}
use of org.opengis.util.FactoryException in project jena by apache.
the class BufferFF method exec.
@Override
public NodeValue exec(NodeValue v1, NodeValue v2, NodeValue v3) {
try {
GeometryWrapper geometry = GeometryWrapper.extract(v1);
// Transfer the parameters as Nodes
if (!v2.isDouble()) {
throw new ExprEvalException("Not a Double: " + FmtUtils.stringForNode(v2.asNode()));
}
Node node2 = v2.asNode();
double radius = Double.parseDouble(node2.getLiteralLexicalForm());
// Obtain the target distance units
if (!v3.isIRI()) {
throw new ExprEvalException("Not a IRI: " + FmtUtils.stringForNode(v3.asNode()));
}
String unitsURI = v3.getNode().getURI();
GeometryWrapper buffer = geometry.buffer(radius, unitsURI);
return buffer.asNodeValue();
} 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);
}
}
use of org.opengis.util.FactoryException in project jena by apache.
the class SymmetricDifferenceFF method exec.
@Override
public NodeValue exec(NodeValue v1, NodeValue v2) {
try {
GeometryWrapper geometry1 = GeometryWrapper.extract(v1, GeometryIndex.PRIMARY);
GeometryWrapper geometry2 = GeometryWrapper.extract(v2, GeometryIndex.SECONDARY);
GeometryWrapper difference = geometry1.symDifference(geometry2);
return difference.asNodeValue();
} 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()), ex);
}
}
Aggregations