Search in sources :

Example 91 with GeometryWrapper

use of org.apache.jena.geosparql.implementation.GeometryWrapper in project jena by apache.

the class GenericSpatialBoxPropertyFunctionTest method testExtractObjectArguments_5args_pos4_fail.

/**
 * Test of extractObjectArguments method, of class
 * GenericSpatialBoxPropertyFunction.
 */
@Test(expected = ExprEvalException.class)
public void testExtractObjectArguments_5args_pos4_fail() {
    GenericSpatialBoxPropertyFunction instance = new WithinBoxPF();
    Node predicate = NodeFactory.createURI(SpatialExtension.WITHIN_BOX_PROP);
    // Geometry and Envelope parameters
    float latMin = 0;
    float lonMin = 1;
    float latMax = 2;
    float lonMax = 3;
    int limit = 10;
    List<Node> objectNodes = Arrays.asList(NodeValue.makeFloat(latMin).asNode(), NodeValue.makeFloat(lonMin).asNode(), NodeValue.makeFloat(latMax).asNode(), NodeValue.makeFloat(lonMax).asNode(), NodeValue.makeString("10").asNode());
    PropFuncArg object = new PropFuncArg(objectNodes);
    // Function arguments
    Literal geometry = ConvertLatLonBox.toLiteral(latMin, lonMin, latMax, lonMax);
    GeometryWrapper geometryWrapper = GeometryWrapper.extract(geometry);
    SearchEnvelope searchEnvelope = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO);
    SpatialArguments expResult = new SpatialArguments(limit, geometryWrapper, searchEnvelope);
    SpatialArguments result = instance.extractObjectArguments(predicate, object, SpatialIndexTestData.WGS_84_SRS_INFO);
// assertEquals(expResult, result);
}
Also used : SpatialArguments(org.apache.jena.geosparql.spatial.property_functions.SpatialArguments) Node(org.apache.jena.graph.Node) Literal(org.apache.jena.rdf.model.Literal) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) SearchEnvelope(org.apache.jena.geosparql.spatial.SearchEnvelope) PropFuncArg(org.apache.jena.sparql.pfunction.PropFuncArg) Test(org.junit.Test)

Example 92 with GeometryWrapper

use of org.apache.jena.geosparql.implementation.GeometryWrapper in project jena by apache.

the class GenericSpatialBoxPropertyFunctionTest method testExtractObjectArguments_4args.

/**
 * Test of extractObjectArguments method, of class
 * GenericSpatialBoxPropertyFunction.
 */
@Test
public void testExtractObjectArguments_4args() {
    GenericSpatialBoxPropertyFunction instance = new WithinBoxPF();
    Node predicate = NodeFactory.createURI(SpatialExtension.WITHIN_BOX_PROP);
    // Geometry and Envelope parameters
    float latMin = 0;
    float lonMin = 1;
    float latMax = 2;
    float lonMax = 3;
    int limit = -1;
    List<Node> objectNodes = Arrays.asList(NodeValue.makeFloat(latMin).asNode(), NodeValue.makeFloat(lonMin).asNode(), NodeValue.makeFloat(latMax).asNode(), NodeValue.makeFloat(lonMax).asNode());
    PropFuncArg object = new PropFuncArg(objectNodes);
    // Function arguments
    Literal geometry = ConvertLatLonBox.toLiteral(latMin, lonMin, latMax, lonMax);
    GeometryWrapper geometryWrapper = GeometryWrapper.extract(geometry);
    SearchEnvelope searchEnvelope = SearchEnvelope.build(geometryWrapper, SpatialIndexTestData.WGS_84_SRS_INFO);
    SpatialArguments expResult = new SpatialArguments(limit, geometryWrapper, searchEnvelope);
    SpatialArguments result = instance.extractObjectArguments(predicate, object, SpatialIndexTestData.WGS_84_SRS_INFO);
    assertEquals(expResult, result);
}
Also used : SpatialArguments(org.apache.jena.geosparql.spatial.property_functions.SpatialArguments) Node(org.apache.jena.graph.Node) Literal(org.apache.jena.rdf.model.Literal) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) SearchEnvelope(org.apache.jena.geosparql.spatial.SearchEnvelope) PropFuncArg(org.apache.jena.sparql.pfunction.PropFuncArg) Test(org.junit.Test)

Example 93 with GeometryWrapper

