Skip to content
Permalink
Browse files

Fix errors and inconsistencies resulting from adding M values to a da…

…taset with a ****25D wkb type
  • Loading branch information
github-actions authored and nyalldawson committed Nov 20, 2020
1 parent f340a33 commit 4447d788c3e3ca00e667a753faa71f110fa9c79f
Showing with 19 additions and 14 deletions.
  1. +12 −7 src/core/geometry/qgswkbtypes.h
  2. +7 −7 tests/src/python/test_qgsgeometry.py
@@ -1169,13 +1169,18 @@ class CORE_EXPORT QgsWkbTypes
return Unknown;
else if ( type == NoGeometry )
return NoGeometry;
else if ( type == Point25D ||
type == LineString25D ||
type == Polygon25D ||
type == MultiPoint25D ||
type == MultiLineString25D ||
type == MultiPolygon25D )
return type; //can't add M dimension to these types
else if ( type == Point25D )
return PointZM;
else if ( type == LineString25D )
return LineStringZM;
else if ( type == Polygon25D )
return PolygonZM;
else if ( type == MultiPoint25D )
return MultiPointZM;
else if ( type == MultiLineString25D )
return MultiLineStringZM;
else if ( type == MultiPolygon25D )
return MultiPolygonZM;

//upgrade with m dimension
Type flat = flatType( type );
@@ -3894,13 +3894,13 @@ def testWkbTypes(self):
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiSurfaceM), QgsWkbTypes.MultiSurfaceM)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiSurfaceZM), QgsWkbTypes.MultiSurfaceZM)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.NoGeometry), QgsWkbTypes.NoGeometry)
# can't be added to these types
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.Point25D), QgsWkbTypes.Point25D)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.LineString25D), QgsWkbTypes.LineString25D)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.Polygon25D), QgsWkbTypes.Polygon25D)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiPoint25D), QgsWkbTypes.MultiPoint25D)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiLineString25D), QgsWkbTypes.MultiLineString25D)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiPolygon25D), QgsWkbTypes.MultiPolygon25D)
# we force upgrade 25D types to "Z" before adding the M value
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.Point25D), QgsWkbTypes.PointZM)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.LineString25D), QgsWkbTypes.LineStringZM)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.Polygon25D), QgsWkbTypes.PolygonZM)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiPoint25D), QgsWkbTypes.MultiPointZM)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiLineString25D), QgsWkbTypes.MultiLineStringZM)
self.assertEqual(QgsWkbTypes.addM(QgsWkbTypes.MultiPolygon25D), QgsWkbTypes.MultiPolygonZM)

# test dropping z dimension from types
self.assertEqual(QgsWkbTypes.dropZ(QgsWkbTypes.Unknown), QgsWkbTypes.Unknown)

0 comments on commit 4447d78

Please sign in to comment.
You can’t perform that action at this time.