From e7cf5904fa27c708968b602b8ec7f1dcf3f7307b Mon Sep 17 00:00:00 2001 From: mhugent Date: Wed, 12 Apr 2006 20:58:03 +0000 Subject: [PATCH] fix for svn compile problem git-svn-id: http://svn.osgeo.org/qgis/trunk@5271 c8812cc2-4d05-0410-92ff-de0c093fc19c --- src/core/qgsgeometry.cpp | 90 ++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/src/core/qgsgeometry.cpp b/src/core/qgsgeometry.cpp index 4fc842d38df9..f8d113302751 100644 --- a/src/core/qgsgeometry.cpp +++ b/src/core/qgsgeometry.cpp @@ -940,55 +940,57 @@ QgsPoint QgsGeometry::closestSegmentWithContext(QgsPoint& point, switch (wkbType) { case QGis::WKBPoint: - // Points have no lines - return QgsPoint(0,0); - + { + // Points have no lines + return QgsPoint(0,0); + } case QGis::WKBLineString: - closestSegmentIndex = 0; - unsigned char* ptr = mGeometry + 5; - int* npoints = (int*) ptr; - ptr += sizeof(int); - for (int index=0; index < *npoints; ++index) { - if (index > 0) - { - prevx = thisx; - prevy = thisy; - } - - thisx = (double*) ptr; - ptr += sizeof(double); - thisy = (double*) ptr; - - if (index > 0) - { - if ( - ( - testdist = distanceSquaredPointToSegment(point, - prevx, prevy, - thisx, thisy, - minDistPoint) // TODO: save minDistPoint into something meaningful. - ) - < sqrDist ) - { + closestSegmentIndex = 0; + unsigned char* ptr = mGeometry + 5; + int* npoints = (int*) ptr; + ptr += sizeof(int); + for (int index=0; index < *npoints; ++index) + { + if (index > 0) + { + prevx = thisx; + prevy = thisy; + } + + thisx = (double*) ptr; + ptr += sizeof(double); + thisy = (double*) ptr; + + if (index > 0) + { + if ( + ( + testdist = distanceSquaredPointToSegment(point, + prevx, prevy, + thisx, thisy, + minDistPoint) // TODO: save minDistPoint into something meaningful. + ) + < sqrDist ) + { #ifdef QGISDEBUG -// std::cout << "QgsGeometry::closestSegment: testDist " -// << testdist << ", sqrDist" -// << sqrDist -// << "." << std::endl; + // std::cout << "QgsGeometry::closestSegment: testDist " + // << testdist << ", sqrDist" + // << sqrDist + // << "." << std::endl; #endif - closestSegmentIndex = index; - sqrDist = testdist; - } - } - - ptr += sizeof(double); + closestSegmentIndex = index; + sqrDist = testdist; + } + } + + ptr += sizeof(double); + } + + beforeVertex.push_back(closestSegmentIndex); + + break; } - - beforeVertex.push_back(closestSegmentIndex); - - break; - //todo: add wkb parsing case QGis::WKBPolygon: {