diff options
-rw-r--r-- | chimere/models.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/chimere/models.py b/chimere/models.py index 122d61f..0a2906c 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -706,7 +706,10 @@ class Marker(GeographicItem): if categories_id and cat.id not in categories_id: continue items = copy.deepcopy(json_tpl) - items['geometry'] = json.loads(self.point.geojson) + try: + items['geometry'] = json.loads(self.point.geojson) + except json.JSONDecodeError: + continue items['properties'].update({ 'pk':self.id, 'name':self.name, @@ -1190,8 +1193,12 @@ class Route(GeographicItem): ''' if '#' not in color: color = '#' + color + try: + geom = json.loads(self.route.geojson) + except json.JSONDecodeError: + return json.dumps('{}') attributes = {"type":"Feature", - "geometry":json.loads(self.route.geojson), + "geometry": geom, "properties":{"pk":self.id, "name":self.name, "color":color}} return json.dumps(attributes) @@ -1289,7 +1296,11 @@ class AggregatedRoute(models.Model): ''' if '#' not in color: color = '#' + color - attributes = {'color':color, 'geometry':json.loads(self.route.geojson), + try: + geom = json.loads(self.route.geojson) + except json.JSONDecodeError: + return json.dumps('{}') + attributes = {'color':color, 'geometry': geom, 'type':"Feature", "properties":{"pk": self.id, "name": u'Aggregated route',}} return json.dumps(attributes) |