[geos-commits] r2547 - in trunk/source: geomgraph headers/geos/geomgraph headers/geos/operation/relate headers/geos/operation/valid operation/relate operation/valid

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Jun 5 09:41:50 EDT 2009


Author: strk
Date: 2009-06-05 09:41:50 -0400 (Fri, 05 Jun 2009)
New Revision: 2547

Modified:
   trunk/source/geomgraph/EdgeEnd.cpp
   trunk/source/geomgraph/EdgeEndStar.cpp
   trunk/source/headers/geos/geomgraph/EdgeEnd.h
   trunk/source/headers/geos/geomgraph/EdgeEndStar.h
   trunk/source/headers/geos/operation/relate/EdgeEndBundle.h
   trunk/source/headers/geos/operation/valid/ConsistentAreaTester.h
   trunk/source/operation/relate/EdgeEndBundle.cpp
   trunk/source/operation/valid/ConsistentAreaTester.cpp
Log:
added BoundaryNodeRule capability to EdgeEnds


Modified: trunk/source/geomgraph/EdgeEnd.cpp
===================================================================
--- trunk/source/geomgraph/EdgeEnd.cpp	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/geomgraph/EdgeEnd.cpp	2009-06-05 13:41:50 UTC (rev 2547)
@@ -14,7 +14,7 @@
  *
  **********************************************************************
  *
- * Last port: geomgraph/EdgeEnd.java rev. 1.5 (JTS-1.7)
+ * Last port: geomgraph/EdgeEnd.java rev. 1.6 (JTS-1.10)
  *
  **********************************************************************/
 
@@ -182,7 +182,7 @@
 
 /*public*/
 void
-EdgeEnd::computeLabel()
+EdgeEnd::computeLabel(const algorithm::BoundaryNodeRule& boundaryNodeRule)
 {
 	// subclasses should override this if they are using labels
 }

Modified: trunk/source/geomgraph/EdgeEndStar.cpp
===================================================================
--- trunk/source/geomgraph/EdgeEndStar.cpp	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/geomgraph/EdgeEndStar.cpp	2009-06-05 13:41:50 UTC (rev 2547)
@@ -14,7 +14,7 @@
  *
  **********************************************************************
  *
- * Last port: geomgraph/EdgeEndStar.java rev. 1.4 (JTS-1.7)
+ * Last port: geomgraph/EdgeEndStar.java rev. 1.8 (JTS-1.10)
  *
  **********************************************************************/
 
@@ -76,10 +76,10 @@
 
 /*public*/
 void
-EdgeEndStar::computeLabelling(std::vector<GeometryGraph*> *geom)
+EdgeEndStar::computeLabelling(std::vector<GeometryGraph*> *geomGraph)
 	//throw(TopologyException *)
 {
-	computeEdgeEndLabels();
+	computeEdgeEndLabels((*geomGraph)[0]->getBoundaryNodeRule());
 
 	// Propagate side labels  around the edges in the star
 	// for each parent Geometry
@@ -156,7 +156,7 @@
 					loc=Location::EXTERIOR;
 				}else {
 					Coordinate& p=e->getCoordinate();
-					loc=getLocation(geomi,p,geom);
+					loc = getLocation(geomi, p, geomGraph);
 				}
 				label->setAllLocationsIfNull(geomi,loc);
 			}
@@ -166,14 +166,15 @@
 
 /*private*/
 void
-EdgeEndStar::computeEdgeEndLabels()
+EdgeEndStar::computeEdgeEndLabels(
+		const algorithm::BoundaryNodeRule& boundaryNodeRule)
 {
 	// Compute edge label for each EdgeEnd
 	for (EdgeEndStar::iterator it=begin(); it!=end(); ++it)
 	{
-		EdgeEnd *e=*it;
-		assert(e);
-		e->computeLabel();
+		EdgeEnd *ee=*it;
+		assert(ee);
+		ee->computeLabel(boundaryNodeRule);
 	}
 }
 
@@ -193,9 +194,9 @@
 
 /*public*/
 bool
-EdgeEndStar::isAreaLabelsConsistent()
+EdgeEndStar::isAreaLabelsConsistent(const GeometryGraph& geomGraph)
 {
-	computeEdgeEndLabels();
+	computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());
 	return checkAreaLabelsConsistent(0);
 }
 

Modified: trunk/source/headers/geos/geomgraph/EdgeEnd.h
===================================================================
--- trunk/source/headers/geos/geomgraph/EdgeEnd.h	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/headers/geos/geomgraph/EdgeEnd.h	2009-06-05 13:41:50 UTC (rev 2547)
@@ -14,9 +14,9 @@
  *
  **********************************************************************
  *
