.. _examples:
Examples and code snippets
==============================
WFS with OpenLayers
-------------------
This example shows the usage of the WFS service for real time bike stands availability using the OpenLayers library.
.. image:: _static/openlayers.png
Corresponding snippet :
.. code-block:: html
GrandLyon Data services usage : OpenLayers
WFS with Leaflet
----------------
This example shows the use of the WFS service of real time bike stands with the Leaflet library.
.. image:: _static/leaflet.png
Corresponding source code :
.. code-block:: html
Usage of GrandLyon data services : Leaflet
KML with GoogleMaps API
------------------------------------
This example shows the usage of the KML service of real-time bike stands monitoring with GoogleMaps API v3. This needs a personal API key.
.. image:: _static/google.png
Corresponding source code :
.. code-block:: html
Use of GrandLyon Data Services : Google API
WCS examples
-------------------
This example shows the usage of a WCS service to retrieve NO2 raw data for 2012 across the Grand Lyon territory.
In this example, we will use the server 2.0.1 of standard, which is the most recent. But it is also possible to use 1.1.1 or even 1.0.0 versions.
**Step 1** : getting the service capabilities
https://data.grandlyon.com/wcs?SERVICE=WCS&REQUEST=GetCapabilities&VERSION=2.0.1
.. image:: _static/wcs_GetCapabilities.png
Among the received information, one can discover the available output formats. WCS is a kind of service designed to provide raw data. Thus it is recommanded to use it with an output format able to handle full image definition, like **image/x-aaigrid** for monoband images or **image/tiff** for a multi-spectral raster file rather than the visualization output formats that are **image/jpeg** or **image/gif**.
In the last part of the returned XML document, we find the coverage list available from the service, and as part of it the **grandlyon:sTFONS_Step_02cm_2018** coverage we will be using in the rest of this example.
**Step 2** : Coverages details
https://data.grandlyon.com/geoserver/wcs?SERVICE=WCS&REQUEST=DescribeCoverage&VERSION=2.0.1&COVERAGEID=grandlyon:STFONS_Step_02cm_2018
Caution ! In the 2.0.1 version, the parameter used to indicate the requested coverage is **COVERAGEID**, but in version 1.0 it's **IDENTIFIER** and in version 1.1, it's **COVERAGE**. Yes, it's a lot of fun and provdes a lot a work for consultants.
Beware the coverage name case as well if you are manually testing the requests from a web browser : the WCS service is case sensitive. That way, the *grandlyon:sTFONS_Step_02cm_2018* coverage (with lower case 'l') won't be found by the service.
.. image:: _static/wcs_DescribeCoverage.png
This request lets you retrieve all the details of the specified coverage, like the geographic extent or information about the different bands. It shows clearly the data source we are requesting is a 3 band multi-spectral image.
**Step 3** : obtention de la couverture
The following request lets you retrieve a sample of the original raster image in TIFF format :
https://data.grandlyon.com/geoserver/wcs?SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&FORMAT=image/tiff&COVERAGEID=grandlyon:STFONS_Step_02cm_2018
CSW Service usage
--------------------------
This example illustrates the usage of a CSW service to get information about the metadata.
**Step 1** : Service capacities reading
https://data.grandlyon.com/geonetwork/srv/fre/csw?version=2.0.2&request=GetCapabilities&service=CSW
XML document rendering example (from QGIS CSW plugin):
.. image:: _static/csw_getCapabilities.png
**Step 2** : Query with keywords (transport here)
POST request : https://data.grandlyon.com/geonetwork/srv/fre/csw
with XML data embedded in the POST body :
.. code-block:: xml
full
csw:AnyText
Réseaux de transport
XML response abstract :
.. code-block:: xml
Alertes accessibilité du réseau TCL
256900994
Réseaux de transport
Services d'utilité publique et services publics
Les alertes accessibilité recensent les ascenseurs et escaliers mécaniques actuellement indisponibles dans les stations de métro et de tramway équipées du réseau TCL.
SYTRAL
nonGeographicDataset
application/json
text/csv
csv (taille : 2 Ko)
Données provenant de la base géographique et topologique TCL SYTRAL.
fre
https://download.data.grandlyon.com/ws/rdata/tcl_sytral.tclalerteaccessibilite/all.json
https://download.data.grandlyon.com/files/rdata/tcl_sytral.tclalerteaccessibilite/alerte_accessibilite.csv
https://download.data.grandlyon.com/files/grandlyon/LicenceEngagee.pdf
North 45.917, South 45.55, East 5.067, West 4.681. GRAND LYON
Licence Engagée
Pas de restriction d'accès public selon INSPIRE
2014-12-04
2015-02-02
16a9a657-e938-484e-a067-5cdacd7a0419
Free access with registration
continuous
2015-11-06T00:02:26
4721ec9e-86c8-4687-8713-f406290949ad
45.55 4.681
45.917 5.067
58f93af3-a651-4cbd-bd9d-b4562f8d404d
2015-11-06T00:04:55
Lignes de métro et funiculaire du réseau TCL
dataset
Réseaux de transport
Services d'utilité publique et services publics
transportation
La représentation graphique des lignes de métro et de funiculaire du réseau TCL est un objet linéaire qui localise la ligne et son parcours de terminus à terminus.
La représentation graphique des lignes est caractérisée par des informations de gestion (identifiant, numéro de ligne et sens, libellé, unité de transport, couleur du tracé, famille de transport) et de tracés (polylignes de terminus à terminus).
La représentation graphique des lignes de métro et de funiculaire du réseau TCL est un objet linéaire qui localise la ligne et son parcours de terminus à terminus.
La représentation graphique des lignes est caractérisée par des informations de gestion (identifiant, numéro de ligne et sens, libellé, unité de transport, couleur du tracé, famille de transport) et de tracés (polylignes de terminus à terminus).
license
fre
Données provenant de la base géographique et topologique TCL SYTRAL.
16a9a657-e938-484e-a067-5cdacd7a0419
5.1410943067093 45.486705557736
4.629545313738 45.945335689366
jdbc:postgresql://postgis_tr:5432/grandlyon:$gl69@rdata
https://download.data.grandlyon.com/wms/rdata
https://download.data.grandlyon.com/wfs/rdata
https://download.data.grandlyon.com/ws/rdata/tcl_sytral.tcllignemf/all.json
https://download.data.grandlyon.com/files/grandlyon/LicenceOuverte.pdf
https://download.data.grandlyon.com/catalogue/srv/fre/resources.get?uuid=58f93af3-a651-4cbd-bd9d-b4562f8d404d&fname=funimetrotrac_s.png
https://download.data.grandlyon.com/catalogue/srv/fre/resources.get?uuid=58f93af3-a651-4cbd-bd9d-b4562f8d404d&fname=funimetrotrac.png
...
Result presentation example (CSW plugin in QGIS) :
.. image:: _static/csw_getRecords1.png
**Step 3** : Query with keywords and a geographic extent.
POST request : https://data.grandlyon.com/geonetwork/srv/fre/csw
with POST data :
.. code-block:: xml
full
ows:BoundingBox
4.7027853 45.597999
4.7191596 45.609031
csw:AnyText
Transport, Bus
Result presentation example (CSW plugin in QGIS) :
.. image:: _static/csw_getRecords2.png
**Step 4** : Metadata retrieval from its ID
https://data.grandlyon.com/geonetwork/srv/fre/csw?outputFormat=application%2Fxml&service=CSW&outputSchema=http%3A%2F%2Fwww.opengis.net%2Fcat%2Fcsw%2F2.0.2&request=GetRecordById&version=2.0.2&elementsetname=full&id=f5b0fe8e-f9cf-4f3c-8684-6b55d6935f6f
resulting XML :
.. code-block:: xml
f5b0fe8e-f9cf-4f3c-8684-6b55d6935f6f
2015-11-06T00:06:17
Aménagement cyclable
dataset
Réseaux de transport
transportation
planningCadastre
L'aménagement cyclable est un objet linéaire décrivant une infrastructure dédiée à la circulation des vélos (piste cyclable, bande cyclable, couloir bus ouverte aux vélos, double-sens cyclable, voie verte, mixité en zone de circulation apaisée). Il est caractérisé par des informations de gestion (nom, description, type d'aménagement, année de réalisation ...)
L'aménagement cyclable est un objet linéaire décrivant une infrastructure dédiée à la circulation des vélos (piste cyclable, bande cyclable, couloir bus ouverte aux vélos, double-sens cyclable, voie verte, mixité en zone de circulation apaisée). Il est caractérisé par des informations de gestion (nom, description, type d'aménagement, année de réalisation ...)
license
fre
Mise à jour en continu : remontée d'informations travaux des services du Grand Lyon et des partenaires et vérification de la donnée sur le terrain.
5.067 45.55
4.681 45.917
https://download.data.grandlyon.com/wms/grandlyon
https://download.data.grandlyon.com/wfs/grandlyon
https://download.data.grandlyon.com/ws/grandlyon/pvo_patrimoine_voirie.pvoamenagementcyclable/all.json
https://download.data.grandlyon.com/files/grandlyon/LicenceOuverte.pdf
https://download.data.grandlyon.com/catalogue/srv/fre/resources.get?uuid=f5b0fe8e-f9cf-4f3c-8684-6b55d6935f6f&fname=DV_AC_s.png
https://download.data.grandlyon.com/catalogue/srv/fre/resources.get?uuid=f5b0fe8e-f9cf-4f3c-8684-6b55d6935f6f&fname=DV_AC.png
Result presentation example (CSW plugin in QGIS) :
.. image:: _static/csw_getRecordByID.png