Skip to content

Commit 1956a38

Browse files
committedSep 19, 2017
When constructing a QgsPoint with explicit WKB type specified,
ignore any explicit z/m value if the WKB type does not have that dimensionality Brings consistent behavior to all QgsPoint constructors
1 parent d861e64 commit 1956a38

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed
 

‎src/core/geometry/qgscircularstring.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,13 @@ void QgsCircularString::setPoints( const QgsPointSequence &points )
496496
mY[i] = points[i].y();
497497
if ( hasZ )
498498
{
499-
mZ[i] = points[i].z();
499+
double z = points.at( i ).z();
500+
mZ[i] = std::isnan( z ) ? 0 : z;
500501
}
501502
if ( hasM )
502503
{
503-
mM[i] = points[i].m();
504+
double m = points.at( i ).m();
505+
mM[i] = std::isnan( m ) ? 0 : m;
504506
}
505507
}
506508
}

‎src/core/geometry/qgslinestring.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,13 @@ void QgsLineString::setPoints( const QgsPointSequence &points )
535535
mY[i] = points.at( i ).y();
536536
if ( hasZ )
537537
{
538-
mZ[i] = points.at( i ).z();
538+
double z = points.at( i ).z();
539+
mZ[i] = std::isnan( z ) ? 0 : z;
539540
}
540541
if ( hasM )
541542
{
542-
mM[i] = points.at( i ).m();
543+
double m = points.at( i ).m();
544+
mM[i] = std::isnan( m ) ? 0 : m;
543545
}
544546
}
545547
}

‎src/core/geometry/qgspoint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ QgsPoint::QgsPoint( QgsWkbTypes::Type wkbType, double x, double y, double z, dou
8080
: QgsAbstractGeometry()
8181
, mX( x )
8282
, mY( y )
83-
, mZ( z )
84-
, mM( m )
83+
, mZ( QgsWkbTypes::hasZ( wkbType ) ? z : std::numeric_limits<double>::quiet_NaN() )
84+
, mM( QgsWkbTypes::hasM( wkbType ) ? m : std::numeric_limits<double>::quiet_NaN() )
8585
{
8686
Q_ASSERT( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point );
8787
mWkbType = wkbType;

0 commit comments

Comments
 (0)
Please sign in to comment.