use of org.apache.jena.geosparql.implementation.GeometryWrapper in project jena by apache.

the class NearbyFFTest method testRelate_OSGB.

/**
 * Test of relate method, of class NearbyFF.
 */
@Test
public void testRelate_OSGB() {
    GeometryWrapper geometry1 = GeometryWrapper.extract("<http://www.opengis.net/def/crs/EPSG/0/27700> POINT(0.0 0.0)", WKTDatatype.URI);
    GeometryWrapper geometry2 = GeometryWrapper.extract("<http://www.opengis.net/def/crs/EPSG/0/27700> POINT(10000.0 0.0)", WKTDatatype.URI);
    ;
    double radius = 10.1;
    String unitsURI = Unit_URI.KILOMETER_URL;
    boolean expResult = true;
    boolean result = NearbyFF.relate(geometry1, geometry2, radius, unitsURI);
    assertEquals(expResult, result);
}
Also used : GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) Test(org.junit.Test)

Example 94 with GeometryWrapper

use of org.apache.jena.geosparql.implementation.GeometryWrapper in project jena by apache.

the class NearbyFFTest method testRelate_fail.

/**
 * Test of relate method, of class NearbyFF.
 */
@Test
public void testRelate_fail() {
    GeometryWrapper geometry1 = GeometryWrapper.extract("<http://www.opengis.net/def/crs/EPSG/0/4326> POINT(10.0 20.0)", WKTDatatype.URI);
    GeometryWrapper geometry2 = GeometryWrapper.extract("<http://www.opengis.net/def/crs/EPSG/0/4326> POINT(10.0 30.0)", WKTDatatype.URI);
    ;
    double radius = 5.0;
    String unitsURI = Unit_URI.KILOMETER_URL;
    boolean expResult = false;
    boolean result = NearbyFF.relate(geometry1, geometry2, radius, unitsURI);
    assertEquals(expResult, result);
}
Also used : GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) Test(org.junit.Test)

Example 95 with GeometryWrapper

use of org.apache.jena.geosparql.implementation.GeometryWrapper in project jena by apache.

the class EqualsFFTest method testRelate_point_point.

@Test
public void testRelate_point_point() throws FactoryException, MismatchedDimensionException, TransformException {
    GeometryWrapper subjectGeometryWrapper = GeometryWrapper.extract(ResourceFactory.createTypedLiteral("<http://www.opengis.net/def/crs/EPSG/0/27700> POINT(60 60)", WKTDatatype.INSTANCE));
    GeometryWrapper objectGeometryWrapper = GeometryWrapper.extract(ResourceFactory.createTypedLiteral("<http://www.opengis.net/def/crs/EPSG/0/27700> POINT(60 60)", WKTDatatype.INSTANCE));
    EqualsFF instance = new EqualsFF();
    Boolean expResult = true;
    Boolean result = instance.relate(subjectGeometryWrapper, objectGeometryWrapper);
    assertEquals(expResult, result);
}
Also used : GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) Test(org.junit.Test)

Aggregations

GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)356 Test (org.junit.Test)297 DimensionInfo (org.apache.jena.geosparql.implementation.DimensionInfo)70 Node (org.apache.jena.graph.Node)64 SearchEnvelope (org.apache.jena.geosparql.spatial.SearchEnvelope)63 Literal (org.apache.jena.rdf.model.Literal)59 PropFuncArg (org.apache.jena.sparql.pfunction.PropFuncArg)53 LineString (org.locationtech.jts.geom.LineString)52 SpatialArguments (org.apache.jena.geosparql.spatial.property_functions.SpatialArguments)51 Geometry (org.locationtech.jts.geom.Geometry)48 CustomCoordinateSequence (org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence)39 ExprEvalException (org.apache.jena.sparql.expr.ExprEvalException)36 DatatypeFormatException (org.apache.jena.datatypes.DatatypeFormatException)32 NodeValue (org.apache.jena.sparql.expr.NodeValue)24 TransformException (org.opengis.referencing.operation.TransformException)21 FactoryException (org.opengis.util.FactoryException)21 Envelope (org.locationtech.jts.geom.Envelope)19 MismatchedDimensionException (org.opengis.geometry.MismatchedDimensionException)19 Coordinate (org.locationtech.jts.geom.Coordinate)15 Resource (org.apache.jena.rdf.model.Resource)13