Search in sources :

Example 26 with MismatchedDimensionException

use of org.opengis.geometry.MismatchedDimensionException 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 27 with MismatchedDimensionException

use of org.opengis.geometry.MismatchedDimensionException 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 28 with MismatchedDimensionException

use of org.opengis.geometry.MismatchedDimensionException 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 29 with MismatchedDimensionException

use of org.opengis.geometry.MismatchedDimensionException 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

MismatchedDimensionException (org.opengis.geometry.MismatchedDimensionException)29 TransformException (org.opengis.referencing.operation.TransformException)26 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)19 FactoryException (org.opengis.util.FactoryException)19 ExprEvalException (org.apache.jena.sparql.expr.ExprEvalException)15 DatatypeFormatException (org.apache.jena.datatypes.DatatypeFormatException)10 Envelope (org.locationtech.jts.geom.Envelope)8 MathTransform (org.opengis.referencing.operation.MathTransform)6 FactoryException (org.opengis.referencing.FactoryException)4 ArrayList (java.util.ArrayList)3 Literal (org.apache.jena.rdf.model.Literal)3 Resource (org.apache.jena.rdf.model.Resource)3 Geometry (org.locationtech.jts.geom.Geometry)3 DirectPosition (org.opengis.geometry.DirectPosition)3 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)3 GeometryFinder (eu.esdihumboldt.hale.common.instance.geometry.GeometryFinder)2 CodeDefinition (eu.esdihumboldt.hale.common.instance.geometry.impl.CodeDefinition)2 DepthFirstInstanceTraverser (eu.esdihumboldt.hale.common.instance.helper.DepthFirstInstanceTraverser)2 InstanceTraverser (eu.esdihumboldt.hale.common.instance.helper.InstanceTraverser)2 GeometryProperty (eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty)2