[geos-commits] r2109 - trunk/source/index/chain
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Jan 17 19:35:10 EST 2008
Author: benjubb
Date: 2008-01-17 19:35:10 -0500 (Thu, 17 Jan 2008)
New Revision: 2109
Modified:
trunk/source/index/chain/MonotoneChainBuilder.cpp
Log:
Fixed a bug in the handling of line strings with repeated points.
-This line, and those below, will be ignored--
M MonotoneChainBuilder.cpp
Modified: trunk/source/index/chain/MonotoneChainBuilder.cpp
===================================================================
--- trunk/source/index/chain/MonotoneChainBuilder.cpp 2008-01-17 19:15:48 UTC (rev 2108)
+++ trunk/source/index/chain/MonotoneChainBuilder.cpp 2008-01-18 00:35:10 UTC (rev 2109)
@@ -98,16 +98,27 @@
int
MonotoneChainBuilder::findChainEnd(const CoordinateSequence *pts, int start)
{
+ std::size_t npts = pts->getSize();
+
+ // skip any zero-length segments at start of sequence
+ while ( pts->getAt( start).equals2D( pts->getAt( start + 1) ) )
+ if ( ++start >= ( npts - 1 ) )
+ // bail if there are no non-zero-length segments
+ return npts - 1;
+
// determine quadrant for chain
int chainQuad=Quadrant::quadrant(pts->getAt(start),pts->getAt(start + 1));
std::size_t last=start+1;
- std::size_t npts=pts->getSize();
while (last < npts)
{
- // compute quadrant for next possible segment in chain
- int quad=Quadrant::quadrant(pts->getAt(last-1),pts->getAt(last));
- if (quad!=chainQuad) break;
- last++;
+ // skip a zero-length segnments
+ if (! pts->getAt( last - 1).equals2D( pts->getAt( last) ) )
+ {
+ // compute quadrant for next possible segment in chain
+ int quad=Quadrant::quadrant(pts->getAt(last-1),pts->getAt(last));
+ if (quad!=chainQuad) break;
+ }
+ last++;
}
#if GEOS_DEBUG
std::cerr<<"MonotoneChainBuilder::findChainEnd() returning"<<std::endl;
More information about the geos-commits
mailing list