You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by manoj deshpande <ma...@gmail.com> on 2020/04/18 10:19:05 UTC

regd : geosparql queries inside Fuseki server

I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
location. How to find out that if two polygons or two rectangles intersect
each other inside Fuseki.

I have stored geocoordinates in WKT serialization format. When I execute
below query

*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#
<http://www.w3.org/2001/XMLSchema#>>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>>
PREFIX geo: <http://www.opengis.net/ont/geosparql#
<http://www.opengis.net/ont/geosparql#>>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#
<http://www.w3.org/2001/XMLSchema#>>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#
<http://www.w3.org/2000/01/rdf-schema#>>
PREFIX : <http://example.org/# <http://example.org/#>>
PREFIX geo: <http://www.opengis.net/ont/geosparql#
<http://www.opengis.net/ont/geosparql#>>
PREFIX spatial: <http://jena.apache.org/spatial#
<http://jena.apache.org/spatial#>>
SELECT ?object
WHERE {
GRAPH <http://project/base/default <http://project/base/default>> {
    ?subject geo:asWKT ?object .
} }*

I get these below results.

object
1
"POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
48.998644821906865,8.46399486064911
48.998764483764916,8.46425771713257
48.99865538031766,8.464375734329225
48.998746886450874,8.463919758796694
48.99893693711346,8.463699817657472 48.99872928913063))"
2
"POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989
48.99847940651206,8.463560342788698 48.99847940651206))"
3
"POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
48.99849348443939,8.463646173477175
48.99849348443939,8.463646173477175
48.99835974396915,8.463447690010073 48.99835974396915))"
4
"POLYGON((8.463254570961 48.99821544463795,8.463254570961
48.99838438039854,8.463635444641115
48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961
48.99821544463795))"
5
"POLYGON((8.463689088821413 48.99826823712468,8.463689088821413
48.99845477012966,8.46402168273926 48.99845477012966,8.46402168273926
48.99826823712468,8.463689088821413 48.99826823712468))"
6
"POLYGON((8.463892936706545 48.99843013373508,8.463892936706545
48.998588510344774,8.464316725730898
48.998588510344774,8.464316725730898
48.99843013373508,8.463892936706545 48.99843013373508))"
7
"POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
48.998243600637835,8.463737368583681
48.998243600637835,8.463737368583681
48.99805354732974,8.463093638420107 48.99805354732974))"
8
"POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
48.998180249615714,8.464118242263796
48.998180249615714,8.464118242263796
48.99797963751407,8.463619351387026 48.99797963751407))"
9
"POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343
48.998303432084754,8.464407920837404 48.998303432084754))"
10
"POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
48.99839141937611,8.464820981025698
48.99839141937611,8.464820981025698
48.99806762537742,8.464225530624391 48.99806762537742))"

Then later I want to filter out these geo:WKT objects based on
geo:intersection (Intersection or equals or contains methods). And I
updated my query as below.

*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#
<http://www.w3.org/2001/XMLSchema#>>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>>
PREFIX geo: <http://www.opengis.net/ont/geosparql#
<http://www.opengis.net/ont/geosparql#>>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#
<http://www.w3.org/2001/XMLSchema#>>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#
<http://www.w3.org/2000/01/rdf-schema#>>
PREFIX : <http://example.org/# <http://example.org/#>>
PREFIX geo: <http://www.opengis.net/ont/geosparql#
<http://www.opengis.net/ont/geosparql#>>
PREFIX spatial: <http://jena.apache.org/spatial#
<http://jena.apache.org/spatial#>>
SELECT ?object
WHERE {
GRAPH <http://project/base/default <http://project/base/default>> {
    ?subject geo:asWKT ?object .
    ?object geo:equals "POLYGON((8.463699817657472
48.99872928913063,8.463887572288515
48.998644821906865,8.46399486064911
48.998764483764916,8.46425771713257
48.99865538031766,8.464375734329225
48.998746886450874,8.463919758796694
48.99893693711346,8.463699817657472 48.99872928913063))"
} } *

Which should result me atleast the coordinates of first geo object
which really equals the POLYGON coordinates but I get empty results as
shown in below image. Please suggest me where I am getting it wrong.

But I get no results as attached in snapshot. Please help me regarding this.

Re: regd : geosparql queries inside Fuseki server

Posted by Greg Albiston <ga...@mail.com>.
Sorry for the late response on this and thank you for replying. A couple
of extra points:

There is a "spatial:equals" property function and a "spatialF:equals"
filter function that should return true to the point equality that
Lorenz tested and is referred to in the Spatial Relations section of the
docs. These aren't part of the GeoSPARQL standard and are provided as
additional Jena Spatial Functions. A point not equalling itself is how
the GeoSPARQL standard describes the "geo:sfEquals" relationship.

The OP was also referring to finding the intersection so could use
"geo:sfIntersects" property function or "geof:sfIntersects" filter
function. There is a table on page 10 of the GeoSPARQL standard that
shows the mapping across the relation families. As also highlighted
previously, there are some fine details contained in pages 8-10 of the
GeoSPARQL standard that can influence the results returned and is one of
the reasons that the JTS library is utilised for relations testing.

The implemented Query Rewriting Extension of GeoSPARQL will give the
same result between property function and filter function style queries.
For example, "?lineA geo:sfEquals ?lineB" is equivalent to
"FILTER(geof:sfEquals(?lineA, ?lineB)) ".

Thanks,

Greg


