This document summarizes a demo of using SPARQLstream and Morphstreams to visualize transport data from Madrid's public transport company (EMT) in a tablet application. Static EMT data like bus stop locations are extracted and mapped to RDF, while live bus waiting time data streams are transformed and queried in real-time. This allows a Map4RDF iOS app to retrieve bus stop information and lookup estimated arrival times using SPARQL and SPARQLstream queries. The demo illustrates how standards like SSN and R2RML can integrate static and streaming sensor data for web-based applications.
Demo: tablet-based visualisation of transport data in Madrid using SPARQLstream
1. ISWC 2013 SSN Workshop
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 Group
Facultad de Informática, Universidad Politécnica de Madrid
jp.calbimonte@upm.es, ocorcho@fi.upm.es
2. Sensor Networks and the Web
users
Volume
Sensor Networks
Velocity
Variety
WEB
applications
data streams
Universal Web-based access to Sensor data
2
3. EMT Bus transport in Madrid
• EMT: Public transport company in Madrid
3
4. Waiting times
• How long do I wait for the next bus?
Only in a few bus
stops
Have to physically
go and watch
EMT wants to be
more WEB friendly
4
5. EMT Web Services
Bus stops
EMT
Services
https://servicios.emtmadrid.es:8
443/geo/servicegeo.asmx
getStopsLine
getArriveStop
<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>
Bus waiting times
<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
5
6. data as RDF
W3C SSN Ontology
static data
Extracting data from EMT
Bus stops
<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>
EMT
Services
https://servicios.emtmadrid.es:8
443/geo/servicegeo.asmx
users applications
6
7. 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
8. data as RDF
W3C SSN Ontology
static data
Extracting data from EMT
Bus stops
<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>
EMT
Services
Streaming data
?
users applications
https://servicios.emtmadrid.es:8
443/geo/servicegeo.asmx
Bus waiting
times
Transform Bus waiting times to RDF Stream?
8
9. EMT Live data streams
Streaming data
Morphstreams
SPARQLStream queries
users
applications
9
EMT
Services
https://servicios.emtmadrid.es:8
443/geo/servicegeo.asmx
Bus waiting
times
10. 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:-Morphstreams
• Register queries
• Pull Data
• Push data through websockets
• Simple SPARQLStream endpoint
10
11. 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.linkedd
ata.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
12. 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><ht
tp://transporte.linkeddata.es/emt/busstop/id/2018>.
?obs
<http://purl.oclc.org/NET/ssnx/ssn#observationResul
t> ?output. ?output
<http://emt.linkeddata.es/data#timeToBusValue>
?av. ?av
<http://data.nasa.gov/qudt/owl/qudt#numericValue
12
17. morph-streams: Ontology-based query rewriting
SELECT ?waittime ?stop
FROM 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.
}
ω 300 second
emt
SELECT timetobus, stopid
FROM emt.win:time(300 second)
Query
rewriting
SPARQLStream
Client
π Timetobus,stopid
Algebra
expression
R2RML
Mappings
[triples/bin
dings]
Esper
Query
Processing
Data
translation
[tuples]
GSN
pull/push
Cosm
Other
SPARQLStream query processing
17
18. SPARQLStream query
Get Bus waiting times
for a stop URI
SPARQL
endpoint
Map4RDF
iOS
SPARQLStream
endpoint
EMT Map4RDF iOS
SPARQL query
Get Bus stops data
and location
18
Morph-streams
EMT Live
Services
R2RML
Mappings
Waiting
times feed
20. 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