Replies: 4 comments
-
Welcome Max. You should get the coordinates in pairs with the following: PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?l_id ?lyon_lat ?lyon_long
WHERE {
SERVICE <x-sparql-anything:lyon_bus_short.json> {
[] xyz:type ?type ;
xyz:features/fx:anySlot
[xyz:id ?lyon_id ;
xyz:geometry/xyz:coordinates/fx:anySlot/fx:anySlot [rdf:_1 ?lyon_lat; rdf:_2 ?lyon_long]].
}
BIND (IRI(CONCAT("http://lyonbus.com/", ?lyon_id )) AS ?l_id).
} |
Beta Was this translation helpful? Give feedback.
-
Thank you enridaga, it works and the SELECT query preserves the coordinates order. But if I do a CONSTRUCT query, the coordinates order is not preserved. Thus, it should be explicitly stated in some way (I have seen the Ordered List Ontology, maybe it can help). But this might be another question to be answered later on. |
Beta Was this translation helpful? Give feedback.
-
Can you share an example of the RDF you would like to generate? The construct query you shared cannot work because all coordinates will be values of the same property. You get the blank node because that is what the variables capture. See the following using a different ontology: PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
CONSTRUCT {
?l_id pos:lat ?lyon_lat ; pos:long ?lyon_long
}
WHERE {
SERVICE <x-sparql-anything:lyon_bus_short.json> {
[] xyz:type ?type ;
xyz:features/fx:anySlot
[xyz:id ?lyon_id ;
xyz:geometry/xyz:coordinates/fx:anySlot/fx:anySlot [rdf:_1 ?lyon_lat; rdf:_2 ?lyon_long]].
}
BIND (fx:entity(CONCAT("http://lyonbus.com/", ?lyon_id )) AS ?l_id).
} |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hello,
I would like to retrieve the lists of coordinates from this JSON representing two bus trips. The list of coordinates is located at the key "coordinates" (features>geometry>coordinates):
I have been able to extract each latitude and longitude separately with this SPARQL query:
But it is not useful because I need to keep the latitude and longitude in pair, and I need these pairs in the right order. So I tried this query:
But I only have blank nodes instead of list of coordinates:
I am stuck. Do you have an idea? I hope I was clear enough.
Beta Was this translation helpful? Give feedback.
All reactions