On 19/04/2020 14:19, Lorenz Buehmann wrote:
> On 19.04.20 14:55, Andy Seaborne wrote:
>> The rdflib output now shows ^^ on the literals so something has
>> changed. maybe it does not print the URI the way you are printing the
>> data.
>>
>> The rdflib project prefer their questions to go to stackoverflow with
>> the tag "rdflib" but before that the URIs for functions and properties
>> need sorting out.
>>
>> GEO[] isn't provided by rdflib.
> Well, I hope and guess the TO created the namespace object before using
> it in the code via
>
> |GEO = Namespace('http://www.opengis.net/ont/geosparql#')|
>
> which is also a Python dictionary, thus, you can call
>
> |GEO['wktLiteral']|
>
> Clearly, more intended by the API would be to call
>
> |GEO.wktLiteral|
>
> but, yeah - very much off-topic.
>
>
> Regarding the equals function, I set up a sample and can say that
> equality isn't what people would probably expect, i.e. even
>
> |PREFIX geo: <http://www.opengis.net/ont/geosparql#>||
> ||PREFIX geof: <http://www.opengis.net/def/function/geosparql/>||
> ||PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>||
> ||PREFIX ex: <http://example.org/>||
> ||SELECT *||
> ||WHERE {||
> ||  BIND((geof:sfEquals("POINT(-0.0754 51.5055)"^^geo:wktLiteral,
> "POINT(-0.0754 51.5055)"^^geo:wktLiteral)) as ?equals)||
> ||  BIND((geof:distance("POINT(-0.0754 51.5055)"^^geo:wktLiteral,
> "POINT(-0.0754 51.5055)"^^geo:wktLiteral, uom:metre)) as ?dist)||
> ||}|
>
> returns (unexpectedly?) "false" although being the same geometry object
> and a (expected) distance of 0.0e0. The implementation is using JTS and
> according to the docs:
>
>> The three equals relations (/sfEquals/, /ehEquals/ and /rccEquals/)
>> use spatial equality and not lexical equality. Therefore, some
>> comparisons using these relations may not be as expected.
>>
>> The JTS description of /sfEquals/ is:
>>
>>    * True if two geometries have at least one point in common and no
>>      point of either geometry lies in the exterior of the other geometry.
>>
>> Therefore, two empty geometries will return false as they are not
>> spatially equal. Shapes which differ in the number of points but have
>> the same geometry are equal and will return true.
>>
>> e.g. |LINESTRING (0 0, 0 10)| and |LINESTRING (0 0, 0 5, 0 10)| are
>> spatially equal.
>>
> so, I doubt using equals is a useful test here. Nevertheless, GeoSPARQL
> itself is working as expected, I tried several common queries. As long
> as you have the correct data loaded ...
>
>
> Lorenz
>
>
>>      Andy
>>
>> On 19/04/2020 12:44, Lorenz Buehmann wrote:
>>> why are you asking about Python based rdflib code on this mailing list?
>>> I mean, it's a totally different API. And what is the purpose of the
>>> code?
>>>
>>> honestly, you should start with a minimal example. Load a sample of RDF
>>> triples with the correct datatype, then try the queries. You should also
>>> check again about GeoSPARQL.
>>>
>>> Also, in the specs the URI is geo:sfEquals for the propertyand
>>> geof:sfEquals to use it as a function. Where did you read about the
>>> usage of the URI geo:equals ?
>>>
>>>
>>> And as Andy already pointed out, the literal that you use for matching
>>> also needs the datatype.
>>>
>>> On 18.04.20 18:47, manoj deshpande wrote:
>>>> I am trying to convert "POLYGON(())" wkt value from string to
>>>> "wktLiteral"
>>>> as suggested above in below code (python rdflib).
>>>>
>>>> if name == "wkt":
>>>>       self._graph.add((image, GEO["asWKT"], rl.Literal(value,
>>>> datatype=GEO["wktLiteral"])))
>>>>
>>>>
>>>>    Is it right method ?
>>>>
>>>> As I see below values when I execute query. The wktliteral value is
>>>> not appended in the end.
>>>>
>>>>
>>>> "POLYGON((8.461714982986452 48.997849415191105,8.461714982986452
>>>> 48.99797963751407,8.461988568305971
>>>> 48.99797963751407,8.461988568305971
>>>> 48.997849415191105,8.461714982986452 48.997849415191105))"^^
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Manoj
>>>>
>>>>
>>>> On Sat, Apr 18, 2020 at 3:47 PM Andy Seaborne <an...@apache.org> wrote:
>>>>
>>>>> The literal need to have a datatype
>>>>>
>>>>> "POLYGON((...))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>
>>>>>
>>>>> judging by your first message, they are strings.
>>>>>
>>>>>        Andy
>>>>>
>>>>> On 18/04/2020 13:03, manoj deshpande wrote:
>>>>>> I tried below query as per suggestion, But this also returns me no
>>>>> results.
>>>>>> Is the query is right ??
>>>>>>
>>>>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>>>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>>>> PREFIX : <http://example.org/#>
>>>>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>>>>> PREFIX spatial: <http://jena.apache.org/spatial#>
>>>>>> SELECT ?object
>>>>>> WHERE {
>>>>>> GRAPH <http://project/base/default> {
>>>>>>        ?subject geo:asWKT ?object FILTER ( geo:equals(?object,
>>>>>> "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
>>>>>> 48.998644821906865,8.46399486064911
>>>>>> 48.998764483764916,8.46425771713257
>>>>>> 48.99865538031766,8.464375734329225
>>>>>> 48.998746886450874,8.463919758796694
>>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))"))
>>>>>> } }
>>>>>>
>>>>>>
>>>>>> *Results*
>>>>>>
>>>>>> {
>>>>>>      "head": {
>>>>>>        "vars": [ "object" ]
>>>>>>      } ,
>>>>>>      "results": {
>>>>>>        "bindings": [
>>>>>>
>>>>>>        ]
>>>>>>      }
>>>>>> }
>>>>>>
>>>>>> Thanks & Regards
>>>>>> Manoj
>>>>>>
>>>>>> On Sat, Apr 18, 2020 at 12:27 PM Lorenz Buehmann <
>>>>>> buehmann@informatik.uni-leipzig.de> wrote:
>>>>>>
>>>>>>> geo:equals is a filter function and not a property function. This
>>>>>>> means
>>>>>>> it returns a boolean value, thus, you have to use it in a FILTER
>>>>>>>
>>>>>>> (untested)
>>>>>>>
>>>>>>> FILTER(geo:equals(?object,
>>>>>>>                                  "POLYGON((8.463699817657472
>>>>>>> 48.99872928913063,8.463887572288515
>>>>>>> 48.998644821906865,8.46399486064911
>>>>>>> 48.998764483764916,8.46425771713257
>>>>>>> 48.99865538031766,8.464375734329225
>>>>>>> 48.998746886450874,8.463919758796694
>>>>>>> 48.99893693711346,8.463699817657472
>>>>>>> 48.99872928913063))"
>>>>>>>                                  )
>>>>>>>               )
>>>>>>>
>>>>>>>
>>>>>>> On 18.04.20 12:19, manoj deshpande wrote:
>>>>>>>> I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
>>>>>>>> location. How to find out that if two polygons or two rectangles
>>>>>>>> intersect each other inside Fuseki.
>>>>>>>>
>>>>>>>> I have stored geocoordinates in WKT serialization format. When I
>>>>>>>> execute below query
>>>>>>>>
>>>>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>>>>> <http://example.org/#> PREFIX geo:
>>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>>>>> <http://project/base/default> { ?subject geo:asWKT ?object . }
>>>>>>>> }*|||
>>>>>>>> I get these below results.
>>>>>>>> |object 1 "POLYGON((8.463699817657472
>>>>>>>> 48.99872928913063,8.463887572288515
>>>>>>>> 48.998644821906865,8.46399486064911
>>>>>>>> 48.998764483764916,8.46425771713257
>>>>>>>> 48.99865538031766,8.464375734329225
>>>>>>>> 48.998746886450874,8.463919758796694
>>>>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" 2
>>>>>>>> "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
>>>>>>>> 48.99864834137738,8.46377491950989
>>>>>>>> 48.99864834137738,8.46377491950989
>>>>>>>> 48.99847940651206,8.463560342788698 48.99847940651206))" 3
>>>>>>>> "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
>>>>>>>> 48.99849348443939,8.463646173477175
>>>>>>>> 48.99849348443939,8.463646173477175
>>>>>>>> 48.99835974396915,8.463447690010073 48.99835974396915))" 4
>>>>>>>> "POLYGON((8.463254570961 48.99821544463795,8.463254570961
>>>>>>>> 48.99838438039854,8.463635444641115
>>>>>>>> 48.99838438039854,8.463635444641115
>>>>>>>> 48.99821544463795,8.463254570961
>>>>>>>> 48.99821544463795))" 5 "POLYGON((8.463689088821413
>>>>>>>> 48.99826823712468,8.463689088821413
>>>>>>>> 48.99845477012966,8.46402168273926
>>>>>>>> 48.99845477012966,8.46402168273926
>>>>>>>> 48.99826823712468,8.463689088821413
>>>>>>>> 48.99826823712468))" 6 "POLYGON((8.463892936706545
>>>>>>>> 48.99843013373508,8.463892936706545
>>>>>>>> 48.998588510344774,8.464316725730898
>>>>>>>> 48.998588510344774,8.464316725730898
>>>>>>>> 48.99843013373508,8.463892936706545 48.99843013373508))" 7
>>>>>>>> "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
>>>>>>>> 48.998243600637835,8.463737368583681
>>>>>>>> 48.998243600637835,8.463737368583681
>>>>>>>> 48.99805354732974,8.463093638420107 48.99805354732974))" 8
>>>>>>>> "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
>>>>>>>> 48.998180249615714,8.464118242263796
>>>>>>>> 48.998180249615714,8.464118242263796
>>>>>>>> 48.99797963751407,8.463619351387026 48.99797963751407))" 9
>>>>>>>> "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
>>>>>>>> 48.99857443244431,8.46477270126343
>>>>>>>> 48.99857443244431,8.46477270126343
>>>>>>>> 48.998303432084754,8.464407920837404 48.998303432084754))" 10
>>>>>>>> "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
>>>>>>>> 48.99839141937611,8.464820981025698
>>>>>>>> 48.99839141937611,8.464820981025698
>>>>>>>> 48.99806762537742,8.464225530624391 48.99806762537742))"|
>>>>>>>> |Then later I want to filter out these geo:WKT objects based on
>>>>>>>> geo:intersection (Intersection or equals or contains methods).
>>>>>>>> And I
>>>>>>>> updated my query as below. |
>>>>>>>> |
>>>>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>>>>> <http://example.org/#> PREFIX geo:
>>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>>>>> <http://project/base/default> { ?subject geo:asWKT ?object .
>>>>>>>> ?object
>>>>>>>> geo:equals "POLYGON((8.463699817657472
>>>>>>>> 48.99872928913063,8.463887572288515
>>>>>>>> 48.998644821906865,8.46399486064911
>>>>>>>> 48.998764483764916,8.46425771713257
>>>>>>>> 48.99865538031766,8.464375734329225
>>>>>>>> 48.998746886450874,8.463919758796694
>>>>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
>>>>>>>> |Which should result me atleast the coordinates of first geo object
>>>>>>>> which really equals the POLYGON coordinates but I get empty
>>>>>>>> results as
>>>>>>>> shown in below image. Please suggest me where I am getting it
>>>>>>>> wrong.**|
>>>>>>>> But I get no results as attached in snapshot. Please help me
>>>>>>>> regarding
>>>>>>> this.|
>>>>>>>

Re: regd : geosparql queries inside Fuseki server

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
On 19.04.20 14:55, Andy Seaborne wrote:
> The rdflib output now shows ^^ on the literals so something has
> changed. maybe it does not print the URI the way you are printing the
> data.
>
> The rdflib project prefer their questions to go to stackoverflow with
> the tag "rdflib" but before that the URIs for functions and properties
> need sorting out.
>
> GEO[] isn't provided by rdflib.

Well, I hope and guess the TO created the namespace object before using
it in the code via

|GEO = Namespace('http://www.opengis.net/ont/geosparql#')|

which is also a Python dictionary, thus, you can call

|GEO['wktLiteral']|

Clearly, more intended by the API would be to call

|GEO.wktLiteral|

but, yeah - very much off-topic.


Regarding the equals function, I set up a sample and can say that
equality isn't what people would probably expect, i.e. even

|PREFIX geo: <http://www.opengis.net/ont/geosparql#>||
||PREFIX geof: <http://www.opengis.net/def/function/geosparql/>||
||PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>||
||PREFIX ex: <http://example.org/>||
||SELECT *||
||WHERE {||
||  BIND((geof:sfEquals("POINT(-0.0754 51.5055)"^^geo:wktLiteral,
"POINT(-0.0754 51.5055)"^^geo:wktLiteral)) as ?equals)||
||  BIND((geof:distance("POINT(-0.0754 51.5055)"^^geo:wktLiteral,
"POINT(-0.0754 51.5055)"^^geo:wktLiteral, uom:metre)) as ?dist)||
||}|

returns (unexpectedly?) "false" although being the same geometry object
and a (expected) distance of 0.0e0. The implementation is using JTS and
according to the docs:

> The three equals relations (/sfEquals/, /ehEquals/ and /rccEquals/)
> use spatial equality and not lexical equality. Therefore, some
> comparisons using these relations may not be as expected.
>
> The JTS description of /sfEquals/ is:
>
>   * True if two geometries have at least one point in common and no
>     point of either geometry lies in the exterior of the other geometry.
>
> Therefore, two empty geometries will return false as they are not
> spatially equal. Shapes which differ in the number of points but have
> the same geometry are equal and will return true.
>
> e.g. |LINESTRING (0 0, 0 10)| and |LINESTRING (0 0, 0 5, 0 10)| are
> spatially equal.
>
so, I doubt using equals is a useful test here. Nevertheless, GeoSPARQL
itself is working as expected, I tried several common queries. As long
as you have the correct data loaded ...


Lorenz


