[geos-commits] [SCM] GEOS branch master updated. 6845c86cdf9a0b6e72294d72c77eff6b557ecef7

git at osgeo.org git at osgeo.org
Thu Dec 6 14:31:45 PST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, master has been updated
       via  6845c86cdf9a0b6e72294d72c77eff6b557ecef7 (commit)
      from  2337c07b0c5146ef0c9a7cd5868fce2fd4c216e9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6845c86cdf9a0b6e72294d72c77eff6b557ecef7
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Thu Dec 6 14:30:55 2018 -0800

    Port from JTS 6e44c5ceb791a939bd54643e38a8fe5ee7b500a6
    Refactor the implementation of geometry type sort order
    and harmonize with JTS method names

diff --git a/include/geos/geom/Geometry.h b/include/geos/geom/Geometry.h
index 9e82ed3..d9cf497 100644
--- a/include/geos/geom/Geometry.h
+++ b/include/geos/geom/Geometry.h
@@ -91,6 +91,17 @@ enum GeometryTypeId {
 	GEOS_GEOMETRYCOLLECTION
 };
 
+enum GeometrySortIndex {
+	SORTINDEX_POINT = 0,
+	SORTINDEX_MULTIPOINT = 1,
+	SORTINDEX_LINESTRING = 2,
+	SORTINDEX_LINEARRING = 3,
+	SORTINDEX_MULTILINESTRING = 4,
+	SORTINDEX_POLYGON = 5,
+	SORTINDEX_MULTIPOLYGON = 6,
+	SORTINDEX_GEOMETRYCOLLECTION = 7
+};
+
 /**
  * \class Geometry geom.h geos.h
  *
@@ -846,9 +857,13 @@ protected:
 	 */
 	Geometry(const GeometryFactory *factory);
 
-private:
 
-	int getClassSortIndex() const;
+protected:
+
+		virtual int getSortIndex() const = 0;
+
+
+private:
 
 	class GEOS_DLL GeometryChangedFilter : public GeometryComponentFilter
 	{
diff --git a/include/geos/geom/GeometryCollection.h b/include/geos/geom/GeometryCollection.h
index 98b6dd8..fa70f7e 100644
--- a/include/geos/geom/GeometryCollection.h
+++ b/include/geos/geom/GeometryCollection.h
@@ -196,6 +196,7 @@ protected:
 	 */
 	GeometryCollection(std::vector<Geometry *> *newGeoms, const GeometryFactory *newFactory);
 
+	int getSortIndex() const override { return SORTINDEX_GEOMETRYCOLLECTION; };
 
 	std::vector<Geometry *>* geometries;
 
diff --git a/include/geos/geom/GeometryFactory.h b/include/geos/geom/GeometryFactory.h
index e75560e..70b8441 100644
--- a/include/geos/geom/GeometryFactory.h
+++ b/include/geos/geom/GeometryFactory.h
@@ -323,9 +323,9 @@ public:
       ++count;
       const Geometry* g = *i;
       if ( geomClass < 0 ) {
-        geomClass = g->getClassSortIndex();
+        geomClass = g->getSortIndex();
       }
-      else if ( geomClass != g->getClassSortIndex() ) {
+      else if ( geomClass != g->getSortIndex() ) {
         isHeterogeneous = true;
       }
     }
diff --git a/include/geos/geom/LineString.h b/include/geos/geom/LineString.h
index 81c6c38..00aff7c 100644
--- a/include/geos/geom/LineString.h
+++ b/include/geos/geom/LineString.h
@@ -202,6 +202,8 @@ protected:
 
 	CoordinateSequence::Ptr points;
 
+	int getSortIndex() const override { return SORTINDEX_LINESTRING; };
+
 private:
 
 	void validateConstruction();
diff --git a/include/geos/geom/LinearRing.h b/include/geos/geom/LinearRing.h
index 085b3ea..9303f42 100644
--- a/include/geos/geom/LinearRing.h
+++ b/include/geos/geom/LinearRing.h
@@ -107,6 +107,11 @@ public:
 
   	Geometry* reverse() const override;
 
+protected:
+
+		int getSortIndex() const override { return SORTINDEX_LINEARRING; };
+
+
 private:
 
 	void validateConstruction();
diff --git a/include/geos/geom/MultiLineString.h b/include/geos/geom/MultiLineString.h
index b26215a..d806481 100644
--- a/include/geos/geom/MultiLineString.h
+++ b/include/geos/geom/MultiLineString.h
@@ -115,6 +115,9 @@ protected:
 			const GeometryFactory *newFactory);
 
 	MultiLineString(const MultiLineString &mp);
+
+	int getSortIndex() const override { return SORTINDEX_MULTILINESTRING; };
+
 };
 
 #ifdef _MSC_VER
