RFC5: apply distance limiting#2229
Conversation
74982b1 to
a78997b
Compare
a78997b to
e4a639a
Compare
e4a639a to
091e992
Compare
| return True | ||
|
|
||
| if max_distance_x is not None: | ||
| requested_distance_x = abs(request_bbox[2] - request_bbox[0]) |
There was a problem hiding this comment.
It might be worth establishing the unit for distance. This as a simple comparison makes some sense when max_distance_units are degrees and the bbox is in OGC:CRS84. However if the bbox is in EPSG:3857, the effective limit would be much smaller.
| server_limits = api.config['server'].get('limits', {}) | ||
| collection_limits = api.config['resources'][dataset].get('limits', {}) # noqa | ||
|
|
||
| _ = evaluate_limit_distance(request.params.get('bbox', []), |
There was a problem hiding this comment.
Related to previous comment, might be worth transforming the bbox to WGS84 here until the unit is applied?
091e992 to
fead0e2
Compare
fead0e2 to
b116b96
Compare
| LOGGER.debug(f'On exceed: {on_exceed}') | ||
| LOGGER.debug(f'Maximum distance x: {max_distance_x}') | ||
| LOGGER.debug(f'Maximum distance y: {max_distance_y}') | ||
| LOGGER.debug(f'Maximum distance units: {max_distance_units}') |
There was a problem hiding this comment.
I am a bit worried about what we can get inside the variable max_distance_units. Does it make sense to create an enum here and validate it against it?
| exceed_msg = 'Maximum distance x exceeded' | ||
|
|
||
| if max_distance_y is not None: | ||
| requested_distance_y = abs(request_bbox[3] - request_bbox[1]) |
There was a problem hiding this comment.
If the bbox uses degrees (e.g: CRS84/WGS84) would it be correct to apply this type of cartesian math? Not an issue for small distances, since the distortion is small; but if we you have larger distances, we could be looking at differences in the requested distance according to the location on earth. The safe solution would be to always project the bbox to a projected coordinated system (e.g.: 3857).
| effective_limits = ChainMap(collection_limits, server_limits) | ||
|
|
||
| on_exceed = effective_limits.get('on_exceed', 'throttle') | ||
| max_distance_x = effective_limits.get('max_distance_x') |
There was a problem hiding this comment.
it may be worth casting max_distance_x and mast_distance_y to floats, and wrap this into a try/catch block
|
Not needed, but nice to have, a more complete limits object here: |
Overview
This PR applies distance limiting per RFC5 for items and coverages.
Related Issue / discussion
https://pygeoapi.io/development/rfc/5
Additional information
Dependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)