Browse Source

minor refacto

Jocelyn Delande 9 years ago
parent
commit
13375f16cc
1 changed files with 10 additions and 16 deletions
  1. 10 16
      backend.py

+ 10 - 16
backend.py

@@ -279,26 +279,20 @@ def orientations_to_angle(orientations):
      return merge_intervals(angles)
 
 # Save feature collection to a json file
-def save_featurecollection_json(id, features, license = None):
+def save_featurecollection_json(id, features, license=None):
     with open('json/' + id + '.json', 'w') as outfile:
-        if license == None:
-            json.dump({
-                "type" : "FeatureCollection",
-                "features" : features,
-                "id" : id,
-            }, outfile)
-        else:
-             json.dump({
-                "type" : "FeatureCollection",
-                "features" : features,
-                "id" : id,
-                "license" : license,
-            }, outfile)
-           
+        geojson = {
+            "type" : "FeatureCollection",
+            "features" : features,
+            "id" : id,
+        }
+        if license:
+            geojson['license'] = license
+        json.dump(geojson, outfile)
+
 
 # Build GeoJSON files from DB
 def build_geojson():
-
     # Read from DB
     DB.row_factory = sqlite3.Row
     cur = DB.execute("""