diff --git a/include/geos/geom/MultiPoint.h b/include/geos/geom/MultiPoint.h
index ec1b718..8e35394 100644
--- a/include/geos/geom/MultiPoint.h
+++ b/include/geos/geom/MultiPoint.h
@@ -113,6 +113,9 @@ protected:
 	MultiPoint(const MultiPoint &mp): Geometry(mp), GeometryCollection(mp) {}
 
 	const Coordinate* getCoordinateN(size_t n) const;
+
+	int getSortIndex() const override { return SORTINDEX_MULTIPOINT; };
+
 };
 
 #ifdef _MSC_VER
diff --git a/include/geos/geom/MultiPolygon.h b/include/geos/geom/MultiPolygon.h
index 9f91393..b270947 100644
--- a/include/geos/geom/MultiPolygon.h
+++ b/include/geos/geom/MultiPolygon.h
@@ -115,6 +115,9 @@ protected:
 	MultiPolygon(std::vector<Geometry *> *newPolys, const GeometryFactory *newFactory);
 
 	MultiPolygon(const MultiPolygon &mp);
+
+	int getSortIndex() const override { return SORTINDEX_MULTIPOLYGON; };
+
 };
 
 #ifdef _MSC_VER
diff --git a/include/geos/geom/Point.h b/include/geos/geom/Point.h
index 000b348..754f1b0 100644
--- a/include/geos/geom/Point.h
+++ b/include/geos/geom/Point.h
@@ -160,6 +160,8 @@ protected:
 
 	int compareToSameClass(const Geometry *p) const override;
 
+	int getSortIndex() const override { return SORTINDEX_POINT; };
+
 private:
 
 	/**
diff --git a/include/geos/geom/Polygon.h b/include/geos/geom/Polygon.h
index a62bd47..8874db2 100644
--- a/include/geos/geom/Polygon.h
+++ b/include/geos/geom/Polygon.h
@@ -176,6 +176,9 @@ protected:
 
 	Envelope::Ptr computeEnvelopeInternal() const override;
 
+	int getSortIndex() const override { return SORTINDEX_POLYGON; };
+
+
 private:
 
 	void normalize(LinearRing *ring, bool clockwise);
diff --git a/src/geom/Geometry.cpp b/src/geom/Geometry.cpp
index 571520a..c83edc9 100644
--- a/src/geom/Geometry.cpp
+++ b/src/geom/Geometry.cpp
@@ -652,10 +652,11 @@ int
 Geometry::compareTo(const Geometry *geom) const
 {
 	// compare to self
-	if ( this == geom ) return 0;
+	if (this == geom) return 0;
 
-	if (getClassSortIndex()!=geom->getClassSortIndex()) {
-		return getClassSortIndex()-geom->getClassSortIndex();
+	if (getSortIndex() != geom->getSortIndex()) {
+		int diff = getSortIndex() - geom->getSortIndex();
+		return (diff > 0) - (diff < 0); // signum()
 	}
 	if (isEmpty() && geom->isEmpty()) {
 		return 0;
@@ -687,32 +688,6 @@ Geometry::checkNotGeometryCollection(const Geometry *g)
 	}
 }
 
-int
-Geometry::getClassSortIndex() const
-{
-	//const type_info &t=typeid(*this);
-
-	     if ( typeid(*this) == typeid(Point)              ) return 0;
-	else if ( typeid(*this) == typeid(MultiPoint)         ) return 1;
-	else if ( typeid(*this) == typeid(LineString)         ) return 2;
-	else if ( typeid(*this) == typeid(LinearRing)         ) return 3;
-	else if ( typeid(*this) == typeid(MultiLineString)    ) return 4;
-	else if ( typeid(*this) == typeid(Polygon)            ) return 5;
-	else if ( typeid(*this) == typeid(MultiPolygon)       ) return 6;
-	else
-	{
-		assert(typeid(*this) == typeid(GeometryCollection)); // unsupported class
-		return 7;
-	}
-
-#if 0
-	string str="Class not supported: ";
-	str.append(typeid(*this).name());
-	str.append("");
-	Assert::shouldNeverReachHere(str);
-	return -1;
-#endif
-}
 
 void Geometry::GeometryChangedFilter::filter_rw(Geometry* geom)
 {

-----------------------------------------------------------------------

Summary of changes:
 include/geos/geom/Geometry.h           | 19 +++++++++++++++++--
 include/geos/geom/GeometryCollection.h |  1 +
 include/geos/geom/GeometryFactory.h    |  4 ++--
 include/geos/geom/LineString.h         |  2 ++
 include/geos/geom/LinearRing.h         |  5 +++++
 include/geos/geom/MultiLineString.h    |  3 +++
 include/geos/geom/MultiPoint.h         |  3 +++
 include/geos/geom/MultiPolygon.h       |  3 +++
 include/geos/geom/Point.h              |  2 ++
 include/geos/geom/Polygon.h            |  3 +++
 src/geom/Geometry.cpp                  | 33 ++++-----------------------------
 11 files changed, 45 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list