Skip to content

Commit

Permalink
Format files
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 27, 2022
1 parent 1322ab9 commit 99c4824
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
6 changes: 5 additions & 1 deletion python/core/auto_generated/geometry/qgsgeometry.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -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``.

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ json QgsGeometry::asJsonObject( int precision ) const

}

QVector<QgsGeometry> QgsGeometry::coerceToType(const QgsWkbTypes::Type type , double defaultZ, double defaultM ) const
QVector<QgsGeometry> QgsGeometry::coerceToType( const QgsWkbTypes::Type type, double defaultZ, double defaultM ) const
{
QVector< QgsGeometry > res;
if ( isNull() )
Expand Down
10 changes: 5 additions & 5 deletions src/core/geometry/qgspoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>::quiet_NaN();
else
return string.toDouble();
if ( string.compare( QLatin1String( "nan" ) ) )
return std::numeric_limits<double>::quiet_NaN();
else
return string.toDouble();
}

/***************************************************************************
Expand Down
10 changes: 5 additions & 5 deletions tests/src/python/test_qgsgeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 99c4824

Please sign in to comment.