From 99c482482f81095a3f12e2b78654cb50f301fdd8 Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Thu, 27 Jan 2022 15:03:55 +0100 Subject: [PATCH] Format files --- python/core/auto_generated/geometry/qgsgeometry.sip.in | 6 +++++- src/core/geometry/qgsgeometry.cpp | 2 +- src/core/geometry/qgspoint.cpp | 10 +++++----- tests/src/python/test_qgsgeometry.py | 10 +++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/python/core/auto_generated/geometry/qgsgeometry.sip.in b/python/core/auto_generated/geometry/qgsgeometry.sip.in index f0728a64d66b9..bd0f9197ece7a 100644 --- a/python/core/auto_generated/geometry/qgsgeometry.sip.in +++ b/python/core/auto_generated/geometry/qgsgeometry.sip.in @@ -1934,7 +1934,7 @@ Exports the geometry to a GeoJSON string. %End - QVector< QgsGeometry > coerceToType( QgsWkbTypes::Type type ) const; + QVector< QgsGeometry > coerceToType( QgsWkbTypes::Type type, double defaultZ = 0.0, double defaultM = 0.0 ) const; %Docstring Attempts to coerce this geometry into the specified destination ``type``. @@ -1950,6 +1950,10 @@ This method will do anything possible to force the current geometry into the spe - single geometries will be upgraded to multi geometries - z or m values will be added or dropped as required. +The parameters ``defaultZ`` and ``defaultM`` control the dimension value added when promoting geometries +to Z, M or ZM versions. +By default 0.0 is used for Z and M. + .. note:: This method is much stricter than :py:func:`~QgsGeometry.convertToType`, as it considers the exact WKB type diff --git a/src/core/geometry/qgsgeometry.cpp b/src/core/geometry/qgsgeometry.cpp index d4732ad828d8c..282eb53bc94cf 100644 --- a/src/core/geometry/qgsgeometry.cpp +++ b/src/core/geometry/qgsgeometry.cpp @@ -1439,7 +1439,7 @@ json QgsGeometry::asJsonObject( int precision ) const } -QVector QgsGeometry::coerceToType(const QgsWkbTypes::Type type , double defaultZ, double defaultM ) const +QVector QgsGeometry::coerceToType( const QgsWkbTypes::Type type, double defaultZ, double defaultM ) const { QVector< QgsGeometry > res; if ( isNull() ) diff --git a/src/core/geometry/qgspoint.cpp b/src/core/geometry/qgspoint.cpp index 1a72ca63843cd..58eee186fc54c 100644 --- a/src/core/geometry/qgspoint.cpp +++ b/src/core/geometry/qgspoint.cpp @@ -154,12 +154,12 @@ bool QgsPoint::fromWkb( QgsConstWkbPtr &wkbPtr ) return true; } -inline double stringToDouble( const QString& string ) +inline double stringToDouble( const QString &string ) { - if (string.compare( QLatin1String("nan"))) - return std::numeric_limits::quiet_NaN(); - else - return string.toDouble(); + if ( string.compare( QLatin1String( "nan" ) ) ) + return std::numeric_limits::quiet_NaN(); + else + return string.toDouble(); } /*************************************************************************** diff --git a/tests/src/python/test_qgsgeometry.py b/tests/src/python/test_qgsgeometry.py index 96c6e36bbc009..66393553ed374 100644 --- a/tests/src/python/test_qgsgeometry.py +++ b/tests/src/python/test_qgsgeometry.py @@ -6285,11 +6285,11 @@ def coerce_to_wkt(wkt, type): ['MultiLineString ((1 1, 1 2, 2 2, 1 1),(3 3, 4 3, 4 4, 3 3))']) # Missing z values - self.assertEqual(coerce_to_wkt('Point (1 1)', QgsWkbTypes.PointZ),['PointZ (1 1 nan)']) - self.assertEqual(coerce_to_wkt('PointZ (1 1 3)', QgsWkbTypes.Point),['Point (1 1)']) - self.assertEqual(coerce_to_wkt('PointZ (1 1 nan)', QgsWkbTypes.PointZM),['PointZM (1 1 nan nan)']) - self.assertEqual(coerce_to_wkt('PointM (1 1 5)', QgsWkbTypes.PointZ),['PointZ (1 1 nan)']) - self.assertEqual(coerce_to_wkt('LineString (1 1, 1 2, 2 2, 1 1)', QgsWkbTypes.LineStringZM),['LineStringZM (1 1 nan nan, 1 2 nan nan, 2 2 nan nan, 1 1 nan nan)']) + self.assertEqual(coerce_to_wkt('Point (1 1)', QgsWkbTypes.PointZ), ['PointZ (1 1 nan)']) + self.assertEqual(coerce_to_wkt('PointZ (1 1 3)', QgsWkbTypes.Point), ['Point (1 1)']) + self.assertEqual(coerce_to_wkt('PointZ (1 1 nan)', QgsWkbTypes.PointZM), ['PointZM (1 1 nan nan)']) + self.assertEqual(coerce_to_wkt('PointM (1 1 5)', QgsWkbTypes.PointZ), ['PointZ (1 1 nan)']) + self.assertEqual(coerce_to_wkt('LineString (1 1, 1 2, 2 2, 1 1)', QgsWkbTypes.LineStringZM), ['LineStringZM (1 1 nan nan, 1 2 nan nan, 2 2 nan nan, 1 1 nan nan)']) def testTriangularWaves(self): """Test triangular waves"""