[geos-commits] r3739 - in branches/3.3: . src/algorithm tests/unit/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Fri Jan 11 06:25:48 PST 2013
Author: strk
Date: 2013-01-11 06:25:46 -0800 (Fri, 11 Jan 2013)
New Revision: 3739
Modified:
branches/3.3/NEWS
branches/3.3/src/algorithm/InteriorPointLine.cpp
branches/3.3/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
Log:
Fix GEOSPointOnSurface with zero-length linestring (#609)
Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS 2012-12-06 17:44:57 UTC (rev 3738)
+++ branches/3.3/NEWS 2013-01-11 14:25:46 UTC (rev 3739)
@@ -5,6 +5,7 @@
- Fix abort in RightmostEdgeFinder (#605)
- Do not force precision reduction below 6 significant digits
while trying to obtain a valid Buffer output (#605)
+ - Fix GEOSPointOnSurface with zero-length linestring (#609)
Changes in 3.3.6
2012-11-15 -- that's Post-GIS day !
Modified: branches/3.3/src/algorithm/InteriorPointLine.cpp
===================================================================
--- branches/3.3/src/algorithm/InteriorPointLine.cpp 2012-12-06 17:44:57 UTC (rev 3738)
+++ branches/3.3/src/algorithm/InteriorPointLine.cpp 2013-01-11 14:25:46 UTC (rev 3739)
@@ -48,8 +48,8 @@
std::cerr << "Centroid: " << centroid << std::endl;
#endif
addInterior(g);
- if (!hasInterior) addEndpoints(g);
}
+ if (!hasInterior) addEndpoints(g);
}
InteriorPointLine::~InteriorPointLine()
@@ -119,8 +119,11 @@
void
InteriorPointLine::addEndpoints(const CoordinateSequence *pts)
{
- add(pts->getAt(0));
- add(pts->getAt(pts->getSize()-1));
+ size_t npts = pts->size();
+ if ( npts ) {
+ add(pts->getAt(0));
+ if ( npts > 1 ) add(pts->getAt(npts-1));
+ }
}
/*private*/
Modified: branches/3.3/tests/unit/capi/GEOSPointOnSurfaceTest.cpp
===================================================================
--- branches/3.3/tests/unit/capi/GEOSPointOnSurfaceTest.cpp 2012-12-06 17:44:57 UTC (rev 3738)
+++ branches/3.3/tests/unit/capi/GEOSPointOnSurfaceTest.cpp 2013-01-11 14:25:46 UTC (rev 3739)
@@ -167,7 +167,25 @@
wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
ensure_equals(std::string(wkt_), std::string( "POINT EMPTY"));
+ }
+ // Single point linestring -- see http://trac.osgeo.org/geos/ticket/609
+ template<>
+ template<>
+ void object::test<6>()
+ {
+ geom1_ = GEOSGeomFromWKT("LINESTRING(0 0, 0 0)");
+
+ ensure( 0 != geom1_ );
+
+ geom2_ = GEOSPointOnSurface(geom1_);
+
+ ensure( 0 != geom2_ );
+
+ wkt_ = GEOSWKTWriter_write(wktw_, geom2_);
+
+ ensure_equals(std::string(wkt_), std::string( "POINT (0 0)"));
+
}
} // namespace tut
More information about the geos-commits
mailing list