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

Reduce number of bbox iterations, use en-US locale, inform client when no features found #4

Merged
merged 5 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pygeoapi/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def get_processes_map(process_id=None):
:returns: HTTP response
"""
return render_j2_template(CONFIG, 'processes/map.html', {})
return render_j2_template(CONFIG, 'processes/map.html', {}, 'en-US')


@BLUEPRINT.route('/processes/<process_id>/jobs')
Expand Down
26 changes: 15 additions & 11 deletions pygeoapi/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
map.setView(e.latlng);
var popup = L.popup(keepInView=true)
.setLatLng(e.latlng)
.setContent('Finding flowpath from this point')
.setContent('Finding flowpath from this point.')
.openOn(map);

$.ajax({
Expand All @@ -53,17 +53,21 @@
processData: false,
success: function(response) {
popup.remove();
var geojson_data = response.value;
var items = new L.GeoJSON(geojson_data, {
onEachFeature: function (feature, layer) {
var url = "{{ config['server']['url'] }}/collections/merit/items/" + feature.id + '?f=html';
var html = '<span><a href="' + url + '">' + feature.properties.nameID + '</a></span>';
layer.bindPopup(html);
}
});
map.addLayer(items);
map.fitBounds(items.getBounds());
loading = false;
var geojson_data = response.value;
if (geojson_data.features.length === 0){
alert('No flowpath found. :(')
} else {
var items = new L.GeoJSON(geojson_data, {
onEachFeature: function (feature, layer) {
var url = "{{ config['server']['url'] }}/collections/merit/items/" + feature.id + '?f=html';
var html = '<span><a href="' + url + '">' + feature.properties.nameID + '</a></span>';
layer.bindPopup(html);
}
});
map.addLayer(items);
map.fitBounds(items.getBounds());
}
},
error: function(error) {
console.log(error)
Expand Down
15 changes: 13 additions & 2 deletions pygeoapi/river_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def __init__(self, processor_def):

def execute(self, data):
mimetype = 'application/json'
outputs = {
'id': 'echo',
'value': {
'type': 'FeatureCollection',
'features': []
}
}
if len(data.get('bbox', [])) != 4 and \
not data.get('lat', '') and \
not data.get('lng', ''):
Expand All @@ -143,12 +150,16 @@ def execute(self, data):

value = self.p.query(bbox=bbox)
i = 1
while len(value['features']) < 1 and i < 10:
while len(value['features']) < 1 and i < 3:
LOGGER.debug(f'No features in bbox {bbox}, expanding')
bbox = self._expand_bbox(bbox, e=0.125*i)
bbox = self._expand_bbox(bbox, e=0.5*i)
value = self.p.query(bbox=bbox)
i = i + 1

if len(value['features']) < 1:
LOGGER.debug('No features found')
return mimetype, outputs

LOGGER.debug('fetching downstream features')
mh = self._compare(value, 'hydroseq', min)
out, trim = [], []
Expand Down