Skip to content
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

Get only "SRID" CRS identifier (not authority+identifier) for GeoPackage layers #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kannes
Copy link

@kannes kannes commented Feb 3, 2025

While for PostgreSQL/PostGIS and MSSQL ST_SRID resp. STSrid are used to get a simple integer EPSG code:

[%s].STSrid AS epsg,

ST_SRID("%s") AS epsg,

For GeoPackage the layer's CRS's authid() is used, which is a full string with authority identifier and code (e.g. "EPSG:4326"):

epsg = layer.crs().authid()

This breaks the transformation in select_result() as QgsCoordinateReferenceSystem.fromEpsgId(foo) is used, which takes only the integer identifier.

transform = QgsCoordinateTransform(QgsCoordinateReferenceSystem.fromEpsgId(src_epsg),

This PR simply strips "EPSG:" from the GeoPackage's auth ID. This won't work with non-EPSG CRSses but then I am not sure what would happen in PostGIS/MSSQL in those cases. It's an improvement for sure as it makes things work again.

Fixes follow-up comments in #95

@kannes
Copy link
Author

kannes commented Feb 3, 2025

Sorry for the force-push mess. I also added a quick check and warning message if a GPKG is not using an EPSG CRS. I was not brave enough to attempt to make the code around PG & MSSQL provide full CRS authority+identifier strings. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant