Skip to content
Snippets Groups Projects
Commit d48e2572 authored by Jonathan Cooper's avatar Jonathan Cooper
Browse files

removed redundant featureinfo endpoint and dependencies

parent d625b7c1
Branches
Tags
1 merge request!3Removed redundant featureinfo endpoint and dependencies
from flask import Flask, jsonify, send_from_directory, after_this_request
from markupsafe import escape
import timeseries, legend, featureinfo, plantinfo, download
import timeseries, legend, plantinfo, download
import logging as log
import os
......@@ -19,15 +19,6 @@ def get_legend(pollutant):
log.debug(f'/api/legend/{pollutant}')
return legend.getlegend(escape(pollutant))
# eg http://localhost:8082/api/featureinfo/NAEIPointsSources_2018/1/2
@app.route('/api/featureinfo/<string:id>/<string:x>/<string:y>')
def get_info(id, x, y):
log.debug(f'/api/featureinfo/{id}/{x}/{y}')
xf = float(escape(x))
yf = float(escape(y))
# return jsonify(timeseries.getdata(xf, yf))
return featureinfo.get(id, xf, yf)
# eg http://localhost:8082/api/plantinfo/NAEIPointsSources_2018/3948
@app.route('/api/plantinfo/<string:datasetid>/<string:plantid>')
def get_plantinfo(datasetid, plantid):
......
import geopandas as gpd
from shapely.geometry import Point
import logging as log
import json
# Get the point features for the dataset named in 'id' that are within 3000m of the incomming point
def get(id, xf, yf):
path = f'/pointdata/{id}.shp'
radius = 3000
try:
buf = Point(xf,yf).buffer(radius)
gdf = gpd.read_file(path, mask=buf)
points = []
for index, row in gdf.iterrows():
coords = [(coords) for coords in list(row['geometry'].coords)][0]
toAppend = {
'coord': {'x': coords[0], 'y': coords[1]},
'properties': {}
}
for col in gdf.columns:
if(col != 'geometry'):
toAppend['properties'][col] = row[col]
points.append(toAppend)
return {'features': points}
except Exception as ex:
log.debug(f'Unknown error: {ex}')
......@@ -4,5 +4,4 @@ pandas==1.3.0
setuptools==57.4.0
netCDF4==1.5.7
xarray==0.18.2
geopandas==0.9.0
gevent==20.9.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment