-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
wkbType of geometries is not same as the layer with z and with geopackage #50218
Comments
I guess there is a problem with the cast to the Qgs Wkb Type from the OGR one. Something like this, works for me: diff --git a/src/core/qgsogrutils.cpp b/src/core/qgsogrutils.cpp
index 3ff54b3e52a..d024be52356 100644
--- a/src/core/qgsogrutils.cpp
+++ b/src/core/qgsogrutils.cpp
@@ -628,7 +628,7 @@ std::unique_ptr< QgsMultiPoint > ogrGeometryToQgsMultiPoint( OGRGeometryH geom )
std::unique_ptr< QgsLineString > ogrGeometryToQgsLineString( OGRGeometryH geom )
{
- QgsWkbTypes::Type wkbType = static_cast<QgsWkbTypes::Type>( OGR_G_GetGeometryType( geom ) );
+ QgsWkbTypes::Type wkbType = QgsOgrUtils::ogrGeometryTypeToQgsWkbType( OGR_G_GetGeometryType( geom ) );
int count = OGR_G_GetPointCount( geom );
QVector< double > x( count ); |
@rouault I wonder why it works for shapefile and the geopackage needs a “better” cast? |
I'm not sure either, but your fix looks good to me |
Because Shapefile use ZM and not only Z. |
As mentionned by @Koyaani a PolygonZ is opened as a Polygon25D and can cause problems. This fix use the QgsOgrUtils method to return the true QGIS wkbType. Fixes qgis#50218
What is the bug or the crash?
When geometries are fetch from a Geopackage table with Z, the
wkbType
of geometries are 25D type (0x80000001
) while thewkbType
of the layer is Z (10XX
). The problem is not present with other providers like shapefile or PostGis, nor when there is no Z or when there is ZM.Steps to reproduce the issue
[f.geometry().wkbType() for f in iface.activeLayer().getFeatures()]
-> The print displays :
[1003]
[f.geometry().wkbType() for f in iface.activeLayer().getFeatures()]
-> The print displays :
[-2147483645]
iface.activeLayer().wkbType()
-> The print displays :
1003
Peek.15-09-2022.15-11.webm
Versions
3.22, 3.26 and master
Supported QGIS version
New profile
Additional context
No response
The text was updated successfully, but these errors were encountered: