opengeospatial / ogc-geosparql

Public Repository for the OGC GeoSPARQL Standards Working Group
78 stars 20 forks source link

Use 2D coordinate for an orthogonal plane #435

Closed steven-bioinfo closed 1 year ago

steven-bioinfo commented 1 year ago

Hello,

I want to run a geosparql query on an orthogonal plane. But I've seen that by default the coordinates are in WGS84 format (latitude/longitude). Is it possible to change this?

For example with this request :

PREFIX units: http://www.opengis.net/def/uom/OGC/1.0/
PREFIX spatial: http://jena.apache.org/spatial#
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#

SELECT ?nearbyObject ?label
WHERE {
  ?nearbyObject spatial:nearby (0 0 1) ;
                rdfs:label ?label ;
}

I want to have all point with coordinate between 0,0 and 1,1. With default WGS84 format I have only point at one kilometer.

Another problem with WGS84 coordinates: In my plan, I can have coordinates > 180. In my plan, points at +180° are not close to points at -180°.

Thanks, Regards,

Steven

situx commented 1 year ago

Hello Steven,

you can define geocoordinates in any coordinate reference system supported in an EPSG registry. To do so, you must add its respective URI at the start of the WKT literal.

Example: "POINT(1 2)"^^geo:wktLiteral has no coordinate system defined and defaults as you say to WGS84 "http://www.opengis.net/def/crs/EPSG/0/4326 Point(2 1)"^^geo:wktLiteral Whereas in this case, the 4326 in the URI stands for the EPSG:4326 coordinate reference system.

Of course, the support of more coordinate reference systems needs to be implemented in the triple store you are using. The last benchmark we know of did not show this for every triple store: https://doi.org/10.3390/ijgi10070487 However, as some time has passed, this might have changed until now.

steven-bioinfo commented 1 year ago

I use geosparql on a jena-fuseki server.

So if I understand well your reply I can declare values like this:

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix geo: <http://www.opengis.net/ont/geosparql#>.
@prefix ex: <http://example.org/>.

# Define the objects
ex:Point1 rdf:type geo:Feature ;
          rdfs:label "Point 1" ;
          geo:asWKT "http://www.opengis.net/def/crs/EPSG/0/3857 POINT(0 0)"^^geo:wktLiteral .

ex:Point2 rdf:type geo:Feature ;
          rdfs:label "Point 2" ;
          geo:asWKT "http://www.opengis.net/def/crs/EPSG/0/3857 POINT(1 1)"^^geo:wktLiteral .

ex:Point3 rdf:type geo:Feature ;
          rdfs:label "Point 3" ;
          geo:asWKT "http://www.opengis.net/def/crs/EPSG/0/3857 POINT(5 5)"^^geo:wktLiteral .

With EPSG:3857 a Cartesian 2D position in meter

and query with this request :

PREFIX units: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX spatial: <http://jena.apache.org/spatial#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?nearbyObject ?label
WHERE{
  ?nearbyObject spatial:nearby (0 0 1 units:meter) ;
                rdfs:label ?label ;
}

With this request i can extract all point at less than one meters from the point(0,0).

thanks

situx commented 1 year ago

Almost correct. You would need to add the < > brackets around the URI which unfortunately were lost in the Github markup here. So like this:

"<http://www.opengis.net/def/crs/EPSG/0/3857> POINT(5 5)"^^geo:wktLiteral 

As far as your query is concerned, I guess it will work. However, you use a function that is not specified in GeoSPARQL, but is a customized function of Apache Jena (hence its definition in the spatial namespace and not the GeoSPARQL namespace). So I have no experience with this customized function.

steven-bioinfo commented 1 year ago

the spatial:nearby function of Apache jena doesn't work with a point.

So i filter my results with geof:sfWithin on a polygon.

thanks