>
>     Andy
>
> On 19/04/2020 12:44, Lorenz Buehmann wrote:
>> why are you asking about Python based rdflib code on this mailing list?
>> I mean, it's a totally different API. And what is the purpose of the
>> code?
>>
>> honestly, you should start with a minimal example. Load a sample of RDF
>> triples with the correct datatype, then try the queries. You should also
>> check again about GeoSPARQL.
>>
>> Also, in the specs the URI is geo:sfEquals for the propertyand
>> geof:sfEquals to use it as a function. Where did you read about the
>> usage of the URI geo:equals ?
>>
>>
>> And as Andy already pointed out, the literal that you use for matching
>> also needs the datatype.
>>
>> On 18.04.20 18:47, manoj deshpande wrote:
>>> I am trying to convert "POLYGON(())" wkt value from string to
>>> "wktLiteral"
>>> as suggested above in below code (python rdflib).
>>>
>>> if name == "wkt":
>>>      self._graph.add((image, GEO["asWKT"], rl.Literal(value,
>>> datatype=GEO["wktLiteral"])))
>>>
>>>
>>>   Is it right method ?
>>>
>>> As I see below values when I execute query. The wktliteral value is
>>> not appended in the end.
>>>
>>>
>>> "POLYGON((8.461714982986452 48.997849415191105,8.461714982986452
>>> 48.99797963751407,8.461988568305971
>>> 48.99797963751407,8.461988568305971
>>> 48.997849415191105,8.461714982986452 48.997849415191105))"^^
>>>
>>>
>>> Thanks,
>>>
>>> Manoj
>>>
>>>
>>> On Sat, Apr 18, 2020 at 3:47 PM Andy Seaborne <an...@apache.org> wrote:
>>>
>>>> The literal need to have a datatype
>>>>
>>>> "POLYGON((...))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>
>>>>
>>>> judging by your first message, they are strings.
>>>>
>>>>       Andy
>>>>
>>>> On 18/04/2020 13:03, manoj deshpande wrote:
>>>>> I tried below query as per suggestion, But this also returns me no
>>>> results.
>>>>> Is the query is right ??
>>>>>
>>>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>>> PREFIX : <http://example.org/#>
>>>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>>>> PREFIX spatial: <http://jena.apache.org/spatial#>
>>>>> SELECT ?object
>>>>> WHERE {
>>>>> GRAPH <http://project/base/default> {
>>>>>       ?subject geo:asWKT ?object FILTER ( geo:equals(?object,
>>>>> "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
>>>>> 48.998644821906865,8.46399486064911
>>>>> 48.998764483764916,8.46425771713257
>>>>> 48.99865538031766,8.464375734329225
>>>>> 48.998746886450874,8.463919758796694
>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))"))
>>>>> } }
>>>>>
>>>>>
>>>>> *Results*
>>>>>
>>>>> {
>>>>>     "head": {
>>>>>       "vars": [ "object" ]
>>>>>     } ,
>>>>>     "results": {
>>>>>       "bindings": [
>>>>>
>>>>>       ]
>>>>>     }
>>>>> }
>>>>>
>>>>> Thanks & Regards
>>>>> Manoj
>>>>>
>>>>> On Sat, Apr 18, 2020 at 12:27 PM Lorenz Buehmann <
>>>>> buehmann@informatik.uni-leipzig.de> wrote:
>>>>>
>>>>>> geo:equals is a filter function and not a property function. This
>>>>>> means
>>>>>> it returns a boolean value, thus, you have to use it in a FILTER
>>>>>>
>>>>>> (untested)
>>>>>>
>>>>>> FILTER(geo:equals(?object,
>>>>>>                                 "POLYGON((8.463699817657472
>>>>>> 48.99872928913063,8.463887572288515
>>>>>> 48.998644821906865,8.46399486064911
>>>>>> 48.998764483764916,8.46425771713257
>>>>>> 48.99865538031766,8.464375734329225
>>>>>> 48.998746886450874,8.463919758796694
>>>>>> 48.99893693711346,8.463699817657472
>>>>>> 48.99872928913063))"
>>>>>>                                 )
>>>>>>              )
>>>>>>
>>>>>>
>>>>>> On 18.04.20 12:19, manoj deshpande wrote:
>>>>>>> I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
>>>>>>> location. How to find out that if two polygons or two rectangles
>>>>>>> intersect each other inside Fuseki.
>>>>>>>
>>>>>>> I have stored geocoordinates in WKT serialization format. When I
>>>>>>> execute below query
>>>>>>>
>>>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>>>> <http://example.org/#> PREFIX geo:
>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>>>> <http://project/base/default> { ?subject geo:asWKT ?object . }
>>>>>>> }*|||
>>>>>>> I get these below results.
>>>>>>> |object 1 "POLYGON((8.463699817657472
>>>>>>> 48.99872928913063,8.463887572288515
>>>>>>> 48.998644821906865,8.46399486064911
>>>>>>> 48.998764483764916,8.46425771713257
>>>>>>> 48.99865538031766,8.464375734329225
>>>>>>> 48.998746886450874,8.463919758796694
>>>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" 2
>>>>>>> "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
>>>>>>> 48.99864834137738,8.46377491950989
>>>>>>> 48.99864834137738,8.46377491950989
>>>>>>> 48.99847940651206,8.463560342788698 48.99847940651206))" 3
>>>>>>> "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
>>>>>>> 48.99849348443939,8.463646173477175
>>>>>>> 48.99849348443939,8.463646173477175
>>>>>>> 48.99835974396915,8.463447690010073 48.99835974396915))" 4
>>>>>>> "POLYGON((8.463254570961 48.99821544463795,8.463254570961
>>>>>>> 48.99838438039854,8.463635444641115
>>>>>>> 48.99838438039854,8.463635444641115
>>>>>>> 48.99821544463795,8.463254570961
>>>>>>> 48.99821544463795))" 5 "POLYGON((8.463689088821413
>>>>>>> 48.99826823712468,8.463689088821413
>>>>>>> 48.99845477012966,8.46402168273926
>>>>>>> 48.99845477012966,8.46402168273926
>>>>>>> 48.99826823712468,8.463689088821413
>>>>>>> 48.99826823712468))" 6 "POLYGON((8.463892936706545
>>>>>>> 48.99843013373508,8.463892936706545
>>>>>>> 48.998588510344774,8.464316725730898
>>>>>>> 48.998588510344774,8.464316725730898
>>>>>>> 48.99843013373508,8.463892936706545 48.99843013373508))" 7
>>>>>>> "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
>>>>>>> 48.998243600637835,8.463737368583681
>>>>>>> 48.998243600637835,8.463737368583681
>>>>>>> 48.99805354732974,8.463093638420107 48.99805354732974))" 8
>>>>>>> "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
>>>>>>> 48.998180249615714,8.464118242263796
>>>>>>> 48.998180249615714,8.464118242263796
>>>>>>> 48.99797963751407,8.463619351387026 48.99797963751407))" 9
>>>>>>> "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
>>>>>>> 48.99857443244431,8.46477270126343
>>>>>>> 48.99857443244431,8.46477270126343
>>>>>>> 48.998303432084754,8.464407920837404 48.998303432084754))" 10
>>>>>>> "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
>>>>>>> 48.99839141937611,8.464820981025698
>>>>>>> 48.99839141937611,8.464820981025698
>>>>>>> 48.99806762537742,8.464225530624391 48.99806762537742))"|
>>>>>>> |Then later I want to filter out these geo:WKT objects based on
>>>>>>> geo:intersection (Intersection or equals or contains methods).
>>>>>>> And I
>>>>>>> updated my query as below. |
>>>>>>> |
>>>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>>>> <http://example.org/#> PREFIX geo:
>>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>>>> <http://project/base/default> { ?subject geo:asWKT ?object .
>>>>>>> ?object
>>>>>>> geo:equals "POLYGON((8.463699817657472
>>>>>>> 48.99872928913063,8.463887572288515
>>>>>>> 48.998644821906865,8.46399486064911
>>>>>>> 48.998764483764916,8.46425771713257
>>>>>>> 48.99865538031766,8.464375734329225
>>>>>>> 48.998746886450874,8.463919758796694
>>>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
>>>>>>> |Which should result me atleast the coordinates of first geo object
>>>>>>> which really equals the POLYGON coordinates but I get empty
>>>>>>> results as
>>>>>>> shown in below image. Please suggest me where I am getting it
>>>>>>> wrong.**|
>>>>>>> But I get no results as attached in snapshot. Please help me
>>>>>>> regarding
>>>>>> this.|
>>>>>>
>>

Re: regd : geosparql queries inside Fuseki server

Posted by Andy Seaborne <an...@apache.org>.
The rdflib output now shows ^^ on the literals so something has changed. 
maybe it does not print the URI the way you are printing the data.

The rdflib project prefer their questions to go to stackoverflow with 
the tag "rdflib" but before that the URIs for functions and properties 
need sorting out.

GEO[] isn't provided by rdflib.

     Andy