- * Last port: geomgraph/EdgeEnd.java rev. 1.5 (JTS-1.7)
+ * Last port: geomgraph/EdgeEnd.java rev. 1.6 (JTS-1.10)
  *
- * EXPOSED GEOS HEADER
+ * EXPOSED GEOS HEADER, but direct use NOT reccommended
  *
  **********************************************************************/
 
@@ -31,6 +31,9 @@
 
 // Forward declarations
 namespace geos {
+	namespace algorithm {
+		class BoundaryNodeRule;
+	}
 	namespace geomgraph {
 		class Label;
 		class Edge;
@@ -111,7 +114,7 @@
 	 */
 	virtual int compareDirection(const EdgeEnd *e) const;
 
-	virtual void computeLabel();
+	virtual void computeLabel(const algorithm::BoundaryNodeRule& bnr);
 
 	virtual std::string print();
 

Modified: trunk/source/headers/geos/geomgraph/EdgeEndStar.h
===================================================================
--- trunk/source/headers/geos/geomgraph/EdgeEndStar.h	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/headers/geos/geomgraph/EdgeEndStar.h	2009-06-05 13:41:50 UTC (rev 2547)
@@ -14,7 +14,7 @@
  *
  **********************************************************************
  *
- * Last port: geomgraph/EdgeEndStar.java rev. 1.4 (JTS-1.7)
+ * Last port: geomgraph/EdgeEndStar.java rev. 1.8 (JTS-1.10)
  *
  * EXPOSED GEOS HEADER
  *
@@ -36,6 +36,9 @@
 
 // Forward declarations
 namespace geos {
+	namespace algorithm {
+		class BoundaryNodeRule;
+	}
 	namespace geomgraph {
 		class GeometryGraph;
 	}
@@ -94,15 +97,11 @@
 
 	virtual EdgeEnd* getNextCW(EdgeEnd *ee);
 
-	virtual void computeLabelling(std::vector<GeometryGraph*> *geom);
+	virtual void computeLabelling(std::vector<GeometryGraph*> *geomGraph);
 		// throw(TopologyException *);
 
-	virtual int getLocation(int geomIndex,
-		const geom::Coordinate& p,
-		std::vector<GeometryGraph*> *geom); 
+	virtual bool isAreaLabelsConsistent(const GeometryGraph& geomGraph);
 
-	virtual bool isAreaLabelsConsistent();
-
 	virtual void propagateSideLabels(int geomIndex);
 		// throw(TopologyException *);
 
@@ -126,13 +125,17 @@
 
 private:
 
+	virtual int getLocation(int geomIndex,
+		const geom::Coordinate& p,
+		std::vector<GeometryGraph*> *geom); 
+
 	/** \brief
 	 * The location of the point for this star in
 	 * Geometry i Areas
 	 */
 	int ptInAreaLocation[2];
 
-	virtual void computeEdgeEndLabels();
+	virtual void computeEdgeEndLabels(const algorithm::BoundaryNodeRule&);
 
 	virtual bool checkAreaLabelsConsistent(int geomIndex);
 

Modified: trunk/source/headers/geos/operation/relate/EdgeEndBundle.h
===================================================================
--- trunk/source/headers/geos/operation/relate/EdgeEndBundle.h	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/headers/geos/operation/relate/EdgeEndBundle.h	2009-06-05 13:41:50 UTC (rev 2547)
@@ -13,7 +13,7 @@
  *
  **********************************************************************
  *
- * Last port: operation/relate/EdgeEndBundle.java rev. 1.15 (JTS-1.7)
+ * Last port: operation/relate/EdgeEndBundle.java rev. 1.17 (JTS-1.10)
  *
  * NON-EXPOSED GEOS HEADER
  *
@@ -28,6 +28,9 @@
 
 // Forward declarations
 namespace geos {
+	namespace algorithm {
+		class BoundaryNodeRule;
+	}
 	namespace geom {
 		class IntersectionMatrix;
 	}
@@ -39,23 +42,57 @@
 namespace relate { // geos::operation::relate
 
 /** \brief
- * Contains all geomgraph::EdgeEnd objectss which start at the same point
- * and are parallel.
+ * A collection of geomgraph::EdgeEnd objects which
+ * originate at the same point and have the same direction.
  */
-class EdgeEndBundle: public geomgraph::EdgeEnd {
+class EdgeEndBundle: public geomgraph::EdgeEnd
+{
 public:
 	EdgeEndBundle(geomgraph::EdgeEnd *e);
 	virtual ~EdgeEndBundle();
 	geomgraph::Label *getLabel();
-//Iterator iterator() //Not needed
 	std::vector<geomgraph::EdgeEnd*>* getEdgeEnds();
 	void insert(geomgraph::EdgeEnd *e);
-	void computeLabel() ; 
+
+	void computeLabel(const algorithm::BoundaryNodeRule& bnr); 
+
 	void updateIM(geom::IntersectionMatrix *im);
 	std::string print();
 protected:
 	std::vector<geomgraph::EdgeEnd*> *edgeEnds;
-	void computeLabelOn(int geomIndex);
+
+	/**
+	 * Compute the overall ON location for the list of EdgeStubs.
+	 *
+	 * (This is essentially equivalent to computing the self-overlay of
+	 * a single Geometry)
+	 *
+	 * edgeStubs can be either on the boundary (eg Polygon edge)
+	 * OR in the interior (e.g. segment of a LineString)
+	 * of their parent Geometry.
+	 *
+	 * In addition, GeometryCollections use a algorithm::BoundaryNodeRule
+	 * to determine whether a segment is on the boundary or not.
+	 *
+	 * Finally, in GeometryCollections it can occur that an edge
+	 * is both
+	 * on the boundary and in the interior (e.g. a LineString segment
+	 * lying on
+	 * top of a Polygon edge.) In this case the Boundary is
+	 * given precendence.
+	 * 
+	 * These observations result in the following rules for computing
+	 * the ON location:
+	 *  - if there are an odd number of Bdy edges, the attribute is Bdy
+	 *  - if there are an even number >= 2 of Bdy edges, the attribute
+	 *    is Int
+	 *  - if there are any Int edges, the attribute is Int
+	 *  - otherwise, the attribute is NULL.
+	 * 
+	 */
+	void computeLabelOn(int geomIndex,
+		const algorithm::BoundaryNodeRule& boundaryNodeRule);
+
 	void computeLabelSides(int geomIndex);
 	void computeLabelSide(int geomIndex,int side);
 };

Modified: trunk/source/headers/geos/operation/valid/ConsistentAreaTester.h
===================================================================
--- trunk/source/headers/geos/operation/valid/ConsistentAreaTester.h	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/headers/geos/operation/valid/ConsistentAreaTester.h	2009-06-05 13:41:50 UTC (rev 2547)
@@ -12,6 +12,12 @@
  * by the Free Software Foundation. 
  * See the COPYING file for more information.
  *
+ **********************************************************************
+ *
+ * Last port: operation/valid/ConsistentAreaTester.java rev. 1.14 (JTS-1.10)
+ *
+ * NON-EXPOSED GEOS HEADER
+ *
  **********************************************************************/
 
 #ifndef GEOS_OP_CONSISTENTAREATESTER_H
@@ -43,7 +49,7 @@
 /** \brief
  * Checks that a {@link geomgraph::GeometryGraph} representing an area
  * (a {@link Polygon} or {@link MultiPolygon} )
- * is consistent with the SFS semantics for area geometries.
+ * is consistent with the OGC-SFS semantics for area geometries.
  *
  * Checks include:
  * 
@@ -54,6 +60,27 @@
  * If an inconsistency if found the location of the problem
  * is recorded.
  */
+/** \brief
+ * Checks that a geomgraph::GeometryGraph representing an area
+ * (a geom::Polygon or geom::MultiPolygon)
+ * has consistent semantics for area geometries.
+ * This check is required for any reasonable polygonal model
+ * (including the OGC-SFS model, as well as models which allow ring
+ * self-intersection at single points)
+ * 
+ * Checks include:
+ * 
+ *  - test for rings which properly intersect
+ *    (but not for ring self-intersection, or intersections at vertices)
+ *  - test for consistent labelling at all node points
+ *    (this detects vertex intersections with invalid topology,
+ *    i.e. where the exterior side of an edge lies in the interior of the area)
+ *  - test for duplicate rings
+ * 
+ * If an inconsistency is found the location of the problem
+ * is recorded and is available to the caller.
+ *
+ */
 class ConsistentAreaTester {
 private:
 
@@ -75,16 +102,29 @@
 
 public:
 
-	/// Caller keeps responsibility for GeometryGraph deletion
+	/**
+	 * Creates a new tester for consistent areas.
+	 *
+	 * @param geomGraph the topology graph of the area geometry.
+	 *                  Caller keeps responsibility for its deletion
+	 */
 	ConsistentAreaTester(geomgraph::GeometryGraph *newGeomGraph);
 
 	~ConsistentAreaTester();
 
 	/**
-	 * @return the intersection point, or <code>null</code> if none was found
+	 * @return the intersection point, or <code>null</code>
+	 *         if none was found
 	 */
 	geom::Coordinate& getInvalidPoint();
 
+	/** \brief
+	 * Check all nodes to see if their labels are consistent with
+	 * area topology.
+	 *
+	 * @return <code>true</code> if this area has a consistent node
+	 *         labelling
+	 */
 	bool isNodeConsistentArea();
 
 	/**

Modified: trunk/source/operation/relate/EdgeEndBundle.cpp
===================================================================
--- trunk/source/operation/relate/EdgeEndBundle.cpp	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/operation/relate/EdgeEndBundle.cpp	2009-06-05 13:41:50 UTC (rev 2547)
@@ -14,7 +14,7 @@
  *
  **********************************************************************
  *
- * Last port: operation/relate/EdgeEndBundle.java rev. 1.15 (JTS-1.7)
+ * Last port: operation/relate/EdgeEndBundle.java rev. 1.17 (JTS-1.10)
  *
  **********************************************************************/
 
@@ -75,7 +75,9 @@
 * edges in this EdgeStubBundle.  It essentially merges
 * the ON and side labels for each edge.  These labels must be compatible
 */
-void EdgeEndBundle::computeLabel() {
+void EdgeEndBundle::computeLabel(
+	const algorithm::BoundaryNodeRule& boundaryNodeRule)
+{
 	// create the label.  If any of the edges belong to areas,
 	// the label must be an area label
 	bool isArea=false;
@@ -95,34 +97,16 @@
 	}
 	// compute the On label, and the side labels if present
 	for(int i=0;i<2;i++) {
-		computeLabelOn(i);
+		computeLabelOn(i, boundaryNodeRule);
 		if (isArea)
 			computeLabelSides(i);
 	}
 }
 
 
-/**
-* Compute the overall ON location for the list of EdgeStubs.
-* (This is essentially equivalent to computing the self-overlay of a single Geometry)
-* edgeStubs can be either on the boundary (eg Polygon edge)
-* OR in the interior (e.g. segment of a LineString)
-* of their parent Geometry.
-* In addition, GeometryCollections use the mod-2 rule to determine
-* whether a segment is on the boundary or not.
-* Finally, in GeometryCollections it can still occur that an edge is both
-* on the boundary and in the interior (e.g. a LineString segment lying on
-* top of a Polygon edge.) In this case as usual the Boundary is given precendence.
-* <br>
-* These observations result in the following rules for computing the ON location:
-* <ul>
-* <li> if there are an odd number of Bdy edges, the attribute is Bdy
-* <li> if there are an even number >= 2 of Bdy edges, the attribute is Int
-* <li> if there are any Int edges, the attribute is Int
-* <li> otherwise, the attribute is NULL.
-* </ul>
-*/
-void EdgeEndBundle::computeLabelOn(int geomIndex) {
+void
+EdgeEndBundle::computeLabelOn(int geomIndex, const algorithm::BoundaryNodeRule& boundaryNodeRule)
+{
 	// compute the ON location value
 	int boundaryCount=0;
 	bool foundInterior=false;
@@ -136,7 +120,8 @@
 	int loc=Location::UNDEF;
 	if (foundInterior) loc=Location::INTERIOR;
 	if (boundaryCount>0) {
-		loc=GeometryGraph::determineBoundary(boundaryCount);
+		loc = GeometryGraph::determineBoundary(boundaryNodeRule,
+		                                       boundaryCount);
 	}
 	label->setLocation(geomIndex,loc);
 }

Modified: trunk/source/operation/valid/ConsistentAreaTester.cpp
===================================================================
--- trunk/source/operation/valid/ConsistentAreaTester.cpp	2009-06-05 12:42:14 UTC (rev 2546)
+++ trunk/source/operation/valid/ConsistentAreaTester.cpp	2009-06-05 13:41:50 UTC (rev 2547)
@@ -12,6 +12,10 @@
  * by the Free Software Foundation. 
  * See the COPYING file for more information.
  *
+ **********************************************************************
+ *
+ * Last port: operation/valid/ConsistentAreaTester.java rev. 1.14 (JTS-1.10)
+ *
  **********************************************************************/
 
 #include <geos/operation/valid/ConsistentAreaTester.h> 
@@ -79,11 +83,13 @@
 bool
 ConsistentAreaTester::isNodeEdgeAreaLabelsConsistent()
 {
+	assert(geomGraph);
+
 	map<Coordinate*,Node*,CoordinateLessThen>& nMap=nodeGraph.getNodeMap();
 	map<Coordinate*,Node*,CoordinateLessThen>::iterator nodeIt;
 	for(nodeIt=nMap.begin();nodeIt!=nMap.end();nodeIt++) {
 		relate::RelateNode *node=static_cast<relate::RelateNode*>(nodeIt->second);
-		if (!node->getEdges()->isAreaLabelsConsistent()) {
+		if (!node->getEdges()->isAreaLabelsConsistent(*geomGraph)) {
 			invalidPoint=node->getCoordinate();
 			return false;
 		}



More information about the geos-commits mailing list