|
42 | 42 |
|
43 | 43 | from pygeoapi.api import ( |
44 | 44 | API, APIRequest, CONFORMANCE_CLASSES, __version__, validate_bbox, |
45 | | - validate_datetime, evaluate_limit, validate_subset, landing_page, openapi_, |
46 | | - conformance, describe_collections, get_collection_schema) |
| 45 | + validate_datetime, evaluate_limit, evaluate_limit_distance, |
| 46 | + validate_subset, landing_page, openapi_, conformance, describe_collections, |
| 47 | + get_collection_schema) |
47 | 48 |
|
48 | 49 | from pygeoapi.formats import FORMAT_TYPES, F_GZIP, F_JSON, F_JSONLD, F_HTML |
49 | 50 | from pygeoapi.util import yaml_load, get_api_rules, get_base_url |
@@ -1023,3 +1024,24 @@ def test_evaluate_limit(): |
1023 | 1024 |
|
1024 | 1025 | assert evaluate_limit(None, server, collection) == 10 |
1025 | 1026 | assert evaluate_limit('40', server, collection) == 3 |
| 1027 | + |
| 1028 | + |
| 1029 | +def test_evaluate_limit_distance(): |
| 1030 | + collection = { |
| 1031 | + 'on_exceed': 'error', |
| 1032 | + 'max_distance_x': 10, |
| 1033 | + 'max_distance_y': 10 |
| 1034 | + } |
| 1035 | + |
| 1036 | + with pytest.raises(ValueError): |
| 1037 | + assert evaluate_limit_distance( |
| 1038 | + {}, collection, request_bbox=[-180, -90, 180, 90]) |
| 1039 | + |
| 1040 | + assert evaluate_limit_distance({}, collection, |
| 1041 | + request_bbox=[-142, 42, -140, 44]) |
| 1042 | + |
| 1043 | + assert evaluate_limit_distance({}, {}, request_bbox=[-180, -90, 180, 90]) |
| 1044 | + |
| 1045 | + collection['on_exceed'] = 'throttle' |
| 1046 | + assert evaluate_limit_distance( |
| 1047 | + {}, collection, request_bbox=[-180, -90, 180, 90]) |
0 commit comments