Repository navigation
Store the SRID when creating a database and reject geographic SRIDs - #150
Merged
Merged
Conversation
CreateModelTables uses its srid argument only to look up a projection and leaves the stored SRID (m_Configuration and geometry_columns) at -1, so Database.srid and every geometry written later used -1. create() now writes the SRID itself, deriving it from projection_string when MIKE+ recognises the projection. Given a geographic SRID such as 4326, MIKE+ silently stored Google Maps - Mercator. create() now raises ValueError for geographic or unknown SRIDs, looked up in a throwaway database so overwrite=True keeps the old file. Fixes #141 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
📚 Preview this PR's docs locallyFetch the just-built site and open it in your browser: # this exact build
great-docs preview --run 37321808323
# or always the latest build for this PR
great-docs preview --pr 150Auth & tips
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #141.
What was wrong
db.srid == -1aftercreate().CreateModelTablesuses itssridargument only to look up a projection string. The SRID it stores, inm_Configurationandgeometry_columns, stays at -1. SoDatabase.sridreads -1, and geometry written later is tagged -1. The same happens when onlyprojection_stringis given.srid=4326gives Google Maps - Mercator. When no projection string is passed, MIKE+ replaces a geographic projection with Google Maps - Mercator, without saying so.MIKE+ GUI comparison
I created a new model through the MIKE+ 2026 U1 GUI (File → New, Coordinate system → Browse). With ETRS89 / UTM zone 32N chosen after Sirius (25832) had been open, the database stored 25832. I then chose ETRS89 / UTM zone 33N, also after Sirius. It stored the 33N projection string but SRID 25832. So the GUI doesn't derive the SRID from the chosen projection either: it carries over the SRID of the project open before. That one is a MIKE+ bug, which I'll report separately. The GUI only offers projected systems (plus Google Maps - Mercator), never geographic ones.
Fix
sridis given,create()looks up its WKT withGetProjectionOGCWKTin a throwaway database before any target file is touched, sooverwrite=Truestill keeps the old file on bad input. Unknown and geographic SRIDs raiseValueError. The WKT is passed toCreateModelTables.projection_stringis given, the SRID is derived withGetSRIDFromProjStr.CreateModelTables, the SRID is written tom_Configurationandgeometry_columns. A node inserted afterwards is stored with SRID 25832, checked in the geometry blob.sridagain, and there's a changelog entry.Tests
pytest tests/database/test_database.py -k "Create or srid or projection"passes (16 tests) against MIKE+ 2026 U1. New tests:srid=25832round trip, including a geometry insert;sridderived fromprojection_string;ValueErrorand keep the existing file underoverwrite=True.just lintandjust typecheckpass.just lint-changedreports nothing indatabase.py; its remaining errors are in files this PR doesn't touch.🤖 Generated with Claude Code