[geos-commits] r3241 - in trunk: . include/geos/geom src/geom
tests/unit/geom
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed Feb 23 10:45:40 EST 2011
Author: strk
Date: 2011-02-23 07:45:40 -0800 (Wed, 23 Feb 2011)
New Revision: 3241
Modified:
trunk/NEWS
trunk/include/geos/geom/LinearRing.h
trunk/src/geom/LinearRing.cpp
trunk/tests/unit/geom/LinearRingTest.cpp
Log:
Sync LinearRing to JTS-1.12: empty LinearRing are closed by definition now
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2011-02-23 14:37:39 UTC (rev 3240)
+++ trunk/NEWS 2011-02-23 15:45:40 UTC (rev 3241)
@@ -25,6 +25,7 @@
- Polygonizer::getDangles returns by const ref
- Polygonizer::getInvalidRingLines returns by const ref and retains
ownership of vector elements
+ - Empty LinearRings are closed by definition
- Bug fixes:
- Invalid compound geometries reported as valid (#333)
- Return up to 15 digits of precision from GEOSisValidReason_t (#329)
Modified: trunk/include/geos/geom/LinearRing.h
===================================================================
--- trunk/include/geos/geom/LinearRing.h 2011-02-23 14:37:39 UTC (rev 3240)
+++ trunk/include/geos/geom/LinearRing.h 2011-02-23 15:45:40 UTC (rev 3241)
@@ -14,7 +14,7 @@
*
**********************************************************************
*
- * Last port: geom/LinearRing.java rev. 1.32 (JTS-1.10)
+ * Last port: geom/LinearRing.java r320 (JTS-1.12)
*
**********************************************************************/
@@ -59,6 +59,12 @@
public:
+ /**
+ * The minimum number of vertices allowed in a valid non-empty ring (= 4).
+ * Empty rings with 0 vertices are also valid.
+ */
+ static const unsigned int MINIMUM_VALID_SIZE = 4;
+
LinearRing(const LinearRing &lr);
/**
@@ -102,6 +108,8 @@
*/
bool isSimple() const;
+ bool isClosed() const;
+
std::string getGeometryType() const;
virtual GeometryTypeId getGeometryTypeId() const;
Modified: trunk/src/geom/LinearRing.cpp
===================================================================
--- trunk/src/geom/LinearRing.cpp 2011-02-23 14:37:39 UTC (rev 3240)
+++ trunk/src/geom/LinearRing.cpp 2011-02-23 15:45:40 UTC (rev 3241)
@@ -14,7 +14,7 @@
*
**********************************************************************
*
- * Last port: geom/LinearRing.java rev. 1.32 (JTS-1.10)
+ * Last port: geom/LinearRing.java r320 (JTS-1.12)
*
**********************************************************************/
@@ -71,7 +71,7 @@
);
}
- if ( points->getSize() <= 3 )
+ if ( points->getSize() < MINIMUM_VALID_SIZE )
{
std::ostringstream os;
os << "Invalid number of points in LinearRing found "
@@ -98,6 +98,16 @@
return true;
}
+bool
+LinearRing::isClosed() const
+{
+ if ( points->isEmpty() ) {
+ // empty LinearRings are closed by definition
+ return true;
+ }
+ return LineString::isClosed();
+}
+
string LinearRing::getGeometryType() const {
return "LinearRing";
}
Modified: trunk/tests/unit/geom/LinearRingTest.cpp
===================================================================
--- trunk/tests/unit/geom/LinearRingTest.cpp 2011-02-23 14:37:39 UTC (rev 3240)
+++ trunk/tests/unit/geom/LinearRingTest.cpp 2011-02-23 15:45:40 UTC (rev 3241)
@@ -141,7 +141,7 @@
template<>
void object::test<4>()
{
- ensure( ! empty_ring_.isClosed() );
+ ensure( empty_ring_.isClosed() );
}
// Test of isRing() for empty LinearRing
@@ -149,7 +149,7 @@
template<>
void object::test<5>()
{
- ensure( ! empty_ring_.isRing() );
+ ensure( empty_ring_.isRing() );
}
// Test of isSimple() for empty LinearRing
More information about the geos-commits
mailing list