# Geo Spatcial query return Eval Query -1 Error

**URL:** <https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581>\
**Category:** Support\
**Created:** [April 8, 2019, 2:44pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581 "2019-04-08T14:44:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![serge](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/serge/32/376_2.png) [@serge](https://community.stardog.com/u/serge)\
**Post date:** [April 8, 2019, 2:44pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/1 "2019-04-08T14:44:33Z")

</div>

In the near future, I will need to perform geo spatial queries, therefore I decided to follow the thread # [Cannot get geof:distance calculated](https://community.stardog.com/t/cannot-get-geof-distance-calculated/1576) closely and see how it works on my side.

Unfortunately I do not get to even run the query provided

```
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
PREFIX wgs: &lt;http://www.w3.org/2003/01/geo/wgs84_pos#&gt;
PREFIX geo: &lt;http://www.opengis.net/ont/geosparql#&gt;
PREFIX geof: &lt;http://www.opengis.net/def/function/geosparql/&gt;
PREFIX unit: &lt;http://qudt.org/vocab/unit#&gt;

select ?distance
where {
BIND(geof:distance(
  &lt;http://topology/location/geo/TOROON07HAS&gt;,
  &lt;http://topology/location/geo/TOROON09HAL&gt;,
  unit:Meter) as ?distance)
}

```

and the logs are not very helpful in helping figuring out what the issue is.

```
ERROR 2019-04-08 10:37:05,437 [stardog-user-1] 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(Unknown Source) ~[?: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(Unknown Source) [?:1.8.0_201]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_201]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at com.complexible.stardog.plan.eval.operator.impl.LeanSolutionImpl.get(LeanSolutionImpl.java:89) ~[stardog-6.1.2.jar:?]
	at com.complexible.stardog.spatial.db.query.DistancePropertyFunction$DistanceOperator.getPoint(DistancePropertyFunction.java:310) ~[stardog-spatial-core-6.1.2.jar:?]
	at com.complexible.stardog.spatial.db.query.DistancePropertyFunction$DistanceOperator.computeNext(DistancePropertyFunction.java:289) ~[stardog-spatial-core-6.1.2.jar:?]
	at com.complexible.stardog.spatial.db.query.DistancePropertyFunction$DistanceOperator.computeNext(DistancePropertyFunction.java:231) ~[stardog-spatial-core-6.1.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:82) ~[stardog-6.1.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.impl.SingleProjectionOp.computeNext(SingleProjectionOp.java:29) ~[stardog-6.1.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:112) ~[stardog-6.1.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.AutoCloseOperator.computeNext(AutoCloseOperator.java:25) ~[stardog-6.1.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.tryToComputeNext(AbstractSkippingIterator.java:143) ~[stardog-utils-common-6.1.2.jar:?]
	at com.complexible.common.collect.AbstractSkippingIterator.hasNext(AbstractSkippingIterator.java:130) ~[stardog-utils-common-6.1.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:116) ~[stardog-6.1.2.jar:?]
	at com.complexible.stardog.plan.eval.operator.util.OpBasedBindingSetIteration.computeNext(OpBasedBindingSetIteration.java:39) ~[stardog-6.1.2.jar:?]
	at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141) ~[guava-26.0-jre.jar:?]
	at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136) ~[guava-26.0-jre.jar:?]
	at com.complexible.common.rdf.query.IteratorAsTupleQueryResult.hasNext(IteratorAsTupleQueryResult.java:78) ~[stardog-utils-rdf-6.1.2.jar:?]
	... 15 more

```

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 8, 2019, 4:49pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/2 "2019-04-08T16:49:18Z")

</div>

Can you share the data over which you're running this query? At least for those two Geometries?

---

<div class="post-metadata">

**Author:** ![serge](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/serge/32/376_2.png) [@serge](https://community.stardog.com/u/serge)\
**Post date:** [April 8, 2019, 5:15pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/3 "2019-04-08T17:15:46Z")

</div>

Sure no problem, this data is public

[export.ttl.zip](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/1X/8b09182affc1569e252f757371c1ab0dbe0880fc.zip) (386.7 KB)

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 8, 2019, 7:20pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/4 "2019-04-08T19:20:48Z")

</div>

Serge,

