opengeospatial / ogc-geosparql

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

Geocoding Support in GeoSPARQL #444

Open situx opened 12 months ago

situx commented 12 months ago

Our group has already received a request from @paulc-dstl to add GeoHash literals to GeoSPARQL.

However, there are more geocoding systems which could be taken into account here.

In fact, a lot of geocoding systems can be resolved to coordinates in either UTM or WGS84-based coordinate reference systems.

My question here:

Would it make sense to maybe define two literal types: "wgs84GeocodingLiteral" and "utmGeoCodingLiteral" and indicate the Geocoding system with a URI definition, similar to how we do it in WKT?

WGS84-based Open Geocoding Systems:

We could curate a list of URIs for well-known geocoding systems which implementers could use.

Or should we proceed with defining GeoHash, and people should create their own literal types outside the standard?

situx commented 11 months ago

As discussed in the last meeting, I will provide possible ways to encode Geocoding types here with the example of a GeoHash.

  1. Using one literal type per geocoding type: "u4pruydqqvj"^^geo:geoHashLiteral
  2. Using one literal type per CRS: "<http://opengis.net/ont/geosparql/geocoding/geohash> u4pruydqqvj"^^geo:wgs84GeocodingLiteral
  3. Using one literal type per CRS, but encoding it as a separate property ex:point rdf:type sf:Point . ex:point geo:in GeoCode <http://opengis.net/ont/geosparql/geocoding/geohash>. ex:point geo:asGeoCode "u4pruydqqvj"^^geo:wgs84GeocodingLiteral
nicholascar commented 10 months ago

I provided an example of catering for just GeoHashes like we do for DGGSes over at Issue #428

VladimirAlexiev commented 9 months ago

There is also Quadtree

jabhay commented 7 months ago

OGC has indicated a willingness to register non-vendor specific or broadly adopted geocode types. I'll track where this conversation leads in this ticket.

VladimirAlexiev commented 2 months ago

@nicholascar @situx The current 1.1 spec https://docs.ogc.org/is/22-047r1/22-047r1.html#10-8-5-1-%C2%A0-rdfs-datatype-geo-dggsliteral uses a belt-and-suspenders approach:

But then the example implements only the first bullet:

geo:asDGGS "<https://w3id.org/dggs/auspix> CELL (R3234)"^^geo:dggsLiteral

Shouldn't this be like:

geo:asDGGS "<https://w3id.org/dggs/auspix> CELL (R3234)"^^<https://w3id.org/dggs/auspix> .
<https://w3id.org/dggs/auspix> a rdfs:Datatype; rdfs:subClassOf geo:dggsLiteral.

I see nothing wrong with using the same URL inside the string, and as a datatype: it's useful if the spec mentions that is legit

situx commented 2 months ago

@nicholascar might correct me on this, but here is my view:

VladimirAlexiev commented 2 months ago

@situx I'm very glad that https://github.com/opengeospatial/ogc-geosparql/pull/537 defines so many geocoding resources! But here are some comments:

situx commented 2 months ago

Hi @VladimirAlexiev thanks for the hints.

Apart from that @VladimirAlexiev feel free to add suggestions of missing GeoCode Systems you would need to PR #537

VladimirAlexiev commented 2 months ago

@situx Maybe I'm confused here: I assumed that DGGS is a subset of Geocoding (some geocoding systems like What3Words are DGGS but others like postal codes are not).

(DGGS) is a different literal type unrelated to the GeoCode Literal

So your Geocoding contribution is not meant to expand on DGGS as defined in GeoSPARQL? But surely What3Words (for example) is a DGGS?!

In the definition of the GeoCode Literal there is no mention of the URIs identifying the Geocode System to be a datatype.

This quotation from https://docs.ogc.org/is/22-047r1/22-047r1.html#10-8-5-1-%C2%A0-rdfs-datatype-geo-dggsliteral:

The specific implementation should be indicated by use of a subclass of the geo:dggsLiteral datatype.

Sounded to me that each DGGS must define its own datatype, being a subclass of geo:dggsLiteral.

what you mean by example

I meant this example:

"<https://w3id.org/dggs/auspix> CELL (R3234)"^^geo:dggsLiteral

In my opinion, defining them as Individuals is better.

Ok, so it would look like this:

# your definitions
<http://opengis.net/ont/geocode/AusPIX> a <http://opengis.net/ont/geocode/GeoCode>;
  rdfs:isDefinedBy "..."; 
  rdfs:comment "Cells are defined as... Eg R3234 is decoded by...".

# Instance data
<myGeometry> geo:asDGGS "<http://opengis.net/ont/geocode/AusPIX> CELL (R3234)"^^geo:dggsLiteral

So to understand AusPIX (to get to your RDF definition), one would need a query like:

where {
  ?geo geo:asDGGS ?literal.
  bind(iri(replace(?literal,"^ *<(.*?*)>.*","$1")) as ?dggs)
  ?dggs rdfs:isDefinedBy ?definedBy; rdfs:comment ?definition

If the geocode URL was used as datatype, then we wouldn't need to manipulate strings:

where {
  ?geo geo:asDGGS ?literal.
  bind(datatype(?literal) as ?dggs)
  ?dggs rdfs:isDefinedBy ?definedBy; rdfs:comment ?definition
nicholascar commented 2 months ago

I think @VladimirAlexiev may be right here. We have a legacy of pairs of matching predicates and datatypes:

Predicate Datatype
asWKT wktLiteral
asGeoJSON geoJSONLiteral
asKML kmlLiteral
asGML gmlLiteral

which was followed for

Predicate Datatype
asWKT wktLiteral

but then we have the CRS/SRS indicator within some of those literals like WKT.

The DGGS type was thought of as being equivalent to an SRS and, I suppose, a GeoCode type is also equivalent because you have to know the SRS/DGGS type/GeoCode type to be able to interpret the literal.

I guess the problem is that there are just multiple dimensions needed to understand the literal:

The OGC will soon have a much better capability to deliver dynamic registers for anything because of a tooling upgrade within the Rainbow, so they could deliver a sophisticated register of GeoSPARQL geometry serialization types which could include:

We could make a new GeometrySerialization class which could be a specialized datatype that, via a mandated axiom/shape defines all the elements we need to efficiently process geometry literals.

@situx @VladimirAlexiev and others:

We can then reduce GeoSPARQL's special properties down with a pattern like this:

ex:feature-x
    a geo:Feature ;
    geo:hasGeometry [
        a geo:Geometry ;
        geo:hasSerialization "lots of stuff"^^geo:GeometrySerialization ;  # <-- but really a subclass of GeometrySerialization
    ] ;
.

We can then move to a new phase of validating GeoSPARQL data v. a dynamic register (in OGC Rainbow) which data stored would need to catch in order to ensure that data they are validating is using GeometrySerialization subclasses that they can handle.

VladimirAlexiev commented 2 months ago

Hi @nicholascar ! I think we need to be backward compatible to 1.0 and 1.1. From that point of view, we should keep using Datatypes. These can be organized in a hierarchy if needed.

For DGGS, having the URL both inside the string and outside as datatype is redundant. I vote to have it only outside as that is more explicit.

(For eg WKT, the datatype specifies the overall structure, whereas the CRS specifies how to interpret the numbers. No such need has perspired for DGGS.)

VladimirAlexiev commented 1 month ago

@situx thanks for the explanations in the telco today!

But please take a look at my second comment:

The specific implementation should be indicated by use of a subclass of the geo:dggsLiteral datatype.

This sentence is from the current standard and IMHO is not satisfied by the example (because that uses a specific URL inside the string, but the general geo:dggsLiteral outside.