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
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
def wrapper(*args, **kwargs): if False: return error(status=400, detail='Validating something in the middleware') return func(*args, **kwargs)
def internal_server_error(e): return error(status=500, detail='Internal Server Error')
def gone(e): return error(status=410, detail='Gone')
def method_not_allowed(e): return error(status=405, detail='Method Not Allowed')
def page_not_found(e): return error(status=404, detail='Not Found')
def forbidden(e): return error(status=403, detail='Forbidden')