Skip to content
Permalink
Browse files

[geometry] optimize point distance to point

  • Loading branch information
nirvn committed Jun 4, 2018
1 parent 84806b9 commit 783b6b8120007b2d9cd8c7112b85f63524a53229
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/core/geometry/qgsgeometry.cpp
@@ -1595,6 +1595,12 @@ double QgsGeometry::distance( const QgsGeometry &geom ) const
return -1.0;
}

// avoid calling geos for trivial point-to-point distance calculations
if ( QgsWkbTypes::flatType( d->geometry->wkbType() ) == QgsWkbTypes::Point && QgsWkbTypes::flatType( geom.wkbType() ) == QgsWkbTypes::Point )
{
return qgsgeometry_cast< const QgsPoint * >( d->geometry.get() )->distance( *qgsgeometry_cast< const QgsPoint * >( geom.constGet() ) );
}

QgsGeos g( d->geometry.get() );
mLastError.clear();
return g.distance( geom.d->geometry.get(), &mLastError );

0 comments on commit 783b6b8

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