On 19/04/2020 12:44, Lorenz Buehmann wrote:
> why are you asking about Python based rdflib code on this mailing list?
> I mean, it's a totally different API. And what is the purpose of the code?
> 
> honestly, you should start with a minimal example. Load a sample of RDF
> triples with the correct datatype, then try the queries. You should also
> check again about GeoSPARQL.
> 
> Also, in the specs the URI is geo:sfEquals for the propertyand
> geof:sfEquals to use it as a function. Where did you read about the
> usage of the URI geo:equals ?
> 
> 
> And as Andy already pointed out, the literal that you use for matching
> also needs the datatype.
> 
> On 18.04.20 18:47, manoj deshpande wrote:
>> I am trying to convert "POLYGON(())" wkt value from string to "wktLiteral"
>> as suggested above in below code (python rdflib).
>>
>> if name == "wkt":
>>      self._graph.add((image, GEO["asWKT"], rl.Literal(value,
>> datatype=GEO["wktLiteral"])))
>>
>>
>>   Is it right method ?
>>
>> As I see below values when I execute query. The wktliteral value is
>> not appended in the end.
>>
>>
>> "POLYGON((8.461714982986452 48.997849415191105,8.461714982986452
>> 48.99797963751407,8.461988568305971
>> 48.99797963751407,8.461988568305971
>> 48.997849415191105,8.461714982986452 48.997849415191105))"^^
>>
>>
>> Thanks,
>>
>> Manoj
>>
>>
>> On Sat, Apr 18, 2020 at 3:47 PM Andy Seaborne <an...@apache.org> wrote:
>>
>>> The literal need to have a datatype
>>>
>>> "POLYGON((...))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>
>>>
>>> judging by your first message, they are strings.
>>>
>>>       Andy
>>>
>>> On 18/04/2020 13:03, manoj deshpande wrote:
>>>> I tried below query as per suggestion, But this also returns me no
>>> results.
>>>> Is the query is right ??
>>>>
>>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>>> PREFIX : <http://example.org/#>
>>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>>> PREFIX spatial: <http://jena.apache.org/spatial#>
>>>> SELECT ?object
>>>> WHERE {
>>>> GRAPH <http://project/base/default> {
>>>>       ?subject geo:asWKT ?object FILTER ( geo:equals(?object,
>>>> "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
>>>> 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257
>>>> 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694
>>>> 48.99893693711346,8.463699817657472 48.99872928913063))"))
>>>> } }
>>>>
>>>>
>>>> *Results*
>>>>
>>>> {
>>>>     "head": {
>>>>       "vars": [ "object" ]
>>>>     } ,
>>>>     "results": {
>>>>       "bindings": [
>>>>
>>>>       ]
>>>>     }
>>>> }
>>>>
>>>> Thanks & Regards
>>>> Manoj
>>>>
>>>> On Sat, Apr 18, 2020 at 12:27 PM Lorenz Buehmann <
>>>> buehmann@informatik.uni-leipzig.de> wrote:
>>>>
>>>>> geo:equals is a filter function and not a property function. This means
>>>>> it returns a boolean value, thus, you have to use it in a FILTER
>>>>>
>>>>> (untested)
>>>>>
>>>>> FILTER(geo:equals(?object,
>>>>>                                 "POLYGON((8.463699817657472
>>>>> 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911
>>>>> 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225
>>>>> 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472
>>>>> 48.99872928913063))"
>>>>>                                 )
>>>>>              )
>>>>>
>>>>>
>>>>> On 18.04.20 12:19, manoj deshpande wrote:
>>>>>> I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
>>>>>> location. How to find out that if two polygons or two rectangles
>>>>>> intersect each other inside Fuseki.
>>>>>>
>>>>>> I have stored geocoordinates in WKT serialization format. When I
>>>>>> execute below query
>>>>>>
>>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>>> <http://example.org/#> PREFIX geo:
>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>>> <http://project/base/default> { ?subject geo:asWKT ?object . } }*|||
>>>>>> I get these below results.
>>>>>> |object 1 "POLYGON((8.463699817657472
>>>>>> 48.99872928913063,8.463887572288515
>>>>>> 48.998644821906865,8.46399486064911
>>>>>> 48.998764483764916,8.46425771713257
>>>>>> 48.99865538031766,8.464375734329225
>>>>>> 48.998746886450874,8.463919758796694
>>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" 2
>>>>>> "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
>>>>>> 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989
>>>>>> 48.99847940651206,8.463560342788698 48.99847940651206))" 3
>>>>>> "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
>>>>>> 48.99849348443939,8.463646173477175
>>>>>> 48.99849348443939,8.463646173477175
>>>>>> 48.99835974396915,8.463447690010073 48.99835974396915))" 4
>>>>>> "POLYGON((8.463254570961 48.99821544463795,8.463254570961
>>>>>> 48.99838438039854,8.463635444641115
>>>>>> 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961
>>>>>> 48.99821544463795))" 5 "POLYGON((8.463689088821413
>>>>>> 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926
>>>>>> 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413
>>>>>> 48.99826823712468))" 6 "POLYGON((8.463892936706545
>>>>>> 48.99843013373508,8.463892936706545
>>>>>> 48.998588510344774,8.464316725730898
>>>>>> 48.998588510344774,8.464316725730898
>>>>>> 48.99843013373508,8.463892936706545 48.99843013373508))" 7
>>>>>> "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
>>>>>> 48.998243600637835,8.463737368583681
>>>>>> 48.998243600637835,8.463737368583681
>>>>>> 48.99805354732974,8.463093638420107 48.99805354732974))" 8
>>>>>> "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
>>>>>> 48.998180249615714,8.464118242263796
>>>>>> 48.998180249615714,8.464118242263796
>>>>>> 48.99797963751407,8.463619351387026 48.99797963751407))" 9
>>>>>> "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
>>>>>> 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343
>>>>>> 48.998303432084754,8.464407920837404 48.998303432084754))" 10
>>>>>> "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
>>>>>> 48.99839141937611,8.464820981025698
>>>>>> 48.99839141937611,8.464820981025698
>>>>>> 48.99806762537742,8.464225530624391 48.99806762537742))"|
>>>>>> |Then later I want to filter out these geo:WKT objects based on
>>>>>> geo:intersection (Intersection or equals or contains methods). And I
>>>>>> updated my query as below. |
>>>>>> |
>>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>>> <http://example.org/#> PREFIX geo:
>>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>>> <http://project/base/default> { ?subject geo:asWKT ?object . ?object
>>>>>> geo:equals "POLYGON((8.463699817657472
>>>>>> 48.99872928913063,8.463887572288515
>>>>>> 48.998644821906865,8.46399486064911
>>>>>> 48.998764483764916,8.46425771713257
>>>>>> 48.99865538031766,8.464375734329225
>>>>>> 48.998746886450874,8.463919758796694
>>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
>>>>>> |Which should result me atleast the coordinates of first geo object
>>>>>> which really equals the POLYGON coordinates but I get empty results as
>>>>>> shown in below image. Please suggest me where I am getting it wrong.**|
>>>>>> But I get no results as attached in snapshot. Please help me regarding
>>>>> this.|
>>>>>
> 

Re: regd : geosparql queries inside Fuseki server

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
why are you asking about Python based rdflib code on this mailing list?
I mean, it's a totally different API. And what is the purpose of the code?

honestly, you should start with a minimal example. Load a sample of RDF
triples with the correct datatype, then try the queries. You should also
check again about GeoSPARQL.

Also, in the specs the URI is geo:sfEquals for the propertyand
geof:sfEquals to use it as a function. Where did you read about the
usage of the URI geo:equals ?


And as Andy already pointed out, the literal that you use for matching
also needs the datatype.