I am unable to reproduce this issue. If I spin up a fresh db on 6.1.2 with `spatial.enabled=true` and your data, I can run the query and get a distance of 4.9280619501054325E3.

Are you running this query federated in some way? Are you using CLI or Studio? Basically anything you might be doing that I'm not thinking to do?

---

<div class="post-metadata">

**Author:** ![serge](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/serge/32/376_2.png) [@serge](https://community.stardog.com/u/serge)\
**Post date:** [April 9, 2019, 12:26pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/5 "2019-04-09T12:26:44Z")

</div>

I did nothing special, but just in case I started from scratch

- I deleted the installation
- reinstall,
- created topology database with spatial.enabled=true
- loaded data
- ran via studio

But just tried with CLI and I get same result. I also tried loading it in a different database and I get the same issue. I will try to load it on another computer to see if the problem persist.

---

<div class="post-metadata">

**Author:** ![serge](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/serge/32/376_2.png) [@serge](https://community.stardog.com/u/serge)\
**Post date:** [April 11, 2019, 1:31pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/6 "2019-04-11T13:31:16Z")

</div>

OK, thanks to @dlbis post [Cannot get geof:distance calculated - #15 by dlbis](https://community.stardog.com/t/cannot-get-geof-distance-calculated/1576/15) I have figure it out how to reproduce.

Create a table in a relational database (CSV may work) with 3 columns

- name
- long
- lat

Create a SMS2 definition to load the data into a database. Then run query and voila Query Eval -1.

As mentioned I got the idea from @dlbis. If I export and import the data (which should be the same) in a different database (on the same installation) the query will work. So this confirm that the spatial index do not get setup properly when loaded with a specific syntax .

---

<div class="post-metadata">

**Author:** ![serge](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/serge/32/376_2.png) [@serge](https://community.stardog.com/u/serge)\
**Post date:** [April 11, 2019, 3:16pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/7 "2019-04-11T15:16:19Z")

</div>

@stephen I believe that this is a bug, should we create something in the Bug forum to track? What's the process?

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 11, 2019, 3:20pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/8 "2019-04-11T15:20:22Z")

</div>

It wouldn't need to be a thread in the Bug forum; this thread is fine. What I basically need is a reliable way to reproduce the issue, since I keep having the unfortunate situation of my spatial index just working 🙂

Edit: I haven't yet been able to try your process from a couple hours ago, but can you clarify a little bit with the mappings and such?

---

<div class="post-metadata">

**Author:** ![serge](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/serge/32/376_2.png) [@serge](https://community.stardog.com/u/serge)\
**Post date:** [April 11, 2019, 3:57pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/9 "2019-04-11T15:57:14Z")

</div>

If you grab the data from the dataset I gave you and create a relational like data source. IE Table 'LOCATION' with 3 column (name, lat, long)

Then you create a mapping SMS2 file

```
MAPPING <urn:building>
FROM SQL {
    SELECT NAME, LAT, LONG
    FROM LOCATION
}

TO {
    ?geoiri a geo:Geometry ;
    wgs:lat "?COORDINATEX"^^xsd:float ;
    wgs:long "?COORDINATEY"^^xsd:float .
}
WHERE {  
    BIND(template("http://mytest/geo/{NAME}") as ?geoiri)
}

```

Then if you run the query provided before you will get an Query Eval -1. If you export and reload and run the query again it will work proving the data and query is fine.

Let me know if you need more info.

---

<div class="post-metadata">

**Author:** ![serge](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/serge/32/376_2.png) [@serge](https://community.stardog.com/u/serge)\
**Post date:** [April 17, 2019, 12:40pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/10 "2019-04-17T12:40:45Z")

</div>

Hi just following up to see if you guys were able to reproduce the issue with the step given.

Thx

---

<div class="post-metadata">

**Author:** ![stephen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/stephen/32/27_2.png) [@stephen](https://community.stardog.com/u/stephen)\
**Post date:** [April 17, 2019, 12:50pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/11 "2019-04-17T12:50:39Z")

</div>

Yes, I was able to reproduce this issue using `virtual import`. We're continuing to look into what's going on

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [May 1, 2019, 1:02pm UTC](https://community.stardog.com/t/geo-spatcial-query-return-eval-query-1-error/1581/12 "2019-05-01T13:02:33Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
