Search in sources :

Example 96 with NodeValue

use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.

the class NearbyFFTest method testExec_Paris_London_fail.

/**
 * Test of exec method, of class NearbyFF.
 */
@Test
public void testExec_Paris_London_fail() {
    NodeValue v1 = SpatialIndexTestData.PARIS_GEOMETRY_WRAPPER.asNodeValue();
    NodeValue v2 = SpatialIndexTestData.LONDON_GEOMETRY_WRAPPER.asNodeValue();
    NodeValue v3 = NodeValue.makeFloat(200);
    NodeValue v4 = NodeValue.makeString(Unit_URI.KILOMETER_URL);
    NearbyFF instance = new NearbyFF();
    NodeValue expResult = NodeValue.makeBoolean(false);
    NodeValue result = instance.exec(v1, v2, v3, v4);
    assertEquals(expResult, result);
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Test(org.junit.Test)

Example 97 with NodeValue

use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.

the class GenericSpatialGeomPropertyFunction method extractObjectArguments.

@Override
protected SpatialArguments extractObjectArguments(Node predicate, PropFuncArg object, SRSInfo indexSRSInfo) {
    try {
        // Check minimum arguments.
        List<Node> objectArgs = object.getArgList();
        if (objectArgs.size() < 1) {
            throw new ExprEvalException(FmtUtils.stringForNode(predicate) + ": Minimum of 1 arguments.");
        } else if (objectArgs.size() > 2) {
            throw new ExprEvalException(FmtUtils.stringForNode(predicate) + ": Maximum of 2 arguments.");
        }
        Node geomLit = object.getArg(GEOM_POS);
        // Find the limit.
        int limit;
        if (objectArgs.size() > LIMIT_POS) {
            NodeValue limitNode = NodeValue.makeNode(objectArgs.get(LIMIT_POS));
            if (!limitNode.isInteger()) {
                throw new ExprEvalException("Not an integer: " + FmtUtils.stringForNode(limitNode.asNode()));
            }
            limit = limitNode.getInteger().intValue();
        } else {
            limit = DEFAULT_LIMIT;
        }
        GeometryWrapper geometryWrapper = GeometryWrapper.extract(geomLit);
        SearchEnvelope searchEnvelope = buildSearchEnvelope(geometryWrapper, indexSRSInfo);
        return new SpatialArguments(limit, geometryWrapper, searchEnvelope);
    } catch (DatatypeFormatException ex) {
        throw new ExprEvalException(ex.getMessage(), ex);
    }
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) DatatypeFormatException(org.apache.jena.datatypes.DatatypeFormatException) Node(org.apache.jena.graph.Node) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) SearchEnvelope(org.apache.jena.geosparql.spatial.SearchEnvelope) ExprEvalException(org.apache.jena.sparql.expr.ExprEvalException)

Example 98 with NodeValue

use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.

the class BufferFFTest method testExec_Geographic_Linear.

/**
 * Test of exec method, of class BufferFF.
 */