On 18.04.20 18:47, manoj deshpande wrote:
> I am trying to convert "POLYGON(())" wkt value from string to "wktLiteral"
> as suggested above in below code (python rdflib).
>
> if name == "wkt":
>     self._graph.add((image, GEO["asWKT"], rl.Literal(value,
> datatype=GEO["wktLiteral"])))
>
>
>  Is it right method ?
>
> As I see below values when I execute query. The wktliteral value is
> not appended in the end.
>
>
> "POLYGON((8.461714982986452 48.997849415191105,8.461714982986452
> 48.99797963751407,8.461988568305971
> 48.99797963751407,8.461988568305971
> 48.997849415191105,8.461714982986452 48.997849415191105))"^^
>
>
> Thanks,
>
> Manoj
>
>
> On Sat, Apr 18, 2020 at 3:47 PM Andy Seaborne <an...@apache.org> wrote:
>
>> The literal need to have a datatype
>>
>> "POLYGON((...))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>
>>
>> judging by your first message, they are strings.
>>
>>      Andy
>>
>> On 18/04/2020 13:03, manoj deshpande wrote:
>>> I tried below query as per suggestion, But this also returns me no
>> results.
>>> Is the query is right ??
>>>
>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
>>> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
>>> PREFIX : <http://example.org/#>
>>> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
>>> PREFIX spatial: <http://jena.apache.org/spatial#>
>>> SELECT ?object
>>> WHERE {
>>> GRAPH <http://project/base/default> {
>>>      ?subject geo:asWKT ?object FILTER ( geo:equals(?object,
>>> "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
>>> 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257
>>> 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694
>>> 48.99893693711346,8.463699817657472 48.99872928913063))"))
>>> } }
>>>
>>>
>>> *Results*
>>>
>>> {
>>>    "head": {
>>>      "vars": [ "object" ]
>>>    } ,
>>>    "results": {
>>>      "bindings": [
>>>
>>>      ]
>>>    }
>>> }
>>>
>>> Thanks & Regards
>>> Manoj
>>>
>>> On Sat, Apr 18, 2020 at 12:27 PM Lorenz Buehmann <
>>> buehmann@informatik.uni-leipzig.de> wrote:
>>>
>>>> geo:equals is a filter function and not a property function. This means
>>>> it returns a boolean value, thus, you have to use it in a FILTER
>>>>
>>>> (untested)
>>>>
>>>> FILTER(geo:equals(?object,
>>>>                                "POLYGON((8.463699817657472
>>>> 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911
>>>> 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225
>>>> 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472
>>>> 48.99872928913063))"
>>>>                                )
>>>>             )
>>>>
>>>>
>>>> On 18.04.20 12:19, manoj deshpande wrote:
>>>>> I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
>>>>> location. How to find out that if two polygons or two rectangles
>>>>> intersect each other inside Fuseki.
>>>>>
>>>>> I have stored geocoordinates in WKT serialization format. When I
>>>>> execute below query
>>>>>
>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>> <http://example.org/#> PREFIX geo:
>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>> <http://project/base/default> { ?subject geo:asWKT ?object . } }*|||
>>>>> I get these below results.
>>>>> |object 1 "POLYGON((8.463699817657472
>>>>> 48.99872928913063,8.463887572288515
>>>>> 48.998644821906865,8.46399486064911
>>>>> 48.998764483764916,8.46425771713257
>>>>> 48.99865538031766,8.464375734329225
>>>>> 48.998746886450874,8.463919758796694
>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" 2
>>>>> "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
>>>>> 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989
>>>>> 48.99847940651206,8.463560342788698 48.99847940651206))" 3
>>>>> "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
>>>>> 48.99849348443939,8.463646173477175
>>>>> 48.99849348443939,8.463646173477175
>>>>> 48.99835974396915,8.463447690010073 48.99835974396915))" 4
>>>>> "POLYGON((8.463254570961 48.99821544463795,8.463254570961
>>>>> 48.99838438039854,8.463635444641115
>>>>> 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961
>>>>> 48.99821544463795))" 5 "POLYGON((8.463689088821413
>>>>> 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926
>>>>> 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413
>>>>> 48.99826823712468))" 6 "POLYGON((8.463892936706545
>>>>> 48.99843013373508,8.463892936706545
>>>>> 48.998588510344774,8.464316725730898
>>>>> 48.998588510344774,8.464316725730898
>>>>> 48.99843013373508,8.463892936706545 48.99843013373508))" 7
>>>>> "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
>>>>> 48.998243600637835,8.463737368583681
>>>>> 48.998243600637835,8.463737368583681
>>>>> 48.99805354732974,8.463093638420107 48.99805354732974))" 8
>>>>> "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
>>>>> 48.998180249615714,8.464118242263796
>>>>> 48.998180249615714,8.464118242263796
>>>>> 48.99797963751407,8.463619351387026 48.99797963751407))" 9
>>>>> "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
>>>>> 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343
>>>>> 48.998303432084754,8.464407920837404 48.998303432084754))" 10
>>>>> "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
>>>>> 48.99839141937611,8.464820981025698
>>>>> 48.99839141937611,8.464820981025698
>>>>> 48.99806762537742,8.464225530624391 48.99806762537742))"|
>>>>> |Then later I want to filter out these geo:WKT objects based on
>>>>> geo:intersection (Intersection or equals or contains methods). And I
>>>>> updated my query as below. |
>>>>> |
>>>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>>>> <http://example.org/#> PREFIX geo:
>>>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>>>> <http://project/base/default> { ?subject geo:asWKT ?object . ?object
>>>>> geo:equals "POLYGON((8.463699817657472
>>>>> 48.99872928913063,8.463887572288515
>>>>> 48.998644821906865,8.46399486064911
>>>>> 48.998764483764916,8.46425771713257
>>>>> 48.99865538031766,8.464375734329225
>>>>> 48.998746886450874,8.463919758796694
>>>>> 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
>>>>> |Which should result me atleast the coordinates of first geo object
>>>>> which really equals the POLYGON coordinates but I get empty results as
>>>>> shown in below image. Please suggest me where I am getting it wrong.**|
>>>>> But I get no results as attached in snapshot. Please help me regarding
>>>> this.|
>>>>

Re: regd : geosparql queries inside Fuseki server

Posted by manoj deshpande <ma...@gmail.com>.
I am trying to convert "POLYGON(())" wkt value from string to "wktLiteral"
as suggested above in below code (python rdflib).

if name == "wkt":
    self._graph.add((image, GEO["asWKT"], rl.Literal(value,
datatype=GEO["wktLiteral"])))


 Is it right method ?

As I see below values when I execute query. The wktliteral value is
not appended in the end.


"POLYGON((8.461714982986452 48.997849415191105,8.461714982986452
48.99797963751407,8.461988568305971
48.99797963751407,8.461988568305971
48.997849415191105,8.461714982986452 48.997849415191105))"^^


Thanks,

Manoj


On Sat, Apr 18, 2020 at 3:47 PM Andy Seaborne <an...@apache.org> wrote:

> The literal need to have a datatype
>
> "POLYGON((...))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>
>
> judging by your first message, they are strings.
>
>      Andy
>
> On 18/04/2020 13:03, manoj deshpande wrote:
> > I tried below query as per suggestion, But this also returns me no
> results.
> > Is the query is right ??
> >
> > PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> > PREFIX geo: <http://www.opengis.net/ont/geosparql#>
> > PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> > PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> > PREFIX : <http://example.org/#>
> > PREFIX geo: <http://www.opengis.net/ont/geosparql#>
> > PREFIX spatial: <http://jena.apache.org/spatial#>
> > SELECT ?object
> > WHERE {
> > GRAPH <http://project/base/default> {
> >      ?subject geo:asWKT ?object FILTER ( geo:equals(?object,
> > "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
> > 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257
> > 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694
> > 48.99893693711346,8.463699817657472 48.99872928913063))"))
> > } }
> >
> >
> > *Results*
> >
> > {
> >    "head": {
> >      "vars": [ "object" ]
> >    } ,
> >    "results": {
> >      "bindings": [
> >
> >      ]
> >    }
> > }
> >
> > Thanks & Regards
> > Manoj
> >
> > On Sat, Apr 18, 2020 at 12:27 PM Lorenz Buehmann <
> > buehmann@informatik.uni-leipzig.de> wrote:
> >
> >> geo:equals is a filter function and not a property function. This means
> >> it returns a boolean value, thus, you have to use it in a FILTER
> >>
> >> (untested)
> >>
> >> FILTER(geo:equals(?object,
> >>                                "POLYGON((8.463699817657472
> >> 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911
> >> 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225
> >> 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472
> >> 48.99872928913063))"
> >>                                )
> >>             )
> >>
> >>
> >> On 18.04.20 12:19, manoj deshpande wrote:
> >>> I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
> >>> location. How to find out that if two polygons or two rectangles
> >>> intersect each other inside Fuseki.
> >>>
> >>> I have stored geocoordinates in WKT serialization format. When I
> >>> execute below query
> >>>
> >>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
> >>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
> >>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
> >>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
> >>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
> >>> <http://example.org/#> PREFIX geo:
> >>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
> >>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
> >>> <http://project/base/default> { ?subject geo:asWKT ?object . } }*|||
> >>> I get these below results.
> >>> |object 1 "POLYGON((8.463699817657472
> >>> 48.99872928913063,8.463887572288515
> >>> 48.998644821906865,8.46399486064911
> >>> 48.998764483764916,8.46425771713257
> >>> 48.99865538031766,8.464375734329225
> >>> 48.998746886450874,8.463919758796694
> >>> 48.99893693711346,8.463699817657472 48.99872928913063))" 2
> >>> "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
> >>> 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989
> >>> 48.99847940651206,8.463560342788698 48.99847940651206))" 3
> >>> "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
> >>> 48.99849348443939,8.463646173477175
> >>> 48.99849348443939,8.463646173477175
> >>> 48.99835974396915,8.463447690010073 48.99835974396915))" 4
> >>> "POLYGON((8.463254570961 48.99821544463795,8.463254570961
> >>> 48.99838438039854,8.463635444641115
> >>> 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961
> >>> 48.99821544463795))" 5 "POLYGON((8.463689088821413
> >>> 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926
> >>> 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413
> >>> 48.99826823712468))" 6 "POLYGON((8.463892936706545
> >>> 48.99843013373508,8.463892936706545
> >>> 48.998588510344774,8.464316725730898
> >>> 48.998588510344774,8.464316725730898
> >>> 48.99843013373508,8.463892936706545 48.99843013373508))" 7
> >>> "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
> >>> 48.998243600637835,8.463737368583681
> >>> 48.998243600637835,8.463737368583681
> >>> 48.99805354732974,8.463093638420107 48.99805354732974))" 8
> >>> "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
> >>> 48.998180249615714,8.464118242263796
> >>> 48.998180249615714,8.464118242263796
> >>> 48.99797963751407,8.463619351387026 48.99797963751407))" 9
> >>> "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
> >>> 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343
> >>> 48.998303432084754,8.464407920837404 48.998303432084754))" 10
> >>> "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
> >>> 48.99839141937611,8.464820981025698
> >>> 48.99839141937611,8.464820981025698
> >>> 48.99806762537742,8.464225530624391 48.99806762537742))"|
> >>> |Then later I want to filter out these geo:WKT objects based on
> >>> geo:intersection (Intersection or equals or contains methods). And I
> >>> updated my query as below. |
> >>> |
> >>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
> >>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
> >>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
> >>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
> >>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
> >>> <http://example.org/#> PREFIX geo:
> >>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
> >>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
> >>> <http://project/base/default> { ?subject geo:asWKT ?object . ?object
> >>> geo:equals "POLYGON((8.463699817657472
> >>> 48.99872928913063,8.463887572288515
> >>> 48.998644821906865,8.46399486064911
> >>> 48.998764483764916,8.46425771713257
> >>> 48.99865538031766,8.464375734329225
> >>> 48.998746886450874,8.463919758796694
> >>> 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
> >>> |Which should result me atleast the coordinates of first geo object
> >>> which really equals the POLYGON coordinates but I get empty results as
> >>> shown in below image. Please suggest me where I am getting it wrong.**|
> >>> But I get no results as attached in snapshot. Please help me regarding
> >> this.|
> >>
> >
>

