Last active
November 10, 2015 21:25
-
-
Save eric-pommereau/1d45d85014224eafe008 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################################### | |
# Exemple d'utilisation du reverse geocodage sur la BAN | |
# D'une série de coordonnées géo (en csv) on récupère les adresses (les plus proches) | |
# Accès : http://api-adresse.data.gouv.fr/reverse/csv/ | |
###################################################################################### | |
# Soit le fichier de base lat pour latitude (y) lon pour longitude (x) | |
lat;lon | |
48.18962;-2.53815 | |
47.99303;-0.81681 | |
47.16353;0.42983 | |
48.86449;2.34176 | |
# pour l'exemple on installe httpie (lib python) --> pip install httpie | |
# Utiliser httpie pour interroger l'api BAN (le chemin du fichier soit être absolu) | |
[eric@Downloads]$ http --timeout 600 -f POST http://api-adresse.data.gouv.fr/reverse/csv/ data@/cheminAbsoluVersMonFichier/test.csv | |
#La réponse --------------------------------------- | |
HTTP/1.1 200 OK | |
Access-Control-Allow-Headers: X-Requested-With | |
Access-Control-Allow-Origin: * | |
Connection: keep-alive | |
Content-Disposition: attachment; filename="test.geocoded.csv" | |
Content-Length: 946 | |
Content-Type: text/csv; charset=utf-8 | |
Date: Mon, 09 Nov 2015 21:50:49 GMT | |
Server: nginx/1.2.1 | |
lat,lon,result_latitude,result_longitude,result_label,result_distance,result_type,result_id,result_housenumber,result_name,result_street,result_postcode,result_city,result_context,result_citycode | |
48.18962,-2.53815,48.18896,-2.538898,"5328 Les Rues Dolo, LE COMMUN 22230 Laurenan",91,housenumber,22122_C398B415_e1bfb4,5328,"Les Rues Dolo, LE COMMUN",,22230,Laurenan,"22, Côtes-d'Armor, Bretagne",22122 | |
47.99303,-0.81681,47.994205,-0.816853,5143 La Goupillère 53970 Montigné-le-Brillant,130,housenumber,53157_B055_f67bfa,5143,La Goupillère,,53970,Montigné-le-Brillant,"53, Mayenne, Pays de la Loire",53157 | |
47.16353,0.42983,47.164671,0.426634,9 La Lande 37220 Panzoult,272,housenumber,37178_B094_3e1bac,9,La Lande,,37220,Panzoult,"37, Indre-et-Loire, Centre Val-de-Loire",37178 | |
48.86449,2.34176,48.864274,2.341588,32 Rue Coquillière 75001 Paris,27,housenumber,75101_2318_04401e,32,Rue Coquillière,,75001,Paris,"75, Île-de-France",75101 | |
# la même avec CURL (-i pour voir les headers) | |
curl --form "data=@/Users/ericpommereau/Downloads/test.csv" http://api-adresse.data.gouv.fr/reverse/csv/ |
Ton problème c'est "lat;long" au lieu de "lat;lon" ;)
du coup... addok/addok#128
Vu merci.. nickel...
J'essaye de le porter en curl, une idée pourquoi
curl -X POST -F [email protected] -x http://login:[email protected]:3128 http://api-adresse.data.gouv.fr/reverse/csv/ -i
me retourne
HTTP/1.1 100 Continue
Connection: keep-alive
HTTP/1.1 400 Bad Request
Server: nginx/1.2.1
Date: Tue, 10 Nov 2015 09:00:49 GMT
Content-Type: text/html
Content-Length: 192
Accept-Ranges: none
X-Cache: MISS from proxy
X-Cache-Lookup: MISS from proxy:3128
Via: 1.1 proxy (squid/3.3.8)
Connection: keep-alive
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>
Et hop... :)
curl --form "data=@/Users/ericpommereau/Downloads/test.csv" http://api-adresse.data.gouv.fr/reverse/csv/
Génial.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quand je crée le fichier avec vim ça marche... pb d'encodage je pense...
Rien à faire quand j'enregistre avec libreoffice... creepy !!