def map_feature_edit(map_id, feature_id): f = MapFeature.get(feature_id) if not f: abort(404) if not request.json or not Feature(request.json).is_valid: abort(400) if 'properties' in request.json: props = request.json['properties'] if 'iconColor' in props: # ensure that we deal with hex values (not rgb(r,g,b)) if props['iconColor'].startswith('rgb'): rgb = re.findall(r'\d+', props['iconColor']) iconColor = ''.join([('%02x' % int(x)) for x in rgb]) props['iconColor'] = '#' + iconColor if 'weight' in props: props['weight'] = int(props['weight']) f.style = props if 'geometry' in request.json: f.geo = request.json['geometry'] db.session.add(f) db.session.commit() return jsonify(f.to_dict())
def map_feature_delete(map_id, feature_id): f = MapFeature.get(feature_id) if not f: abort(404) db.session.delete(f) db.session.commit() return ('', 200)