-
Notifications
You must be signed in to change notification settings - Fork 3
CRTM SSN v2.0
This page provides an example of how the W3C SSN Ontology, which is a W3C Recommendation from 19 October 2017, can be used for describing the validations that users do in the transport system of the region of Madrid with their transport card.
Note that there was a previous version of these guidelines (https://github.com/oeg-upm/ssn-resource-center/wiki/CRTM-SSN-v1.0) based on the earlier version of the SSN Ontology.
We will focus for the time being on the Skeleton and Data parts of the SSN Ontology, which cover the main concepts that we need at this stage, namely the observations, sensor outputs, observation values, sensors, properties, and features of interest. These classes, and their corresponding properties, can be found in Figure 1 "Overview of the SOSA classes and properties (observation perspective)" and Figure 2 "Overview of the SSN classes and properties (observation perspective)":
Figure 1 - Overview of the SOSA classes and properties (observation perspective)
Figure 2 - Overview of the SSN classes and properties (observation perspective)
To facilitate the reading and understanding of the examples that follow, we will use the following diagram to represent the basic concepts that we will be making use of:
Figure 3 - An Excerpt of the Skeleton and Data parts of the SSN Ontology
We can now specialise this skeleton with the types of observations, sensors, properties and observation values that we have to deal with in the case of the CRTM transport card validation, something that is applicable to most of the current transport systems deployed nowadays that make use of smart transport cards.
Figure 4 - A Diagram of the Card Validation Ontology, which extends the SSN Ontology
Let us know imagine that a user with transport card number VAL_CF446342E9FD3D2FB6F16003EF28A3FD uses his card to enter into the Metro system in Madrid on July 1st, 2016, at 14:29, assuming that we are using the timezone GMT+02:00, using the sensor with number 02_L7_P21.
The graphical view of the instances that would be generated of the previous ontology is provided in the following figure
Figure 5 - A Diagram of an example of a card validation
And the corresponding JSON-LD and RDF Turtle representations of these instances are provided in the following code snippets and files:
We provide two different possibilities:
- https://github.com/oeg-upm/ssn-resource-center/blob/master/usage-examples/CRTM/v2/examples/validationExampleV2.jsonld
- https://github.com/oeg-upm/ssn-resource-center/blob/master/usage-examples/CRTM/v2/examples/validationExampleV2_reducedContext.jsonld
The first one is providing the whole context inside the JSON-LD file, while the second one refers to the context that is stored in other files. The last one will not work for the time being in the JSON-LD playground, since it requires CORS to be enabled to work properly.
{
"@context": ["http://oeg-upm.github.io/ssn-resource-center/json-ld/ssnContextV2.json","http://oeg-upm.github.io/ssn-resource-center/json-ld/crtmContextV2.json"],
"@id": "validacionInstancia:VAL_CF446342E9FD3D2FB6F16003EF28A3FD",
"@type": "esttp:CardValidation",
"rdfs:comment": "VALIDACION tarjeta 0421BAF79E2B05C7CA3E39BEE4837E1A en 2016-07-01T14:29:58",
"sosa:madeBySensor": {
"@id":"ttpDpaypoint:02_L7_P21",
"@type":"esttp:CardValidationSensor"
},
"sosa:resultTime": "2016-07-01T14:29:58",
"sosa:observedProperty": {
"@id": "esttp:UserEntry",
"@type": "sosa:ObservableProperty"
},
"sosa:hasFeatureOfInterest": {
"@id":"ttpHash:0421BAF79E2B05C7CA3E39BEE4837E1A",
"@type":"esttp:TransportCard"
},
"sosa:hasResult": {
"@id": "validacionValor:VAL_CF446342E9FD3D2FB6F16003EF28A3FD",
"@type": "esttp:CardValidationResult",
"esttp:validationType": "http://vocab.linkeddata.es/datosabiertos/kos/transporte/tipovalidacion/abono",
"esttp:titulo": "titulo:4107",
"esttp:perfil": "perfil:01"
}
}
<http://crtm.linkeddata.es/recurso/transporte/tarjeta-transporte-publico/0421BAF79E2B05C7CA3E39BEE4837E1A>
a <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#TarjetaTransporte> .
<http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#UserEntry>
a <http://www.w3.org/ns/sosa/ObservableProperty> .
<http://crtm.linkeddata.es/recurso/transporte/validacion/VAL_CF446342E9FD3D2FB6F16003EF28A3FD>
a <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#CardValidation> ;
<http://www.w3.org/2000/01/rdf-schema#comment>
"VALIDACION tarjeta 0421BAF79E2B05C7CA3E39BEE4837E1A en 2016-07-01T14:29:58"^^<http://www.w3.org/2001/XMLSchema#string> ;
<http://www.w3.org/ns/sosa/hasFeatureOfInterest>
<http://crtm.linkeddata.es/recurso/transporte/tarjeta-transporte-publico/0421BAF79E2B05C7CA3E39BEE4837E1A> ;
<http://www.w3.org/ns/sosa/hasResult>
<http://crtm.linkeddata.es/recurso/transporte/validacion/valor/VAL_CF446342E9FD3D2FB6F16003EF28A3FD> ;
<http://www.w3.org/ns/sosa/madeBySensor>
<http://crtm.linkeddata.es/recurso/transporte/validacion/dpaypoint/02_L7_P21> ;
<http://www.w3.org/ns/sosa/observedProperty>
<http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#UserEntry> ;
<http://www.w3.org/ns/sosa/resultTime>
"2016-07-01T14:29:58"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://crtm.linkeddata.es/recurso/transporte/validacion/dpaypoint/02_L7_P21>
a <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#CardValidationSensor> .
<http://crtm.linkeddata.es/recurso/transporte/validacion/valor/VAL_CF446342E9FD3D2FB6F16003EF28A3FD>
a <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#CardValidationResult> ;
<http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#perfil>
"perfil:01"^^<http://www.w3.org/2001/XMLSchema#string> ;
<http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#validationType>
"http://vocab.linkeddata.es/datosabiertos/kos/transporte/tipovalidacion/abono"^^<http://www.w3.org/2001/XMLSchema#string> ;
<http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#titulo>
"titulo:4107"^^<http://www.w3.org/2001/XMLSchema#string> .
We have set up a SPARQL endpoint to query a data sample containing card validations and card charges from several months (dates to be specified). The IRI of the card validations graph is http://crtm.linkeddata.es/graph/data/validaciones. The IRI of the card charges graph is http://crtm.linkeddata.es/graph/data/cargas.
This SPARQL query returns validation records. Each record includes: transport card id, validation title, validation type, validation profile, observed property, timestamp, and validation point. https://github.com/oeg-upm/ssn-resource-center/blob/master/usage-examples/CRTM/v2/queries/Q01_W3CCardValidation.sparql
PREFIX estp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico#>
PREFIX esttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
SELECT DISTINCT (?feature AS ?idTitulo) (?title AS ?tituloValidacion) (?type AS ?tipoValidacion) (?profile as ?perfil) (?property AS ?propiedad) (?time AS ?fecha) (?observedBy AS ?dpaypoint)
WHERE {
?obs a esttp:CardValidation .
?obs sosa:resultTime ?time .
?obs sosa:madeBySensor ?observedBy .
?obs sosa:hasFeatureOfInterest ?feature .
?obs sosa:hasResult ?obsValue .
?obsValue esttp:titulo ?title .
?obsValue esttp:perfil ?profile .
?obsValue esttp:validationType ?type .
?obs sosa:observedProperty ?property .
FILTER(month(?time)=7 && year(?time)=2016)
} LIMIT 100
This SPARQL query returns 100 validation records for August 2013. Each record includes: transport card id, charge title, charge type, charge profile, observed property, timestamp, and charge point. https://github.com/oeg-upm/ssn-resource-center/blob/master/usage-examples/CRTM/v2/queries/Q02_W3CCardCharge.sparql
PREFIX estp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico#>
PREFIX esttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
SELECT DISTINCT (?feature AS ?idTitulo) (?title AS ?tituloValidacion) (?type AS ?tipoValidacion) (?profile as ?perfil) (?property AS ?propiedad) (?time AS ?fecha) (?observedBy AS ?dpaypoint)
WHERE {
?obs a esttp:CardChargeObservation .
?obs sosa:resultTime ?time .
?obs sosa:madeBySensor ?observedBy .
?obs sosa:hasFeatureOfInterest ?feature .
?obs sosa:hasResult ?obsValue .
?obsValue esttp:titulo ?title .
?obsValue esttp:perfil ?profile .
?obsValue esttp:validationType ?type .
?obs sosa:observedProperty ?property .
FILTER(month(?time)=7 && year(?time)=2016)
} LIMIT 100
This SPARQL query returns the characteristics of all users such as document type, gender, birth date and address. The graph for users is: http://crtm.linkeddata.es/graph/data/usuarios https://github.com/oeg-upm/ssn-resource-center/blob/master/usage-examples/CRTM/v2/queries/Q03_W3CCharacterizationAllUsers.sparql
PREFIX esttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#>
PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
SELECT ?idTarjeta ?tipoDocumento ?genero ?fechaNacimiento ?localidad ?provincia ?codigoPostal ?coordenadas
WHERE {
?usuario a esttp:Usuario .
?usuario esttp:idTarjeta ?idTarjeta .
?usuario esttp:tipoDocumento ?tipoDocumento .
?usuario schema:gender ?genero .
?usuario schema:birthDate ?fechaNacimiento .
?usuario schema:address ?postalAddress .
?postalAddress schema:addressRegion ?provincia .
?postalAddress schema:addressLocality ?localidad .
?postalAddress schema:postalCode ?codigoPostal .
?postalAddress geosparql:hasGeometry ?geometry .
?geometry geosparql:asWKT ?coordenadas .
}
-
Filtering based on the birth year. Add the characterization query (Q03) in the WHERE block with the following line:
FILTER( ?fechaNacimiento > "1991" ) .
-
Filtering based on the document type (01=Spanish Document of Identification, 02=Passport, 03=Non-Spanish Document of Identification, 04=Residence Card). Add the characterization query (Q03) in the WHERE block with the following line:
FILTER( ?tipoDocumento = "04" ) .
-
Query for checking users with special needs with subsidized profile (large families and people with disabilities). TODO
-
Query on the distribution of users belong the frequency of recharge they did of their Smart card. This analysis provides information about the behavior of individuals in relation to the use of their transport card. Combine Q02 with Q03.
-
Filtering based on the individual type (01=Normal, 02=Senior Citizen, 03=Young People). For example, to filter only the trips by senior citizens, add the following line to Q01 inside the WHERE block:
FILTER ( regex( ?profile, "02", "i") )
-
Filtering based on the mode of transport (02=Metro, 03=EMT, 04=RENFE). For example, to filter only the METRO trips, add the following line to Q01 inside the WHERE block:
FILTER ( regex( ?observedBy, "02_", "i") )
PREFIX esttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
SELECT DISTINCT ?hashTarjeta ?title ?perfil ?dPayPoint ?FechaYhora
FROM NAMED <http://crtm.linkeddata.es/graph/data/validaciones>
WHERE {
GRAPH <http://crtm.linkeddata.es/graph/data/validaciones> {
?obs a esttp:CardValidation .
?obs sosa:resultTime ?FechaYhora .
?obs sosa:madeBySensor ?dPayPoint .
?obs sosa:hasFeatureOfInterest ?hashTarjeta .
?obs sosa:hasResult ?instanciaValidacion
?instanciaValidacion esttp:titulo ?title .
?instanciaValidacion esttp:perfil ?perfil .
FILTER (?FechaYhora>= "2016-03-08"^^xsd:date && ?FechaYhora< "2016-03-10"^^xsd:date)
}
} LIMIT 10
PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
PREFIX esttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
SELECT DISTINCT ?dPayPoint ?geometry
FROM NAMED <http://crtm.linkeddata.es/graph/data/validaciones>
FROM NAMED <http://crtm.linkeddata.es/graph/data/dpaypoints>
WHERE {
GRAPH <http://crtm.linkeddata.es/graph/data/validaciones> {
?obs a esttp:CardValidation .
?obs sosa:madeBySensor ?dPayPoint .
# FILTER (?time >= "2016-03-08"^^xsd:date && ?time < "2016-03-10"^^xsd:date)
}
GRAPH <http://crtm.linkeddata.es/graph/data/dpaypoints> {
?dPayPoint geosparql:hasGeometry/geosparql:asWKT ?geometry .
}
} LIMIT 10
PREFIX geosparql: <http://www.opengis.net/ont/geosparql#>
PREFIX esttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/transporte-publico/tarjeta#>
PREFIX sosa: <http://www.w3.org/ns/sosa/>
SELECT DISTINCT ?hashTarjeta ?title ?perfil ?FechaYhora ?dPayPoint ?coordenadas
FROM NAMED <http://crtm.linkeddata.es/graph/data/validaciones>
FROM NAMED <http://crtm.linkeddata.es/graph/data/dpaypoints>
WHERE {
GRAPH <http://crtm.linkeddata.es/graph/data/validaciones> {
?obs a esttp:CardValidation .
?obs sosa:resultTime ?FechaYhora.
?obs sosa:madeBySensor ?dPayPoint .
?obs sosa:hasFeatureOfInterest ?hashTarjeta .
?obs sosa:hasResult ?instanciaValidacion.
?instanciaValidacion esttp:titulo ?title .
?instanciaValidacion esttp:perfil ?perfil .
FILTER (?FechaYhora>= "2016-03-08"^^xsd:date && ?FechaYhora< "2016-03-10"^^xsd:date)
}
#OPTIONAL{
GRAPH <http://crtm.linkeddata.es/graph/data/dpaypoints> {
?dPayPoint geosparql:hasGeometry/geosparql:asWKT ?coordenadas .
}
#}
} LIMIT 10