@Test
public void testExec_Geographic_Linear() {
    NodeValue v1 = NodeValue.makeNode("<http://www.opengis.net/def/crs/EPSG/0/4326> POLYGON((49.9 -7.5, 50.0 -7.5, 50.0 -7.4, 49.9 -7.4, 49.9 -7.5))", WKTDatatype.INSTANCE);
    NodeValue v2 = NodeValue.makeDecimal(20);
    NodeValue v3 = NodeValue.makeNode(NodeFactory.createURI(Unit_URI.METRE_URL));
    BufferFF instance = new BufferFF();
    NodeValue expResult = NodeValue.makeNode("<http://www.opengis.net/def/crs/EPSG/0/4326> POLYGON((49.89982 -7.5, 49.899824 -7.500054, 49.899834 -7.500106, 49.89985 -7.500155, 49.899873 -7.500197, 49.8999 -7.500231, 49.899931 -7.500257, 49.899965 -7.500273, 49.9 -7.500278, 50 -7.500279, 50.000035 -7.500274, 50.000069 -7.500258, 50.0001 -7.500232, 50.000127 -7.500197, 50.00015 -7.500155, 50.000166 -7.500107, 50.000176 -7.500055, 50.00018 -7.5, 50.00018 -7.4, 50.000176 -7.399945, 50.000166 -7.399893, 50.000149 -7.399845, 50.000127 -7.399803, 50.0001 -7.399768, 50.000069 -7.399742, 50.000035 -7.399726, 50 -7.399721, 49.9 -7.399722, 49.899965 -7.399727, 49.899931 -7.399743, 49.8999 -7.399769, 49.899873 -7.399803, 49.89985 -7.399845, 49.899834 -7.399894, 49.899824 -7.399946, 49.89982 -7.4, 49.89982 -7.5))", WKTDatatype.INSTANCE);
    NodeValue result = instance.exec(v1, v2, v3);
    assertEquals(expResult, result);
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Test(org.junit.Test)

Example 99 with NodeValue

use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.

the class BufferFFTest method testExec_Projection_NonLinear.

/**
 * Test of exec method, of class BufferFF.
 */
@Test
public void testExec_Projection_NonLinear() {
    NodeValue v1 = NodeValue.makeNode("<http://www.opengis.net/def/crs/EPSG/0/27700> POINT(60 60)", WKTDatatype.INSTANCE);
    NodeValue v2 = NodeValue.makeDecimal(0.0002);
    NodeValue v3 = NodeValue.makeNode(NodeFactory.createURI(Unit_URI.DEGREE_URL));
    BufferFF instance = new BufferFF();
    NodeValue expResult = NodeValue.makeNode("<http://www.opengis.net/def/crs/EPSG/0/27700> POLYGON((74.40146 58.902956, 73.79184 54.591588, 72.686764 50.428725, 71.039028 46.753001, 68.992545 43.553727, 66.627526 40.936656, 64.024179 39.007539, 61.199008 37.98857, 58.359636 37.752618, 55.586275 38.405436, 52.942632 39.830584, 50.652834 42.123122, 48.700379 45.06086, 47.148974 48.527356, 46.062326 52.406168, 45.584349 56.686608, 45.61833 61.040732, 46.227974 65.352098, 47.33307 69.514956, 48.980819 73.190674, 51.027306 76.38994, 53.392322 79.007004, 55.995657 80.936115, 58.820809 81.955081, 61.660158 82.191031, 64.433497 81.538215, 67.07712 80.113072, 69.366904 77.82054, 71.319354 74.882809, 72.870762 71.416321, 73.957423 67.537515, 74.435419 63.257079, 74.40146 58.902956))", WKTDatatype.INSTANCE);
    NodeValue result = instance.exec(v1, v2, v3);
    assertEquals(expResult, result);
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Test(org.junit.Test)

Example 100 with NodeValue

use of org.apache.jena.sparql.expr.NodeValue in project jena by apache.

the class SpatialDimensionFFTest method testExec_3M_Dimension.

/**
 * Test of exec method, of class SpatialDimensionFF.
 */
@Test
public void testExec_3M_Dimension() {
    NodeValue geometryLiteral = NodeValue.makeNode("<http://www.opengis.net/def/crs/EPSG/0/27700> POINT ZM (90 60 30 10)", WKTDatatype.INSTANCE);
    SpatialDimensionFF instance = new SpatialDimensionFF();
    NodeValue expResult = NodeValue.makeNodeInteger(3);
    NodeValue result = instance.exec(geometryLiteral);
    assertEquals(expResult, result);
}
Also used : NodeValue(org.apache.jena.sparql.expr.NodeValue) Test(org.junit.Test)

Aggregations

NodeValue (org.apache.jena.sparql.expr.NodeValue)255 Test (org.junit.Test)197 BaseTest (org.apache.jena.atlas.junit.BaseTest)42 Node (org.apache.jena.graph.Node)31 ExprEvalException (org.apache.jena.sparql.expr.ExprEvalException)26 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)24 Expr (org.apache.jena.sparql.expr.Expr)12 NodeValueNode (org.apache.jena.sparql.expr.nodevalue.NodeValueNode)10 ARQInternalErrorException (org.apache.jena.sparql.ARQInternalErrorException)7 DatatypeFormatException (org.apache.jena.datatypes.DatatypeFormatException)6 ArrayList (java.util.ArrayList)5 SearchEnvelope (org.apache.jena.geosparql.spatial.SearchEnvelope)5 LibTestExpr (org.apache.jena.sparql.expr.LibTestExpr)5 Duration (javax.xml.datatype.Duration)4 SpatialArguments (org.apache.jena.geosparql.spatial.property_functions.SpatialArguments)4 BigDecimal (java.math.BigDecimal)3 AssemblerException (org.apache.jena.assembler.exceptions.AssemblerException)3 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)3 Var (org.apache.jena.sparql.core.Var)3 ValueSpaceClassification (org.apache.jena.sparql.expr.ValueSpaceClassification)3