Пример #1
0
def area_intersect():
    """World Endpoint"""

    logging.info('[ROUTER]: Parse webservics')

    args = request.args

    geostore_id = request.args.get('geostore', None)
    webservices = getlist('ws', args)
    logging.debug('[ROUTER]: Webserivce: {}'.format(webservices))

    logging.info('[ROUTER]: Fetch geostore')
    geostore = get_geostore(geostore_id=geostore_id, format="esri")

    if "errors" in geostore.keys():
        logging.debug(
            '[ROUTER]: ERROR while fetching geostore: {}'.format(geostore))

        if geostore['errors'][0]['status'] == 404:
            return error(status=404, detail="GeoStore not found")
        else:
            return error(status=400, detail="Error while fetching geostore")

    geometry = geostore["data"]["attributes"]["esrijson"]

    intersecting_geoms = list()

    for webservice in webservices:
        response = get_service_info(webservice)
        logging.debug('[ROUTER]: service info response: {}'.format(response))
        if "errors" in response.keys():
            logging.error('[ROUTER]: {}'.format(response["errors"]))
            return error(status=response["errors"][0]["status"],
                         detail=response["errors"][0]["detail"])
        else:
            geoms = get_features(webservice, response["objectid"], geometry)
        if "errors" in geoms.keys():
            logging.error('[ROUTER]: {}'.format(geoms["errors"]))
            return error(status=geoms["errors"][0]["status"],
                         detail=geoms["errors"][0]["detail"])
        else:
            intersecting_geoms.append(geoms)

        for geom in intersecting_geoms:
            inter = intersection(geostore["data"]["attributes"]["geojson"],
                                 geom)

    result = {
        "geostore": geostore,
        "webservices": str(webservices),
        "args": args,
        "geoms": intersecting_geoms,
        "inter": inter
    }

    return jsonify(data=result), 200
Пример #2
0
def get_esrijson_wm(geostore_id):
    """ get esrijson from geostore and reproject is into webmercator """

    geostore = get_geostore(geostore_id)

    if "errors" in geostore.keys():
        return error(status=400, detail=geostore["errors"])
    else:
        esrijson = reproject_esrijson(
            geostore["data"]["attributes"]["esrijson"])

    return esrijson
Пример #3
0
 def wrapper(*args, **kwargs):
     if False:
         return error(status=400,
                      detail='Validating something in the middleware')
     return func(*args, **kwargs)
Пример #4
0
def internal_server_error(e):
    return error(status=500, detail='Internal Server Error')
Пример #5
0
def gone(e):
    return error(status=410, detail='Gone')
Пример #6
0
def method_not_allowed(e):
    return error(status=405, detail='Method Not Allowed')
Пример #7
0
def page_not_found(e):
    return error(status=404, detail='Not Found')
Пример #8
0
def forbidden(e):
    return error(status=403, detail='Forbidden')