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):
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "tcl_sytral.tcllignebus_2_0_0.C4-1",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
4.84213733,
45.74561994
],
[
4.84198449,
45.74535432
],
[
4.84203846,
45.74531134
],
[
4.84238282,
45.74521409
]
]
]
},
"geometry_name": "the_geom",
"properties": {
"ligne": "C4",
"code_trace": "C4-1",
"code_ligne": "C4A",
"type_trace": "NOM",
"nom_trace": "Jean Macé - Cité Internationale Centre de Congrès",
"sens": "Aller",
"origine": "10593",
"destination": "11792",
"nom_origine": "Jean Macé",
"nom_destination": "Cité Internationale",
"famille_transport": "BUS",
"date_debut": "20180101",
"date_fin": null,
"code_type_ligne": "REG",
"nom_type_ligne": "Régulière",
"pmr": true,
"code_tri_ligne": "C 4",
"nom_version": "Mars_2024",
"last_update": "2024-03-14T16:49:38+01:00",
"last_update_fme": "2024-03-20T06:00:19.056+01:00",
"gid": 357
},
"bbox": [
4.84198449,
45.74521409,
4.85679521,
45.78469769
]
},
{
"type": "Feature",
"id": "tcl_sytral.tcllignebus_2_0_0.C4-2",
"geometry": {
"type": "MultiLineString",
"coordinates": [
[
[
4.84213554,
45.74561682
],
[
4.84270835,
45.74661155
],
[
4.84312831,
45.74732425
],
[
4.84365184,
45.74821879
]
]
]
},
"geometry_name": "the_geom",
"properties": {
"ligne": "C4",
"code_trace": "C4-2",
"code_ligne": "C4A",
"type_trace": "NOM",
"nom_trace": "Cité Internationale Centre de Congrès - Jean Macé",
"sens": "Retour",
"origine": "11792",
"destination": "10593",
"nom_origine": "Cité Internationale",
"nom_destination": "Jean Macé",
"famille_transport": "BUS",
"date_debut": "20180101",
"date_fin": null,
"code_type_ligne": "REG",
"nom_type_ligne": "Régulière",
"pmr": true,
"code_tri_ligne": "C 4",
"nom_version": "Mars_2024",
"last_update": "2024-03-14T16:49:38+01:00",
"last_update_fme": "2024-03-20T06:00:19.057+01:00",
"gid": 358
},
"bbox": [
4.84213554,
45.74561682,
4.85738663,
45.78471602
]
}
]
}
I have been able to extract each latitude and longitude separately with this SPARQL query:
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/>
CONSTRUCT {
?l_id a geo:Feature;
geo:asGML ?lyon_coords.
}
WHERE {
SERVICE <x-sparql-anything:location=/home/maximeb/github/datasets_alignment/datasets/lyon_bus_short.json> {
[] xyz:type ?type ;
xyz:features/
fx:anySlot
[xyz:id ?lyon_id ;
xyz:geometry/xyz:coordinates/fx:anySlot/fx:anySlot [?slot ?lyon_coords]].
}
BIND (IRI(CONCAT("http://lyonbus.com/", ?lyon_id )) AS ?l_id).
}
<http://lyonbus.com/tcl_sytral.tcllignebus_2_0_0.C4-2> <http://www.opengis.net/ont/geosparql#asGML> "4.85063417"^^<http://www.w3.org/2001/XMLSchema#double> .
[...]
<http://lyonbus.com/tcl_sytral.tcllignebus_2_0_0.C4-1> <http://www.opengis.net/ont/geosparql#asGML> "4.84325375"^^<http://www.w3.org/2001/XMLSchema#double> .
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:
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/>
CONSTRUCT {
?l_id a geo:Feature;
geo:asGML ?lyon_coords.
}
WHERE {
SERVICE <x-sparql-anything:location=/home/maximeb/github/datasets_alignment/datasets/lyon_bus_short.json> {
[] xyz:type ?type ;
xyz:features/
fx:anySlot
[xyz:id ?lyon_id ;
xyz:geometry/xyz:coordinates/fx:anySlot/fx:anySlot ?lyon_coords].
}
BIND (IRI(CONCAT("http://lyonbus.com/", ?lyon_id )) AS ?l_id).
}
But I only have blank nodes instead of list of coordinates:
<http://lyonbus.com/tcl_sytral.tcllignebus_2_0_0.C4-2> <http://www.opengis.net/ont/geosparql#asGML> _:BX2FfeaturesX2FX5F2X2FgeometryX2FcoordinatesX2FX5F1X2FX5F66 .
[...]
<http://lyonbus.com/tcl_sytral.tcllignebus_2_0_0.C4-1> <http://www.opengis.net/ont/geosparql#asGML> _:BX2FfeaturesX2FX5F1X2FgeometryX2FcoordinatesX2FX5F1X2FX5F51 .
I am stuck. Do you have an idea? I hope I was clear enough.
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):
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "id": "tcl_sytral.tcllignebus_2_0_0.C4-1", "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 4.84213733, 45.74561994 ], [ 4.84198449, 45.74535432 ], [ 4.84203846, 45.74531134 ], [ 4.84238282, 45.74521409 ] ] ] }, "geometry_name": "the_geom", "properties": { "ligne": "C4", "code_trace": "C4-1", "code_ligne": "C4A", "type_trace": "NOM", "nom_trace": "Jean Macé - Cité Internationale Centre de Congrès", "sens": "Aller", "origine": "10593", "destination": "11792", "nom_origine": "Jean Macé", "nom_destination": "Cité Internationale", "famille_transport": "BUS", "date_debut": "20180101", "date_fin": null, "code_type_ligne": "REG", "nom_type_ligne": "Régulière", "pmr": true, "code_tri_ligne": "C 4", "nom_version": "Mars_2024", "last_update": "2024-03-14T16:49:38+01:00", "last_update_fme": "2024-03-20T06:00:19.056+01:00", "gid": 357 }, "bbox": [ 4.84198449, 45.74521409, 4.85679521, 45.78469769 ] }, { "type": "Feature", "id": "tcl_sytral.tcllignebus_2_0_0.C4-2", "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 4.84213554, 45.74561682 ], [ 4.84270835, 45.74661155 ], [ 4.84312831, 45.74732425 ], [ 4.84365184, 45.74821879 ] ] ] }, "geometry_name": "the_geom", "properties": { "ligne": "C4", "code_trace": "C4-2", "code_ligne": "C4A", "type_trace": "NOM", "nom_trace": "Cité Internationale Centre de Congrès - Jean Macé", "sens": "Retour", "origine": "11792", "destination": "10593", "nom_origine": "Cité Internationale", "nom_destination": "Jean Macé", "famille_transport": "BUS", "date_debut": "20180101", "date_fin": null, "code_type_ligne": "REG", "nom_type_ligne": "Régulière", "pmr": true, "code_tri_ligne": "C 4", "nom_version": "Mars_2024", "last_update": "2024-03-14T16:49:38+01:00", "last_update_fme": "2024-03-20T06:00:19.057+01:00", "gid": 358 }, "bbox": [ 4.84213554, 45.74561682, 4.85738663, 45.78471602 ] } ] }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.