Last active
August 29, 2015 13:59
-
-
Save 2xyo/11001093 to your computer and use it in GitHub Desktop.
Mantes-la-Jolie Opendata
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
| import json, requests, sys | |
| from geojson import Feature, Point, FeatureCollection, dumps | |
| url = 'http://manteslajolie.blueapps.com/photos/cat{}.json' | |
| categories = { | |
| 27: "Alimentaire", | |
| 28: "Prêt à Porter", | |
| 29: "Déco / Bricolage", | |
| 30: "Santé", | |
| 43: "Beauté", | |
| 31: "Services", | |
| 44: "Technologies", | |
| 41: "Banques / Assurances", | |
| 42: "Boulangerie et confiseries", | |
| 46: "Automobiles" | |
| } | |
| def toFeatures(items): | |
| features = [] | |
| for item in items: | |
| try: | |
| features.append( | |
| Feature( | |
| geometry=Point((float(item['longitude']), float(item['latitude']))), | |
| properties={ | |
| "_storage_options": { | |
| "showLabel": True | |
| }, | |
| "name": item['categorie'] + ": " + item['titre'], | |
| "description": item['adresse_agenda'] | |
| } | |
| ) | |
| ) | |
| except: | |
| pass | |
| return features | |
| for k, v in categories.iteritems(): | |
| HTML("<h1>{}</h1>".format(v)) | |
| resp = requests.get(url=url.format(k)) | |
| print("Catégorie : {}\n".format(v)) | |
| print(dumps(FeatureCollection(toFeatures(json.loads(resp.content))))) | |
| print("\n\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment