[geos-commits] r3185 - in trunk: . include/geos/geom src/geom
svn_geos at osgeo.org
svn_geos at osgeo.org
Mon Feb 7 10:39:27 EST 2011
Author: strk
Date: 2011-02-07 07:39:27 -0800 (Mon, 07 Feb 2011)
New Revision: 3185
Modified:
trunk/NEWS
trunk/include/geos/geom/GeometryCollection.h
trunk/include/geos/geom/LineString.h
trunk/include/geos/geom/Lineal.h
trunk/include/geos/geom/MultiLineString.inl
trunk/include/geos/geom/MultiPoint.h
trunk/include/geos/geom/MultiPolygon.inl
trunk/include/geos/geom/Point.h
trunk/include/geos/geom/Polygon.h
trunk/include/geos/geom/Polygonal.h
trunk/include/geos/geom/Puntal.h
trunk/src/geom/LinearRing.cpp
trunk/src/geom/MultiLineString.cpp
trunk/src/geom/MultiPoint.cpp
trunk/src/geom/MultiPolygon.cpp
Log:
Turn Puntal, Lineal and Polygonal into Geometry derivates. This commit introduces virtual inheritance and 3 diamonds.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/NEWS 2011-02-07 15:39:27 UTC (rev 3185)
@@ -16,6 +16,8 @@
- CAPI: GEOSRelatePatternMatch
- PHP: new PHP5 bindings based on CAPI
- C++ API changes:
+ - Geometry inheritance chain changed to introduce Puntal, Lineal
+ and Polygonal classes (virtual inheritance introduced)
- Geometry::isWithinDistance method is now const
- Polygonizer::getCutEdges returns by const ref
- Polygonizer::getDangles returns by const ref
Modified: trunk/include/geos/geom/GeometryCollection.h
===================================================================
--- trunk/include/geos/geom/GeometryCollection.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/GeometryCollection.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -54,7 +54,7 @@
* represented by GeometryCollection subclasses MultiPoint,
* MultiLineString, MultiPolygon.
*/
-class GEOS_DLL GeometryCollection : public Geometry {
+class GEOS_DLL GeometryCollection : public virtual Geometry {
public:
friend class GeometryFactory;
Modified: trunk/include/geos/geom/LineString.h
===================================================================
--- trunk/include/geos/geom/LineString.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/LineString.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -68,7 +68,7 @@
* If these conditions are not met, the constructors throw
* an {@link IllegalArgumentException}
*/
-class GEOS_DLL LineString: public Geometry, public Lineal {
+class GEOS_DLL LineString: public virtual Geometry, public Lineal {
public:
@@ -223,10 +223,6 @@
} // namespace geos::geom
} // namespace geos
-//#ifdef GEOS_INLINE
-//# include "geos/geom/LineString.inl"
-//#endif
-
#ifdef _MSC_VER
#pragma warning(pop)
#endif
Modified: trunk/include/geos/geom/Lineal.h
===================================================================
--- trunk/include/geos/geom/Lineal.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/Lineal.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -27,7 +27,11 @@
* Identifies {@link Geometry} subclasses which
* are 1-dimensional and with components which are {@link LineString}s.
*/
-class Lineal {};
+class Lineal : public virtual Geometry
+{
+protected:
+ Lineal(): Geometry(0) {}
+};
} // namespace geos::geom
} // namespace geos
Modified: trunk/include/geos/geom/MultiLineString.inl
===================================================================
--- trunk/include/geos/geom/MultiLineString.inl 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/MultiLineString.inl 2011-02-07 15:39:27 UTC (rev 3185)
@@ -32,6 +32,7 @@
INLINE
MultiLineString::MultiLineString(const MultiLineString &mp)
:
+ Geometry(mp),
GeometryCollection(mp)
{
}
Modified: trunk/include/geos/geom/MultiPoint.h
===================================================================
--- trunk/include/geos/geom/MultiPoint.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/MultiPoint.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -104,7 +104,7 @@
*/
MultiPoint(std::vector<Geometry *> *newPoints, const GeometryFactory *newFactory);
- MultiPoint(const MultiPoint &mp): GeometryCollection(mp) {}
+ MultiPoint(const MultiPoint &mp): Geometry(mp), GeometryCollection(mp) {}
const Coordinate* getCoordinateN(int n) const;
};
Modified: trunk/include/geos/geom/MultiPolygon.inl
===================================================================
--- trunk/include/geos/geom/MultiPolygon.inl 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/MultiPolygon.inl 2011-02-07 15:39:27 UTC (rev 3185)
@@ -29,6 +29,7 @@
INLINE
MultiPolygon::MultiPolygon(const MultiPolygon &mp)
:
+ Geometry(mp),
GeometryCollection(mp)
{
}
Modified: trunk/include/geos/geom/Point.h
===================================================================
--- trunk/include/geos/geom/Point.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/Point.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -65,7 +65,7 @@
* (i.e does not have an NaN X or Y ordinate)
*
*/
-class GEOS_DLL Point : public Geometry, public Puntal
+class GEOS_DLL Point : public virtual Geometry, public Puntal
{
public:
Modified: trunk/include/geos/geom/Polygon.h
===================================================================
--- trunk/include/geos/geom/Polygon.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/Polygon.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -64,7 +64,7 @@
* Specification for SQL</A> .
*
*/
-class GEOS_DLL Polygon: public Geometry, public Polygonal
+class GEOS_DLL Polygon: public virtual Geometry, public Polygonal
{
public:
Modified: trunk/include/geos/geom/Polygonal.h
===================================================================
--- trunk/include/geos/geom/Polygonal.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/Polygonal.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -27,7 +27,11 @@
* Identifies {@link Geometry} subclasses which
* are 2-dimensional and with components which are {@link Polygon}s.
*/
-class Polygonal {};
+class Polygonal : public virtual Geometry
+{
+protected:
+ Polygonal(): Geometry(0) {}
+};
} // namespace geos::geom
} // namespace geos
Modified: trunk/include/geos/geom/Puntal.h
===================================================================
--- trunk/include/geos/geom/Puntal.h 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/include/geos/geom/Puntal.h 2011-02-07 15:39:27 UTC (rev 3185)
@@ -27,7 +27,11 @@
* Identifies {@link Geometry} subclasses which
* are 0-dimensional and with components which are {@link Point}s.
*/
-class Puntal {};
+class Puntal : public virtual Geometry
+{
+protected:
+ Puntal(): Geometry(0) {}
+};
} // namespace geos::geom
} // namespace geos
Modified: trunk/src/geom/LinearRing.cpp
===================================================================
--- trunk/src/geom/LinearRing.cpp 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/src/geom/LinearRing.cpp 2011-02-07 15:39:27 UTC (rev 3185)
@@ -35,12 +35,13 @@
namespace geom { // geos::geom
/*public*/
-LinearRing::LinearRing(const LinearRing &lr): LineString(lr) {}
+LinearRing::LinearRing(const LinearRing &lr): Geometry(lr), LineString(lr) {}
/*public*/
LinearRing::LinearRing(CoordinateSequence* newCoords,
const GeometryFactory *newFactory)
:
+ Geometry(newFactory),
LineString(newCoords, newFactory)
{
validateConstruction();
@@ -50,6 +51,7 @@
LinearRing::LinearRing(CoordinateSequence::AutoPtr newCoords,
const GeometryFactory *newFactory)
:
+ Geometry(newFactory),
LineString(newCoords, newFactory)
{
validateConstruction();
Modified: trunk/src/geom/MultiLineString.cpp
===================================================================
--- trunk/src/geom/MultiLineString.cpp 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/src/geom/MultiLineString.cpp 2011-02-07 15:39:27 UTC (rev 3185)
@@ -45,6 +45,7 @@
MultiLineString::MultiLineString(vector<Geometry *> *newLines,
const GeometryFactory *factory)
:
+ Geometry(factory),
GeometryCollection(newLines,factory)
{
}
@@ -71,8 +72,9 @@
if (isEmpty()) {
return false;
}
- for (size_t i = 0; i < geometries->size(); i++) {
- if (!((LineString *)(*geometries)[i])->isClosed()) {
+ for (size_t i = 0, n = geometries->size(); i < n; ++i) {
+ LineString *ls = dynamic_cast<LineString*>((*geometries)[i]);
+ if ( ! ls->isClosed() ) {
return false;
}
}
@@ -112,8 +114,8 @@
Geometry::NonConstVect *revLines = new Geometry::NonConstVect(nLines);
for (size_t i=0; i<nLines; ++i)
{
- assert(dynamic_cast<LineString*>((*geometries)[i]));
- LineString *iLS = static_cast<LineString*>((*geometries)[i]);
+ LineString *iLS = dynamic_cast<LineString*>((*geometries)[i]);
+ assert(iLS);
(*revLines)[nLines-1-i] = iLS->reverse();
}
return getFactory()->createMultiLineString(revLines);
Modified: trunk/src/geom/MultiPoint.cpp
===================================================================
--- trunk/src/geom/MultiPoint.cpp 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/src/geom/MultiPoint.cpp 2011-02-07 15:39:27 UTC (rev 3185)
@@ -35,6 +35,7 @@
/*protected*/
MultiPoint::MultiPoint(vector<Geometry *> *newPoints, const GeometryFactory *factory)
:
+ Geometry(factory),
GeometryCollection(newPoints,factory)
{
}
Modified: trunk/src/geom/MultiPolygon.cpp
===================================================================
--- trunk/src/geom/MultiPolygon.cpp 2011-02-04 12:27:01 UTC (rev 3184)
+++ trunk/src/geom/MultiPolygon.cpp 2011-02-07 15:39:27 UTC (rev 3185)
@@ -41,7 +41,8 @@
/*protected*/
MultiPolygon::MultiPolygon(vector<Geometry *> *newPolys, const GeometryFactory *factory)
- : GeometryCollection(newPolys,factory)
+ : Geometry(factory),
+ GeometryCollection(newPolys,factory)
{}
MultiPolygon::~MultiPolygon(){}
More information about the geos-commits
mailing list