Skip to content

Instantly share code, notes, and snippets.

@2xyo
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save 2xyo/11001093 to your computer and use it in GitHub Desktop.

Select an option

Save 2xyo/11001093 to your computer and use it in GitHub Desktop.
Mantes-la-Jolie Opendata
Display the source blob
Display the rendered blob
Raw
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