Re: regd : geosparql queries inside Fuseki server

Posted by Andy Seaborne <an...@apache.org>.
The literal need to have a datatype

"POLYGON((...))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>

judging by your first message, they are strings.

     Andy

On 18/04/2020 13:03, manoj deshpande wrote:
> I tried below query as per suggestion, But this also returns me no results.
> Is the query is right ??
> 
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
> PREFIX : <http://example.org/#>
> PREFIX geo: <http://www.opengis.net/ont/geosparql#>
> PREFIX spatial: <http://jena.apache.org/spatial#>
> SELECT ?object
> WHERE {
> GRAPH <http://project/base/default> {
>      ?subject geo:asWKT ?object FILTER ( geo:equals(?object,
> "POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
> 48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257
> 48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694
> 48.99893693711346,8.463699817657472 48.99872928913063))"))
> } }
> 
> 
> *Results*
> 
> {
>    "head": {
>      "vars": [ "object" ]
>    } ,
>    "results": {
>      "bindings": [
> 
>      ]
>    }
> }
> 
> Thanks & Regards
> Manoj
> 
> On Sat, Apr 18, 2020 at 12:27 PM Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
> 
>> geo:equals is a filter function and not a property function. This means
>> it returns a boolean value, thus, you have to use it in a FILTER
>>
>> (untested)
>>
>> FILTER(geo:equals(?object,
>>                                "POLYGON((8.463699817657472
>> 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911
>> 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225
>> 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472
>> 48.99872928913063))"
>>                                )
>>             )
>>
>>
>> On 18.04.20 12:19, manoj deshpande wrote:
>>> I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
>>> location. How to find out that if two polygons or two rectangles
>>> intersect each other inside Fuseki.
>>>
>>> I have stored geocoordinates in WKT serialization format. When I
>>> execute below query
>>>
>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>> <http://example.org/#> PREFIX geo:
>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>> <http://project/base/default> { ?subject geo:asWKT ?object . } }*|||
>>> I get these below results.
>>> |object 1 "POLYGON((8.463699817657472
>>> 48.99872928913063,8.463887572288515
>>> 48.998644821906865,8.46399486064911
>>> 48.998764483764916,8.46425771713257
>>> 48.99865538031766,8.464375734329225
>>> 48.998746886450874,8.463919758796694
>>> 48.99893693711346,8.463699817657472 48.99872928913063))" 2
>>> "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
>>> 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989
>>> 48.99847940651206,8.463560342788698 48.99847940651206))" 3
>>> "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
>>> 48.99849348443939,8.463646173477175
>>> 48.99849348443939,8.463646173477175
>>> 48.99835974396915,8.463447690010073 48.99835974396915))" 4
>>> "POLYGON((8.463254570961 48.99821544463795,8.463254570961
>>> 48.99838438039854,8.463635444641115
>>> 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961
>>> 48.99821544463795))" 5 "POLYGON((8.463689088821413
>>> 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926
>>> 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413
>>> 48.99826823712468))" 6 "POLYGON((8.463892936706545
>>> 48.99843013373508,8.463892936706545
>>> 48.998588510344774,8.464316725730898
>>> 48.998588510344774,8.464316725730898
>>> 48.99843013373508,8.463892936706545 48.99843013373508))" 7
>>> "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
>>> 48.998243600637835,8.463737368583681
>>> 48.998243600637835,8.463737368583681
>>> 48.99805354732974,8.463093638420107 48.99805354732974))" 8
>>> "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
>>> 48.998180249615714,8.464118242263796
>>> 48.998180249615714,8.464118242263796
>>> 48.99797963751407,8.463619351387026 48.99797963751407))" 9
>>> "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
>>> 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343
>>> 48.998303432084754,8.464407920837404 48.998303432084754))" 10
>>> "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
>>> 48.99839141937611,8.464820981025698
>>> 48.99839141937611,8.464820981025698
>>> 48.99806762537742,8.464225530624391 48.99806762537742))"|
>>> |Then later I want to filter out these geo:WKT objects based on
>>> geo:intersection (Intersection or equals or contains methods). And I
>>> updated my query as below. |
>>> |
>>> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
>>> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
>>> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
>>> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
>>> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
>>> <http://example.org/#> PREFIX geo:
>>> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
>>> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
>>> <http://project/base/default> { ?subject geo:asWKT ?object . ?object
>>> geo:equals "POLYGON((8.463699817657472
>>> 48.99872928913063,8.463887572288515
>>> 48.998644821906865,8.46399486064911
>>> 48.998764483764916,8.46425771713257
>>> 48.99865538031766,8.464375734329225
>>> 48.998746886450874,8.463919758796694
>>> 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
>>> |Which should result me atleast the coordinates of first geo object
>>> which really equals the POLYGON coordinates but I get empty results as
>>> shown in below image. Please suggest me where I am getting it wrong.**|
>>> But I get no results as attached in snapshot. Please help me regarding
>> this.|
>>
> 

Re: regd : geosparql queries inside Fuseki server

Posted by manoj deshpande <ma...@gmail.com>.
I tried below query as per suggestion, But this also returns me no results.
Is the query is right ??

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example.org/#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX spatial: <http://jena.apache.org/spatial#>
SELECT ?object
WHERE {
GRAPH <http://project/base/default> {
    ?subject geo:asWKT ?object FILTER ( geo:equals(?object,
"POLYGON((8.463699817657472 48.99872928913063,8.463887572288515
48.998644821906865,8.46399486064911 48.998764483764916,8.46425771713257
48.99865538031766,8.464375734329225 48.998746886450874,8.463919758796694
48.99893693711346,8.463699817657472 48.99872928913063))"))
} }


*Results*

{
  "head": {
    "vars": [ "object" ]
  } ,
  "results": {
    "bindings": [

    ]
  }
}

Thanks & Regards
Manoj

On Sat, Apr 18, 2020 at 12:27 PM Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:

> geo:equals is a filter function and not a property function. This means
> it returns a boolean value, thus, you have to use it in a FILTER
>
> (untested)
>
> FILTER(geo:equals(?object,
>                               "POLYGON((8.463699817657472
> 48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911
> 48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225
> 48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472
> 48.99872928913063))"
>                               )
>            )
>
>
> On 18.04.20 12:19, manoj deshpande wrote:
> > I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
> > location. How to find out that if two polygons or two rectangles
> > intersect each other inside Fuseki.
> >
> > I have stored geocoordinates in WKT serialization format. When I
> > execute below query
> >
> > |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
> > <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
> > <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
> > <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
> > <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
> > <http://example.org/#> PREFIX geo:
> > <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
> > <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
> > <http://project/base/default> { ?subject geo:asWKT ?object . } }*|||
> > I get these below results.
> > |object 1 "POLYGON((8.463699817657472
> > 48.99872928913063,8.463887572288515
> > 48.998644821906865,8.46399486064911
> > 48.998764483764916,8.46425771713257
> > 48.99865538031766,8.464375734329225
> > 48.998746886450874,8.463919758796694
> > 48.99893693711346,8.463699817657472 48.99872928913063))" 2
> > "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
> > 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989
> > 48.99847940651206,8.463560342788698 48.99847940651206))" 3
> > "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
> > 48.99849348443939,8.463646173477175
> > 48.99849348443939,8.463646173477175
> > 48.99835974396915,8.463447690010073 48.99835974396915))" 4
> > "POLYGON((8.463254570961 48.99821544463795,8.463254570961
> > 48.99838438039854,8.463635444641115
> > 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961
> > 48.99821544463795))" 5 "POLYGON((8.463689088821413
> > 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926
> > 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413
> > 48.99826823712468))" 6 "POLYGON((8.463892936706545
> > 48.99843013373508,8.463892936706545
> > 48.998588510344774,8.464316725730898
> > 48.998588510344774,8.464316725730898
> > 48.99843013373508,8.463892936706545 48.99843013373508))" 7
> > "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
> > 48.998243600637835,8.463737368583681
> > 48.998243600637835,8.463737368583681
> > 48.99805354732974,8.463093638420107 48.99805354732974))" 8
> > "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
> > 48.998180249615714,8.464118242263796
> > 48.998180249615714,8.464118242263796
> > 48.99797963751407,8.463619351387026 48.99797963751407))" 9
> > "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
> > 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343
> > 48.998303432084754,8.464407920837404 48.998303432084754))" 10
> > "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
> > 48.99839141937611,8.464820981025698
> > 48.99839141937611,8.464820981025698
> > 48.99806762537742,8.464225530624391 48.99806762537742))"|
> > |Then later I want to filter out these geo:WKT objects based on
> > geo:intersection (Intersection or equals or contains methods). And I
> > updated my query as below. |
> > |
> > |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
> > <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
> > <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
> > <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
> > <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
> > <http://example.org/#> PREFIX geo:
> > <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
> > <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
> > <http://project/base/default> { ?subject geo:asWKT ?object . ?object
> > geo:equals "POLYGON((8.463699817657472
> > 48.99872928913063,8.463887572288515
> > 48.998644821906865,8.46399486064911
> > 48.998764483764916,8.46425771713257
> > 48.99865538031766,8.464375734329225
> > 48.998746886450874,8.463919758796694
> > 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
> > |Which should result me atleast the coordinates of first geo object
> > which really equals the POLYGON coordinates but I get empty results as
> > shown in below image. Please suggest me where I am getting it wrong.**|
> > But I get no results as attached in snapshot. Please help me regarding
> this.|
>

Re: regd : geosparql queries inside Fuseki server

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
geo:equals is a filter function and not a property function. This means
it returns a boolean value, thus, you have to use it in a FILTER

(untested)

FILTER(geo:equals(?object,
                              "POLYGON((8.463699817657472
48.99872928913063,8.463887572288515 48.998644821906865,8.46399486064911
48.998764483764916,8.46425771713257 48.99865538031766,8.464375734329225
48.998746886450874,8.463919758796694 48.99893693711346,8.463699817657472
48.99872928913063))"
                              )
           )


On 18.04.20 12:19, manoj deshpande wrote:
> I am using Apache Jena Fuseki Server for Storing Geo Coordinates of
> location. How to find out that if two polygons or two rectangles
> intersect each other inside Fuseki.
>
> I have stored geocoordinates in WKT serialization format. When I
> execute below query
>
> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
> <http://example.org/#> PREFIX geo:
> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
> <http://project/base/default> { ?subject geo:asWKT ?object . } }*|||
> I get these below results.
> |object 1 "POLYGON((8.463699817657472
> 48.99872928913063,8.463887572288515
> 48.998644821906865,8.46399486064911
> 48.998764483764916,8.46425771713257
> 48.99865538031766,8.464375734329225
> 48.998746886450874,8.463919758796694
> 48.99893693711346,8.463699817657472 48.99872928913063))" 2
> "POLYGON((8.463560342788698 48.99847940651206,8.463560342788698
> 48.99864834137738,8.46377491950989 48.99864834137738,8.46377491950989
> 48.99847940651206,8.463560342788698 48.99847940651206))" 3
> "POLYGON((8.463447690010073 48.99835974396915,8.463447690010073
> 48.99849348443939,8.463646173477175
> 48.99849348443939,8.463646173477175
> 48.99835974396915,8.463447690010073 48.99835974396915))" 4
> "POLYGON((8.463254570961 48.99821544463795,8.463254570961
> 48.99838438039854,8.463635444641115
> 48.99838438039854,8.463635444641115 48.99821544463795,8.463254570961
> 48.99821544463795))" 5 "POLYGON((8.463689088821413
> 48.99826823712468,8.463689088821413 48.99845477012966,8.46402168273926
> 48.99845477012966,8.46402168273926 48.99826823712468,8.463689088821413
> 48.99826823712468))" 6 "POLYGON((8.463892936706545
> 48.99843013373508,8.463892936706545
> 48.998588510344774,8.464316725730898
> 48.998588510344774,8.464316725730898
> 48.99843013373508,8.463892936706545 48.99843013373508))" 7
> "POLYGON((8.463093638420107 48.99805354732974,8.463093638420107
> 48.998243600637835,8.463737368583681
> 48.998243600637835,8.463737368583681
> 48.99805354732974,8.463093638420107 48.99805354732974))" 8
> "POLYGON((8.463619351387026 48.99797963751407,8.463619351387026
> 48.998180249615714,8.464118242263796
> 48.998180249615714,8.464118242263796
> 48.99797963751407,8.463619351387026 48.99797963751407))" 9
> "POLYGON((8.464407920837404 48.998303432084754,8.464407920837404
> 48.99857443244431,8.46477270126343 48.99857443244431,8.46477270126343
> 48.998303432084754,8.464407920837404 48.998303432084754))" 10
> "POLYGON((8.464225530624391 48.99806762537742,8.464225530624391
> 48.99839141937611,8.464820981025698
> 48.99839141937611,8.464820981025698
> 48.99806762537742,8.464225530624391 48.99806762537742))"|
> |Then later I want to filter out these geo:WKT objects based on
> geo:intersection (Intersection or equals or contains methods). And I
> updated my query as below. |
> |
> |*PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdf:
> <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX geo:
> <http://www.opengis.net/ont/geosparql#> PREFIX xsd:
> <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs:
> <http://www.w3.org/2000/01/rdf-schema#> PREFIX :
> <http://example.org/#> PREFIX geo:
> <http://www.opengis.net/ont/geosparql#> PREFIX spatial:
> <http://jena.apache.org/spatial#> SELECT ?object WHERE { GRAPH
> <http://project/base/default> { ?subject geo:asWKT ?object . ?object
> geo:equals "POLYGON((8.463699817657472
> 48.99872928913063,8.463887572288515
> 48.998644821906865,8.46399486064911
> 48.998764483764916,8.46425771713257
> 48.99865538031766,8.464375734329225
> 48.998746886450874,8.463919758796694
> 48.99893693711346,8.463699817657472 48.99872928913063))" } } *|
> |Which should result me atleast the coordinates of first geo object
> which really equals the POLYGON coordinates but I get empty results as
> shown in below image. Please suggest me where I am getting it wrong.**|
> But I get no results as attached in snapshot. Please help me regarding this.|