demo: tablet-based visualisation of transport data in madrid using sparqlstream
DESCRIPTION
by Jean-Paul Calbimonte, Alejandro Fernández Carrera, Oscar Corcho @ISWC 2013 SSN WorkshopTRANSCRIPT
![Page 1: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/1.jpg)
Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream
Jean-Paul Calbimonte, Alejandro Fernández Carrera, Oscar Corcho
22/10/2013
Ontology Engineering GroupFacultad de Informática, Universidad Politécnica de Madrid
[email protected], [email protected]
ISWC 2013 SSN Workshop
![Page 2: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/2.jpg)
Sensor Networks and the Web
2
Sensor Networks
users
applicationsdata
streams
Volume
VelocityVariety WEB
Universal Web-based access to Sensor data
![Page 3: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/3.jpg)
EMT Bus transport in Madrid
• EMT: Public transport company in Madrid
3
![Page 4: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/4.jpg)
Waiting times
• How long do I wait for the next bus?
4
Only in a few bus stops
Have to physically go
and watch
EMT wants to be more WEB friendly
![Page 5: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/5.jpg)
EMT Web Services
5
EMT Services
Bus stops
https://servicios.emtmadrid.es:8443/geo/servicegeo.asmx
Bus waiting times
<Stop><IdStop>28</IdStop><PMV>61247</PMV><Name>P CASTELLANA-JUZGADOS</Name><PostalAdress>P de la Castellana, 187</PostalAdress><CoordinateX>-3.68972639781606</CoordinateX><CoordinateY>40.4650604583015</CoordinateY></Stop>
getStopsLine
getArriveStop<Arrives><Arrive><IdStop>30</IdStop><idLine>5</idLine><IsHead>True</IsHead><Destination>CHAMARTIN</Destination><IdBus>0000</IdBus><TimeLeftBus>0</TimeLeftBus><DistanceBus>16</DistanceBus><PositionXBus>-1</PositionXBus><PositionYBus>-1</PositionYBus><PositionTypeBus>0</PositionTypeBus></Arrive>
Ad-hoc XML model
Identifiers not web-friendly
Not ready for integration w/ other datasets
Working with EMT to define an Open Data strategy
![Page 6: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/6.jpg)
Extracting data from EMT
6
EMT Services
data as RDF
W3C SSN Ontology
Bus stops
https://servicios.emtmadrid.es:8443/geo/servicegeo.asmx
stati
c d
ata
<Stop><IdStop>28</IdStop><PMV>61247</PMV><Name>P CASTELLANA-JUZGADOS</Name><PostalAdress>P de la Castellana, 187</PostalAdress><CoordinateX>-3.68972639781606</CoordinateX><CoordinateY>40.4650604583015</CoordinateY></Stop>
users
applications
![Page 7: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/7.jpg)
Static part (bus stops)
• Currently at:• http://linkeddata4.dia.fi.upm.es:8080/sparql• Graph:
http://emt.transporte.linkeddata.es/graph/stops
• All bus stops (query)• select distinct ?x where
{?x a <http://transporte.linkeddata.es/emt#BusStop>}
• URI:• http://transporte.linkeddata.es/emt/busstop/id/104
• (in the process of defining the URIs)• Could also be:
http://datos.emtmadrid.es/recurso/BusStop/104 or similar
7
![Page 8: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/8.jpg)
Extracting data from EMT
8
EMT Services
data as RDF
W3C SSN Ontology
Bus stops
https://servicios.emtmadrid.es:8443/geo/servicegeo.asmx
Bus waiting times
stati
c d
ata
<Stop><IdStop>28</IdStop><PMV>61247</PMV><Name>P CASTELLANA-JUZGADOS</Name><PostalAdress>P de la Castellana, 187</PostalAdress><CoordinateX>-3.68972639781606</CoordinateX><CoordinateY>40.4650604583015</CoordinateY></Stop>
users
applications S
tream
ing
data
?
Transform Bus waiting times to RDF Stream?
![Page 9: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/9.jpg)
EMT Live data streams
9
EMT Services
https://servicios.emtmadrid.es:8443/geo/servicegeo.asmx
Bus waiting times
Str
eam
ing
data
Morph-streams
users applications
SPARQLStream queries
![Page 10: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/10.jpg)
Endpoint available
• We’ll be using this server for the hands-on:
• http://linkeddata2.dia.fi.upm.es:9000
• The instructions of a demo are on the github wiki:• https://github.com/jpcik/morph-web/wiki/Tutorial:-Mor
ph-streams• Register queries• Pull Data• Push data through websockets• Simple SPARQLStream endpoint
10
![Page 11: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/11.jpg)
Querying live data streams
• Currently at:• http://streams.linkeddata.es/emt/sparqlstream
• Example• SELECT DISTINCT ?timeto ?obs
FROM NAMED STREAM <http://emt.linkeddata.es/data#busstops.srdf> [NOW - 59 S] WHERE { ?obs a <http://emt.linkeddata.es/data#BusObservation>. ?obs <http://purl.oclc.org/NET/ssnx/ssn#observedBy><http://transporte.linkeddata.es/emt/busstop/id/2018>. ?obs <http://purl.oclc.org/NET/ssnx/ssn#observationResult> ?output. ?output <http://emt.linkeddata.es/data#timeToBusValue> ?av. ?av <http://data.nasa.gov/qudt/owl/qudt#numericValue> ?timeto. }
11
![Page 12: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/12.jpg)
Some commands in Linux
• encoded_value=$(python -c "import urllib; print urllib.quote('''SELECT DISTINCT ?timeto ?obs FROM NAMED STREAM <http://emt.linkeddata.es/data#busstops.srdf> [NOW - 30 S] WHERE { ?obs a <http://emt.linkeddata.es/data#BusObservation>. ?obs <http://purl.oclc.org/NET/ssnx/ssn#observedBy><http://transporte.linkeddata.es/emt/busstop/id/2018>. ?obs <http://purl.oclc.org/NET/ssnx/ssn#observationResult> ?output. ?output <http://emt.linkeddata.es/data#timeToBusValue> ?av. ?av <http://data.nasa.gov/qudt/owl/qudt#numericValue> ?timeto. }''')")
• curl "http://streams.linkeddata.es/emt/sparqlstream?query=$encoded_value”
12
![Page 13: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/13.jpg)
Sample result
{ "head": { "vars": [ "timeto" , "obs" ] } , "results": { "bindings": [ { "timeto": { "datatype": "http://www.w3.org/2001/XMLSchema#string" , "type": "typed-literal" , "value": "0" } , "obs": { "type": "uri" , "value": "http://transporte.linkeddata.es/emt/busstop/id/2018/busline/9/observation/20/09/2013%2010:28:19%20%2B0200" } } ] }}
13
![Page 14: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/14.jpg)
Configuring Morph-streams
• Main ingredients:
14
1. Data streams
2. Ontology (network)
3. R2RML mappings
Link both models
![Page 15: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/15.jpg)
SSN Ontology with other ontologies
15
W3C SSN Ontology
tool for modeling our sensor datacombine with domain ontologies
![Page 16: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/16.jpg)
R2RML mappings
16
busObservation a rr:TriplesMap; rr:logicalTable :emtStream;
rr:subjectMap [ rr:template "http://transporte.linkeddata.es/emt/busstop/id/{stopid}/busline/{lineid}/observation/{timed}"; rr:class emt:BusObservation; rr:graph emt:busstops.srdf ]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant ssn:observedProperty ]; rr:objectMap [ rr:constant emt:time_to_bus ]]; rr:predicateObjectMap [ rr:predicateMap [ rr:constant ssn:observationResult ]; rr:objectMap [ rr:parentTriplesMap :busOutput; rr:joinCondition "" ]]; busOutput a rr:TriplesMap; rr:logicalTable :emtStream; …
![Page 17: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/17.jpg)
17
morph-streams: Ontology-based query rewriting
Query rewriting
Query ProcessingC
lien
t
SPARQLStream
[tuples][triples/
bindings]
Algebra expression
R2RML Mappings
SPARQLStream query processing
SELECT ?waittime ?stopFROM NAMED STREAM <http://emt.linkeddata.es/data#busstops.srdf> [NOW - 300 S]WHERE {?obs a emt:BusObservation;ssn:observedBy ?stop.ssn:observationResult ?result.?result emt:timeToBusValue ?av.?av qudt:numericValue ?waittime.}
SELECT timetobus, stopidFROM emt.win:time(300 second)
πTimetobus,stopid
ω300 -second
emt
Data translation
Esper
GSNCosmpull/
push Other
![Page 18: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/18.jpg)
EMT Map4RDF iOS
18
Map4RDFiOS
EMT Live Services
Waiting times feed
Get Bus stops data and location
SPARQLStream query
SPARQL query
Get Bus waiting times for a stop URI
Morph-streams
R2RML Mappings
SP
AR
QL
Str
eam
en
dp
oin
tS
PA
RQ
L
end
po
int
![Page 19: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/19.jpg)
Map4RDF iOS
19
![Page 20: Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream](https://reader035.vdocuments.site/reader035/viewer/2022081403/555ded24d8b42a192c8b5a66/html5/thumbnails/20.jpg)
Conclusions
• A bit of evangelization at EMT• Use of Web standards for Open Data• Use URIs for identifying stops, bus lines, etc• Use well defined sensor ontologies (SSN)• Use standard geolocation vocabularies• Mix static and streaming dat through URIs
• From the developer point of view• JSON results easy to consume• SPARQLstream endpoint through HTTP GET
• The Demo is a very simple but practical example of how this can be done fairly easily
20