[Fixes #13952] Handle the exception when the update bbox method fails at managing the SRID for a dataset#13953
[Fixes #13952] Handle the exception when the update bbox method fails at managing the SRID for a dataset#13953
Conversation
… at managing the SRID for a dataset
Summary of ChangesHello @sijandh35, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the system failed to properly manage Spatial Reference IDs (SRIDs) when updating dataset bounding boxes from GeoServer, leading to potential errors. It introduces a refactored and more resilient approach by centralizing the bounding box and SRID update logic into a dedicated method. This new method includes a robust fallback mechanism that ensures data integrity by defaulting to 'EPSG:4326' and the lat/lon bounding box if the native SRID is unsupported, thereby preventing synchronization failures and improving overall stability. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the bounding box and SRID setting logic from GeoServer into a new method set_bbox_and_srid_from_geoserver on the Dataset model. This is a good improvement as it encapsulates complex logic, improves error handling by adding a fallback mechanism, and increases code clarity. The addition of unit tests for the new method is also a great practice. I've found a couple of minor areas for improvement regarding code style and redundancy.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #13953 +/- ##
==========================================
+ Coverage 74.24% 74.27% +0.02%
==========================================
Files 947 950 +3
Lines 56620 56833 +213
Branches 7675 7703 +28
==========================================
+ Hits 42038 42211 +173
- Misses 12892 12922 +30
- Partials 1690 1700 +10 🚀 New features to boost your workflow:
|
geonode/layers/models.py
Outdated
| return True | ||
|
|
||
| def set_bbox_and_srid(self, bbox, ll_bbox, srid): | ||
| if not ll_bbox or len(ll_bbox) < 4: |
There was a problem hiding this comment.
@sijandh35 i propose to impove a bit the check here, if the function is called with ll_bbo='abcd' the check is considered valid, while it should not. i would verify that is at least a list with some numeric values, something like:
def check_bbox_validity(value):
if not value or not isinstance(value, list) or not all(isinstance(x, (int, float)) for x in value):
return False
return True
if not check_bbox_validity(ll_bbox):
raise ...
geonode/layers/models.py
Outdated
|
|
||
| ll_bbox_gn = [ll_bbox[0], ll_bbox[2], ll_bbox[1], ll_bbox[3]] | ||
| # Try to use native bbox if available | ||
| if bbox and len(bbox) >= 4 and srid: |
Fixes #13952
Checklist
For all pull requests:
The following are required only for core and extension modules (they are welcomed, but not required, for contrib modules):
Submitting the PR does not require you to check all items, but by the time it gets merged, they should be either satisfied or inapplicable.