diff --git a/src/core/pal/feature.cpp b/src/core/pal/feature.cpp index 6df3e94a9971..ce6f91fc4343 100644 --- a/src/core/pal/feature.cpp +++ b/src/core/pal/feature.cpp @@ -40,6 +40,7 @@ #include "qgstextlabelfeature.h" #include "qgsmessagelog.h" #include "qgsgeometryutils.h" +#include "qgsgeometryutils_base.h" #include "qgslabeling.h" #include "qgspolygon.h" #include "qgstextrendererutils.h" @@ -801,7 +802,7 @@ std::size_t FeaturePart::createHorizontalCandidatesAlongLine( std::vectornbPoints - 1] = totalLineLength; @@ -933,7 +934,7 @@ std::size_t FeaturePart::createCandidatesAlongLineNearStraightSegments( std::vec else distanceToSegment[i] = distanceToSegment[i - 1] + segmentLengths[i - 1]; - segmentLengths[i] = GeomFunction::dist_euc2d( x[i], y[i], x[i + 1], y[i + 1] ); + segmentLengths[i] = QgsGeometryUtilsBase:distance2D( x[i], y[i], x[i + 1], y[i + 1] ); totalLineLength += segmentLengths[i]; if ( extremeAngleNodes.contains( i ) ) { @@ -1150,7 +1151,7 @@ std::size_t FeaturePart::createCandidatesAlongLineNearMidpoint( std::vector< std else distanceToSegment[i] = distanceToSegment[i - 1] + segmentLengths[i - 1]; - segmentLengths[i] = GeomFunction::dist_euc2d( x[i], y[i], x[i + 1], y[i + 1] ); + segmentLengths[i] = QgsGeometryUtilsBase:distance2D( x[i], y[i], x[i + 1], y[i + 1] ); totalLineLength += segmentLengths[i]; } distanceToSegment[line->nbPoints - 1] = totalLineLength; diff --git a/src/core/pal/geomfunction.cpp b/src/core/pal/geomfunction.cpp index 4baa71067a0d..0021799a34d9 100644 --- a/src/core/pal/geomfunction.cpp +++ b/src/core/pal/geomfunction.cpp @@ -27,6 +27,7 @@ * */ +#include "qgsgeometryutils_base.h" #include "geomfunction.h" #include "feature.h" #include "util.h" @@ -225,8 +226,8 @@ std::vector< int > GeomFunction::convexHullId( std::vector< int > &id, const std // Coolineaire !! garder le plus éloigné if ( qgsDoubleNear( result, 0.0 ) ) { - if ( dist_euc2d_sq( x[id[stack[second]]], y[id[stack[second]]], x[id[convexHull[i]]], y[id[convexHull[i]]] ) - > dist_euc2d_sq( x[id[stack[second]]], y[id[stack[second]]], x[id[stack[top]]], y[id[stack[top]]] ) ) + if ( QgsGeometryUtilsBase::sqrDistance2D( x[id[stack[second]]], y[id[stack[second]]], x[id[convexHull[i]]], y[id[convexHull[i]]] ) + > QgsGeometryUtilsBase::sqrDistance2D( x[id[stack[second]]], y[id[stack[second]]], x[id[stack[top]]], y[id[stack[top]]] ) ) { stack[top] = convexHull[i]; } diff --git a/src/core/pal/geomfunction.h b/src/core/pal/geomfunction.h index 8a83a3627241..e357f389c161 100644 --- a/src/core/pal/geomfunction.h +++ b/src/core/pal/geomfunction.h @@ -64,16 +64,6 @@ namespace pal return ( x2 - x1 ) * ( y3 - y1 ) - ( x3 - x1 ) * ( y2 - y1 ); } - static inline double dist_euc2d( double x1, double y1, double x2, double y2 ) - { - return std::sqrt( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ); - } - - static inline double dist_euc2d_sq( double x1, double y1, double x2, double y2 ) - { - return ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ); - } - static void findLineCircleIntersection( double cx, double cy, double radius, double x1, double y1, double x2, double y2, double &xRes, double &yRes ); diff --git a/src/core/pal/labelposition.cpp b/src/core/pal/labelposition.cpp index 3bf8d97b8d97..28b7703eadcb 100644 --- a/src/core/pal/labelposition.cpp +++ b/src/core/pal/labelposition.cpp @@ -33,6 +33,7 @@ #include "labelposition.h" #include "geomfunction.h" #include "qgsgeos.h" +#include "qgsgeometryutils_base.h" #include "qgsmessagelog.h" #include #include @@ -622,7 +623,7 @@ double LabelPosition::getDistanceToPoint( double xp, double yp, bool useOuterBou else { ( void )GEOSCoordSeq_getXY_r( geosctxt, nearestCoord.get(), 0, &nx, &ny ); - distance = GeomFunction::dist_euc2d_sq( xp, yp, nx, ny ); + distance = QgsGeometryUtilsBase:sqrDistance2D( xp, yp, nx, ny ); } } catch ( GEOSException &e ) diff --git a/src/core/pal/pointset.cpp b/src/core/pal/pointset.cpp index 34ecabec113b..e1c3fa61cf6f 100644 --- a/src/core/pal/pointset.cpp +++ b/src/core/pal/pointset.cpp @@ -33,6 +33,7 @@ #include "qgsgeos.h" #include "qgsmessagelog.h" #include "qgsgeometryutils.h" +#include "qgsgeometryutils_base.h" #include using namespace pal; @@ -357,13 +358,13 @@ QLinkedList PointSet::splitPolygons( PointSet *inputShape, double la if ( pt != -1 ) { // compute the ihs->ihn->pt triangle's area - const double base = GeomFunction::dist_euc2d( x[shape->convexHull[ihs]], y[shape->convexHull[ihs]], + const double base = QgsGeometryUtilsBase:distance2D( x[shape->convexHull[ihs]], y[shape->convexHull[ihs]], x[shape->convexHull[ihn]], y[shape->convexHull[ihn]] ); - b = GeomFunction::dist_euc2d( x[shape->convexHull[ihs]], y[shape->convexHull[ihs]], + b = QgsGeometryUtilsBase:distance2D( x[shape->convexHull[ihs]], y[shape->convexHull[ihs]], x[pt], y[pt] ); - const double c = GeomFunction::dist_euc2d( x[shape->convexHull[ihn]], y[shape->convexHull[ihn]], + const double c = QgsGeometryUtilsBase:distance2D( x[shape->convexHull[ihn]], y[shape->convexHull[ihn]], x[pt], y[pt] ); const double s = ( base + b + c ) / 2; // s = half perimeter @@ -406,7 +407,7 @@ QLinkedList PointSet::splitPolygons( PointSet *inputShape, double la // compute distance between retainedPoint and segment // whether perpendicular distance (if retaindPoint is fronting segment i->j) // or distance between retainedPt and i or j (choose the nearest) - seg_length = GeomFunction::dist_euc2d( x[i], y[i], x[j], y[j] ); + seg_length = QgsGeometryUtilsBase:distance2D( x[i], y[i], x[j], y[j] ); cx = ( x[i] + x[j] ) / 2.0; cy = ( y[i] + y[j] ) / 2.0; dx = cy - y[i]; @@ -419,7 +420,7 @@ QLinkedList PointSet::splitPolygons( PointSet *inputShape, double la if ( seg_length < EPSILON || std::fabs( ( b = GeomFunction::cross_product( ex, ey, fx, fy, x[retainedPt], y[retainedPt] ) / ( seg_length ) ) ) > ( seg_length / 2 ) ) // retainedPt is not fronting i->j { - if ( ( ex = GeomFunction::dist_euc2d_sq( x[i], y[i], x[retainedPt], y[retainedPt] ) ) < ( ey = GeomFunction::dist_euc2d_sq( x[j], y[j], x[retainedPt], y[retainedPt] ) ) ) + if ( ( ex = QgsGeometryUtilsBase:sqrDistance2D( x[i], y[i], x[retainedPt], y[retainedPt] ) ) < ( ey = QgsGeometryUtilsBase:sqrDistance2D( x[j], y[j], x[retainedPt], y[retainedPt] ) ) ) { b = ex; ps = i; @@ -904,7 +905,7 @@ double PointSet::minDistanceToPoint( double px, double py, double *rx, double *r if ( ry ) *ry = ny; - return GeomFunction::dist_euc2d_sq( px, py, nx, ny ); + return QgsGeometryUtilsBase:sqrDistance2D( px, py, nx, ny ); } catch ( GEOSException &e ) {