Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nyalldawson committed Sep 19, 2017
1 parent d861e64 commit 1956a38
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/core/geometry/qgscircularstring.cpp
Expand Up @@ -496,11 +496,13 @@ void QgsCircularString::setPoints( const QgsPointSequence &points )
mY[i] = points[i].y();
if ( hasZ )
{
mZ[i] = points[i].z();
double z = points.at( i ).z();
mZ[i] = std::isnan( z ) ? 0 : z;
}
if ( hasM )
{
mM[i] = points[i].m();
double m = points.at( i ).m();
mM[i] = std::isnan( m ) ? 0 : m;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/core/geometry/qgslinestring.cpp
Expand Up @@ -535,11 +535,13 @@ void QgsLineString::setPoints( const QgsPointSequence &points )
mY[i] = points.at( i ).y();
if ( hasZ )
{
mZ[i] = points.at( i ).z();
double z = points.at( i ).z();
mZ[i] = std::isnan( z ) ? 0 : z;
}
if ( hasM )
{
mM[i] = points.at( i ).m();
double m = points.at( i ).m();
mM[i] = std::isnan( m ) ? 0 : m;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgspoint.cpp
Expand Up @@ -80,8 +80,8 @@ QgsPoint::QgsPoint( QgsWkbTypes::Type wkbType, double x, double y, double z, dou
: QgsAbstractGeometry()
, mX( x )
, mY( y )
, mZ( z )
, mM( m )
, mZ( QgsWkbTypes::hasZ( wkbType ) ? z : std::numeric_limits<double>::quiet_NaN() )
, mM( QgsWkbTypes::hasM( wkbType ) ? m : std::numeric_limits<double>::quiet_NaN() )
{
Q_ASSERT( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point );
mWkbType = wkbType;
Expand Down

0 comments on commit 1956a38

Please sign in to comment.