Queries about buses

4.2 Queries about buses

This section presents a subset of queries about buses, bus stops and bus lines. For instance, to get bus stops near a particular location, we can query as follows.

PREFIX : http://www.gambas-ict.eu/ont/ PREFIX spt: http:// spitfire-project.eu/ontology/ns/

SELECT ?place WHERE ?place a :BusStop ; spt:nearby <locationURI>.

Figure 28 – Query: Nearest bus stops, given a location

Alternatively, we can ask for bus stops near a GPS location.

PREFIX : http://www.gambas-ict.eu/ont/ PREFIX geo: http://www.w3.org/2003/01/geo/wgs84_pos# PREFIX spt: http:// spitfire-project.eu/ontology/ns/

SELECT ?place WHERE ?place a :BusStop ; spt:nearby ?location. ?location a :Place ; geo:Lat “50.0” ; geo:long “3.0”.

Figure 29 – Query: Nearest bus stops, given a GPS location

The next three queries return the set of all bus lines, all bus stops, and all buses respectively. In this updated version, all these information can be found in instances of the GAMBAS ontology.

PREFIX : http://www.gambas-ict.eu/ont/ SELECT ?busline WHERE ? busline a :BusLine .

Figure 30 – Query: All bus lines

PREFIX : http://www.gambas-ict.eu/ont/ SELECT ?stop WHERE ?stop a :BusStop .

Figure 31 – Query: All bus stops

PREFIX : http://www.gambas-ict.eu/ont/ SELECT ?bus WHERE ?bus a :Bus .

Figure 32 – Query: All buses

Similarly we can also retrieve the bus route for a particular bus line.

PREFIX : http://www.gambas-ict.eu/ont/ SELECT ?busroute WHERE ? busline a :BusLine ; :route ?busRoute

Figure 33 – Query: Route of a bus line

To retrieve the list of stops covered by a bus line in the correct sequence we can use the ordered list to iterate over the different steps.

PREFIX : http://www.gambas-ict.eu/ont/ PREFIX olo: http://purl.org/ontology/olo/core# SELECT ?start ?stop WHERE {?busline a :BusLine ; :route ?busRoute. ?busRoute :orderedSteps ?list. ?list olo:slot ?slot . ?slot olo:item ?step ; olo:index ?index . ?step :startLoc ?start ; :endLoc ?end} ORDER BY ASC(?index).

Figure 34 – Query: Bus stops of a bus line

The query above might return duplicates of start/end locations overlap. However, this can be easily fixed by a simple scan over the results list.

With the modified version of the Place ontology we can easy query for all bus lines that run on a stop, similar to the previous version, but without the overhead and complexity of the TRANSIT ontology. We can also query for bus lines that run on a given date on that stop.

PREFIX : http://www.gambas-ict.eu/ont/ SELECT ?busline WHERE <busstopURI> :busLine ?busline .

Figure 35 – Query: Bus lines that run through a given bus stop

PREFIX : http://www.gambas-ict.eu/ont/ PREFIX prov: http://www.w3.org/ns/prov# SELECT ?busline WHERE <busstopURI> :busLine ?busline . ?busline :route ?route. ?route prov:startedAtTime ?start ; prov:endedAtTime ?end. FILTER( ?start > <date>). FILTER (?end < <date>).

Figure 36 – Query: Bus lines that run through a given bus stop, filtered by given date

The query above looks at the routes of the bus lines and filters them by the date. For a user waiting at a bus stop we want to send notifications of possible delays. We can first retrieve

all the bus lines that run on that stop and check their timetables against the stream of estimated times.

PREFIX foaf: http://ns.com/foaf/0.1/ PREFIX : http://www.gambas-ict.eu/ont/ SELECT ?estimateddeparture

WHERE ?x foaf:nick "userid" ; :location ?stop. ?stop :busline ?line . ?line :route ?route . ?route :singleStep ?step . ?step :startLocation ?stop ; :scheduleDeparture ?scheduleDeparture STREAM <streamURI> [NOW] {?step :estimatedDeparture ?estimatedDeparture}. FILTER (?estimateddeparture > ?scheduleDeparturel +threshold).

