[geos-commits] r3554 - branches/3.3/src/operation/overlay/snap
svn_geos at osgeo.org
svn_geos at osgeo.org
Fri Dec 16 09:12:21 EST 2011
Author: strk
Date: 2011-12-16 06:12:20 -0800 (Fri, 16 Dec 2011)
New Revision: 3554
Modified:
branches/3.3/src/operation/overlay/snap/LineStringSnapper.cpp
Log:
Make debugging output of LineStringSnapper more readable
Modified: branches/3.3/src/operation/overlay/snap/LineStringSnapper.cpp
===================================================================
--- branches/3.3/src/operation/overlay/snap/LineStringSnapper.cpp 2011-12-15 14:36:15 UTC (rev 3553)
+++ branches/3.3/src/operation/overlay/snap/LineStringSnapper.cpp 2011-12-16 14:12:20 UTC (rev 3554)
@@ -65,6 +65,10 @@
{
if ( srcCoords.empty() ) return;
+#if GEOS_DEBUG
+cerr << "Snapping vertices of: " << srcCoords << endl;
+#endif
+
using geom::CoordinateList;
geom::Coordinate::ConstVect::const_iterator not_found = snapPts.end();
@@ -87,7 +91,7 @@
if ( found == not_found )
{ // no snaps found (or no need to snap)
#if GEOS_DEBUG
-cerr << "No snap found" << endl;
+cerr << " no snap found" << endl;
#endif
continue;
}
@@ -96,14 +100,14 @@
const Coordinate& snapPt = *(*found);
#if GEOS_DEBUG
-cerr << "Found snap point " << snapPt << endl;
+cerr << " found snap point " << snapPt << endl;
#endif
// update src with snap pt
*it = snapPt;
#if GEOS_DEBUG
-cerr << "Source point became " << srcPt << endl;
+cerr << " source point became " << srcPt << endl;
#endif
// keep final closing point in synch (rings only)
@@ -130,10 +134,6 @@
assert(*it);
const Coordinate& snapPt = *(*it);
-#if GEOS_DEBUG
-cerr << " misuring distance between snap point " << snapPt << " and source point " << pt << endl;
-#endif
-
// shouldn't we look for *all* segments to be snapped rather then a single one?
if ( snapPt.equals2D(pt) )
{
@@ -145,17 +145,21 @@
}
double dist = snapPt.distance(pt);
+#if GEOS_DEBUG
+cerr << " distance from snap point " << snapPt << ": " << dist << endl;
+#endif
+
if ( dist < snapTolerance )
{
#if GEOS_DEBUG
-cerr << " points are within distance (" << dist << ") returning iterator to snap point" << endl;
+cerr << " snap point within tolerance, returning iterator to it" << endl;
#endif
return it;
}
}
#if GEOS_DEBUG
-cerr << " No snap point within distance, returning not-found" << endl;
+cerr << " no snap point within distance, returning not-found" << endl;
#endif
return end;
@@ -168,13 +172,13 @@
const geom::Coordinate::ConstVect& snapPts)
{
+ // nothing to do if there are no source coords..
+ if ( srcCoords.empty() ) return;
+
#if GEOS_DEBUG
-cerr << " Snapping segment from: " << srcCoords << endl;
+cerr << "Snapping segments of: " << srcCoords << endl;
#endif
- // nothing to do if there are no source coords..
- if ( srcCoords.empty() ) return;
-
for ( Coordinate::ConstVect::const_iterator
it=snapPts.begin(), end=snapPts.end();
it != end;
@@ -235,7 +239,7 @@
seg.p1 = *to;
#if GEOS_DEBUG
-cerr << " Checking segment " << seg << " for snapping against point " << snapPt << endl;
+cerr << " Checking segment " << seg << endl;
#endif
/** * Check if the snap pt is equal to one of
@@ -248,28 +252,45 @@
if ( seg.p0.equals2D(snapPt) || seg.p1.equals2D(snapPt) )
{
+ if (allowSnappingToSourceVertices) {
#if GEOS_DEBUG
-cerr << " One of segment endpoints equal snap point, returning too_far" << endl;
+cerr << " snap point matches a segment endpoint, checking next segment"
+ << endl;
#endif
- if (allowSnappingToSourceVertices) {
continue;
} else {
+#if GEOS_DEBUG
+cerr << " snap point matches a segment endpoint, giving up seek" << endl;
+#endif
return too_far;
}
}
double dist = seg.distance(snapPt);
+ if ( dist < snapTolerance ) {
+ if ( dist < minDist ) {
#if GEOS_DEBUG
-cerr << " dist=" << dist << " minDist=" << minDist << " snapTolerance=" << snapTolerance << endl;
+cerr << " snap point distance " << dist << " within tolerance "
+ << snapTolerance << " and closer than previous candidate " << minDist
+ << endl;
#endif
- if ( dist < minDist && dist < snapTolerance )
- {
+ match = from;
+ minDist = dist;
+ }
#if GEOS_DEBUG
-cerr << " Segment/snapPt distance within tolerance and closer then previous match (" << dist << ") " << endl;
+ else {
+cerr << " snap point distance " << dist << " within tolerance "
+ << snapTolerance << " but not closer than previous candidate " << minDist
+ << endl;
+ }
#endif
- match = from;
- minDist = dist;
- }
+ }
+#if GEOS_DEBUG
+ else {
+cerr << " snap point distance " << dist << " bigger than tolerance "
+ << snapTolerance << endl;
+ }
+#endif
}
return match;
More information about the geos-commits
mailing list