Skip to content

Commit bd82ca3

Browse files
committed
Compare Z and M values in QgsPoint::operator== only when required
1 parent 1808dc9 commit bd82ca3

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/core/geometry/qgspoint.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,17 @@ QgsPoint::QgsPoint( QgsWkbTypes::Type wkbType, double x, double y, double z, dou
9595

9696
bool QgsPoint::operator==( const QgsPoint &pt ) const
9797
{
98-
return ( pt.wkbType() == wkbType() &&
99-
qgsDoubleNear( pt.x(), mX, 1E-8 ) &&
100-
qgsDoubleNear( pt.y(), mY, 1E-8 ) &&
101-
qgsDoubleNear( pt.z(), mZ, 1E-8 ) &&
102-
qgsDoubleNear( pt.m(), mM, 1E-8 ) );
98+
const QgsWkbTypes::Type type = wkbType();
99+
100+
bool equal = pt.wkbType() == type;
101+
equal &= qgsDoubleNear( pt.x(), mX, 1E-8 );
102+
equal &= qgsDoubleNear( pt.y(), mY, 1E-8 );
103+
if ( QgsWkbTypes::hasZ( type ) )
104+
equal &= qgsDoubleNear( pt.z(), mZ, 1E-8 );
105+
if ( QgsWkbTypes::hasM( type ) )
106+
equal &= qgsDoubleNear( pt.m(), mM, 1E-8 );
107+
108+
return equal;
103109
}
104110

105111
bool QgsPoint::operator!=( const QgsPoint &pt ) const

0 commit comments

Comments
 (0)