You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Florian Beckh <fb...@gmail.com> on 2015/06/27 23:37:12 UTC
Spatial SPARSQL - query with variable positions in Jena
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 :)
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Andy Seaborne <an...@apache.org>.
On 02/07/15 12:02, Florian Beckh wrote:
> Hallo Andy,
>
> Thanks again for your response,
>
> I would like to have a model for:
>
> 1. an event handling; like this
> https://jena.apache.org/documentation/notes/event-handler-howto.html
Getting the DatasetGraph and using it would DatasetGraphMonitor will
give you a hook for events. DatasetGraphMonitor will make a call out in
each quad operation. When combined with SPARQL Update, that can be a lot!
This part of the DatasetGraph stack isn't very well worked out yet and
has not been check with spatial datasets as far as I know.
> 2. and concurrent acces to the model, like this
> https://jena.apache.org/documentation/notes/concurrency-howto.html
Datasets have a loc so you can use that lock but using transactions is
better (if they are supported).
Andy
>
> So what are the best practices for these features in combination with
> spatial datasets?
>
> Regards,
>
> Florian
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Florian Beckh <fb...@gmail.com>.
Hallo Andy,
Thanks again for your response,
I would like to have a model for:
1. an event handling; like this
https://jena.apache.org/documentation/notes/event-handler-howto.html
2. and concurrent acces to the model, like this
https://jena.apache.org/documentation/notes/concurrency-howto.html
So what are the best practices for these features in combination with
spatial datasets?
Regards,
Florian
Am 02.07.2015 um 12:52 schrieb Andy Seaborne:
> On 01/07/15 19:56, Florian Beckh wrote:
>> Hallo Andy,
>>
>> sorry for my inaccurate response, I found my error! :) It added the
>> current apache snapshot repository to my maven pom.xml, that solved the
>> problem. Thanks for the evidence and your time.
>>
>> I have another small issue, if I convert the dataset with the method
>> /getDefaultModel/() and use the model for the query; the spatial
>> restrictions, part of the query, are ignored. I get no errors or
>> exceptions. So how do I convert a spatial dataset to a model?
>>
>> Regards,
>>
>> Florian
>>
>
> SPARQL queries operate on datasets. It looks like if you take a model
> view but then query only the view, it's put in another temporary
> dataset and the spatial property functions will not be activated.
>
> Is there reason for using getDefaultModel or can you query the spatial
> dataset itself instead?
>
> Andy
>
>> Am 30.06.2015 um 19:11 schrieb Andy Seaborne:
>>> On 30/06/15 17:02, Florian Beckh wrote:
>>>> Thanks for reply andy,
>>>>
>>>> I tried your min. code example. It did not work. what version of the
>>>> dependencies do you use?
>>>
>>> When you say "does not work" do you mean no results or an expection?
>>>
>>> I was using current jena development head whihc might be close to the
>>> 3.0.0-SNAPSHOT you used. When did you resolve that dependency last?
>>>
>>> What is your development OS and environment?
>>>
>>> Andy
>>>
>>>>
>>>> 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 :)
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Andy Seaborne <an...@apache.org>.
On 01/07/15 19:56, Florian Beckh wrote:
> Hallo Andy,
>
> sorry for my inaccurate response, I found my error! :) It added the
> current apache snapshot repository to my maven pom.xml, that solved the
> problem. Thanks for the evidence and your time.
>
> I have another small issue, if I convert the dataset with the method
> /getDefaultModel/() and use the model for the query; the spatial
> restrictions, part of the query, are ignored. I get no errors or
> exceptions. So how do I convert a spatial dataset to a model?
>
> Regards,
>
> Florian
>
SPARQL queries operate on datasets. It looks like if you take a model
view but then query only the view, it's put in another temporary dataset
and the spatial property functions will not be activated.
Is there reason for using getDefaultModel or can you query the spatial
dataset itself instead?
Andy
> Am 30.06.2015 um 19:11 schrieb Andy Seaborne:
>> On 30/06/15 17:02, Florian Beckh wrote:
>>> Thanks for reply andy,
>>>
>>> I tried your min. code example. It did not work. what version of the
>>> dependencies do you use?
>>
>> When you say "does not work" do you mean no results or an expection?
>>
>> I was using current jena development head whihc might be close to the
>> 3.0.0-SNAPSHOT you used. When did you resolve that dependency last?
>>
>> What is your development OS and environment?
>>
>> Andy
>>
>>>
>>> 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 :)
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Florian Beckh <fb...@gmail.com>.
Hallo Andy,
sorry for my inaccurate response, I found my error! :) It added the
current apache snapshot repository to my maven pom.xml, that solved the
problem. Thanks for the evidence and your time.
I have another small issue, if I convert the dataset with the method
/getDefaultModel/() and use the model for the query; the spatial
restrictions, part of the query, are ignored. I get no errors or
exceptions. So how do I convert a spatial dataset to a model?
Regards,
Florian
Am 30.06.2015 um 19:11 schrieb Andy Seaborne:
> On 30/06/15 17:02, Florian Beckh wrote:
>> Thanks for reply andy,
>>
>> I tried your min. code example. It did not work. what version of the
>> dependencies do you use?
>
> When you say "does not work" do you mean no results or an expection?
>
> I was using current jena development head whihc might be close to the
> 3.0.0-SNAPSHOT you used. When did you resolve that dependency last?
>
> What is your development OS and environment?
>
> Andy
>
>>
>> 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 :)
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Andy Seaborne <an...@apache.org>.
On 30/06/15 17:02, Florian Beckh wrote:
> Thanks for reply andy,
>
> I tried your min. code example. It did not work. what version of the
> dependencies do you use?
When you say "does not work" do you mean no results or an expection?
I was using current jena development head whihc might be close to the
3.0.0-SNAPSHOT you used. When did you resolve that dependency last?
What is your development OS and environment?
Andy
>
> 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 :)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Florian Beckh <fb...@gmail.com>.
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 :)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Andy Seaborne <an...@apache.org>.
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 :)
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Florian Beckh <fb...@gmail.com>.
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 :)
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Andy Seaborne <an...@apache.org>.
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 :)
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Florian Beckh <fb...@gmail.com>.
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 :)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Yang Yuanzhe <ya...@proxml.be>.
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 :)
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Florian Beckh <fb...@gmail.com>.
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 :)
>>
>>
>>
>>
>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Andy Seaborne <an...@apache.org>.
On 27/06/15 22: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
Documentation (in staging) has now been fixed
Andy
>
>
>
> 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 :)
>>
>>
>>
>>
>>
>>
>
Re: Spatial SPARSQL - query with variable positions in Jena
Posted by Yang Yuanzhe <ya...@proxml.be>.
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 :)
>
>
>
>
>
>