def update_geom(org_geom, json): to_update = json.get('geometry_edited') if not to_update: return org_geom g = json.get('geometry') if not g: return None the_geom = WKTElement(wkt.dumps(g), srid=4326) the_geom = the_geom.ST_Multi().ST_Transform(32737) return the_geom
def update_from_json(self, json): for c in self.__mapper__.columns: name = c.name jsonValue = json['properties'].get(name) or json['properties'].get(name.upper()) if name == 'geom': jsonValue = json['geometry'] if jsonValue is None: continue if isinstance(c.type, Numeric): value = to_decimal(jsonValue) elif isinstance(c.type, Date): value = to_date(jsonValue) elif isinstance(c.type, Geometry): value = WKTElement(wkt.dumps(jsonValue), srid=4326) value = value.ST_Transform(32737) else: value = jsonValue setattr(self, name, value)