Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix /map & POST lat/lng #7

Merged
merged 14 commits into from
Sep 14, 2021
14 changes: 8 additions & 6 deletions pygeoapi/river_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
'minOccurs': 0,
'maxOccurs': 1,
'metadata': None, # TODO how to use?
'keywords': ['coordinates', 'geography']
'keywords': ['coordinates', 'latitude', 'longitude']
},
'lat': {
'title': 'Latitude',
Expand All @@ -94,7 +94,7 @@
'minOccurs': 0,
'maxOccurs': 1,
'metadata': None, # TODO how to use?
'keywords': ['coordinates', 'longitude']
'keywords': ['coordinates', 'latitude']
},
'lng': {
'title': 'Longitude',
Expand All @@ -105,7 +105,7 @@
'minOccurs': 0,
'maxOccurs': 1,
'metadata': None, # TODO how to use?
'keywords': ['coordinates', 'latitude']
'keywords': ['coordinates', 'longitude']
}
},
'outputs': {
Expand Down Expand Up @@ -140,7 +140,6 @@ def __init__(self, processor_def):
super().__init__(processor_def, PROCESS_METADATA)

def execute(self, data):
p = load_plugin('provider', PROVIDER_DEF)
mimetype = 'application/json'
outputs = {
'id': 'echo',
Expand All @@ -156,18 +155,21 @@ def execute(self, data):

for k, v in data.items():
if isinstance(v, str):
data[k] = ','.join(v.split(',')).strip('()[]').split(',')
data[k] = ','.join(v.split(',')).strip('()[]')
if k in ['latlng', 'bbox']:
data[k] = data[k].split(',')

if data.get('bbox', []):
bbox = data.get('bbox')
elif data.get('latlng', ''):
bbox = data.get('latlng')
else:
bbox = (*data.get('lng'), *data.get('lat'))
bbox = (data.get('lng'), data.get('lat'))

bbox = bbox * 2 if len(bbox) == 2 else bbox
bbox = self._expand_bbox(bbox)

p = load_plugin('provider', PROVIDER_DEF)
value = p.query(bbox=bbox)
i = 1
while len(value['features']) < 1 and i < 3:
Expand Down