def put_documentesribyid(id): data = request.body.readline() result = json.loads(data) print data entity = db['documents'].find_one({'_id':id}) if not entity: entity = result tmp = {} tmp["features"] = [entity] tmp["geometryType"] = entity["geometryType"] geojs = esri_to_geo(tmp) geojs["_id"] = entity["_id"] near_dict = {"$near": geojs["geometry"]["coordinates"]} max_dict = max_dict = {"$maxDistance": 0.001} q = SON(near_dict) q.update(max_dict) gq = {"geometry.coordinates": q} check = db["documents"].find(gq) print check if check: abort(400, {"success": False, "error": "Already exist"}) else: geojs = entity geojs["properties"]["votes"] = result["attributes"]["votes"] try: db['documents'].save(geojs) except ValidationError as ve: abort(400, str(ve)) return result
def put_geojs(): data = request.body.readline() if not data: abort(400, 'No data received') entity = json.loads(data) result = esri_to_geo(entity) return result
def put_documentesri(): data = request.body.readline() print data if not data: abort(400, 'No data received') entity = json.loads(data) if not entity.has_key('_id'): abort(400, 'No _id specified') geojs = esri_to_geo(entity) geojs["_id"] = entity["_id"] try: db['documents'].save(geojs) except ValidationError as ve: abort(400, str(ve)) result = geo_to_esri(geojs["features"]) return result