Figure 37 – Query: Bus lines that run through a given bus stop, filtered by given date

In the query above we can specify a threshold (for example 5min), and if the current live departure time estimation is over the threshold specified, then the system will notify the user.

The last query examples on this section are related to the crowd level information. To access the latest status and crowd level information of a particular bus we can do as follows:

PREFIX : http://www.gambas-ict.eu/ont/ SELECT ?crowdLevel ?status

WHERE ?bus a:Bus STREAM <streamURI> [NOW] {?bus :crowdLevel ?crowdLevel}. STREAM <streamURI> [NOW] {?bus :status ?status}.

Figure 38 – Query: Bus lines that run through a given bus stop, filtered by given date

In our ontology we can store an aggregated value of crowd levels recorded in a particular step of a journey. This value can be for instance the maximum crowd level at any stage of that step or the average value. In the query below we show how to extract the maximum crowd level of a step.

PREFIX : http://www.gambas-ict.eu/ont/ SELECT MAX (?crowdLevel)

WHERE ?step a :Step ; :estimatedDeparture ?start ; :estimatedArrival ?end ; :travelMode ?busride . ?busride :serviceBus ?bus . STREAM <streamURI> [RANGE 30min] {?bus:crowdLevel ?crowdLevel[timeStamp]}. FILTER (?start < timeStamp < ?end).

Figure 39 – Query: Bus lines that run through a given bus stop, filtered by given date

When processing data streams, we can extract windows of data, by specifying the window parameters. In the example of the query in Figure 37 we use [NOW] to extract the latest value. Here we select all the data of the last 30 minutes. Note that it is not possible to specify a start/end time interval for the window operators. Nevertheless we can take advantage of the fact that every stream data can have a timestamp associated with it. In the case of this query we assume that the start time did not occur before 30 minutes ago, and we select the valid crowd levels during the step in the filter condition.

Dokumen yang terkait

Perencanaan Proses Pembuatan Cetakan Casing Handphone Nokia Type 3330 Melalui Program Mastercam V.9 dengan Menggunakan Mesin Frais CNC

0 11 1

Perancangan Pompa Hidram Type Double Waste Valve Dengan Head Pompa 20 m

1 22 1

Faktor yang Berhubungan dengan Tingkat Kecemasan Penderita Diabetes Mellitus Tipe 2 di Rumah Sakit Nusantara Medika Utama (Factors Associated With Anxiety Type 2 Diabetes Mellitus Patients at Nusantara Medika Utama Hospital )

0 3 7

Hubungan Tingkat Kecemasan pada Pasien Multigravida dalam Persalinan Normal dengan Lama Persalinan di RSD dr.Soebandi Kabupaten Jember (The Relationship between Anxiety Level in Multigravida on Facing Normal Delivery and Length of Delivery at dr.Soebandi

2 46 4

The Ways In Which Information Given Related To The Type Of Visitor (A Description on Guiding Technique at the Room of History of Life in Bandung Museum of Geology)

0 16 48

Cover kaset Actual

0 3 24

PENGARUH ARUS PENGELASAN TERHADAP KEKUATAN TARIK PADA PENGELASAN BIMETAL (STAINLESS STEEL A 240 Type 304 DAN CARBON STEEL A 516 Grade 70) DENGAN ELEKTRODA E 309-16

10 133 86

Analisis Pengaruh Pengumuman Dividen Terhadap Harga Saham Disekitar Tanggal Ex-Dividen Date

0 8 56

Efek Pemberian Asam Alfa Lipoat terhadap Kadar MDA dan Gambaran Histologi pada Hati Tikus Model Diabetes Melitus Tipe 1 Effect of Alpha Lipoic Acid Administration on MDA Levelsa and Liver Histology of Type 1 Diabetes Mellitus Mice Model

0 0 7

Efek Asam Alfa Lipoat pada Kadar MDA dan Histologi Ginjal Tikus Wistar Diabetes Melitus Tipe1 Effect of Alpha Lipoic Acid on MDA Levels and Histology of Wistar Rats' Kidney Type 1 Diabetes Mellitus

0 0 5