Les moteurs de recherche du Géoportail reposent sur le standard OGC "Location Utility Service" (OpenLS). Les requêtes OpenLS peuvent être soit des requêtes POST XML, soit des requêtes KVP GET. Comme l'accès aux moteurs de recherche est protégé par la GeoRM, l'URL de la requête doit contenir un jeton à jour de façon à obtenir un résultat des moteurs de recherche.
http://wxs.ign.fr/geoportail/gazetteer/OpenLSPOST?gppkey= gC2UZGUr_JJi5Nm7QKN5hQG06pEAAAAAAAHWLRe_BD6d4QTVAAABHiB QmEAAAAAAAlgAAQECvZr3ME_66sRrEAaAwzQAAEM0AADCtAAAQrQAAA
La balise freeFormAddress contient la localisation à rechercher :
<xls:XLS xmlns:xls="http://www.opengis.net/xls" version="1.0">
<xls:RequestHeader sessionID=""/>
<xls:Request methodName="GeocodeRequest" version="1.0" requestID="" maximumResponses="50">
<xls:GeocodeRequest>
<xls:Address countryCode="FR">
<xls:freeFormAddress>eifel</xls:freeFormAddress>
</xls:Address>
</xls:GeocodeRequest>
</xls:Request>
</xls:XLS>La localisation géographique est stockée dans la balise Point. La balise Place contient le nom trouvé. La balise PostalCode contient le type du toponyme trouvé (Cf. liste des types pour plus d'informations). La balise GeocodeMatchCode contient un indicateur de pertinence.
<xls:XLS
xmlns:xls="http://www.opengis.net/xls"
version="1.000000"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/xls LocationUtilityService.xsd">
<ResponseHeader xmlns="http://www.opengis.net/xls"/>
<Response xmlns="http://www.opengis.net/xls" requestID="" version="1.0">
<GeocodeResponse>
<GeocodeResponseList numberOfGeocodedAddresses="27">
<GeocodedAddress>
<Point xmlns="http://www.opengis.net/gml">
<pos dimension="2">48.858263 2.294243</pos>
</Point>
<Address countryCode="BDNYME">
<StreetAddress>
<Street></Street>
</StreetAddress>
<Place type="Municipality">tour eiffel</Place>
<PostalCode>Monument</PostalCode>
</Address>
<GeocodeMatchCode accuracy="0.904621" matchType="City"/>
</GeocodedAddress>
...
</GeocodeResponseList>
</GeocodeResponse>
</Response>
</xls:XLS>Le corps de la requête POST XML est encodé pour permettre son passage par valeur via le paramètre xls :
http://wxs.ign.fr/geoportail/gazetteer/OpenLSPOST?gppkey= gC2UZGUr_JJi5Nm7QKN5hQG06pEAAAAAAAHWLRe_BD6d4QTVAAABHiB QmEAAAAAAAlgAAQECvZr3ME_66sRrEAaAwzQAAEM0AADCtAAAQrQAAA& xls=%3Cxls%3AXLS%20xmlns%3Axls%3D%22http%3A%2F%2Fwww.opengis.net%2Fxls%22%20version%3D%221.0%22%3E %3Cxls%3ARequestHeader%20sessionID%3D%22%22%2F%3E %3Cxls%3ARequest%20methodName%3D%22GeocodeRequest%22%20version%3D%221.0%22%20requestID%3D%22%22%20maximumResponses%3D%2250%22%3E %3Cxls%3AGeocodeRequest%3E %3Cxls%3AAddress%20countryCode%3D%22FR%22%3E %3Cxls%3AfreeFormAddress%3Eeifel %3C%2Fxls%3AfreeFormAddress%3E%3C%2Fxls%3AAddress%3E %3C%2Fxls%3AGeocodeRequest%3E %3C%2Fxls%3ARequest%3E %3C%2Fxls%3ARequest%3E %3C%2Fxls%3AXLS%3E& callback=MyCallBack
Le paramètre callback est optionnel (mais, très utile pour des requêtes JSONP).
La réponse est une chaîne JSON :
MyCallBack && MyCallBack({"http":{"code":200,"url":""},"xml":
"<xls:XLS
xmlns:xls=\"http://www.opengis.net/xls\"
version=\"1.000000\"
xmlns:gml=\"http://www.opengis.net/gml\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.opengis.net/xls LocationUtilityService.xsd\">
<ResponseHeader xmlns=\"http://www.opengis.net/xls\"/>
<Response xmlns=\"http://www.opengis.net/xls\" requestID=\"\" version=\"1.0\">
<GeocodeResponse>
<GeocodeResponseList numberOfGeocodedAddresses=\"27\">
<GeocodedAddress>
<Point xmlns=\"http://www.opengis.net/gml\">
<pos dimension=\"2\">48.858263 2.294243</pos>
</Point>
<Address countryCode=\"BDNYME\">
<StreetAddress>
<Street></Street>
</StreetAddress>
<Place type=\"Municipality\">tour eiffel</Place>
<PostalCode>Monument</PostalCode>
</Address>
<GeocodeMatchCode accuracy=\"0.904621\" matchType=\"City\"/>
</GeocodedAddress>
...
</GeocodeResponseList>
</GeocodeResponse>
</Response>
</xls:XLS>"})http://wxs.ign.fr/geoportail/ols/OpenLSPOST?gppkey= gC2UZGUr_JJi5Nm7QKN5hQG06pEAAAAAAAHWLRe_BD6d4QTVAAABHiB QmEAAAAAAAlgAAQECvZr3ME_66sRrEAaAwzQAAEM0AADCtAAAQrQAAA
La balise Street contient les informations sur la rue; la balise Place contient le nom de la localité pour la recherche.
<xls:XLS xmlns:xls="http://www.opengis.net/xls" version="1.0">
<xls:RequestHeader sessionID=""/>
<xls:Request methodName="GeocodeRequest" version="1.0" requestID="" maximumResponses="50">
<xls:GeocodeRequest>
<xls:Address countryCode="FR">
<xls:StreetAddress>
<xls:Street>73, avenue de paris</xls:Street>
</xls:StreetAddress>
<xls:Place type="Municipality">saint mande</xls:Place>
<xls:PostalCode/>
</xls:Address>
</xls:GeocodeRequest>
</xls:Request>
</xls:XLS>La localisation géographique est stockée dans la balise Point. La balise Address contient l'adresse trouvée. La balise Street contient l'adresse exacte. La balise Place contient la ville, la balise PostalCode contient le code postal. La balise GeocodeMatchCode contient un indicateur de pertinence.
<xls:XLS
xmlns:xls="http://www.opengis.net/xls"
version="1.000000"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/xls LocationUtilityService.xsd">
<ResponseHeader xmlns="http://www.opengis.net/xls"/>
<Response xmlns="http://www.opengis.net/xls" requestID="" version="1.0">
<GeocodeResponse>
<GeocodeResponseList numberOfGeocodedAddresses="1">
<GeocodedAddress>
<Point xmlns="http://www.opengis.net/gml">
<pos dimension="2">48.845885 2.424274</pos>
</Point>
<Address countryCode="FR">
<StreetAddress>
<Street>73 AV DE PARIS</Street>
</StreetAddress>
<Place type="Municipality">Saint-Mandé</Place>
<PostalCode>94160</PostalCode>
</Address>
<GeocodeMatchCode accuracy="1" matchType="Street number"/>
</GeocodedAddress>
</GeocodeResponseList>
</GeocodeResponse>
</Response>
</xls:XLS>Quant l'attribut countryCode de la balise Address d'une requête est égal à "PointOfInterest", il spécifie une recherche par lieux.
http://wxs.ign.fr/VOTRE_LICENCE/geoportail/ols?
La balise freeFormAddress contient la localisation à rechercher :
<?xml version="1.0" encoding="UTF-8"?>
<XLS
xmlns:xls="http://www.opengis.net/xls"
xmlns:gml="http://www.opengis.net/gml"
xmlns="http://www.opengis.net/xls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.2"
xsi:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd">
<RequestHeader/>
<Request requestID="1" version="1.2" methodName="LocationUtilityService">
<GeocodeRequest returnFreeForm="false">
<Address countryCode="PointOfInterest">
<freeFormAddress>rennes</freeFormAddress>
</Address>
</GeocodeRequest>
</Request>
</XLS>La localisation géographique est stockée dans la balise Point. La balise Place contient le nom trouvé. La balise GeocodeMatchCode contient un indicateur de pertinence.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XLS
version="1.2"
ns4:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd"
xmlns="http://www.opengis.net/xls"
xmlns:ns4="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlsext="http://www.opengis.net/xlsext"
xmlns:gml="http://www.opengis.net/gml">
<ResponseHeader/>
<Response version="1.2" requestID="1">
<GeocodeResponse>
<GeocodeResponseList numberOfGeocodedAddresses="1">
<GeocodedAddress>
<gml:Point>
<gml:pos>48.111679 -1.681862</gml:pos>
</gml:Point>
<Address countryCode="PointOfInterest">
<StreetAddress>
<Street></Street>
</StreetAddress>
<Place type="Municipality">Rennes</Place>
<Place type="IRIS">RENNES;RENNES;ILLE-ET-VILAINE;BRETAGNE</Place>
<PostalCode>35238</PostalCode>
</Address>
<GeocodeMatchCode matchType="City" accuracy="1.0"/>
</GeocodedAddress>
</GeocodeResponseList>
</GeocodeResponse>
</Response>
</XLS><?xml version="1.0" encoding="UTF-8"?>
<XLS
xmlns:xls="http://www.opengis.net/xls"
xmlns:gml="http://www.opengis.net/gml"
xmlns="http://www.opengis.net/xls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.2"
xsi:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd">
<RequestHeader/>
<Request requestID="1" version="1.2" methodName="LocationUtilityService">
<GeocodeRequest returnFreeForm="false">
<Address countryCode="PointOfInterest">
<freeFormAddress>rennes</freeFormAddress>
<gml:pos> -2.494259 48.533782</gml:pos>
<gml:pos>-1.07059 47.790983</gml:pos>
</Address>
</GeocodeRequest>
</Request>
</XLS><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XLS
version="1.2"
ns4:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd"
xmlns="http://www.opengis.net/xls"
xmlns:ns4="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlsext="http://www.opengis.net/xlsext"
xmlns:gml="http://www.opengis.net/gml">
<ResponseHeader/>
<Response version="1.2" requestID="1">
<GeocodeResponse>
<GeocodeResponseList numberOfGeocodedAddresses="1">
<GeocodedAddress>
<gml:Point>
<gml:pos>48.111679 -1.681862</gml:pos>
</gml:Point>
<Address countryCode="PointOfInterest">
<StreetAddress>
<Street></Street>
</StreetAddress>
<Place type="Municipality">Rennes</Place>
<Place type="IRIS">RENNES;RENNES;ILLE-ET-VILAINE;BRETAGNE</Place>
<PostalCode>35238</PostalCode>
</Address>
<GeocodeMatchCode matchType="City" accuracy="1.0"/>
</GeocodedAddress>
</GeocodeResponseList>
</GeocodeResponse>
</Response>
</XLS>
http://wxs.ign.fr/VOTRE_LICENCE/geoportail/ols?
L'attribut countryCode de la balise Address d'une requête est égal à "StreetAddress", il spécifie une recherche par adresses.
<?xml version="1.0" encoding="UTF-8"?>
<XLS
xmlns:xls="http://www.opengis.net/xls"
xmlns:gml="http://www.opengis.net/gml"
xmlns="http://www.opengis.net/xls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.2"
xsi:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd">
<RequestHeader/>
<Request requestID="1" version="1.2" methodName="LocationUtilityService">
<GeocodeRequest returnFreeForm="false">
<Address countryCode="StreetAddress">
<freeFormAddress>1 rue Marconi 57000 Metz</freeFormAddress>
</Address>
</GeocodeRequest>
</Request>
</XLS>La localisation géographique est stockée dans la balise Point. La balise Address contient l'adresse trouvée. La balise Street contient l'adresse exacte. La balise Place contient la ville, la balise PostalCode contient le code postal. La balise GeocodeMatchCode contient un indicateur de pertinence.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XLS
version="1.2"
ns4:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd"
xmlns="http://www.opengis.net/xls"
xmlns:ns4="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlsext="http://www.opengis.net/xlsext"
xmlns:gml="http://www.opengis.net/gml">
<ResponseHeader/>
<Response version="1.2" requestID="1">
<GeocodeResponse>
<GeocodeResponseList numberOfGeocodedAddresses="1">
<GeocodedAddress>
<gml:Point>
<gml:pos>49.104565 6.214763</gml:pos>
</gml:Point>
<Address countryCode="StreetAddress">
<StreetAddress>
<Building number="1"/>
<Street>R MARCONI</Street>
</StreetAddress>
<Place type="Municipality">Metz</Place>
<Place type="IRIS">57463</Place>
<PostalCode>57463</PostalCode>
</Address>
<GeocodeMatchCode matchType="StreetNumber" accuracy="0.9495000000000001"/>
</GeocodedAddress>
</GeocodeResponseList>
</GeocodeResponse>
</Response>
</XLS>La balise Street contient les informations sur la rue; la balise Place contient le nom de la localité pour la recherche.
<?xml version="1.0" encoding="UTF-8"?>
<XLS
xmlns:xls="http://www.opengis.net/xls"
xmlns:gml="http://www.opengis.net/gml"
xmlns="http://www.opengis.net/xls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.2"
xsi:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd">
<RequestHeader/>
<Request requestID="1" version="1.2" methodName="LocationUtilityService">
<GeocodeRequest returnFreeForm="false">
<Address countryCode="StreetAddress">
<StreetAddress>
<Street>1 rue Marconi</Street>
</StreetAddress>
<Place type="Municipality">Metz</Place>
<PostalCode>57000</PostalCode>
</Address>
</GeocodeRequest>
</Request>
</XLS><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XLS
version="1.2"
ns4:schemaLocation="http://www.opengis.net/xls http://schemas.opengis.net/ols/1.2/olsAll.xsd"
xmlns="http://www.opengis.net/xls"
xmlns:ns4="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlsext="http://www.opengis.net/xlsext"
xmlns:gml="http://www.opengis.net/gml">
<ResponseHeader/>
<Response version="1.2" requestID="1">
<GeocodeResponse>
<GeocodeResponseList numberOfGeocodedAddresses="1">
<GeocodedAddress>
<gml:Point>
<gml:pos>49.104565 6.214763</gml:pos>
</gml:Point>
<Address countryCode="StreetAddress">
<StreetAddress>
<Building number="1"/>
<Street>R MARCONI</Street>
</StreetAddress>
<Place type="Municipality">Metz</Place>
<Place type="IRIS">57463</Place>
<PostalCode>57463</PostalCode>
</Address>
<GeocodeMatchCode matchType="StreetNumber" accuracy="0.9495000000000001"/>
</GeocodedAddress>
</GeocodeResponseList>
</GeocodeResponse>
</Response>
</XLS>Toutes les URLs précédentes répondent aussi à la méthode GET. Le corps de la requête est encodé pour être assigné comme valeur au paramètre xls. De plus, l'ajout du paramètre output avec la valeur 'json' indique de retourner une réponse XML imbriquée dans une syntaxe JSON. L'utilisation du paramètre callback permet aussi de mettre en oeuvre le protocole JSONP.