def add_location_element(request, elem):
    body = request.body.decode('utf-8')
    json_value = json.loads(body)
    poly = GEOSGeometry(str(json_value['geometry']))
    (lon, lat) = (0, 0)
    if (len(poly.coord_seq) == 1):
        (lon, lat) = (poly[0], poly[1])
    loc = Location(elem=elem, lat=lat, lon=lon, poly=poly, json_representation=body)
    log_element(loc, request)
    json_object = {'data': [loc.elem.name, loc.json_representation], 'type': 'add', 'id': loc.elem.id, 'table': 'water_element_details'}
    return HttpResponse(json.dumps(json_object), status=200)
def add_location_element(request, elem):
    body = request.body.decode('utf-8')
    json_value = json.loads(body)
    poly = GEOSGeometry(str(json_value['geometry']))
    (lon, lat) = (0, 0)
    if (len(poly.coord_seq) == 1):
        (lon, lat) = (poly[0], poly[1])
    loc = Location(elem=elem, lat=lat, lon=lon, poly=poly, json_representation=body)
    log_element(loc, request)
    json_object = {'data': [loc.elem.name, loc.json_representation], 'type': 'add', 'id': loc.elem.id, 'table': 'water_element_details'}
    return HttpResponse(json.dumps(json_object), status=200)