Thanks for reply andy,

I tried your min. code example. It did not work. what version of the dependencies do you use?

regards,

Florian

Am 30.06.2015 um 16:33 schrieb Andy Seaborne:
In your query you have:

   ?place rdfs:label?placeName

and there is not rdf:label in your data.

When I correct that, and spatial:query => spatial:nearby,
I tried this:

https://gist.github.com/afs/5f3b040abc87b14cf68d

which outputs a results.

    Andy

On 30/06/15 09:12, Florian Beckh wrote:
Hallo Andy,
*
**in the beginning I created the dataset:*

private Dataset createInitDataSet() {
         Dataset newDataset = DatasetFactory.createMem();
         EntityDefinition entDef = new EntityDefinition("entityField",
"geoField");

         Directory dir = new RAMDirectory();
         Dataset spatialDataset =
SpatialDatasetFactory.createLucene(newDataset, dir, entDef);

         //DatasetGraph graph = spatialDataset.asDatasetGraph();
         return spatialDataset;
}

btw how do I convert a spatial dataset to a model? If I use
getDefaultModel() I cannot do spatial queries any longer and get the
following error messages:

09:59:28 WARN  SpatialOperationWithCircleBase :: Failed to find the
spatial index : tried context and as a spatial-enabled dataset
09:59:28 WARN  IsNearByPF                :: No text index - no text
search performed
*
**To update the data I used this function: *

public void trySPARSQLUpdateStatement(String currentQueryString) throws
ARQException {
     this.dataset.begin(ReadWrite.WRITE);
     UpdateAction.parseExecute(currentQueryString, this.dataset);
     this.dataset.commit();
     this.dataset.end();
}
*
**To select the data I used: *

public ResultSet trySPARSQLSelectStatement(String currentQueryString) {
         ResultSet results;
         Query query = QueryFactory.create(currentQueryString);
         QueryExecution qe;

         this.dataset.begin(ReadWrite.READ);

         qe = QueryExecutionFactory.create(query, dataset);

         results =  qe.execSelect();
         results = ResultSetFactory.copyResults(results) ;
         qe.close();
         this.dataset.end();
         return results;
}
*
**Here are my maven dep. : *

<dependency>
       <groupId>org.apache.jena</groupId>
       <artifactId>apache-jena-libs</artifactId>
       <version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
       <groupId>org.apache.jena</groupId>
       <artifactId>jena-spatial</artifactId>
       <version>3.0.0-SNAPSHOT</version>
</dependency>

All taken from this source
https://github.com/apache/jena/tree/master/jena-spatial

Regards,

Florian




On 29.06.2015 23:17, Andy Seaborne wrote:
Florian,

Do you have a complete, minimal example?

It seems the details matter, such as how the spatial dataset is
created, how the data is loaded (so did the spatial index chnage when
you executed that INSERT DATA?), how the query is executed.

A short program as a complete, minimal example would make all this clear.

And which version of the software are you using?

    Andy

On 29/06/15 19:47, Florian Beckh wrote:
Thanks again for your response,

I have the following insert query:

prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix person: <http://example.org/person#>

INSERT DATA {
     person:testPerson1 person:name "Max Muster" .
     person:testPerson1 geo:lat 51.46 .
     person:testPerson1 geo:long 2.6 .
}

If I execute the Spatial-Query, I get the following error (and the
result is empty):

"WARN  SpatialOperationWithCircleBase :: Latitude is not a literal
[?lat, ?long, "10"^^http://www.w3.org/2001/XMLSchema#integer, "km"]"

Regards,

Florian


On 28.06.2015 01:14, Yang Yuanzhe wrote:
Hi Florian,

Then I get confused. I tried your second query and it works fine for
me. Did you get any error message?

Regards,
Yang

On 06/28/2015 12:13 AM, Florian Beckh wrote:
Hello Yang,

thanks for your quick answer, I did this already and it worked with
fixed values in the query. But how can I make  such a query with
long. and lat. from a source (e.g. long. and lat. from a person), not
fixed numbers?

Regards,
Florian

On 27.06.2015 23:55, Yang Yuanzhe wrote:

Hi Florian,

Can you please try spatial:nearby instead of spatial:query? I think
the example code is out of date.

Regards,
Yang



On 06/27/2015 11:37 PM, Florian Beckh wrote:
Hello everyone,


I'm currenty trying to generate a query with jena spatial
(https://jena.apache.org/documentation/query/spatial-query.html)

|PREFIX spatial: <http://jena.apache.org/spatial#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

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

The example shows a fixed lat/lon to work with. I want to query a
variable position given by some position values (e.g of a person):

|PREFIX spatial: <http://jena.apache.org/spatial#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX person:  <http://example.org/person#>

SELECT  ?placeName
{
    ?person geo:lat?lat.
    ?person geo:long?long.      ?place spatial:query(?lat?long10
'km')  .
    ?place rdfs:label?placeName
    FILTER(?person=  person:testPerson1)  }|

The second statement does not work and is only an indicator to what
i mean.

The question is: how can I do that?


Ty., greetings :)















Reply via email to