Skip to content

Commit

Permalink
Compare Z and M values in QgsPoint::operator== only when required
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 14, 2017
1 parent 1808dc9 commit bd82ca3
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/core/geometry/qgspoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ QgsPoint::QgsPoint( QgsWkbTypes::Type wkbType, double x, double y, double z, dou

bool QgsPoint::operator==( const QgsPoint &pt ) const
{
return ( pt.wkbType() == wkbType() &&
qgsDoubleNear( pt.x(), mX, 1E-8 ) &&
qgsDoubleNear( pt.y(), mY, 1E-8 ) &&
qgsDoubleNear( pt.z(), mZ, 1E-8 ) &&
qgsDoubleNear( pt.m(), mM, 1E-8 ) );
const QgsWkbTypes::Type type = wkbType();

bool equal = pt.wkbType() == type;
equal &= qgsDoubleNear( pt.x(), mX, 1E-8 );
equal &= qgsDoubleNear( pt.y(), mY, 1E-8 );
if ( QgsWkbTypes::hasZ( type ) )
equal &= qgsDoubleNear( pt.z(), mZ, 1E-8 );
if ( QgsWkbTypes::hasM( type ) )
equal &= qgsDoubleNear( pt.m(), mM, 1E-8 );

return equal;
}

bool QgsPoint::operator!=( const QgsPoint &pt ) const
Expand Down

0 comments on commit bd82ca3

Please sign in to comment.