Search in sources :

Example 51 with PropFuncArg

use of org.apache.jena.sparql.pfunction.PropFuncArg in project jena by apache.

the class listIndex method execObjectList.

@Override
protected QueryIterator execObjectList(Binding binding, Var listVar, Node predicate, List<Node> objectArgs, ExecutionContext execCxt) {
    if (objectArgs.size() != 2)
        throw new ExprEvalException("ListIndex : object not a list of length 2");
    Node indexNode = objectArgs.get(0);
    Node memberNode = objectArgs.get(1);
    final Collection<Node> x;
    if (!Var.isVar(memberNode))
        // If memberNode is defined, find lists containing it.
        x = GraphList.listFromMember(new GNode(execCxt.getActiveGraph(), memberNode));
    else
        // Hard. Subject unbound, no fixed member. Find every list and use BFI.
        x = GraphList.findAllLists(execCxt.getActiveGraph());
    return super.allLists(binding, x, listVar, predicate, new PropFuncArg(objectArgs, null), execCxt);
}
Also used : GNode(org.apache.jena.sparql.util.graph.GNode) Node(org.apache.jena.graph.Node) GNode(org.apache.jena.sparql.util.graph.GNode) PropFuncArg(org.apache.jena.sparql.pfunction.PropFuncArg) ExprEvalException(org.apache.jena.sparql.expr.ExprEvalException)

Example 52 with PropFuncArg

use of org.apache.jena.sparql.pfunction.PropFuncArg in project jena by apache.

the class OpPropFunc method equalTo.

@Override
public boolean equalTo(Op other, NodeIsomorphismMap labelMap) {
    if (!(other instanceof OpPropFunc))
        return false;
    OpPropFunc procFunc = (OpPropFunc) other;
    if (!this.getProperty().equals(procFunc.getProperty()))
        return false;
    PropFuncArg s1 = getSubjectArgs();
    PropFuncArg s2 = procFunc.getSubjectArgs();
    s1.equals(s2);
    if (!isomorphic(getSubjectArgs(), procFunc.getSubjectArgs(), labelMap))
        return false;
    if (!isomorphic(getObjectArgs(), procFunc.getObjectArgs(), labelMap))
        return false;
    return getSubOp().equalTo(procFunc.getSubOp(), labelMap);
}
Also used : PropFuncArg(org.apache.jena.sparql.pfunction.PropFuncArg)

Example 53 with PropFuncArg

use of org.apache.jena.sparql.pfunction.PropFuncArg in project jena by apache.

the class OpRewriter method visit.

@Override
public void visit(OpPropFunc opPropFunc) {
    opPropFunc.getSubOp().visit(this);
    Op op = pop();
    Node uri = changeNode(opPropFunc.getProperty());
    PropFuncArg args1 = rewrite(opPropFunc.getSubjectArgs());
    PropFuncArg args2 = rewrite(opPropFunc.getObjectArgs());
    push(new OpPropFunc(uri, args1, args2, op));
}
Also used : Op(org.apache.jena.sparql.algebra.Op) Node(org.apache.jena.graph.Node) PropFuncArg(org.apache.jena.sparql.pfunction.PropFuncArg) OpPropFunc(org.apache.jena.sparql.algebra.op.OpPropFunc)

Example 54 with PropFuncArg

use of org.apache.jena.sparql.pfunction.PropFuncArg in project jena by apache.

the class WithinBoxGeomPFTest method testCheckSecondFilter.

/**
 * Test of checkSecondFilter method, of class WithinBoxGeomPF.
 */
@Test
public void testCheckSecondFilter() {
    WithinBoxGeomPF instance = new WithinBoxGeomPF();
    // Property Function
    Node predicate = NodeFactory.createURI(SpatialExtension.WITHIN_BOX_GEOM_PROP);
    // Geometry and Envelope parameters
    float lat = 1;
    float lon = 1;
    float latMin = 0;
    float lonMin = 0;
    float latMax = 2;
    float lonMax = 2;
    Literal geometry = ConvertLatLonBox.toLiteral(latMin, lonMin, latMax, lonMax);
    Literal targetGeometry = ConvertLatLon.toLiteral(lat, lon);
    List<Node> objectNodes = Arrays.asList(geometry.asNode());
    PropFuncArg object = new PropFuncArg(objectNodes);
    // Function arguments
    SpatialArguments spatialArguments = instance.extractObjectArguments(predicate, object, SpatialIndexTestData.WGS_84_SRS_INFO);
    GeometryWrapper targetGeometryWrapper = GeometryWrapper.extract(targetGeometry);
    // Test arguments
    boolean expResult = true;
    boolean result = instance.checkSecondFilter(spatialArguments, targetGeometryWrapper);
    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) PropFuncArg(org.apache.jena.sparql.pfunction.PropFuncArg) Test(org.junit.Test)

Example 55 with PropFuncArg

use of org.apache.jena.sparql.pfunction.PropFuncArg in project jena by apache.

the class WithinBoxGeomPFTest method testCheckSecondFilter_fail.

/**
 * Test of checkSecondFilter method, of class WithinBoxGeomPF.
 */
@Test
public void testCheckSecondFilter_fail() {
    WithinBoxGeomPF instance = new WithinBoxGeomPF();
    // Property Function
    Node predicate = NodeFactory.createURI(SpatialExtension.WITHIN_BOX_GEOM_PROP);
    // Geometry and Envelope parameters
    float lat = 5;
    float lon = 5;
    float latMin = 0;
    float lonMin = 0;
    float latMax = 2;
    float lonMax = 2;
    Literal geometry = ConvertLatLonBox.toLiteral(latMin, lonMin, latMax, lonMax);
    Literal targetGeometry = ConvertLatLon.toLiteral(lat, lon);
    List<Node> objectNodes = Arrays.asList(geometry.asNode());
    PropFuncArg object = new PropFuncArg(objectNodes);
    // Function arguments
    SpatialArguments spatialArguments = instance.extractObjectArguments(predicate, object, SpatialIndexTestData.WGS_84_SRS_INFO);
    GeometryWrapper targetGeometryWrapper = GeometryWrapper.extract(targetGeometry);
    // Test arguments
    boolean expResult = false;
    boolean result = instance.checkSecondFilter(spatialArguments, targetGeometryWrapper);
    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) PropFuncArg(org.apache.jena.sparql.pfunction.PropFuncArg) Test(org.junit.Test)

Aggregations

PropFuncArg (org.apache.jena.sparql.pfunction.PropFuncArg)57 Node (org.apache.jena.graph.Node)56 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)53 Literal (org.apache.jena.rdf.model.Literal)53 Test (org.junit.Test)53 SpatialArguments (org.apache.jena.geosparql.spatial.property_functions.SpatialArguments)47 SearchEnvelope (org.apache.jena.geosparql.spatial.SearchEnvelope)41 IntersectBoxGeomPF (org.apache.jena.geosparql.spatial.property_functions.box.IntersectBoxGeomPF)6 GNode (org.apache.jena.sparql.util.graph.GNode)2 ArrayList (java.util.ArrayList)1 Triple (org.apache.jena.graph.Triple)1 Op (org.apache.jena.sparql.algebra.Op)1 OpPropFunc (org.apache.jena.sparql.algebra.op.OpPropFunc)1 ExprEvalException (org.apache.jena.sparql.expr.ExprEvalException)1