Arquisoft / viadeSpec

Viade Data Model Specification
https://arquisoft.github.io/viadeSpec/
MIT License
7 stars 1 forks source link

Simplification of viade:points properties #20

Open christianpe98 opened 4 years ago

christianpe98 commented 4 years ago

Currently the viade:points property is a closed list. To make queries against this type of structure you need SPARQL 1.1 feature (e.g. properties path). Most reference libraries (rdflib,rdfstore-js) dont support full SPARQL 1.1 .I propose to modify the property to make things easier.

viade_es4c team

christianpe98 commented 4 years ago

From the viadeEs4C group we propose to change the viade:points property from closed list to open list(container). In our opinion, this change does not modify the semantics of the routes and allows us to obtain (through queries using blank nodes) the values of the points' properties.

(The use of blank nodes in queries is still a feature of SPARQL 1.1, but it seems that the sparql-fiddle library supports it (so rdf-lib supports it too))

@labra

labra commented 4 years ago

I partially agree that handling RDF lists can be more difficult with SPARQL and the representation could be done in a different way.

The use of RDF lists was proposed to ensure that the list of points is ordered.

A representation like:

:route viade:points ( 
  [ schema:latitude 47.644548 ; schema:longitude -122.326897 ]
  [ schema:latitude 47.644532 ; schema:longitude -123.3345 ]
 ).

is equivalent to something like:

:myRoute2 viade:points _:1 .
_:1 rdf:rest _:2 .
_:2 rdf:rest _:3 .
_:3 rdf:rest rdf:nil .
_:1 rdf:first _:p1 .
_:2 rdf:first _:p2 .
_:p1 schema:latitude 47.64458 ;
     schema:longitude -122.326897 .
_:p2 schema:latitude 47.644532 ; 
     schema:longitude -123.3345 .

In this way, a SPARQL query to retrieve the points can be something like:

SELECT ?lat ?lon WHERE {
 ?ruta a viade:Route.
 ?ruta viade:points/rdf:rest*/rdf:first ?point .
 ?point schema:latitude ?lat ;
        schema:longitude ?lon .
}

One problem of that query is that it would be better to retrieve also the position of each point in the list. It is possible to do it, but not inmediate.

There are other alternatives to represent the points that can facilitate their processing. One possibility is to have a single property like viade:point and add a viade:order property to each point. It could be something like:

:myRoute2 viade:point [  
  schema:latitude 47.64458 ;
  schema:longitude -122.326897 ;
  viade:order 1 ] ;
 viade:point [ 
  schema:latitude 47.644532;
  schema:longitude -123.3345 ;
  viade:order 2
 ] .

In this way, a SPARQL query to get the points and their order could be:

SELECT ?lat ?long ?order WHERE {
 ?ruta a viade:Route.
 ?ruta viade:point ?point .
 ?point schema:latitude ?lat ;
        schema:longitude ?long ;
        viade:order ?order
}

Do you want to change the representation of points to this model?

christianpe98 commented 4 years ago

For me your option is perfect. And how could we get the optional point values? I tried this query but it doesn't seem right:

PREFIX schema: <http://schema.org/>
PREFIX viade:<http://arquisoft.github.io/viadeSpec/>
PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?lat ?long ?order ?name ?description ?name ?elevation WHERE {
 ?ruta a viade:Route.
 ?ruta viade:point ?point .
 ?point schema:latitude ?lat ;
        schema:longitude ?long ;
        viade:order ?order.
OPTIONAL {?point schema:description ?description.}
OPTIONAL {?point schema:name ?name.}
OPTIONAL {?point schema:elevation ?elevation.}
}

For example, it doesnt show the name of the points unless everyone has it.

labra commented 4 years ago

A possible query could be something like:

PREFIX schema: <http://schema.org/>
PREFIX viade:<http://arquisoft.github.io/viadeSpec/>
PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?lat ?long ?order ?name ?description ?name ?elevation WHERE {
 ?route a viade:Route.
 ?route viade:point ?point .
 ?point schema:latitude ?lat ;
        schema:longitude ?long ;
        viade:order ?order.
OPTIONAL {?route schema:description ?description.}
OPTIONAL {?route schema:name ?name.}
OPTIONAL {?point schema:elevation ?elevation.}
}

You can see it working here.

I have also updated the spec with the new ShEx definition, a new RDF data example and the previous SPARQL query.