-
Notifications
You must be signed in to change notification settings - Fork 9
[OSDEV-1577] Add geo-bounding box support to the GET /v1/production-locations/ endpoint
#503
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
Merged
mazursasha1990
merged 28 commits into
main
from
OSDEV-1577-add-geo-bounding-box-support-to-the-production-locations-endpoint
Feb 12, 2025
Merged
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
bca61f5
Add geo_bounding_box to the V1_PARAMETERS_LIST class
mazursasha1990 55b92bd
Add __process_filter method to the OpenSearchQueryDirector
mazursasha1990 e22d7e2
Add GeoBoundingBoxValidator class
mazursasha1990 d67e341
Add GeoBoundingBoxValidator to the ProductionLocationsSerializer
mazursasha1990 0cf8b6b
Add add_geo_bounding_box method to the ProductionLocationsQueryBuilder
mazursasha1990 413be10
Add geo_bounding_box for preparing params in serialize_params
mazursasha1990 768c8f1
Refactor __process_filter
mazursasha1990 e39d950
Refactor add_geo_bounding_box
mazursasha1990 3f97fd8
Refactor serialize_params
mazursasha1990 28406d2
Refactor ProductionLocationsSerializer
mazursasha1990 11e7c65
Refactor GeoBoundingBoxValidator
mazursasha1990 19e1e01
Refactor GeoBoundingBoxValidator
mazursasha1990 d3db0d8
Update order of parameters
mazursasha1990 6d4acc1
Add test_add_geo_bounding_box test to the TestProductionLocationsQuer…
mazursasha1990 6ebd690
Add test cases to cover serialization of geo bounding box to the V1Ut…
mazursasha1990 09d5563
Fix linter error
mazursasha1990 21045c2
Add integrational test case to test geo bounding box
mazursasha1990 d22f577
Merge branch 'main' into OSDEV-1577-add-geo-bounding-box-support-to-t…
mazursasha1990 407702c
Remove unused import json from opensearch_query_director.py
mazursasha1990 bc02354
Fix test_production_locations_geo_bounding_box
mazursasha1990 a91639c
Remove unnecessary print statements in the ProductionLocationsTest
mazursasha1990 e86ec7b
Add release notes
mazursasha1990 07f5813
Convert top, left, bottom, and right parameters to float
mazursasha1990 dc5b82a
Convert top, left, bottom, and right parameters to float
mazursasha1990 87cae94
Change order of parameters in the test_add_geo_bounding_box
mazursasha1990 4deeb3f
Remove unnecessary print statement
mazursasha1990 fe46ace
Add class CoordinateLimits and use it in the GeoBoundingBoxValidator …
mazursasha1990 416c0fa
Combine the two conditions into one if statement in the CoordinatesVa…
mazursasha1990 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/django/api/serializers/v1/opensearch_common_validators/geo_bounding_box_validator.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| from api.constants import CoordinateLimits | ||
| from api.serializers.v1.opensearch_validation_interface import ( | ||
| OpenSearchValidationInterface, | ||
| ) | ||
|
|
||
|
|
||
| class GeoBoundingBoxValidator(OpenSearchValidationInterface): | ||
| def validate_opensearch_params(self, data): | ||
| errors = [] | ||
|
|
||
| fields = ['top', 'left', 'bottom', 'right'] | ||
| coords = { | ||
| field: data.get(f'geo_bounding_box_{field}') for field in fields | ||
| } | ||
|
|
||
| if any(value is not None for value in coords.values()) and not all( | ||
| value is not None for value in coords.values() | ||
| ): | ||
| errors.append( | ||
| { | ||
| "field": "geo_bounding_box", | ||
| "detail": "All coordinates (top, left, bottom, right) " | ||
| "must be provided.", | ||
| } | ||
| ) | ||
|
|
||
| return errors | ||
|
|
||
| if not any(value is not None for value in coords.values()): | ||
| return errors | ||
|
|
||
| range_limits = { | ||
| 'top': (CoordinateLimits.LAT_MIN, CoordinateLimits.LAT_MAX), | ||
| 'bottom': (CoordinateLimits.LAT_MIN, CoordinateLimits.LAT_MAX), | ||
| 'left': (CoordinateLimits.LNG_MIN, CoordinateLimits.LNG_MAX), | ||
| 'right': (CoordinateLimits.LNG_MIN, CoordinateLimits.LNG_MAX), | ||
| } | ||
|
|
||
| for field, (min_val, max_val) in range_limits.items(): | ||
| value = coords[field] | ||
|
|
||
| if value < min_val or value > max_val: | ||
| errors.append( | ||
| { | ||
| "field": "geo_bounding_box", | ||
| "detail": f"The {field} value must be between " | ||
| f"{min_val} and {max_val}.", | ||
| } | ||
| ) | ||
|
|
||
| if coords['top'] <= coords['bottom']: | ||
| errors.append( | ||
| { | ||
| "field": "geo_bounding_box", | ||
| "detail": "The top must be greater than bottom.", | ||
| } | ||
| ) | ||
|
|
||
| if coords['right'] <= coords['left']: | ||
| errors.append( | ||
| { | ||
| "field": "geo_bounding_box", | ||
| "detail": "The right must be greater than left.", | ||
| } | ||
| ) | ||
|
|
||
| return errors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.