Search in sources :

Example 81 with FactoryException

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);
    }
}
Also used : DatatypeFormatException(org.apache.jena.datatypes.DatatypeFormatException) FactoryException(org.opengis.util.FactoryException) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) TransformException(org.opengis.referencing.operation.TransformException) ExprEvalException(org.apache.jena.sparql.expr.ExprEvalException) MismatchedDimensionException(org.opengis.geometry.MismatchedDimensionException)

Example 82 with FactoryException

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);
    }
}
Also used : DatatypeFormatException(org.apache.jena.datatypes.DatatypeFormatException) FactoryException(org.opengis.util.FactoryException) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) IntersectionMatrix(org.locationtech.jts.geom.IntersectionMatrix) TransformException(org.opengis.referencing.operation.TransformException) ExprEvalException(org.apache.jena.sparql.expr.ExprEvalException) MismatchedDimensionException(org.opengis.geometry.MismatchedDimensionException)

Example 83 with FactoryException

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);
    }
}
Also used : DatatypeFormatException(org.apache.jena.datatypes.DatatypeFormatException) FactoryException(org.opengis.util.FactoryException) Node(org.apache.jena.graph.Node) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) TransformException(org.opengis.referencing.operation.TransformException) ExprEvalException(org.apache.jena.sparql.expr.ExprEvalException) MismatchedDimensionException(org.opengis.geometry.MismatchedDimensionException)

Example 84 with FactoryException

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);
    }
}
Also used : DatatypeFormatException(org.apache.jena.datatypes.DatatypeFormatException) FactoryException(org.opengis.util.FactoryException) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) TransformException(org.opengis.referencing.operation.TransformException) ExprEvalException(org.apache.jena.sparql.expr.ExprEvalException) MismatchedDimensionException(org.opengis.geometry.MismatchedDimensionException)

Aggregations

FactoryException (org.opengis.util.FactoryException)84 TransformException (org.opengis.referencing.operation.TransformException)27 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)21 MismatchedDimensionException (org.opengis.geometry.MismatchedDimensionException)19 ExprEvalException (org.apache.jena.sparql.expr.ExprEvalException)17 MathTransform (org.opengis.referencing.operation.MathTransform)15 DatatypeFormatException (org.apache.jena.datatypes.DatatypeFormatException)12 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)8 Envelope (org.locationtech.jts.geom.Envelope)7 ArrayList (java.util.ArrayList)6 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)6 NoninvertibleTransformException (org.opengis.referencing.operation.NoninvertibleTransformException)6 Literal (org.apache.jena.rdf.model.Literal)5 UnavailableFactoryException (org.apache.sis.referencing.factory.UnavailableFactoryException)5 CoordinateSystem (org.opengis.referencing.cs.CoordinateSystem)5 ParseException (java.text.ParseException)4 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)4 BackingStoreException (org.apache.sis.util.collection.BackingStoreException)4 Test (org.junit.Test)4