Skip to content
Permalink
Browse files

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 18, 2017
1 parent d861e64 commit 1956a381995afaa2451b7adc78ec6a23feb33ea4
Showing with 10 additions and 6 deletions.
  1. +4 −2 src/core/geometry/qgscircularstring.cpp
  2. +4 −2 src/core/geometry/qgslinestring.cpp
  3. +2 −2 src/core/geometry/qgspoint.cpp
@@ -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;
}
}
}
@@ -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;
}
}
}
@@ -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;

0 comments on commit 1956a38

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