CRTM SSN v1.0 - oeg-upm/ssn-resource-center GitHub Wiki
Usage of SSN at CRTM (initial version of the SSN Ontology)
This page provides an example of how the SSN Ontology can be used for describing the validations that users do in the transport system of the region of Madrid with their transport card. The work described below uses the SSN Ontology available at the following url http://purl.oclc.org/NET/ssnx/ssn#. This is not the final version of the SSN Ontology but the work developed by the W3C Semantic Sensor Networks Incubator Group (SSN-XG).
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 the central part of the following figure (which comes from the SSN Ontology final report):

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:

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.

This ontology is available at XXXXXXXXXXX
A transport card validation example
Let us know imagine that a user with transport card number 111222333 uses his card to enter into the Metro system in Madrid on May 30th, 2002, ten seconds after 9:30am, assuming that we are using the timezone GMT+02:00, using the sensor with number 444555666.
The graphical view of the instances that would be generated of the previous ontology is provided in the following figure

And the corresponding JSON-LD and RDF Turtle representations of these instances are provided in the following code snippets and files:
JSON-LD
We provide two different possibilities:
- https://github.com/oeg-upm/ssn-resource-center/blob/master/usage-examples/CRTM/v1/examples/validationExample.jsonld
- https://github.com/oeg-upm/ssn-resource-center/blob/master/usage-examples/CRTM/v1/examples/validationExample_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/ssnContext.json","http://oeg-upm.github.io/ssn-resource-center/json-ld/crtmContext.json"],
"@id": "crtm:observacion/111222333-2002-05-30T09:30:10+02:00",
"@type": "estrnttp:CardValidationObservation",
"dcterms:title": "Validación de tarjeta 111222333 en 2002-05-30T09:30:10+02:00",
"dcterms:identifier": "111222333-2002-05-30T09:30:10+02:00",
"ssn:observedBy": {
"@id":"crtm:dpaypoint/444555666",
"@type":"estrnttp:CardValidationSensor"
},
"ssn:observationResultTime": "2002-05-30T09:30:10+02:00",
"ssn:observedProperty": {
"@id": "estrnttp:entradaUsuario",
"@type": "ssn:Property",
"ssn:isPropertyOf": "crtm:ttp/111222333"
},
"ssn:featureOfInterest": {
"@id":"crtm:ttp/111222333",
"@type":"estrnttp:TarjetaTransporte"
},
"ssn:observationResult": {
"@id": "crtm:resultadoValidacion/111222333-2002-05-30T09:30:10+02:00",
"@type": "estrnttp:CardValidationSensorOutput",
"ssn:isProducedBy": "crtm:dpaypoint/444555666",
"ssn:hasValue": {
"@id":"crtm:resultadoValidacion/111222333-2002-05-30T09:30:10+02:00/value",
"@type":"estrnttp:CardValidationObservationValue",
"estrnttp:validationType": "http://crtm.linkeddata.es/datosabiertos/kos/transporte/tipoValidacion/ant"
}
}
}
Turtle
@prefix dc: <http://purl.org/dc/terms/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://crtm.linkeddata.es/datosabiertos/recurso/transporte/observacion/111222333-2002-05-30T09:30:10+02:00> a <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#CardValidationObservation>;
dc:title "Validación de tarjeta 111222333 en 2002-05-30T09:30:10+02:00";
<http://purl.oclc.org/NET/ssnx/ssn#featureOfInterest> <http://crtm.linkeddata.es/datosabiertos/recurso/transporte/ttp/111222333>;
<http://purl.oclc.org/NET/ssnx/ssn#observationResult> <http://crtm.linkeddata.es/datosabiertos/recurso/transporte/resultadoValidacion/111222333-2002-05-30T09:30:10+02:00>;
<http://purl.oclc.org/NET/ssnx/ssn#observationResultTime> "2002-05-30T09:30:10+02:00"^^xsd:dateTime;
<http://purl.oclc.org/NET/ssnx/ssn#observedBy> <http://crtm.linkeddata.es/datosabiertos/recurso/transporte/dpaypoint/444555666>;
<http://purl.oclc.org/NET/ssnx/ssn#observedProperty> <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#entradaUsuario>;
dc:identifier "111222333-2002-05-30T09:30:10+02:00" .
<http://crtm.linkeddata.es/datosabiertos/recurso/transporte/resultadoValidacion/111222333-2002-05-30T09:30:10+02:00> a <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#CardValidationSensorOutput>;
<http://purl.oclc.org/NET/ssnx/ssn#isProducedBy> <http://crtm.linkeddata.es/datosabiertos/recurso/transporte/dpaypoint/444555666>;
<http://purl.oclc.org/NET/ssnx/ssn#hasValue> <http://crtm.linkeddata.es/datosabiertos/recurso/transporte/resultadoValidacion/111222333-2002-05-30T09:30:10+02:00/value> .
<http://crtm.linkeddata.es/datosabiertos/recurso/transporte/resultadoValidacion/111222333-2002-05-30T09:30:10+02:00/value> a <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#CardValidationObservationValue>;
<http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#validationType> <http://crtm.linkeddata.es/datosabiertos/kos/transporte/tipoValidacion/ant> .
<http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#entradaUsuario> a <http://purl.oclc.org/NET/ssnx/ssn#Property>;
<http://purl.oclc.org/NET/ssnx/ssn#isPropertyOf> <http://crtm.linkeddata.es/datosabiertos/recurso/transporte/ttp/111222333> .
<http://crtm.linkeddata.es/datosabiertos/recurso/transporte/dpaypoint/444555666> a <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#CardValidationSensor> .
<http://crtm.linkeddata.es/datosabiertos/recurso/transporte/ttp/111222333> a <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjetaTransportePublico#TarjetaTransporte> .
Query examples
# DATA IN NO LONGER AVAILABLE
We have set up a SPARQL endpoint to query a data sample containing card validations and card charges from August 2013 to July 2014 (both included) for 5.800 users. 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.
# DATA IN NO LONGER AVAILABLE
Q01: A card validation query
This SPARQL query returns validation records. Each record includes: transport card id, validation title, validation type, validation profile, observed property, timestamp, and validation point.
Validation records before 2016
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 ttp:CardValidationObservation .
?obs ssn:observationResultTime ?time .
?obs ssn:observedBy ?observedBy .
?obs ssn:featureOfInterest ?feature .
?obs ssn:observationResult ?sensorOutput .
?sensorOutput ssn:hasValue ?obsValue .
?obsValue ttp:validationTitle ?title .
?obsValue ttp:validationProfile ?profile .
?obsValue ttp:validationType ?type .
?obs ssn:observedProperty ?property .
FILTER(month(?time)=8 && year(?time)=2013)
} LIMIT 100
Validation records after 2016
Use default graph IRI: http://crtm.linkeddata.es/graph/data/validaciones
SELECT (?feature AS ?idTitulo) (?title AS ?tituloValidacion) (?type AS ?tipoValidacion) (?profile as ?perfil) (?property AS ?propiedad) (?time AS ?fecha) (?observedBy AS ?dpaypoint)
WHERE {
?obs a <http://datos.crtm.es/recurso/transporte/Validacion> .
?obs ssn:observationResultTime ?time .
?obs ssn:observedBy ?observedBy .
?obs ssn:featureOfInterest ?feature .
?obs ssn:observationResult ?sensorOutput .
?sensorOutput ssn:hasValue ?obsValue .
?obsValue <http://datos.crtm.es/recurso/transporte/titulo> ?title .
?obsValue <http://datos.crtm.es/recurso/transporte/perfil> ?profile .
?obsValue <http://datos.crtm.es/recurso/transporte/tipoValidacion> ?type .
?obs ssn:observedProperty ?property .
FILTER(month(?time)=1 && year(?time)=2016)
} LIMIT 100
Q02: A card charge query
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.
SELECT DISTINCT (?feature AS ?idTitulo) (?title AS ?tituloCarga) (?type AS ?tipoCarga) (?profile as ?perfil) (?property AS ?propiedad) (?time AS ?fecha) (?observedBy AS ?dsalepoint)
WHERE {
?obs a ttp:CardChargeObservation .
?obs ssn:observationResultTime ?time .
?obs ssn:observedBy ?observedBy .
?obs ssn:featureOfInterest ?feature .
?obs ssn:observationResult ?sensorOutput .
?sensorOutput ssn:hasValue ?obsValue .
?obsValue ttp:chargeTitle ?title .
?obsValue ttp:chargeProfile ?profile .
?obsValue ttp:chargeType ?type .
?obs ssn:observedProperty ?property .
FILTER(month(?time)=8 && year(?time)=2013)
} LIMIT 100
Q03: Characterization of all users
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
SELECT ?idTarjeta ?tipoDocumento ?genero ?fechaNacimiento ?localidad ?provincia ?codigoPostal ?coordenadas
WHERE {
?usuario a ttp:Usuario .
?usuario ttp:idTarjeta ?idTarjeta .
?usuario ttp: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 .
}
Possible exploitation based on the queries above
-
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 smartcard. 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") )
Q04: valid validation for a given time period
PREFIX dpay: <http://datos.crtm.es/recurso/transporte/validacion/dpaypoint/>
PREFIX gsp: <http://www.opengis.net/ont/geosparql#>
PREFIX ttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjeta-transporte-publico#>
PREFIX validacionInstancia: <http://crtm.linkeddata.es/recurso/transporte/validacion/>
PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn>
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 ttp:Validacion .
?obs ssn:observationResultTime ?FechaYhora.
?obs ssn:observedBy ?dPayPoint .
?obs ssn:observationResult ?sensorOutput .
?obs ssn:featureOfInterest ?hashTarjeta .
?sensorOutput ssn:hasValue ?instanciaValidacion.
?instanciaValidacion ttp:titulo ?title .
?instanciaValidacion ttp:perfil ?perfil .
FILTER (?FechaYhora>= "2016-03-08"^^xsd:date && ?FechaYhora< "2016-03-10"^^xsd:date)
}
} LIMIT 10
Q05: obtain dPayPoints with their coordinates
PREFIX dpay: <http://datos.crtm.es/recurso/transporte/validacion/dpaypoint/>
PREFIX gsp: <http://www.opengis.net/ont/geosparql#>
PREFIX ttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjeta-transporte-publico#>
PREFIX validacionInstancia: <http://crtm.linkeddata.es/recurso/transporte/validacion/>
PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn>
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 ttp:Validacion .
?obs ssn:observationResultTime ?time .
?obs ssn:observedBy ?dPayPoint .
?obs ssn:observationResult ?sensorOutput .
?sensorOutput ssn:hasValue ?obsValue .
# FILTER (?time >= "2016-03-08"^^xsd:date && ?time < "2016-03-10"^^xsd:date)
}
GRAPH <http://crtm.linkeddata.es/graph/data/dpaypoints> {
?dPayPoint gsp:hasGeometry/gsp:asWKT ?geometry .
}
} LIMIT 10
Q06: valid validations with coordinates for a given time period
PREFIX dpay: <http://datos.crtm.es/recurso/transporte/validacion/dpaypoint/>
PREFIX gsp: <http://www.opengis.net/ont/geosparql#>
PREFIX ttp: <http://vocab.linkeddata.es/datosabiertos/def/transporte/tarjeta-transporte-publico#>
PREFIX validacionInstancia: <http://crtm.linkeddata.es/recurso/transporte/validacion/>
PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn>
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 ttp:Validacion .
?obs ssn:observationResultTime ?FechaYhora.
?obs ssn:observedBy ?dPayPoint .
?obs ssn:observationResult ?sensorOutput .
?obs ssn:featureOfInterest ?hashTarjeta .
?sensorOutput ssn:hasValue ?instanciaValidacion.
?instanciaValidacion ttp:titulo ?title .
?instanciaValidacion ttp: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 gsp:hasGeometry/gsp:asWKT ?coordenadas .
}
#}
} LIMIT 10