Thanks again for your help Stephen,
I did a few other tests and got something new. I have used a combination of your test dataset and mine. And I have tried to calculate the distance 3 different ways:
(1) Using two variables ?geom1 and ?geom2
(2) Directly referring to your dataset IRI short names using the prefix
(3) And doing the same with the IRI of my dataset
The results were as following:
(1) No distance obtained, as before for my dataset but even for yours.
(2) Distance obtained as before for your dataset.
(3) I had to put that line in comment because it was crashing with QueryEval: -1 and the following message in the log.
ERROR 2019-04-08 20:04:05,947 [stardog-user-21] com.complexible.stardog.protocols.http.server.StardogHttpServiceLoader:accept(235): An unexpected exception was handled by the server
com.stardog.stark.query.QueryExecutionFailure: -1
at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:82) ~[stardog-utils-rdf-6.1.2.jar:?]
at com.stardog.stark.query.ClosingSpliterator.forEachRemaining(ClosingSpliterator.java:37) ~[stardog-stark-query-api-6.1.2.jar:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580) ~[?:1.8.0_201]
at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:142) ~[stardog-stark-query-io-6.1.2.jar:?]
at com.stardog.stark.query.io.QueryResultWriters.write(QueryResultWriters.java:127) ~[stardog-stark-query-io-6.1.2.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.writeTupleResponse(ProtocolUtils.java:579) ~[stardog-protocols-http-server-6.1.2.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:489) ~[stardog-protocols-http-server-6.1.2.jar:?]
at com.complexible.stardog.protocols.http.server.ProtocolUtils.executeReadQuery(ProtocolUtils.java:474) ~[stardog-protocols-http-server-6.1.2.jar:?]
at com.complexible.stardog.protocols.http.server.SPARQLProtocol.executeQuery(SPARQLProtocol.java:127) ~[stardog-protocols-http-server-6.1.2.jar:?]
at com.complexible.stardog.protocols.http.server.SPARQLProtocol.post(SPARQLProtocol.java:91) ~[stardog-protocols-http-server-6.1.2.jar:?]
at com.stardog.http.server.undertow.jaxrs.ExtractRoutes.lambda$handleIt$5(ExtractRoutes.java:192) ~[stardog-protocols-http-server-6.1.2.jar:?]
at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) [shiro-core-1.2.3.jar:1.2.3]
at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) [shiro-core-1.2.3.jar:1.2.3]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_201]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_201]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_201]
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
Conclusions:
Can we use or not variables as argument in the distance function or do we have to use IRI?
What IRI formats are supported?
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <XML Schema;
PREFIX onto: <http://www.cdpq.com/ontology#>
PREFIX wgs: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX unit: <http://qudt.org/vocab/unit#>
PREFIX : <Cannot get geof:distance calculated;
PREFIX geom: <http://www.cdpq.com/PropertyGeom/>
select ?geom1 ?lat1 ?long1 ?geom2 ?lat2 ?long2
?distance ?distanceSDdataset ?distanceCDPQdataset
from <http://cdpq.com/rcagraph_geo>
from <http://cdpq.com/rcagraph_geo_sd>
where {
{ { select * where
{?geom1 wgs:lat ?lat1; wgs:long ?long1 .
} limit 1 offset 10 }
{ select * where
{?geom2 wgs:lat ?lat2; wgs:long ?long2 .
} limit 1 offset 20 } }
union
{
{ values(?geom1) {(:geom1)}
?geom1 wgs:lat ?lat1; wgs:long ?long1 }
{ values(?geom2) {(:geom2)}
?geom2 wgs:lat ?lat2; wgs:long ?long2 }
}
optional { bind(geof:distance(?geom1, ?geom2, unit:Meter) as ?distance) }
optional { bind(geof:distance(:geom1, :geom2, unit:Meter) as ?distanceSDdataset) }
#optional { bind(geof:distance(geom:6b8ebc9f90e85ffce1d722702a132a75, geom:d2026ee617b6ca0ba19430e3eea7bee9, unit:Meter) as ?distanceCDPQdataset) }