Cette carte interactive a été générée grâce à l'app embedMap : https://www.owlapps.net/modules/owlapps_apps/embedmap
<script src = "https://www.owlapps.net/modules/owlapps_apps/embedmap/main.js" language="javascript" defer></script> <iframe name="Demo for WMS GetFeatureInfo functionalities" data-owlappslayers = '[ { "overlay":"yes", "type":"wms", "name":"France Densité INSEE.FILOSOFI.POPULATION", "url": "https://data.geopf.fr/wmts?VERSION=1.0.0&TILEMATRIXSET=PM&TRANSPARENT=true&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}", "layer": "INSEE.FILOSOFI.POPULATION", "legend": "https://data.geopf.fr/wms-v/ows?service=WMS&version=1.3.0&request=GetLegendGraphic&format=image%2Fpng&width=20&height=20&layer=INSEE.FILOSOFI.POPULATION", "format": "image/png", "service": "WMTS", "request": "GetTile", "style": "INSEE", "attribution" : ", Carte © IGN-F/Geoportail", "GetFeatureInfoParams": [ { "infolabel" : "INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET (html format)", "url": "https://data.geopf.fr/wms-v/ows?SERVICE=WMS", "query_layers": "INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET", "layers": "INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET", "version" : "1.3.0", "info_format": "text/html" } ] }, { "overlay":"yes", "type":"wms", "name":"France CADASTRALPARCELS.PARCELLAIRE_EXPRESS", "url": "https://data.geopf.fr/wmts?VERSION=1.0.0&TILEMATRIXSET=PM&TRANSPARENT=true&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}", "layer": "CADASTRALPARCELS.PARCELLAIRE_EXPRESS", "legend": "https://data.geopf.fr/annexes/ressources/legendes/CADASTRALPARCELS.PARCELLAIRE_EXPRESS.png", "format": "image/png", "service": "WMTS", "request": "GetTile", "style": "normal", "attribution" : ", Carte © IGN-F/Geoportail" }, { "type":"wms" , "url": "https://data.geopf.fr/wmts?VERSION=1.0.0&TILEMATRIXSET=PM&TRANSPARENT=true&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}", "name":"France altimétrie GEOGRAPHICALGRIDSYSTEMS.SLOPES.MOUNTAIN", "format": "image/png", "service": "WMTS", "request": "GetTile", "layer":"GEOGRAPHICALGRIDSYSTEMS.SLOPES.MOUNTAIN", "overlay": "yes", "style":"normal", "attribution" : ", Carte © IGN-F/Geoportail", "legend": "https://data.geopf.fr/annexes/ressources/legendes/LEGEND.jpg", "GetFeatureInfoParams" : [ { "infolabel" : "API REST calcul altimétrique (format xml)", "url": "https://www.owlapps.net/test_rest_adapter_altimetrie.php" , "info_format": "text/xml" }, { "infolabel" : "API REST calcul altimétrique (format json)", "url": "https://www.owlapps.net/test_rest_adapter_altimetrie.php" , "info_format": "json" }, { "infolabel" : "API REST calcul altimétrique (format html)", "url": "https://www.owlapps.net/test_rest_adapter_altimetrie.php" , "info_format": "text/html" } ] }, { "type":"wms", "url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", "name":"Click-sensitive layer for <strong>WMS GetFeatureInfo</strong> functionalities,<br/>with an 0% opacity it is not visible on the map even if it is checked!", "attribution": "WMS GetFeatureInfo funcs layer!", "opacity": 0, "checked": "yes", "overlay": "yes", "GetFeatureInfoParams": [ { "infolabel" : "CADASTRALPARCELS.COMMUNES (text format)", "url": "https://data.geopf.fr/wms-v/ows?SERVICE=WMS" , "query_layers": "CADASTRALPARCELS.COMMUNES", "version" : "1.3.0", "layers": "CADASTRALPARCELS.COMMUNES" , "info_format": "text/plain" }, { "infolabel" : "CADASTRALPARCELS.COMMUNES (html format)", "url": "https://data.geopf.fr/wms-v/ows?SERVICE=WMS" , "query_layers": "CADASTRALPARCELS.COMMUNES", "version" : "1.3.0", "layers": "CADASTRALPARCELS.COMMUNES" , "info_format": "text/html" } ] } ]' name="2 GetFeatureInfo on a single WMS layer" style = "border:none;width:100%;min-height:350px;height:80%;" data-owlappsmap = "yes" > <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <Snippet> <![CDATA[ About the overlay layer called "France altimétrie GEOGRAPHICALGRIDSYSTEMS.SLOPES.MOUNTAIN": it has GetFeatureInfo functionalities based on the web service of the IGN Géoportail altimetrie REST API.<br/> The embedMap app implements the query functionalities of the <a href="http://opengeospatial.github.io/e-learning/wms/text/operations.html#getfeatureinfo" target="_blank" >GetFeatureInfo request protocol</a>: it sends the X and Y expressed in pixels relating to the click on the map however the <a href="https://geoservices.ign.fr/documentation/services/services-geoplateforme/altimetrie" target="_blank" >Géoportail web service relating to altimetry</a> only accepts longitude and latitude expressed in decimal degrees (WGS84).</br/></br/> This is why a match must be made before sending the request to the web service in question, this operation is carried out by the <strong>test_rest_adapter_altimetrie.php</strong> file.</br/></br/> It is also at the level of this file that a rework of the formatting of the information returned by the Géoportail web service is done for the "text/html" format: use of a space as a thousands separator, comma rather than period as decimal separator, etc.<br/> <hr> The overlay layer called "France Densité INSEE.FILOSOFI.POPULATION" has GetFeatureInfo functionalities based on the INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET queryable layer (html format),<br/> the params are written from <a target="_blank" href="https://geoservices.ign.fr/services-web-experts-economie" >from https://geoservices.ign.fr/services-web-experts-economie</a> and from <a target="_blank" href="https://data.geopf.fr/wms-v/ows?SERVICE=WMS&REQUEST=GetCapabilities&version=1.3.0" >https://data.geopf.fr/wms-v/ows?SERVICE=WMS&REQUEST=GetCapabilities&version=1.3.0</a>.<br/> GetFeatureInfo params : <br/> <strong> "GetFeatureInfoParams": [ { "infolabel" : "INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET (html format)", "url": "https://data.geopf.fr/wms-v/ows?SERVICE=WMS", "query_layers": "INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET", "layers": "INSEE.FILOSOFI.PART.PLUS.65.ANS.SECRET" , "version" : "1.3.0", "info_format": "text/html" } ] </strong> <hr> Click on the map to display feature info on: <br/><br/> <a href="geo:48.85339,2.34815?z=17"> Commune of Paris </a> <br/><br/> <a href="geo:48.84311,2.21857?z=16"> Commune of Saint-Cloud </a> <br/><br/> <a href="geo:48.87086,2.22511?z=17"> Commune of Suresnes </a> <br/><br/> The GetFeatureInfo params for the click-sensitive layer are: <br/> <strong> "GetFeatureInfoParams" : [ { "infolabel" : "CADASTRALPARCELS.COMMUNES (text format)", "url": "https://data.geopf.fr/wms-v/ows?SERVICE=WMS" , "query_layers": "CADASTRALPARCELS.COMMUNES", "version" : "1.3.0", "layers": "CADASTRALPARCELS.COMMUNES" , "info_format": "text/plain" }, { "infolabel" : "CADASTRALPARCELS.COMMUNES (html format)", "url": "https://data.geopf.fr/wms-v/ows?SERVICE=WMS" , "query_layers": "CADASTRALPARCELS.COMMUNES", "version" : "1.3.0", "layers": "CADASTRALPARCELS.COMMUNES" , "info_format": "text/html" } ] </strong> <br/><br/> Params written from: <br/> <a target="_blank" href="https://data.geopf.fr/wms-v/ows?SERVICE=WMS&REQUEST=GetCapabilities&version=1.3.0" > https://data.geopf.fr/wms-v/ows?SERVICE=WMS&REQUEST=GetCapabilities&version=1.3.0</a> and from <a target="_blank" href="https://geoservices.ign.fr/services-web-experts-parcellaire" > https://geoservices.ign.fr/services-web-experts-parcellaire </a> ]]> </Snippet> <Placemark> <name>Saint-Benoît (97410)</name> <Point> <coordinates> 55.53404,-21.13098 </coordinates> </Point> </Placemark> </Document> </kml> </iframe>
<?php header('Content-type: text/plain'); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Connection: close"); header('Content-type: text/html; charset=UTF-8'); /* very important */ header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); $contentType = 'text/xml' ; $format = strtolower($_GET["INFO_FORMAT"]); $bbox = explode(",", $_GET["BBOX"]); $dLon = abs($bbox[2] - $bbox[0]) ; // difference max longitude - min longitude $dLat = abs($bbox[3] - $bbox[1]) ; // difference max latitude - min latitude $clickLat = $bbox[1] + ($dLat * floatval($_GET["Y"])) / floatval($_GET["HEIGHT"]); $clickLon = $bbox[0] + ($dLon * floatval($_GET["X"])) / floatval($_GET["WIDTH"]); if ($format == 'text/xml') { $format = 'xml'; }elseif ($format == 'json') { $format = 'json'; $contentType = 'application/json'; }elseif ($format == 'text/html') { $format = 'xml'; $contentType = 'text/html'; } else { $format = 'xml'; } $ch = curl_init(); /* URl params written from https://geoservices.ign.fr/documentation/services/services-geoplateforme/altimetrie and from https://data.geopf.fr/wms-v/ows?SERVICE=WMS&REQUEST=GetCapabilities&version=1.3.0 */ curl_setopt($ch, CURLOPT_URL, "https://data.geopf.fr/altimetrie/1.0/calcul/alti/rest/elevation." . $format . "?lon=" .$clickLon . "&lat=" . $clickLat . "&resource=ign_rge_alti_wld&delimiter=|&indent=true&measures=false&zonly=true&zonly=true" ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:' . $contentType )); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $resp = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if(curl_errno($ch)) { echo curl_error($ch) ; } else { if ($contentType == 'text/html') { $xml = simplexml_load_string($resp); echo ( '<html><body>Valeur trouvée: <strong>' . number_format(floatval($xml->z), 2, ',', ' ') . ' mètres</strong>, merci l'IGN ! </body></html>' ); } else { echo $resp; } } curl_close($ch); ?>