On 16/07/14 09:08, David Torres wrote:
Hello,

I'm trying to implement this using ARQ API:

SELECT ?placeName{
     ?place spatial:nearby (51.46 2.6 10 'km') .
     ?place rdfs:label ?placeName}

I'm able to create the function as follows:

ExprList args = new ExprList();

NodeValue nodeLatitud = NodeValue.makeDecimal(51.46);
NodeValue nodeLongitud = NodeValue.makeDecimal(2.6);
NodeValue nodeRadius = NodeValue.makeDecimal(10);
NodeValue nodeUnit = NodeValue.makeString("km");

args.add(nodeLatitud);
args.add(nodeLongitud);
args.add(nodeRadius);
args.add(nodeUnit);

Expr function = new E_Function("http://jena.apache.org/spatial#nearby";,
args);

But now, I don't know how to insert this function in the main query.

For example, this would include as filter clause, but of course it hasn't
the same effects:

ElementGroup body = new ElementGroup();

ElementFilter emfilter = new ElementFilter(function);
body.addElement(emfilter) ;

Any help would be appreciated!

David


(brief reply)

ElementFilter and E_* are all about FILTER expressions.

Property Functions like spatial:nearby are completely different :

1/ Build the query using basic graph patterns - no mention of "property functions"

Basic graph pattern of

?place spatial:nearby bnode .

and bnode is head of the RDF list (more triples).

2/ register the property function with the property function registry.

then when a query is compiled (first stage of execution) the registered property triggers code to convert the triples to the algebra for calling a property function.

Try using "arq.qparse" on a query you know works with a property function and a list as object argument. e.g.

---------------
prefix list: <http://jena.hpl.hp.com/ARQ/list#>

SELECT * {
 ?x list:index (?idx ?m)
}
----------------

then try:
arq.qparse --print=op (outputs the raw algebra as per the SPARQL spec)

arq.qparse --print=opt (outputs the algebra after the optimizer)

The optimizer includes the property function translation.

        Andy


Reply via email to