[geos-commits] r2462 - in trunk: source/headers/geos/operation/overlay source/headers/geos/operation/overlay/validate source/operation/overlay source/operation/overlay/validate tests/unit tests/unit/operation/overlay tests/unit/operation/overlay/validate

svn_geos at osgeo.org svn_geos at osgeo.org
Mon May 4 17:28:26 EDT 2009


Author: strk
Date: 2009-05-04 17:28:26 -0400 (Mon, 04 May 2009)
New Revision: 2462

Added:
   trunk/source/headers/geos/operation/overlay/validate/
   trunk/source/headers/geos/operation/overlay/validate/FuzzyPointLocator.h
   trunk/source/headers/geos/operation/overlay/validate/OffsetPointGenerator.h
   trunk/source/headers/geos/operation/overlay/validate/OverlayResultValidator.h
   trunk/source/operation/overlay/validate/
   trunk/source/operation/overlay/validate/FuzzyPointLocator.cpp
   trunk/source/operation/overlay/validate/OffsetPointGenerator.cpp
   trunk/source/operation/overlay/validate/OverlayResultValidator.cpp
   trunk/tests/unit/operation/overlay/validate/
   trunk/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp
   trunk/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp
   trunk/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp
Removed:
   trunk/source/headers/geos/operation/overlay/FuzzyPointLocator.h
   trunk/source/headers/geos/operation/overlay/OffsetPointGenerator.h
   trunk/source/headers/geos/operation/overlay/OverlayResultValidator.h
   trunk/source/operation/overlay/FuzzyPointLocator.cpp
   trunk/source/operation/overlay/OffsetPointGenerator.cpp
   trunk/source/operation/overlay/OverlayResultValidator.cpp
   trunk/tests/unit/operation/overlay/FuzzyPointLocatorTest.cpp
   trunk/tests/unit/operation/overlay/OffsetPointGeneratorTest.cpp
   trunk/tests/unit/operation/overlay/OverlayResultValidatorTest.cpp
Modified:
   trunk/source/headers/geos/operation/overlay/Makefile.am
   trunk/source/operation/overlay/Makefile.am
   trunk/source/operation/overlay/OverlayOp.cpp
   trunk/tests/unit/Makefile.am
Log:
Move overlay.validate package files where they belong


Deleted: trunk/source/headers/geos/operation/overlay/FuzzyPointLocator.h
===================================================================
--- trunk/source/headers/geos/operation/overlay/FuzzyPointLocator.h	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/headers/geos/operation/overlay/FuzzyPointLocator.h	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,92 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.refractions.net
- *
- * Copyright (C) 2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
- * See the COPYING file for more information.
- *
- ***********************************************************************
- *
- * Last port: operation/overlay/validate/FuzzyPointLocator.java rev. 1.1
- * (we should move in GEOS too, probably)
- *
- **********************************************************************/
-
-#ifndef GEOS_OP_OVERLAY_FUZZYPOINTLOCATOR_H
-#define GEOS_OP_OVERLAY_FUZZYPOINTLOCATOR_H
-
-#include <geos/algorithm/PointLocator.h> // for composition
-#include <geos/geom/Geometry.h> // for auto_ptr visibility of dtor
-#include <geos/geom/Location.h> // for Location::Value enum
-
-#include <vector>
-#include <memory> // for auto_ptr
-
-// Forward declarations
-namespace geos {
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-	}
-}
-
-namespace geos {
-namespace operation { // geos::operation
-namespace overlay { // geos::operation::overlay
-
-/** \brief
- * Finds the most likely Location of a point relative to
- * the polygonal components of a geometry, using a tolerance value.
- *
- * If a point is not clearly in the Interior or Exterior,
- * it is considered to be on the Boundary.
- * In other words, if the point is within the tolerance of the Boundary,
- * it is considered to be on the Boundary; otherwise,
- * whether it is Interior or Exterior is determined directly.
- */
-class FuzzyPointLocator {
-
-public:
-
-	FuzzyPointLocator(const geom::Geometry& geom, double nTolerance);
-
-	geom::Location::Value getLocation(const geom::Coordinate& pt);
-
-private:
-
-	const geom::Geometry& g;
-
-	double tolerance;
-
-	algorithm::PointLocator ptLocator;
-
-	std::auto_ptr<geom::Geometry> linework;
-
-	// this function has been obsoleted
-	std::auto_ptr<geom::Geometry> getLineWork(const geom::Geometry& geom);
-
-	/// Extracts linework for polygonal components.
-	//
-	/// @param g the geometry from which to extract
-	/// @return a lineal geometry containing the extracted linework
-	std::auto_ptr<geom::Geometry> extractLineWork(const geom::Geometry& geom);
-
-
-};
-
-} // namespace geos::operation::overlay
-} // namespace geos::operation
-} // namespace geos
-
-#endif // ndef GEOS_OP_OVERLAY_FUZZYPOINTLOCATOR_H
-
-/**********************************************************************
- * $Log$
- **********************************************************************/
-

Modified: trunk/source/headers/geos/operation/overlay/Makefile.am
===================================================================
--- trunk/source/headers/geos/operation/overlay/Makefile.am	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/headers/geos/operation/overlay/Makefile.am	2009-05-04 21:28:26 UTC (rev 2462)
@@ -14,16 +14,16 @@
 	EdgeSetNoder.h		\
 	ElevationMatrixCell.h	\
 	ElevationMatrix.h	\
-	FuzzyPointLocator.h	\
 	LineBuilder.h		\
 	MaximalEdgeRing.h	\
 	MinimalEdgeRing.h	\
 	MinimalEdgeRing.inl	\
-	OffsetPointGenerator.h	\
 	OverlayNodeFactory.h	\
-	OverlayResultValidator.h \
 	PointBuilder.h		\
 	PolygonBuilder.h	\
 	snap/GeometrySnapper.h	\
 	snap/LineStringSnapper.h \
-	snap/SnapOverlayOp.h
+	snap/SnapOverlayOp.h	\
+	validate/FuzzyPointLocator.h	\
+	validate/OffsetPointGenerator.h	\
+	validate/OverlayResultValidator.h 

Deleted: trunk/source/headers/geos/operation/overlay/OffsetPointGenerator.h
===================================================================
--- trunk/source/headers/geos/operation/overlay/OffsetPointGenerator.h	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/headers/geos/operation/overlay/OffsetPointGenerator.h	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,80 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.refractions.net
- *
- * Copyright (C) 2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
- * See the COPYING file for more information.
- *
- ***********************************************************************
- *
- * Last port: operation/overlay/validate/OffsetPointGenerator.java rev. 1.1
- * (we should move in GEOS too, probably)
- *
- **********************************************************************/
-
-#ifndef GEOS_OP_OVERLAY_OFFSETPOINTGENERATOR_H
-#define GEOS_OP_OVERLAY_OFFSETPOINTGENERATOR_H
-
-#include <geos/algorithm/PointLocator.h> // for composition
-#include <geos/geom/Geometry.h> // for auto_ptr visibility of dtor
-#include <geos/geom/MultiPoint.h> // for auto_ptr visibility of dtor
-#include <geos/geom/Coordinate.h> // for use in vector
-
-#include <vector>
-#include <memory> // for auto_ptr
-
-// Forward declarations
-namespace geos {
-	namespace geom {
-		//class Geometry;
-		//class MultiPoint;
-		class LineString;
-		//class Coordinate;
-	}
-}
-
-namespace geos {
-namespace operation { // geos::operation
-namespace overlay { // geos::operation::overlay
-
-/// Generates points offset from both sides of all segments in a geometry
-//
-class OffsetPointGenerator {
-
-public:
-
-	OffsetPointGenerator(const geom::Geometry& geom, double offset);
-
-	/// Gets the computed offset points.
-	std::auto_ptr< std::vector<geom::Coordinate> > getPoints();
-
-private:
-
-	const geom::Geometry& g;
-
-	double offsetDistance;
-
-	std::auto_ptr< std::vector<geom::Coordinate> > offsetPts;
-
-	void extractPoints(const geom::LineString* line);
-
-	void computeOffsets(const geom::Coordinate& p0,
-			const geom::Coordinate& p1);
-};
-
-} // namespace geos::operation::overlay
-} // namespace geos::operation
-} // namespace geos
-
-#endif // ndef GEOS_OP_OVERLAY_OFFSETPOINTGENERATOR_H
-
-/**********************************************************************
- * $Log$
- **********************************************************************/
-

Deleted: trunk/source/headers/geos/operation/overlay/OverlayResultValidator.h
===================================================================
--- trunk/source/headers/geos/operation/overlay/OverlayResultValidator.h	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/headers/geos/operation/overlay/OverlayResultValidator.h	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,117 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.refractions.net
- *
- * Copyright (C) 2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
- * See the COPYING file for more information.
- *
- ***********************************************************************
- *
- * Last port: operation/overlay/validate/OverlayResultValidator.java rev. 1.1
- * (we should move in GEOS too, probably)
- *
- **********************************************************************/
-
-#ifndef GEOS_OP_OVERLAY_OVERLAYRESULTVALIDATOR_H
-#define GEOS_OP_OVERLAY_OVERLAYRESULTVALIDATOR_H
-
-#include <geos/operation/overlay/OverlayOp.h> // for OpCode enum
-#include <geos/operation/overlay/FuzzyPointLocator.h> 
-#include <geos/geom/Location.h> // for Location::Value type
-
-#include <vector>
-
-// Forward declarations
-namespace geos {
-	namespace geom {
-		class Geometry;
-		class Coordinate;
-	}
-}
-
-namespace geos {
-namespace operation { // geos::operation
-namespace overlay { // geos::operation::overlay
-
-/** \brief
- * Validates that the result of an overlay operation is
- * geometrically correct within a given tolerance.
- *
- * Uses fuzzy point location, which only works with polygonal
- * components of geometries.
- *
- * This is a heuristic test, and may return incorrect results.
- * It should never return a false negative result, however
- * (I.e. reporting a valid result as invalid.)
- * 
- * @see OverlayOp
- */
-class OverlayResultValidator {
-
-public:
-
-	static bool isValid(
-			const geom::Geometry& geom0,
-			const geom::Geometry& geom1,
-			OverlayOp::OpCode opCode,
-			const geom::Geometry& result);
-
-	OverlayResultValidator(
-			const geom::Geometry& geom0,
-			const geom::Geometry& geom1,
-			const geom::Geometry& result);
-
-	bool isValid(OverlayOp::OpCode opCode);
-
-	geom::Coordinate& getInvalidLocation() {
-		return invalidLocation;
-	}
-
-private:
-
-	const geom::Geometry& g0;
-
-	const geom::Geometry& g1;
-
-	const geom::Geometry& gres;
-
-	FuzzyPointLocator fpl0;
-
-	FuzzyPointLocator fpl1;
-
-	FuzzyPointLocator fplres;
-
-	geom::Coordinate invalidLocation;
-
-	static double _TOLERANCE; // 0.000001
-	
-	std::vector<geom::Coordinate> testCoords;
-
-	void addTestPts(const geom::Geometry& g);
-
-	void addVertices(const geom::Geometry& g);
-
-	bool testValid(OverlayOp::OpCode overlayOp);
-
-	bool testValid(OverlayOp::OpCode overlayOp, const geom::Coordinate& pt);
-
-	bool isValidResult(OverlayOp::OpCode overlayOp,
-			std::vector<geom::Location::Value>& location);
-};
-
-} // namespace geos::operation::overlay
-} // namespace geos::operation
-} // namespace geos
-
-#endif // ndef GEOS_OP_OVERLAY_OVERLAYRESULTVALIDATOR_H
-
-/**********************************************************************
- * $Log$
- **********************************************************************/
-

Copied: trunk/source/headers/geos/operation/overlay/validate/FuzzyPointLocator.h (from rev 2455, trunk/source/headers/geos/operation/overlay/FuzzyPointLocator.h)
===================================================================
--- trunk/source/headers/geos/operation/overlay/validate/FuzzyPointLocator.h	                        (rev 0)
+++ trunk/source/headers/geos/operation/overlay/validate/FuzzyPointLocator.h	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,94 @@
+/**********************************************************************
+ * $Id$
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation. 
+ * See the COPYING file for more information.
+ *
+ ***********************************************************************
+ *
+ * Last port: operation/overlay/validate/FuzzyPointLocator.java rev. 1.1
+ * (we should move in GEOS too, probably)
+ *
+ **********************************************************************/
+
+#ifndef GEOS_OP_OVERLAY_FUZZYPOINTLOCATOR_H
+#define GEOS_OP_OVERLAY_FUZZYPOINTLOCATOR_H
+
+#include <geos/algorithm/PointLocator.h> // for composition
+#include <geos/geom/Geometry.h> // for auto_ptr visibility of dtor
+#include <geos/geom/Location.h> // for Location::Value enum
+
+#include <vector>
+#include <memory> // for auto_ptr
+
+// Forward declarations
+namespace geos {
+	namespace geom {
+		class Geometry;
+		class Coordinate;
+	}
+}
+
+namespace geos {
+namespace operation { // geos::operation
+namespace overlay { // geos::operation::overlay
+namespace validate { // geos::operation::overlay::validate
+
+/** \brief
+ * Finds the most likely Location of a point relative to
+ * the polygonal components of a geometry, using a tolerance value.
+ *
+ * If a point is not clearly in the Interior or Exterior,
+ * it is considered to be on the Boundary.
+ * In other words, if the point is within the tolerance of the Boundary,
+ * it is considered to be on the Boundary; otherwise,
+ * whether it is Interior or Exterior is determined directly.
+ */
+class FuzzyPointLocator {
+
+public:
+
+	FuzzyPointLocator(const geom::Geometry& geom, double nTolerance);
+
+	geom::Location::Value getLocation(const geom::Coordinate& pt);
+
+private:
+
+	const geom::Geometry& g;
+
+	double tolerance;
+
+	algorithm::PointLocator ptLocator;
+
+	std::auto_ptr<geom::Geometry> linework;
+
+	// this function has been obsoleted
+	std::auto_ptr<geom::Geometry> getLineWork(const geom::Geometry& geom);
+
+	/// Extracts linework for polygonal components.
+	//
+	/// @param g the geometry from which to extract
+	/// @return a lineal geometry containing the extracted linework
+	std::auto_ptr<geom::Geometry> extractLineWork(const geom::Geometry& geom);
+
+
+};
+
+} // namespace geos::operation::overlay::validate
+} // namespace geos::operation::overlay
+} // namespace geos::operation
+} // namespace geos
+
+#endif // ndef GEOS_OP_OVERLAY_FUZZYPOINTLOCATOR_H
+
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+


Property changes on: trunk/source/headers/geos/operation/overlay/validate/FuzzyPointLocator.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Copied: trunk/source/headers/geos/operation/overlay/validate/OffsetPointGenerator.h (from rev 2455, trunk/source/headers/geos/operation/overlay/OffsetPointGenerator.h)
===================================================================
--- trunk/source/headers/geos/operation/overlay/validate/OffsetPointGenerator.h	                        (rev 0)
+++ trunk/source/headers/geos/operation/overlay/validate/OffsetPointGenerator.h	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,81 @@
+/**********************************************************************
+ * $Id$
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation. 
+ * See the COPYING file for more information.
+ *
+ ***********************************************************************
+ *
+ * Last port: operation/overlay/validate/OffsetPointGenerator.java rev. 1.1
+ *
+ **********************************************************************/
+
+#ifndef GEOS_OP_OVERLAY_OFFSETPOINTGENERATOR_H
+#define GEOS_OP_OVERLAY_OFFSETPOINTGENERATOR_H
+
+#include <geos/algorithm/PointLocator.h> // for composition
+#include <geos/geom/Geometry.h> // for auto_ptr visibility of dtor
+#include <geos/geom/MultiPoint.h> // for auto_ptr visibility of dtor
+#include <geos/geom/Coordinate.h> // for use in vector
+
+#include <vector>
+#include <memory> // for auto_ptr
+
+// Forward declarations
+namespace geos {
+	namespace geom {
+		//class Geometry;
+		//class MultiPoint;
+		class LineString;
+		//class Coordinate;
+	}
+}
+
+namespace geos {
+namespace operation { // geos::operation
+namespace overlay { // geos::operation::overlay
+namespace validate { // geos::operation::overlay::validate
+
+/// Generates points offset from both sides of all segments in a geometry
+//
+class OffsetPointGenerator {
+
+public:
+
+	OffsetPointGenerator(const geom::Geometry& geom, double offset);
+
+	/// Gets the computed offset points.
+	std::auto_ptr< std::vector<geom::Coordinate> > getPoints();
+
+private:
+
+	const geom::Geometry& g;
+
+	double offsetDistance;
+
+	std::auto_ptr< std::vector<geom::Coordinate> > offsetPts;
+
+	void extractPoints(const geom::LineString* line);
+
+	void computeOffsets(const geom::Coordinate& p0,
+			const geom::Coordinate& p1);
+};
+
+} // namespace geos::operation::overlay::validate
+} // namespace geos::operation::overlay
+} // namespace geos::operation
+} // namespace geos
+
+#endif // ndef GEOS_OP_OVERLAY_OFFSETPOINTGENERATOR_H
+
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+


Property changes on: trunk/source/headers/geos/operation/overlay/validate/OffsetPointGenerator.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Copied: trunk/source/headers/geos/operation/overlay/validate/OverlayResultValidator.h (from rev 2455, trunk/source/headers/geos/operation/overlay/OverlayResultValidator.h)
===================================================================
--- trunk/source/headers/geos/operation/overlay/validate/OverlayResultValidator.h	                        (rev 0)
+++ trunk/source/headers/geos/operation/overlay/validate/OverlayResultValidator.h	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,118 @@
+/**********************************************************************
+ * $Id$
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation. 
+ * See the COPYING file for more information.
+ *
+ ***********************************************************************
+ *
+ * Last port: operation/overlay/validate/OverlayResultValidator.java rev. 1.1
+ *
+ **********************************************************************/
+
+#ifndef GEOS_OP_OVERLAY_OVERLAYRESULTVALIDATOR_H
+#define GEOS_OP_OVERLAY_OVERLAYRESULTVALIDATOR_H
+
+#include <geos/operation/overlay/OverlayOp.h> // for OpCode enum
+#include <geos/operation/overlay/validate/FuzzyPointLocator.h> // composition
+#include <geos/geom/Location.h> // for Location::Value type
+
+#include <vector>
+
+// Forward declarations
+namespace geos {
+	namespace geom {
+		class Geometry;
+		class Coordinate;
+	}
+}
+
+namespace geos {
+namespace operation { // geos::operation
+namespace overlay { // geos::operation::overlay
+namespace validate { // geos::operation::overlay::validate
+
+/** \brief
+ * Validates that the result of an overlay operation is
+ * geometrically correct within a given tolerance.
+ *
+ * Uses fuzzy point location, which only works with polygonal
+ * components of geometries.
+ *
+ * This is a heuristic test, and may return incorrect results.
+ * It should never return a false negative result, however
+ * (I.e. reporting a valid result as invalid.)
+ * 
+ * @see OverlayOp
+ */
+class OverlayResultValidator {
+
+public:
+
+	static bool isValid(
+			const geom::Geometry& geom0,
+			const geom::Geometry& geom1,
+			OverlayOp::OpCode opCode,
+			const geom::Geometry& result);
+
+	OverlayResultValidator(
+			const geom::Geometry& geom0,
+			const geom::Geometry& geom1,
+			const geom::Geometry& result);
+
+	bool isValid(OverlayOp::OpCode opCode);
+
+	geom::Coordinate& getInvalidLocation() {
+		return invalidLocation;
+	}
+
+private:
+
+	const geom::Geometry& g0;
+
+	const geom::Geometry& g1;
+
+	const geom::Geometry& gres;
+
+	FuzzyPointLocator fpl0;
+
+	FuzzyPointLocator fpl1;
+
+	FuzzyPointLocator fplres;
+
+	geom::Coordinate invalidLocation;
+
+	static double _TOLERANCE; // 0.000001
+	
+	std::vector<geom::Coordinate> testCoords;
+
+	void addTestPts(const geom::Geometry& g);
+
+	void addVertices(const geom::Geometry& g);
+
+	bool testValid(OverlayOp::OpCode overlayOp);
+
+	bool testValid(OverlayOp::OpCode overlayOp, const geom::Coordinate& pt);
+
+	bool isValidResult(OverlayOp::OpCode overlayOp,
+			std::vector<geom::Location::Value>& location);
+};
+
+} // namespace geos::operation::overlay::validate
+} // namespace geos::operation::overlay
+} // namespace geos::operation
+} // namespace geos
+
+#endif // ndef GEOS_OP_OVERLAY_OVERLAYRESULTVALIDATOR_H
+
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+


Property changes on: trunk/source/headers/geos/operation/overlay/validate/OverlayResultValidator.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Deleted: trunk/source/operation/overlay/FuzzyPointLocator.cpp
===================================================================
--- trunk/source/operation/overlay/FuzzyPointLocator.cpp	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/operation/overlay/FuzzyPointLocator.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,156 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.refractions.net
- *
- * Copyright (C) 2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
- * See the COPYING file for more information.
- *
- ***********************************************************************
- *
- * Last port: operation/overlay/validate/FuzzyPointLocator.java rev. 1.1
- * (we should move in GEOS too, probably)
- *
- **********************************************************************/
-
-#include <geos/operation/overlay/FuzzyPointLocator.h>
-#include <geos/geom/Geometry.h>
-#include <geos/geom/Point.h> // for Point upcast
-#include <geos/geom/GeometryFactory.h>
-#include <geos/geom/Location.h> // for Location::Value enum
-#include <geos/util.h>
-
-#include <cassert>
-#include <functional>
-#include <vector>
-#include <sstream>
-#include <memory> // for auto_ptr
-
-#ifndef GEOS_DEBUG
-#define GEOS_DEBUG 0
-#endif
-
-#define COMPUTE_Z 1
-#define USE_ELEVATION_MATRIX 1
-#define USE_INPUT_AVGZ 0
-
-using namespace std;
-using namespace geos::geom;
-using namespace geos::algorithm;
-
-namespace geos {
-namespace operation { // geos.operation
-namespace overlay { // geos.operation.overlay
-
-FuzzyPointLocator::FuzzyPointLocator(const geom::Geometry& geom,
-		double nTolerance)
-	:
-	g(geom),
-	tolerance(nTolerance),
-	ptLocator(),
-	linework(extractLineWork(g))
-{
-}
-
-/*private*/
-std::auto_ptr<Geometry>
-FuzzyPointLocator::extractLineWork(const geom::Geometry& geom)
-{
-    UNREFERENCED_PARAMETER(geom);
-
-	vector<Geometry*>* lineGeoms = new vector<Geometry*>();
-	try { // geoms array will leak if an exception is thrown
-
-	for (size_t i=0, n=g.getNumGeometries(); i<n; ++i)
-	{
-		const Geometry* gComp = g.getGeometryN(i);
-		Geometry* lineGeom = NULL;
-
-		// only get linework for polygonal components
-		if (gComp->getDimension() == 2) {
-			lineGeom = gComp->getBoundary();
-			lineGeoms->push_back(lineGeom);
-		}
-	}
-	return std::auto_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
-
-	} catch (...) { // avoid leaks
-		for (size_t i=0, n=lineGeoms->size(); i<n; ++i)
-		{
-			delete (*lineGeoms)[i];
-		}
-		delete lineGeoms;
-		throw;
-	}
- 
-}
-
-/*private*/
-std::auto_ptr<Geometry>
-FuzzyPointLocator::getLineWork(const geom::Geometry& geom)
-{
-    UNREFERENCED_PARAMETER(geom);
-
-	vector<Geometry*>* lineGeoms = new vector<Geometry*>();
-	try { // geoms array will leak if an exception is thrown
-
-	for (size_t i=0, n=g.getNumGeometries(); i<n; ++i)
-	{
-		const Geometry* gComp = g.getGeometryN(i);
-		Geometry* lineGeom;
-		if (gComp->getDimension() == 2) {
-			lineGeom = gComp->getBoundary();
-		}
-		else {
-			lineGeom = gComp->clone();
-		}
-		lineGeoms->push_back(lineGeom);
-	}
-	return std::auto_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
-
-	} catch (...) { // avoid leaks
-		for (size_t i=0, n=lineGeoms->size(); i<n; ++i)
-		{
-
-			delete (*lineGeoms)[i];
-		}
-		delete lineGeoms;
-		throw;
-	}
- 
-}
-
-/* public */
-Location::Value
-FuzzyPointLocator::getLocation(const Coordinate& pt)
-{
-	auto_ptr<Geometry> point(g.getFactory()->createPoint(pt));
-
-	double dist = linework->distance(point.get());
-
-	// if point is close to boundary, it is considered
-	// to be on the boundary
-	if (dist < tolerance)
-		return Location::BOUNDARY;
-
-	// now we know point must be clearly inside or outside geometry,
-	// so return actual location value
-
-	// (the static_cast is needed because PointLocator doesn't cleanly
-	// return a Location::Value - it should !!)
-	return static_cast<Location::Value>(ptLocator.locate(pt, &g));
-}
-
-} // namespace geos.operation.overlay
-} // namespace geos.operation
-} // namespace geos
-
-/**********************************************************************
- * $Log$
- **********************************************************************/
-

Modified: trunk/source/operation/overlay/Makefile.am
===================================================================
--- trunk/source/operation/overlay/Makefile.am	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/operation/overlay/Makefile.am	2009-05-04 21:28:26 UTC (rev 2462)
@@ -8,19 +8,19 @@
 	EdgeSetNoder.cpp \
 	ElevationMatrixCell.cpp \
 	ElevationMatrix.cpp \
-	FuzzyPointLocator.cpp \
 	LineBuilder.cpp \
 	MaximalEdgeRing.cpp \
 	MinimalEdgeRing.cpp \
-	OffsetPointGenerator.cpp \
 	OverlayNodeFactory.cpp \
 	OverlayOp.cpp \
-	OverlayResultValidator.cpp \
 	PointBuilder.cpp \
 	PolygonBuilder.cpp \
 	snap/GeometrySnapper.cpp \
 	snap/LineStringSnapper.cpp \
-	snap/SnapOverlayOp.cpp
+	snap/SnapOverlayOp.cpp \
+	validate/FuzzyPointLocator.cpp \
+	validate/OffsetPointGenerator.cpp \
+	validate/OverlayResultValidator.cpp 
 
 libopoverlay_la_LIBADD = 
 

Deleted: trunk/source/operation/overlay/OffsetPointGenerator.cpp
===================================================================
--- trunk/source/operation/overlay/OffsetPointGenerator.cpp	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/operation/overlay/OffsetPointGenerator.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,112 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.refractions.net
- *
- * Copyright (C) 2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
- * See the COPYING file for more information.
- *
- ***********************************************************************
- *
- * Last port: operation/overlay/validate/OffsetPointGenerator.java rev. 1.1
- * (we should move in GEOS too, probably)
- *
- **********************************************************************/
-
-#include <geos/operation/overlay/OffsetPointGenerator.h>
-#include <geos/geom/Geometry.h>
-#include <geos/geom/LineString.h> 
-#include <geos/geom/MultiPoint.h> 
-#include <geos/geom/CoordinateSequence.h> 
-#include <geos/geom/GeometryFactory.h>
-#include <geos/geom/util/LinearComponentExtracter.h> 
-
-#include <cassert>
-#include <functional>
-#include <vector>
-#include <memory> // for auto_ptr
-#include <cmath>
-#include <algorithm> // std::for_each
-
-#ifndef GEOS_DEBUG
-#define GEOS_DEBUG 0
-#endif
-
-using namespace std;
-using namespace geos::geom;
-using namespace geos::algorithm;
-
-namespace geos {
-namespace operation { // geos.operation
-namespace overlay { // geos.operation.overlay
-
-/*public*/
-OffsetPointGenerator::OffsetPointGenerator(const geom::Geometry& geom,
-		double offset)
-	:
-	g(geom),
-	offsetDistance(offset)
-{
-}
-
-/*public*/
-std::auto_ptr< std::vector<geom::Coordinate> >
-OffsetPointGenerator::getPoints()
-{
-	assert (offsetPts.get() == NULL);
-	offsetPts.reset(new vector<Coordinate>());
-
-	vector<const LineString*> lines;
-	geos::geom::util::LinearComponentExtracter::getLines(g, lines);
-	for_each(lines.begin(), lines.end(),
-		bind1st(mem_fun(&OffsetPointGenerator::extractPoints), this));
-
-	return offsetPts;
-}
-
-/*private*/
-void
-OffsetPointGenerator::extractPoints(const LineString* line)
-{
-	const CoordinateSequence& pts = *(line->getCoordinatesRO());
-	assert(pts.size() > 1 );
-
-	for (size_t i=0, n=pts.size()-1; i<n; ++i)
-	{
-		computeOffsets(pts[i], pts[i + 1]);
-	}
-}
-
-/*private*/
-void
-OffsetPointGenerator::computeOffsets(const Coordinate& p0,
-		const Coordinate& p1)
-{
-	double dx = p1.x - p0.x;
-	double dy = p1.y - p0.y;
-	double len = sqrt(dx * dx + dy * dy);
-
-	// u is the vector that is the length of the offset,
-	// in the direction of the segment
-	double ux = offsetDistance * dx / len;
-	double uy = offsetDistance * dy / len;
-
-	double midX = (p1.x + p0.x) / 2;
-	double midY = (p1.y + p0.y) / 2;
-
-	Coordinate offsetLeft(midX - uy, midY + ux);
-	Coordinate offsetRight(midX + uy, midY - ux);
-
-	offsetPts->push_back(offsetLeft);
-	offsetPts->push_back(offsetRight);
-}
-
-} // namespace geos.operation.overlay
-} // namespace geos.operation
-} // namespace geos
-

Modified: trunk/source/operation/overlay/OverlayOp.cpp
===================================================================
--- trunk/source/operation/overlay/OverlayOp.cpp	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/operation/overlay/OverlayOp.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -19,7 +19,7 @@
  **********************************************************************/
 
 #include <geos/operation/overlay/OverlayOp.h>
-#include <geos/operation/overlay/OverlayResultValidator.h>
+#include <geos/operation/overlay/validate/OverlayResultValidator.h>
 #include <geos/operation/overlay/ElevationMatrix.h>
 #include <geos/operation/overlay/OverlayNodeFactory.h>
 #include <geos/operation/overlay/PolygonBuilder.h>
@@ -962,7 +962,7 @@
 	// This only work for FLOATING precision
 	if ( resultPrecisionModel->isFloating() )
 	{
-		OverlayResultValidator validator( *(arg[0]->getGeometry()),
+		validate::OverlayResultValidator validator( *(arg[0]->getGeometry()),
 			*(arg[1]->getGeometry()), *(resultGeom));
 		bool isvalid = validator.isValid(opCode);
 		if ( ! isvalid )

Deleted: trunk/source/operation/overlay/OverlayResultValidator.cpp
===================================================================
--- trunk/source/operation/overlay/OverlayResultValidator.cpp	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/source/operation/overlay/OverlayResultValidator.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,242 +0,0 @@
-/**********************************************************************
- * $Id$
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.refractions.net
- *
- * Copyright (C) 2006 Refractions Research Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation. 
- * See the COPYING file for more information.
- *
- ***********************************************************************
- *
- * Last port: operation/overlay/validate/OverlayResultValidator.java rev. 1.1
- * (we should move in GEOS too, probably)
- *
- **********************************************************************/
-
-#include <geos/operation/overlay/OverlayResultValidator.h>
-#include <geos/operation/overlay/FuzzyPointLocator.h>
-#include <geos/operation/overlay/OffsetPointGenerator.h>
-#include <geos/geom/CoordinateSequence.h>
-#include <geos/geom/MultiPoint.h>
-#include <geos/geom/GeometryFactory.h>
-#include <geos/geom/CoordinateSequenceFactory.h>
-
-#include <cassert>
-#include <functional>
-#include <vector>
-#include <memory> // for auto_ptr
-#include <algorithm>
-
-#ifndef GEOS_DEBUG
-#define GEOS_DEBUG 0
-#endif
-
-#if GEOS_DEBUG
-#include <iomanip> // for setprecision
-#endif
-
-#define COMPUTE_Z 1
-#define USE_ELEVATION_MATRIX 1
-#define USE_INPUT_AVGZ 0
-
-using namespace std;
-using namespace geos::geom;
-using namespace geos::geomgraph;
-using namespace geos::algorithm;
-
-namespace geos {
-namespace operation { // geos.operation
-namespace overlay { // geos.operation.overlay
-
-double OverlayResultValidator::_TOLERANCE = 0.000001;
-
-namespace { // anonymous namespace
-
-bool
-isArea(const Geometry& g)
-{
-        GeometryTypeId type = g.getGeometryTypeId();
-        if ( type == GEOS_POLYGON ) return true;
-        if ( type == GEOS_MULTIPOLYGON ) return true;
-#if GEOS_DEBUG
-	cerr << "OverlayResultValidator: one of the geoms being checked is not a POLYGON or MULTIPOLYGON, blindly returning a positive answer (is valid)" << endl;
-#endif
-        return false;
-}
-
-auto_ptr<MultiPoint>
-toMultiPoint(vector<Coordinate>& coords)
-{
-	const GeometryFactory& gf = *(GeometryFactory::getDefaultInstance());
-	const CoordinateSequenceFactory& csf = 
-			*(gf.getCoordinateSequenceFactory());
-
-	auto_ptr< vector<Coordinate> > nc ( new vector<Coordinate>(coords) );
-	auto_ptr<CoordinateSequence> cs(csf.create(nc.release()));
-
-	auto_ptr<MultiPoint> mp ( gf.createMultiPoint(*cs) );
-
-	return mp;
-}
-
-} // anonymous namespace
-
-
-/* static public */
-bool
-OverlayResultValidator::isValid(const Geometry& geom0, const Geometry& geom1,
-		OverlayOp::OpCode opCode,
-		const Geometry& result)
-{
-	OverlayResultValidator validator(geom0, geom1, result);
-	return validator.isValid(opCode);
-}
-
-/*public*/
-OverlayResultValidator::OverlayResultValidator(
-		const Geometry& geom0,
-		const Geometry& geom1,
-		const Geometry& result)
-	:
-	g0(geom0),
-	g1(geom1),
-	gres(result),
-	fpl0(g0, _TOLERANCE),
-	fpl1(g1, _TOLERANCE),
-	fplres(gres, _TOLERANCE),
-	invalidLocation()
-{
-}
-
-/*public*/
-bool
-OverlayResultValidator::isValid(OverlayOp::OpCode overlayOp)
-{
-	// The check only works for areal geoms
-#if 0 // now that FuzzyPointLocator extracts polygonal geoms,
-      // there should be no problem here
-	if ( ! isArea(g0) ) return true;
-	if ( ! isArea(g1) ) return true;
-	if ( ! isArea(gres) ) return true;
-#endif
-
-	addTestPts(g0);
-	addTestPts(g1);
-	addTestPts(gres);
-
-	if (! testValid(overlayOp) )
-	{
-#if GEOS_DEBUG
-	cerr << "OverlayResultValidator:" << endl
-		<< "Points:" << *toMultiPoint(testCoords) << endl
-		<< "Geom0: " << g0 << endl
-		<< "Geom1: " << g1 << endl
-		<< "Reslt: " << gres << endl
-		<< "Locat: " << getInvalidLocation()
-		<< endl;
-#endif
-		return false;
-	}
-
-
-	return true;
-}
-
-/*private*/
-void
-OverlayResultValidator::addTestPts(const Geometry& g)
-{
-	OffsetPointGenerator ptGen(g, 5 * _TOLERANCE);
-	auto_ptr< vector<geom::Coordinate> > pts = ptGen.getPoints();
-	testCoords.insert(testCoords.end(), pts->begin(), pts->end());
-}
-
-/*private*/
-void
-OverlayResultValidator::addVertices(const Geometry& g)
-{
-	// TODO: optimize this by not copying coordinates
-	//       and pre-allocating memory
-	auto_ptr<CoordinateSequence> cs ( g.getCoordinates() );
-	const vector<Coordinate>* coords = cs->toVector();
-	testCoords.insert(testCoords.end(), coords->begin(), coords->end());
-}
-
-/*private*/
-bool
-OverlayResultValidator::testValid(OverlayOp::OpCode overlayOp)
-{
-	for (size_t i=0, n=testCoords.size(); i<n; ++i)
-	{
-		Coordinate& pt = testCoords[i];
-		if (! testValid(overlayOp, pt)) {
-			invalidLocation = pt;
-			return false;
-		}
-	}
-	return true;
-}
-
-/*private*/
-bool
-OverlayResultValidator::testValid(OverlayOp::OpCode overlayOp,
-		const Coordinate& pt)
-{
-	std::vector<geom::Location::Value> location(3);
-
-	location[0] = fpl0.getLocation(pt);
-	location[1] = fpl1.getLocation(pt);
-	location[2] = fplres.getLocation(pt);
-
-#if GEOS_DEBUG
-	cerr << setprecision(10) << "Point " << pt << endl
-		<< "Loc0: " << location[0] << endl
-		<< "Loc1: " << location[1] << endl
-		<< "Locr: " << location[2] << endl;
-#endif
-
-	/*
-	 * If any location is on the Boundary, can't deduce anything,
-	 * so just return true
-	 */
-	if ( find(location.begin(), location.end(), Location::BOUNDARY) != location.end() )
-	{
-#if GEOS_DEBUG
-		cerr << "OverlayResultValidator: testpoint " << pt << " is on the boundary, blindly returning a positive answer (is valid)" << endl;
-#endif
-		return true;
-	}
-
-	return isValidResult(overlayOp, location);
-}
-
-/* private */
-bool
-OverlayResultValidator::isValidResult(OverlayOp::OpCode overlayOp,
-	std::vector<geom::Location::Value>& location)
-{
-	bool expectedInterior = OverlayOp::isResultOfOp(location[0],
-			location[1], overlayOp);
-
-	bool resultInInterior = (location[2] == Location::INTERIOR);
-
-	bool isValid = ! (expectedInterior ^ resultInInterior);
-
-	return isValid;
-}
-
-
-
-} // namespace geos.operation.overlay
-} // namespace geos.operation
-} // namespace geos
-
-/**********************************************************************
- * $Log$
- **********************************************************************/
-

Copied: trunk/source/operation/overlay/validate/FuzzyPointLocator.cpp (from rev 2455, trunk/source/operation/overlay/FuzzyPointLocator.cpp)
===================================================================
--- trunk/source/operation/overlay/validate/FuzzyPointLocator.cpp	                        (rev 0)
+++ trunk/source/operation/overlay/validate/FuzzyPointLocator.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,157 @@
+/**********************************************************************
+ * $Id$
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation. 
+ * See the COPYING file for more information.
+ *
+ ***********************************************************************
+ *
+ * Last port: operation/overlay/validate/FuzzyPointLocator.java rev. 1.1
+ *
+ **********************************************************************/
+
+#include <geos/operation/overlay/validate/FuzzyPointLocator.h>
+#include <geos/geom/Geometry.h>
+#include <geos/geom/Point.h> // for Point upcast
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Location.h> // for Location::Value enum
+#include <geos/util.h>
+
+#include <cassert>
+#include <functional>
+#include <vector>
+#include <sstream>
+#include <memory> // for auto_ptr
+
+#ifndef GEOS_DEBUG
+#define GEOS_DEBUG 0
+#endif
+
+#define COMPUTE_Z 1
+#define USE_ELEVATION_MATRIX 1
+#define USE_INPUT_AVGZ 0
+
+using namespace std;
+using namespace geos::geom;
+using namespace geos::algorithm;
+
+namespace geos {
+namespace operation { // geos.operation
+namespace overlay { // geos.operation.overlay
+namespace validate { // geos.operation.overlay.validate
+
+FuzzyPointLocator::FuzzyPointLocator(const geom::Geometry& geom,
+		double nTolerance)
+	:
+	g(geom),
+	tolerance(nTolerance),
+	ptLocator(),
+	linework(extractLineWork(g))
+{
+}
+
+/*private*/
+std::auto_ptr<Geometry>
+FuzzyPointLocator::extractLineWork(const geom::Geometry& geom)
+{
+    UNREFERENCED_PARAMETER(geom);
+
+	vector<Geometry*>* lineGeoms = new vector<Geometry*>();
+	try { // geoms array will leak if an exception is thrown
+
+	for (size_t i=0, n=g.getNumGeometries(); i<n; ++i)
+	{
+		const Geometry* gComp = g.getGeometryN(i);
+		Geometry* lineGeom = NULL;
+
+		// only get linework for polygonal components
+		if (gComp->getDimension() == 2) {
+			lineGeom = gComp->getBoundary();
+			lineGeoms->push_back(lineGeom);
+		}
+	}
+	return std::auto_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
+
+	} catch (...) { // avoid leaks
+		for (size_t i=0, n=lineGeoms->size(); i<n; ++i)
+		{
+			delete (*lineGeoms)[i];
+		}
+		delete lineGeoms;
+		throw;
+	}
+ 
+}
+
+/*private*/
+std::auto_ptr<Geometry>
+FuzzyPointLocator::getLineWork(const geom::Geometry& geom)
+{
+    UNREFERENCED_PARAMETER(geom);
+
+	vector<Geometry*>* lineGeoms = new vector<Geometry*>();
+	try { // geoms array will leak if an exception is thrown
+
+	for (size_t i=0, n=g.getNumGeometries(); i<n; ++i)
+	{
+		const Geometry* gComp = g.getGeometryN(i);
+		Geometry* lineGeom;
+		if (gComp->getDimension() == 2) {
+			lineGeom = gComp->getBoundary();
+		}
+		else {
+			lineGeom = gComp->clone();
+		}
+		lineGeoms->push_back(lineGeom);
+	}
+	return std::auto_ptr<Geometry>(g.getFactory()->buildGeometry(lineGeoms));
+
+	} catch (...) { // avoid leaks
+		for (size_t i=0, n=lineGeoms->size(); i<n; ++i)
+		{
+
+			delete (*lineGeoms)[i];
+		}
+		delete lineGeoms;
+		throw;
+	}
+ 
+}
+
+/* public */
+Location::Value
+FuzzyPointLocator::getLocation(const Coordinate& pt)
+{
+	auto_ptr<Geometry> point(g.getFactory()->createPoint(pt));
+
+	double dist = linework->distance(point.get());
+
+	// if point is close to boundary, it is considered
+	// to be on the boundary
+	if (dist < tolerance)
+		return Location::BOUNDARY;
+
+	// now we know point must be clearly inside or outside geometry,
+	// so return actual location value
+
+	// (the static_cast is needed because PointLocator doesn't cleanly
+	// return a Location::Value - it should !!)
+	return static_cast<Location::Value>(ptLocator.locate(pt, &g));
+}
+
+} // namespace geos.operation.overlay.validate
+} // namespace geos.operation.overlay
+} // namespace geos.operation
+} // namespace geos
+
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+


Property changes on: trunk/source/operation/overlay/validate/FuzzyPointLocator.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Copied: trunk/source/operation/overlay/validate/OffsetPointGenerator.cpp (from rev 2455, trunk/source/operation/overlay/OffsetPointGenerator.cpp)
===================================================================
--- trunk/source/operation/overlay/validate/OffsetPointGenerator.cpp	                        (rev 0)
+++ trunk/source/operation/overlay/validate/OffsetPointGenerator.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,113 @@
+/**********************************************************************
+ * $Id$
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation. 
+ * See the COPYING file for more information.
+ *
+ ***********************************************************************
+ *
+ * Last port: operation/overlay/validate/OffsetPointGenerator.java rev. 1.1
+ *
+ **********************************************************************/
+
+#include <geos/operation/overlay/validate/OffsetPointGenerator.h>
+#include <geos/geom/Geometry.h>
+#include <geos/geom/LineString.h> 
+#include <geos/geom/MultiPoint.h> 
+#include <geos/geom/CoordinateSequence.h> 
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/util/LinearComponentExtracter.h> 
+
+#include <cassert>
+#include <functional>
+#include <vector>
+#include <memory> // for auto_ptr
+#include <cmath>
+#include <algorithm> // std::for_each
+
+#ifndef GEOS_DEBUG
+#define GEOS_DEBUG 0
+#endif
+
+using namespace std;
+using namespace geos::geom;
+using namespace geos::algorithm;
+
+namespace geos {
+namespace operation { // geos.operation
+namespace overlay { // geos.operation.overlay
+namespace validate { // geos.operation.overlay.validate
+
+/*public*/
+OffsetPointGenerator::OffsetPointGenerator(const geom::Geometry& geom,
+		double offset)
+	:
+	g(geom),
+	offsetDistance(offset)
+{
+}
+
+/*public*/
+std::auto_ptr< std::vector<geom::Coordinate> >
+OffsetPointGenerator::getPoints()
+{
+	assert (offsetPts.get() == NULL);
+	offsetPts.reset(new vector<Coordinate>());
+
+	vector<const LineString*> lines;
+	geos::geom::util::LinearComponentExtracter::getLines(g, lines);
+	for_each(lines.begin(), lines.end(),
+		bind1st(mem_fun(&OffsetPointGenerator::extractPoints), this));
+
+	return offsetPts;
+}
+
+/*private*/
+void
+OffsetPointGenerator::extractPoints(const LineString* line)
+{
+	const CoordinateSequence& pts = *(line->getCoordinatesRO());
+	assert(pts.size() > 1 );
+
+	for (size_t i=0, n=pts.size()-1; i<n; ++i)
+	{
+		computeOffsets(pts[i], pts[i + 1]);
+	}
+}
+
+/*private*/
+void
+OffsetPointGenerator::computeOffsets(const Coordinate& p0,
+		const Coordinate& p1)
+{
+	double dx = p1.x - p0.x;
+	double dy = p1.y - p0.y;
+	double len = sqrt(dx * dx + dy * dy);
+
+	// u is the vector that is the length of the offset,
+	// in the direction of the segment
+	double ux = offsetDistance * dx / len;
+	double uy = offsetDistance * dy / len;
+
+	double midX = (p1.x + p0.x) / 2;
+	double midY = (p1.y + p0.y) / 2;
+
+	Coordinate offsetLeft(midX - uy, midY + ux);
+	Coordinate offsetRight(midX + uy, midY - ux);
+
+	offsetPts->push_back(offsetLeft);
+	offsetPts->push_back(offsetRight);
+}
+
+} // namespace geos.operation.overlay.validate
+} // namespace geos.operation.overlay
+} // namespace geos.operation
+} // namespace geos
+


Property changes on: trunk/source/operation/overlay/validate/OffsetPointGenerator.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Copied: trunk/source/operation/overlay/validate/OverlayResultValidator.cpp (from rev 2455, trunk/source/operation/overlay/OverlayResultValidator.cpp)
===================================================================
--- trunk/source/operation/overlay/validate/OverlayResultValidator.cpp	                        (rev 0)
+++ trunk/source/operation/overlay/validate/OverlayResultValidator.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,242 @@
+/**********************************************************************
+ * $Id$
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation. 
+ * See the COPYING file for more information.
+ *
+ ***********************************************************************
+ *
+ * Last port: operation/overlay/validate/OverlayResultValidator.java rev. 1.1
+ *
+ **********************************************************************/
+
+#include <geos/operation/overlay/validate/OverlayResultValidator.h>
+#include <geos/operation/overlay/validate/FuzzyPointLocator.h>
+#include <geos/operation/overlay/validate/OffsetPointGenerator.h>
+#include <geos/geom/CoordinateSequence.h>
+#include <geos/geom/MultiPoint.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/CoordinateSequenceFactory.h>
+
+#include <cassert>
+#include <functional>
+#include <vector>
+#include <memory> // for auto_ptr
+#include <algorithm>
+
+#ifndef GEOS_DEBUG
+#define GEOS_DEBUG 0
+#endif
+
+#if GEOS_DEBUG
+#include <iomanip> // for setprecision
+#endif
+
+#define COMPUTE_Z 1
+#define USE_ELEVATION_MATRIX 1
+#define USE_INPUT_AVGZ 0
+
+using namespace std;
+using namespace geos::geom;
+using namespace geos::geomgraph;
+using namespace geos::algorithm;
+
+namespace geos {
+namespace operation { // geos.operation
+namespace overlay { // geos.operation.overlay
+namespace validate { // geos.operation.overlay.validate
+
+double OverlayResultValidator::_TOLERANCE = 0.000001;
+
+namespace { // anonymous namespace
+
+bool
+isArea(const Geometry& g)
+{
+        GeometryTypeId type = g.getGeometryTypeId();
+        if ( type == GEOS_POLYGON ) return true;
+        if ( type == GEOS_MULTIPOLYGON ) return true;
+#if GEOS_DEBUG
+	cerr << "OverlayResultValidator: one of the geoms being checked is not a POLYGON or MULTIPOLYGON, blindly returning a positive answer (is valid)" << endl;
+#endif
+        return false;
+}
+
+auto_ptr<MultiPoint>
+toMultiPoint(vector<Coordinate>& coords)
+{
+	const GeometryFactory& gf = *(GeometryFactory::getDefaultInstance());
+	const CoordinateSequenceFactory& csf = 
+			*(gf.getCoordinateSequenceFactory());
+
+	auto_ptr< vector<Coordinate> > nc ( new vector<Coordinate>(coords) );
+	auto_ptr<CoordinateSequence> cs(csf.create(nc.release()));
+
+	auto_ptr<MultiPoint> mp ( gf.createMultiPoint(*cs) );
+
+	return mp;
+}
+
+} // anonymous namespace
+
+
+/* static public */
+bool
+OverlayResultValidator::isValid(const Geometry& geom0, const Geometry& geom1,
+		OverlayOp::OpCode opCode,
+		const Geometry& result)
+{
+	OverlayResultValidator validator(geom0, geom1, result);
+	return validator.isValid(opCode);
+}
+
+/*public*/
+OverlayResultValidator::OverlayResultValidator(
+		const Geometry& geom0,
+		const Geometry& geom1,
+		const Geometry& result)
+	:
+	g0(geom0),
+	g1(geom1),
+	gres(result),
+	fpl0(g0, _TOLERANCE),
+	fpl1(g1, _TOLERANCE),
+	fplres(gres, _TOLERANCE),
+	invalidLocation()
+{
+}
+
+/*public*/
+bool
+OverlayResultValidator::isValid(OverlayOp::OpCode overlayOp)
+{
+	// The check only works for areal geoms
+#if 0 // now that FuzzyPointLocator extracts polygonal geoms,
+      // there should be no problem here
+	if ( ! isArea(g0) ) return true;
+	if ( ! isArea(g1) ) return true;
+	if ( ! isArea(gres) ) return true;
+#endif
+
+	addTestPts(g0);
+	addTestPts(g1);
+	addTestPts(gres);
+
+	if (! testValid(overlayOp) )
+	{
+#if GEOS_DEBUG
+	cerr << "OverlayResultValidator:" << endl
+		<< "Points:" << *toMultiPoint(testCoords) << endl
+		<< "Geom0: " << g0 << endl
+		<< "Geom1: " << g1 << endl
+		<< "Reslt: " << gres << endl
+		<< "Locat: " << getInvalidLocation()
+		<< endl;
+#endif
+		return false;
+	}
+
+
+	return true;
+}
+
+/*private*/
+void
+OverlayResultValidator::addTestPts(const Geometry& g)
+{
+	OffsetPointGenerator ptGen(g, 5 * _TOLERANCE);
+	auto_ptr< vector<geom::Coordinate> > pts = ptGen.getPoints();
+	testCoords.insert(testCoords.end(), pts->begin(), pts->end());
+}
+
+/*private*/
+void
+OverlayResultValidator::addVertices(const Geometry& g)
+{
+	// TODO: optimize this by not copying coordinates
+	//       and pre-allocating memory
+	auto_ptr<CoordinateSequence> cs ( g.getCoordinates() );
+	const vector<Coordinate>* coords = cs->toVector();
+	testCoords.insert(testCoords.end(), coords->begin(), coords->end());
+}
+
+/*private*/
+bool
+OverlayResultValidator::testValid(OverlayOp::OpCode overlayOp)
+{
+	for (size_t i=0, n=testCoords.size(); i<n; ++i)
+	{
+		Coordinate& pt = testCoords[i];
+		if (! testValid(overlayOp, pt)) {
+			invalidLocation = pt;
+			return false;
+		}
+	}
+	return true;
+}
+
+/*private*/
+bool
+OverlayResultValidator::testValid(OverlayOp::OpCode overlayOp,
+		const Coordinate& pt)
+{
+	std::vector<geom::Location::Value> location(3);
+
+	location[0] = fpl0.getLocation(pt);
+	location[1] = fpl1.getLocation(pt);
+	location[2] = fplres.getLocation(pt);
+
+#if GEOS_DEBUG
+	cerr << setprecision(10) << "Point " << pt << endl
+		<< "Loc0: " << location[0] << endl
+		<< "Loc1: " << location[1] << endl
+		<< "Locr: " << location[2] << endl;
+#endif
+
+	/*
+	 * If any location is on the Boundary, can't deduce anything,
+	 * so just return true
+	 */
+	if ( find(location.begin(), location.end(), Location::BOUNDARY) != location.end() )
+	{
+#if GEOS_DEBUG
+		cerr << "OverlayResultValidator: testpoint " << pt << " is on the boundary, blindly returning a positive answer (is valid)" << endl;
+#endif
+		return true;
+	}
+
+	return isValidResult(overlayOp, location);
+}
+
+/* private */
+bool
+OverlayResultValidator::isValidResult(OverlayOp::OpCode overlayOp,
+	std::vector<geom::Location::Value>& location)
+{
+	bool expectedInterior = OverlayOp::isResultOfOp(location[0],
+			location[1], overlayOp);
+
+	bool resultInInterior = (location[2] == Location::INTERIOR);
+
+	bool isValid = ! (expectedInterior ^ resultInInterior);
+
+	return isValid;
+}
+
+
+} // namespace geos.operation.overlay.validate
+} // namespace geos.operation.overlay
+} // namespace geos.operation
+} // namespace geos
+
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+


Property changes on: trunk/source/operation/overlay/validate/OverlayResultValidator.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Modified: trunk/tests/unit/Makefile.am
===================================================================
--- trunk/tests/unit/Makefile.am	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/tests/unit/Makefile.am	2009-05-04 21:28:26 UTC (rev 2462)
@@ -67,9 +67,9 @@
 	noding/SegmentPointComparatorTest.cpp \
 	operation/distance/DistanceOpTest.cpp \
 	operation/IsSimpleOpTest.cpp \
-	operation/overlay/FuzzyPointLocatorTest.cpp \
-	operation/overlay/OffsetPointGeneratorTest.cpp \
-	operation/overlay/OverlayResultValidatorTest.cpp \
+	operation/overlay/validate/FuzzyPointLocatorTest.cpp \
+	operation/overlay/validate/OffsetPointGeneratorTest.cpp \
+	operation/overlay/validate/OverlayResultValidatorTest.cpp \
 	operation/union/CascadedPolygonUnionTest.cpp \
 	operation/valid/IsValidTest.cpp \
 	operation/valid/ValidClosedRingTest.cpp \

Deleted: trunk/tests/unit/operation/overlay/FuzzyPointLocatorTest.cpp
===================================================================
--- trunk/tests/unit/operation/overlay/FuzzyPointLocatorTest.cpp	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/tests/unit/operation/overlay/FuzzyPointLocatorTest.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,199 +0,0 @@
-// $Id$
-// 
-// Test Suite for geos::operation::overlay::FuzzyPointLocator class.
-
-
-// tut
-#include <tut.hpp>
-// geos
-#include <geos/operation/overlay/FuzzyPointLocator.h>
-#include <geos/geom/GeometryFactory.h>
-#include <geos/geom/Geometry.h>
-#include <geos/io/WKTReader.h>
-#include <geos/io/WKBReader.h>
-#include <geos/geom/Coordinate.h>
-#include <geos/geom/Location.h>
-// std
-#include <memory>
-#include <sstream>
-
-namespace tut
-{
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_fuzzypointlocator_data
-	{
-		geos::geom::GeometryFactory gf;
-		geos::io::WKTReader wktreader;
-		geos::io::WKBReader wkbreader;
-
-		typedef geos::geom::Geometry::AutoPtr GeomPtr;
-
-		GeomPtr g;
-
-		test_fuzzypointlocator_data()
-			:
-			gf(),
-			wktreader(&gf),
-			wkbreader(gf)
-		{
-			std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-			g.reset(wktreader.read(wkt));
-		}
-	};
-	
-
-	typedef test_group<test_fuzzypointlocator_data> group;
-	typedef group::object object;
-
-	group test_fuzzypointlocator_group("geos::operation::overlay::FuzzyPointLocator");
-
-	//
-	// Test Cases
-	//
-
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::operation::overlay::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 10);
-
-		ensure_equals(locator.getLocation(Coordinate(10, 0)),
-			Location::BOUNDARY); 
-
-		// 8 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(18, 5)),
-			Location::BOUNDARY); 
-	}
-
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::operation::overlay::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 10);
-
-		//
-		// These are corner cases. I think they should
-		// return Location::BOUNDARY, but need to discuss
-		// this with Martin Davis
-		//
-
-		// 10 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(20, 2)),
-			Location::EXTERIOR); 
-
-		// 10 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(-10, 5)),
-			Location::EXTERIOR); 
-	}
-
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::operation::overlay::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 8);
-
-		// 5 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(5, 5)),
-			Location::BOUNDARY); 
-
-		// 2 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(2, 8)),
-			Location::BOUNDARY); 
-	}
-
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		using geos::operation::overlay::FuzzyPointLocator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-
-		FuzzyPointLocator locator(*g, 2);
-
-		// 5 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(5, 5)),
-			Location::INTERIOR); 
-
-		// 3 units away from boundary
-		ensure_equals(locator.getLocation(Coordinate(3, 7)),
-			Location::INTERIOR); 
-	}
-
-
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		using geos::operation::overlay::FuzzyPointLocator;
-		using geos::geom::Location;
-		geos::geom::Coordinate pt(160.000000125, 119.500004998);
-
-		std::string wkt0("POLYGON((20 40,20 200,180 200,180 120,140 120,180 119,180 40,20 40),(140 160,80 120,140 80,140 160))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		FuzzyPointLocator locator(*g0, 0.00001);
-
-		// On the boundary ?
-		ensure_equals(locator.getLocation(pt), Location::BOUNDARY); 
-
-	}
-
-	template<>
-	template<>
-	void object::test<6>()
-	{
-		using geos::operation::overlay::FuzzyPointLocator;
-		using geos::geom::Location;
-		// this would return the expected result
-		//geos::geom::Coordinate pt(160, 120);
-		geos::geom::Coordinate pt(160, 120.000005);
-
-		std::stringstream wkb0("0103000000020000000800000000000000000034400000000000004440000000000000344000000000000069400000000000806640000000000000694000000000008066400000000000005E4000000000008061400000000000005E4000000000008066400000000000C05D400000000000806640000000000000444000000000000034400000000000004440040000000000000000806140000000000000644000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000006440");
-		GeomPtr g0(wkbreader.readHEX(wkb0));
-
-		FuzzyPointLocator locator(*g0, 0.000001);
-
-		// On the boundary ?
-		ensure_equals(locator.getLocation(pt), Location::INTERIOR); 
-
-	}
-
-	template<>
-	template<>
-	void object::test<7>()
-	{
-		using geos::operation::overlay::FuzzyPointLocator;
-		using geos::geom::Location;
-		// this would return the expected result
-		//geos::geom::Coordinate pt(160, 120);
-		geos::geom::Coordinate pt(160, 120.000005);
-
-		std::stringstream wkb0("0106000000020000000103000000020000000A000000000000000000344000000000000044400000000000003440000000000000694000000000008066400000000000006940000000000080664000000000000064400000000000C0624000000000000064400000000000C062400000000000005E400000000000C0624000000000000054400000000000806640000000000000544000000000008066400000000000004440000000000000344000000000000044400500000000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000005E400000000000806140000000000000644000000000000054400000000000005E40010300000001000000080000000000000000C062400000000000005E4000000000008066400000000000005E400000000000806640000000000000644000000000000069400000000000006440000000000000694000000000000054400000000000806640000000000000544000000000008066400000000000C05D400000000000C062400000000000005E40");
-		GeomPtr g0(wkbreader.readHEX(wkb0));
-
-		FuzzyPointLocator locator(*g0, 0.000001);
-
-		// On the boundary ?
-		ensure_equals(locator.getLocation(pt), Location::EXTERIOR); 
-
-	}
-
-} // namespace tut
-

Deleted: trunk/tests/unit/operation/overlay/OffsetPointGeneratorTest.cpp
===================================================================
--- trunk/tests/unit/operation/overlay/OffsetPointGeneratorTest.cpp	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/tests/unit/operation/overlay/OffsetPointGeneratorTest.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,204 +0,0 @@
-// $Id$
-// 
-// Test Suite for geos::operation::overlay::OffsetPointGenerator class.
-
-// tut
-#include <tut.hpp>
-// geos
-#include <geos/operation/overlay/OffsetPointGenerator.h>
-#include <geos/geom/GeometryFactory.h>
-#include <geos/geom/Point.h>
-#include <geos/geom/Geometry.h>
-#include <geos/algorithm/PointLocator.h>
-#include <geos/io/WKTReader.h>
-#include <geos/geom/Coordinate.h>
-// std
-#include <memory>
-#include <vector>
-
-namespace tut
-{
-	using namespace std;
-	using namespace geos::geom;
-
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_offsetpointgenerator_data
-	{
-		geos::geom::GeometryFactory gf;
-		geos::io::WKTReader wktreader;
-		geos::algorithm::PointLocator locator;
-
-		typedef geos::geom::Geometry::AutoPtr GeomPtr;
-
-		GeomPtr g;
-
-		test_offsetpointgenerator_data()
-			:
-			gf(),
-			wktreader(&gf)
-		{
-		}
-
-		bool
-		pointsWithinDistance(vector<Coordinate>& coords, double dist)
-		{
-			// we expect some numerical instability here
-			// OffsetPointGenerator could produce points
-			// at *slightly* farther locations then
-			// requested
-			//
-			dist *= 1.0000001;
-
-			for (size_t i=0, n=coords.size(); i<n; ++i)
-			{
-				const Coordinate& c = coords[i];
-				auto_ptr<Geometry> pg(gf.createPoint(c));
-				double rdist =  g->distance(pg.get());
-				if ( rdist > dist )
-				{
-					return false;
-				}
-			}
-			return true;
-		}
-
-	};
-	
-
-	typedef test_group<test_offsetpointgenerator_data> group;
-	typedef group::object object;
-
-	group test_offsetpointgenerator_group("geos::operation::overlay::OffsetPointGenerator");
-
-	//
-	// Test Cases
-	//
-
-	template<>
-	template<>
-	void object::test<1>()
-	{
-		using geos::operation::overlay::OffsetPointGenerator;
-		using geos::geom::Coordinate;
-		using geos::algorithm::PointLocator;
-		using std::auto_ptr;
-		using std::vector;
-
-		std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		g.reset(wktreader.read(wkt));
-
-		double dist = 10;
-		OffsetPointGenerator gen(*g, dist);
-
-		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
-
-		ensure_equals(coords->size(), (g->getNumPoints()-1)*2);
-
-		ensure(pointsWithinDistance(*coords, dist));
-
-	}
-
-	template<>
-	template<>
-	void object::test<2>()
-	{
-		using geos::operation::overlay::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::auto_ptr;
-		using std::vector;
-
-		std::string wkt("POLYGON((0 0, 10 0, 10 5, 10 10, 0 10, 0 0))");
-		g.reset(wktreader.read(wkt));
-
-		double dist = 0.0003;
-
-		OffsetPointGenerator gen(*g, dist);
-
-		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
-
-		ensure_equals(coords->size(), 10u);
-
-		ensure(pointsWithinDistance(*coords, dist));
-	}
-
-	template<>
-	template<>
-	void object::test<3>()
-	{
-		using geos::operation::overlay::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::auto_ptr;
-		using std::vector;
-
-		std::string wkt("POINT(10 -10)");
-		g.reset(wktreader.read(wkt));
-
-		double dist = 0.0003;
-
-		OffsetPointGenerator gen(*g, dist);
-
-		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
-
-		ensure_equals(coords->size(), 0u);
-
-		//ensure(pointsWithinDistance(*coords, dist));
-	}
-
-	template<>
-	template<>
-	void object::test<4>()
-	{
-		using geos::operation::overlay::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::auto_ptr;
-		using std::vector;
-
-		std::string wkt("LINESTRING(10 -10, 5 600)");
-		g.reset(wktreader.read(wkt));
-
-		double dist = 0.03;
-
-		OffsetPointGenerator gen(*g, dist);
-
-		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
-
-		ensure_equals(coords->size(), 2u);
-
-		ensure(pointsWithinDistance(*coords, dist));
-	}
-
-	template<>
-	template<>
-	void object::test<5>()
-	{
-		using geos::operation::overlay::OffsetPointGenerator;
-		using geos::geom::Location;
-		using geos::geom::Coordinate;
-		using std::auto_ptr;
-		using std::vector;
-
-		std::string wkt("MULTILINESTRING((10 -10, 5 600), (1045 -12, 0 0, -435 34))");
-		g.reset(wktreader.read(wkt));
-
-		double dist = 0.2;
-
-		OffsetPointGenerator gen(*g, dist);
-
-		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
-
-		ensure_equals(coords->size(), 6u);
-
-		ensure(pointsWithinDistance(*coords, dist));
-	}
-
-
-
-} // namespace tut
-

Deleted: trunk/tests/unit/operation/overlay/OverlayResultValidatorTest.cpp
===================================================================
--- trunk/tests/unit/operation/overlay/OverlayResultValidatorTest.cpp	2009-05-04 21:02:18 UTC (rev 2461)
+++ trunk/tests/unit/operation/overlay/OverlayResultValidatorTest.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -1,182 +0,0 @@
-// $Id$
-// 
-// Test Suite for geos::operation::overlay::OverlayResultValidator class.
-
-// tut
-#include <tut.hpp>
-// geos
-#include <geos/operation/overlay/OverlayOp.h>
-#include <geos/operation/overlay/OverlayResultValidator.h>
-#include <geos/geom/GeometryFactory.h>
-#include <geos/geom/Geometry.h>
-#include <geos/algorithm/PointLocator.h>
-#include <geos/io/WKTReader.h>
-#include <geos/geom/Coordinate.h>
-// std
-#include <memory>
-#include <vector>
-
-namespace tut
-{
-	using namespace geos::operation::overlay;
-
-	//
-	// Test Group
-	//
-
-	// Common data used by tests
-	struct test_overlayresultvalidator_data
-	{
-		geos::geom::GeometryFactory gf;
-		geos::io::WKTReader wktreader;
-		geos::algorithm::PointLocator locator;
-
-		typedef geos::geom::Geometry::AutoPtr GeomPtr;
-
-		GeomPtr g0, g1, gres;
-
-		test_overlayresultvalidator_data()
-			:
-			gf(),
-			wktreader(&gf)
-		{
-		}
-
-	};
-	
-
-	typedef test_group<test_overlayresultvalidator_data> group;
-	typedef group::object object;
-
-	group test_overlayresultvalidator_group("geos::operation::overlay::OverlayResultValidator");
-
-	//
-	// Test Cases
-	//
-
-	template<>
-	template<>
-	void object::test<1>()
-	{
-
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g1(wktreader.read(wkt1));
-
-		std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr gres(wktreader.read(wkt1));
-
-		OverlayResultValidator validator(*g0, *g1, *gres);
-
-		ensure( validator.isValid(OverlayOp::opUNION) );
-	}
-
-	template<>
-	template<>
-	void object::test<2>()
-	{
-
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g1(wktreader.read(wkt1));
-
-		std::string wktres("POLYGON((0 0, 10.001 0, 10 10, 0 10, 0 0))");
-		GeomPtr gres(wktreader.read(wktres));
-
-		OverlayResultValidator validator(*g0, *g1, *gres);
-
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
-
-	template<>
-	template<>
-	void object::test<3>()
-	{
-
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g1(wktreader.read(wkt1));
-
-		std::string wktres("POLYGON((0 0, 9.999 0, 10 10, 0 10, 0 0))");
-		GeomPtr gres(wktreader.read(wktres));
-
-		OverlayResultValidator validator(*g0, *g1, *gres);
-
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
-
-	// Result of union has an hole not in input
-	template<>
-	template<>
-	void object::test<4>()
-	{
-
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g1(wktreader.read(wkt1));
-
-		std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 5 6, 6 6, 5 5))");
-		GeomPtr gres(wktreader.read(wktres));
-
-		OverlayResultValidator validator(*g0, *g1, *gres);
-
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
-
-
-	template<>
-	template<>
-	void object::test<5>()
-	{
-
-		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		std::string wkt1("POLYGON((5 0, 1500 0, 1500 10, 5 10, 5 0))");
-		GeomPtr g1(wktreader.read(wkt1));
-
-		// small shift
-		std::string wktres("POLYGON((0 0, 750 0.0001, 150 0, 150 10, 0 10, 0 0))");
-		GeomPtr gres(wktreader.read(wktres));
-
-		OverlayResultValidator validator(*g0, *g1, *gres);
-
-		ensure (! validator.isValid(OverlayOp::opUNION) );
-	}
-
-	template<>
-	template<>
-	void object::test<6>() 
-	{
-
-		std::string wkt0("POLYGON ((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 120.0, 140.0 120.0, 180.0 119.0, 180.0 40.0, 20.0 40.0), (140.0 160.0, 80.0 120.0, 140.0 80.0, 140.0 160.0))");
-		GeomPtr g0(wktreader.read(wkt0));
-
-		std::string wkt1("POLYGON ((200.0 160.0, 150.0 160.0, 150.0 80.0, 200.0 80.0, 200.0 160.0))");
-		GeomPtr g1(wktreader.read(wkt1));
-
-		std::string wktres("MULTIPOLYGON (((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 160.0, 150.0 160.0, 150.0 120.0, 150.0 80.0, 180.0 80.0, 180.0 40.0, 20.0 40.0), (80.0 120.0, 140.0 80.0, 140.0 120.0, 140.0 160.0, 80.0 120.0)), ((150.0 120.0, 180.0 120.0, 180.0 160.0, 200.0 160.0, 200.0 80.0, 180.0 80.0, 180.0 119.0, 150.0 120.0)))");
-		GeomPtr gres(wktreader.read(wktres));
-
-		OverlayResultValidator validator(*g0, *g1, *gres);
-
-		ensure ( ! validator.isValid(OverlayOp::opSYMDIFFERENCE) );
-	}
-
-
-	//
-	// TODO: add tests for other operations
-	//       and other geometry types (IFF we drop the limit of the
-	//       class to only work with areal geoms)
-
-
-} // namespace tut
-

Copied: trunk/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp (from rev 2455, trunk/tests/unit/operation/overlay/FuzzyPointLocatorTest.cpp)
===================================================================
--- trunk/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp	                        (rev 0)
+++ trunk/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,199 @@
+// $Id$
+// 
+// Test Suite for geos::operation::overlay::validate::FuzzyPointLocator class.
+
+
+// tut
+#include <tut.hpp>
+// geos
+#include <geos/operation/overlay/validate/FuzzyPointLocator.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Geometry.h>
+#include <geos/io/WKTReader.h>
+#include <geos/io/WKBReader.h>
+#include <geos/geom/Coordinate.h>
+#include <geos/geom/Location.h>
+// std
+#include <memory>
+#include <sstream>
+
+namespace tut
+{
+	//
+	// Test Group
+	//
+
+	// Common data used by tests
+	struct test_fuzzypointlocator_data
+	{
+		geos::geom::GeometryFactory gf;
+		geos::io::WKTReader wktreader;
+		geos::io::WKBReader wkbreader;
+
+		typedef geos::geom::Geometry::AutoPtr GeomPtr;
+
+		GeomPtr g;
+
+		test_fuzzypointlocator_data()
+			:
+			gf(),
+			wktreader(&gf),
+			wkbreader(gf)
+		{
+			std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+			g.reset(wktreader.read(wkt));
+		}
+	};
+	
+
+	typedef test_group<test_fuzzypointlocator_data> group;
+	typedef group::object object;
+
+	group test_fuzzypointlocator_group("geos::operation::overlay::validate::FuzzyPointLocator");
+
+	//
+	// Test Cases
+	//
+
+	template<>
+	template<>
+	void object::test<1>()
+	{
+		using geos::operation::overlay::validate::FuzzyPointLocator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+
+		FuzzyPointLocator locator(*g, 10);
+
+		ensure_equals(locator.getLocation(Coordinate(10, 0)),
+			Location::BOUNDARY); 
+
+		// 8 units away from boundary
+		ensure_equals(locator.getLocation(Coordinate(18, 5)),
+			Location::BOUNDARY); 
+	}
+
+	template<>
+	template<>
+	void object::test<2>()
+	{
+		using geos::operation::overlay::validate::FuzzyPointLocator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+
+		FuzzyPointLocator locator(*g, 10);
+
+		//
+		// These are corner cases. I think they should
+		// return Location::BOUNDARY, but need to discuss
+		// this with Martin Davis
+		//
+
+		// 10 units away from boundary
+		ensure_equals(locator.getLocation(Coordinate(20, 2)),
+			Location::EXTERIOR); 
+
+		// 10 units away from boundary
+		ensure_equals(locator.getLocation(Coordinate(-10, 5)),
+			Location::EXTERIOR); 
+	}
+
+	template<>
+	template<>
+	void object::test<3>()
+	{
+		using geos::operation::overlay::validate::FuzzyPointLocator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+
+		FuzzyPointLocator locator(*g, 8);
+
+		// 5 units away from boundary
+		ensure_equals(locator.getLocation(Coordinate(5, 5)),
+			Location::BOUNDARY); 
+
+		// 2 units away from boundary
+		ensure_equals(locator.getLocation(Coordinate(2, 8)),
+			Location::BOUNDARY); 
+	}
+
+	template<>
+	template<>
+	void object::test<4>()
+	{
+		using geos::operation::overlay::validate::FuzzyPointLocator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+
+		FuzzyPointLocator locator(*g, 2);
+
+		// 5 units away from boundary
+		ensure_equals(locator.getLocation(Coordinate(5, 5)),
+			Location::INTERIOR); 
+
+		// 3 units away from boundary
+		ensure_equals(locator.getLocation(Coordinate(3, 7)),
+			Location::INTERIOR); 
+	}
+
+
+	template<>
+	template<>
+	void object::test<5>()
+	{
+		using geos::operation::overlay::validate::FuzzyPointLocator;
+		using geos::geom::Location;
+		geos::geom::Coordinate pt(160.000000125, 119.500004998);
+
+		std::string wkt0("POLYGON((20 40,20 200,180 200,180 120,140 120,180 119,180 40,20 40),(140 160,80 120,140 80,140 160))");
+		GeomPtr g0(wktreader.read(wkt0));
+
+		FuzzyPointLocator locator(*g0, 0.00001);
+
+		// On the boundary ?
+		ensure_equals(locator.getLocation(pt), Location::BOUNDARY); 
+
+	}
+
+	template<>
+	template<>
+	void object::test<6>()
+	{
+		using geos::operation::overlay::validate::FuzzyPointLocator;
+		using geos::geom::Location;
+		// this would return the expected result
+		//geos::geom::Coordinate pt(160, 120);
+		geos::geom::Coordinate pt(160, 120.000005);
+
+		std::stringstream wkb0("0103000000020000000800000000000000000034400000000000004440000000000000344000000000000069400000000000806640000000000000694000000000008066400000000000005E4000000000008061400000000000005E4000000000008066400000000000C05D400000000000806640000000000000444000000000000034400000000000004440040000000000000000806140000000000000644000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000006440");
+		GeomPtr g0(wkbreader.readHEX(wkb0));
+
+		FuzzyPointLocator locator(*g0, 0.000001);
+
+		// On the boundary ?
+		ensure_equals(locator.getLocation(pt), Location::INTERIOR); 
+
+	}
+
+	template<>
+	template<>
+	void object::test<7>()
+	{
+		using geos::operation::overlay::validate::FuzzyPointLocator;
+		using geos::geom::Location;
+		// this would return the expected result
+		//geos::geom::Coordinate pt(160, 120);
+		geos::geom::Coordinate pt(160, 120.000005);
+
+		std::stringstream wkb0("0106000000020000000103000000020000000A000000000000000000344000000000000044400000000000003440000000000000694000000000008066400000000000006940000000000080664000000000000064400000000000C0624000000000000064400000000000C062400000000000005E400000000000C0624000000000000054400000000000806640000000000000544000000000008066400000000000004440000000000000344000000000000044400500000000000000000054400000000000005E400000000000806140000000000000544000000000008061400000000000005E400000000000806140000000000000644000000000000054400000000000005E40010300000001000000080000000000000000C062400000000000005E4000000000008066400000000000005E400000000000806640000000000000644000000000000069400000000000006440000000000000694000000000000054400000000000806640000000000000544000000000008066400000000000C05D400000000000C062400000000000005E40");
+		GeomPtr g0(wkbreader.readHEX(wkb0));
+
+		FuzzyPointLocator locator(*g0, 0.000001);
+
+		// On the boundary ?
+		ensure_equals(locator.getLocation(pt), Location::EXTERIOR); 
+
+	}
+
+} // namespace tut
+


Property changes on: trunk/tests/unit/operation/overlay/validate/FuzzyPointLocatorTest.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Copied: trunk/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp (from rev 2455, trunk/tests/unit/operation/overlay/OffsetPointGeneratorTest.cpp)
===================================================================
--- trunk/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp	                        (rev 0)
+++ trunk/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,204 @@
+// $Id$
+// 
+// Test Suite for geos::operation::overlay::validate::OffsetPointGenerator class.
+
+// tut
+#include <tut.hpp>
+// geos
+#include <geos/operation/overlay/validate/OffsetPointGenerator.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Point.h>
+#include <geos/geom/Geometry.h>
+#include <geos/algorithm/PointLocator.h>
+#include <geos/io/WKTReader.h>
+#include <geos/geom/Coordinate.h>
+// std
+#include <memory>
+#include <vector>
+
+namespace tut
+{
+	using namespace std;
+	using namespace geos::geom;
+
+	//
+	// Test Group
+	//
+
+	// Common data used by tests
+	struct test_offsetpointgenerator_data
+	{
+		geos::geom::GeometryFactory gf;
+		geos::io::WKTReader wktreader;
+		geos::algorithm::PointLocator locator;
+
+		typedef geos::geom::Geometry::AutoPtr GeomPtr;
+
+		GeomPtr g;
+
+		test_offsetpointgenerator_data()
+			:
+			gf(),
+			wktreader(&gf)
+		{
+		}
+
+		bool
+		pointsWithinDistance(vector<Coordinate>& coords, double dist)
+		{
+			// we expect some numerical instability here
+			// OffsetPointGenerator could produce points
+			// at *slightly* farther locations then
+			// requested
+			//
+			dist *= 1.0000001;
+
+			for (size_t i=0, n=coords.size(); i<n; ++i)
+			{
+				const Coordinate& c = coords[i];
+				auto_ptr<Geometry> pg(gf.createPoint(c));
+				double rdist =  g->distance(pg.get());
+				if ( rdist > dist )
+				{
+					return false;
+				}
+			}
+			return true;
+		}
+
+	};
+	
+
+	typedef test_group<test_offsetpointgenerator_data> group;
+	typedef group::object object;
+
+	group test_offsetpointgenerator_group("geos::operation::overlay::validate::OffsetPointGenerator");
+
+	//
+	// Test Cases
+	//
+
+	template<>
+	template<>
+	void object::test<1>()
+	{
+		using geos::operation::overlay::validate::OffsetPointGenerator;
+		using geos::geom::Coordinate;
+		using geos::algorithm::PointLocator;
+		using std::auto_ptr;
+		using std::vector;
+
+		std::string wkt("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		g.reset(wktreader.read(wkt));
+
+		double dist = 10;
+		OffsetPointGenerator gen(*g, dist);
+
+		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
+
+		ensure_equals(coords->size(), (g->getNumPoints()-1)*2);
+
+		ensure(pointsWithinDistance(*coords, dist));
+
+	}
+
+	template<>
+	template<>
+	void object::test<2>()
+	{
+		using geos::operation::overlay::validate::OffsetPointGenerator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+		using std::auto_ptr;
+		using std::vector;
+
+		std::string wkt("POLYGON((0 0, 10 0, 10 5, 10 10, 0 10, 0 0))");
+		g.reset(wktreader.read(wkt));
+
+		double dist = 0.0003;
+
+		OffsetPointGenerator gen(*g, dist);
+
+		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
+
+		ensure_equals(coords->size(), 10u);
+
+		ensure(pointsWithinDistance(*coords, dist));
+	}
+
+	template<>
+	template<>
+	void object::test<3>()
+	{
+		using geos::operation::overlay::validate::OffsetPointGenerator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+		using std::auto_ptr;
+		using std::vector;
+
+		std::string wkt("POINT(10 -10)");
+		g.reset(wktreader.read(wkt));
+
+		double dist = 0.0003;
+
+		OffsetPointGenerator gen(*g, dist);
+
+		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
+
+		ensure_equals(coords->size(), 0u);
+
+		//ensure(pointsWithinDistance(*coords, dist));
+	}
+
+	template<>
+	template<>
+	void object::test<4>()
+	{
+		using geos::operation::overlay::validate::OffsetPointGenerator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+		using std::auto_ptr;
+		using std::vector;
+
+		std::string wkt("LINESTRING(10 -10, 5 600)");
+		g.reset(wktreader.read(wkt));
+
+		double dist = 0.03;
+
+		OffsetPointGenerator gen(*g, dist);
+
+		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
+
+		ensure_equals(coords->size(), 2u);
+
+		ensure(pointsWithinDistance(*coords, dist));
+	}
+
+	template<>
+	template<>
+	void object::test<5>()
+	{
+		using geos::operation::overlay::validate::OffsetPointGenerator;
+		using geos::geom::Location;
+		using geos::geom::Coordinate;
+		using std::auto_ptr;
+		using std::vector;
+
+		std::string wkt("MULTILINESTRING((10 -10, 5 600), (1045 -12, 0 0, -435 34))");
+		g.reset(wktreader.read(wkt));
+
+		double dist = 0.2;
+
+		OffsetPointGenerator gen(*g, dist);
+
+		auto_ptr< vector<Coordinate> > coords(gen.getPoints());
+
+		ensure_equals(coords->size(), 6u);
+
+		ensure(pointsWithinDistance(*coords, dist));
+	}
+
+
+
+} // namespace tut
+


Property changes on: trunk/tests/unit/operation/overlay/validate/OffsetPointGeneratorTest.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 

Copied: trunk/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp (from rev 2455, trunk/tests/unit/operation/overlay/OverlayResultValidatorTest.cpp)
===================================================================
--- trunk/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp	                        (rev 0)
+++ trunk/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp	2009-05-04 21:28:26 UTC (rev 2462)
@@ -0,0 +1,183 @@
+// $Id$
+// 
+// Test Suite for geos::operation::overlay::validate::OverlayResultValidator class.
+
+// tut
+#include <tut.hpp>
+// geos
+#include <geos/operation/overlay/OverlayOp.h>
+#include <geos/operation/overlay/validate/OverlayResultValidator.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/Geometry.h>
+#include <geos/algorithm/PointLocator.h>
+#include <geos/io/WKTReader.h>
+#include <geos/geom/Coordinate.h>
+// std
+#include <memory>
+#include <vector>
+
+namespace tut
+{
+	using namespace geos::operation::overlay;
+	using namespace geos::operation::overlay::validate;
+
+	//
+	// Test Group
+	//
+
+	// Common data used by tests
+	struct test_overlayresultvalidator_data
+	{
+		geos::geom::GeometryFactory gf;
+		geos::io::WKTReader wktreader;
+		geos::algorithm::PointLocator locator;
+
+		typedef geos::geom::Geometry::AutoPtr GeomPtr;
+
+		GeomPtr g0, g1, gres;
+
+		test_overlayresultvalidator_data()
+			:
+			gf(),
+			wktreader(&gf)
+		{
+		}
+
+	};
+	
+
+	typedef test_group<test_overlayresultvalidator_data> group;
+	typedef group::object object;
+
+	group test_overlayresultvalidator_group("geos::operation::overlay::validate::OverlayResultValidator");
+
+	//
+	// Test Cases
+	//
+
+	template<>
+	template<>
+	void object::test<1>()
+	{
+
+		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g0(wktreader.read(wkt0));
+
+		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g1(wktreader.read(wkt1));
+
+		std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr gres(wktreader.read(wkt1));
+
+		OverlayResultValidator validator(*g0, *g1, *gres);
+
+		ensure( validator.isValid(OverlayOp::opUNION) );
+	}
+
+	template<>
+	template<>
+	void object::test<2>()
+	{
+
+		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g0(wktreader.read(wkt0));
+
+		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g1(wktreader.read(wkt1));
+
+		std::string wktres("POLYGON((0 0, 10.001 0, 10 10, 0 10, 0 0))");
+		GeomPtr gres(wktreader.read(wktres));
+
+		OverlayResultValidator validator(*g0, *g1, *gres);
+
+		ensure (! validator.isValid(OverlayOp::opUNION) );
+	}
+
+	template<>
+	template<>
+	void object::test<3>()
+	{
+
+		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g0(wktreader.read(wkt0));
+
+		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g1(wktreader.read(wkt1));
+
+		std::string wktres("POLYGON((0 0, 9.999 0, 10 10, 0 10, 0 0))");
+		GeomPtr gres(wktreader.read(wktres));
+
+		OverlayResultValidator validator(*g0, *g1, *gres);
+
+		ensure (! validator.isValid(OverlayOp::opUNION) );
+	}
+
+	// Result of union has an hole not in input
+	template<>
+	template<>
+	void object::test<4>()
+	{
+
+		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g0(wktreader.read(wkt0));
+
+		std::string wkt1("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g1(wktreader.read(wkt1));
+
+		std::string wktres("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 5 6, 6 6, 5 5))");
+		GeomPtr gres(wktreader.read(wktres));
+
+		OverlayResultValidator validator(*g0, *g1, *gres);
+
+		ensure (! validator.isValid(OverlayOp::opUNION) );
+	}
+
+
+	template<>
+	template<>
+	void object::test<5>()
+	{
+
+		std::string wkt0("POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))");
+		GeomPtr g0(wktreader.read(wkt0));
+
+		std::string wkt1("POLYGON((5 0, 1500 0, 1500 10, 5 10, 5 0))");
+		GeomPtr g1(wktreader.read(wkt1));
+
+		// small shift
+		std::string wktres("POLYGON((0 0, 750 0.0001, 150 0, 150 10, 0 10, 0 0))");
+		GeomPtr gres(wktreader.read(wktres));
+
+		OverlayResultValidator validator(*g0, *g1, *gres);
+
+		ensure (! validator.isValid(OverlayOp::opUNION) );
+	}
+
+	template<>
+	template<>
+	void object::test<6>() 
+	{
+
+		std::string wkt0("POLYGON ((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 120.0, 140.0 120.0, 180.0 119.0, 180.0 40.0, 20.0 40.0), (140.0 160.0, 80.0 120.0, 140.0 80.0, 140.0 160.0))");
+		GeomPtr g0(wktreader.read(wkt0));
+
+		std::string wkt1("POLYGON ((200.0 160.0, 150.0 160.0, 150.0 80.0, 200.0 80.0, 200.0 160.0))");
+		GeomPtr g1(wktreader.read(wkt1));
+
+		std::string wktres("MULTIPOLYGON (((20.0 40.0, 20.0 200.0, 180.0 200.0, 180.0 160.0, 150.0 160.0, 150.0 120.0, 150.0 80.0, 180.0 80.0, 180.0 40.0, 20.0 40.0), (80.0 120.0, 140.0 80.0, 140.0 120.0, 140.0 160.0, 80.0 120.0)), ((150.0 120.0, 180.0 120.0, 180.0 160.0, 200.0 160.0, 200.0 80.0, 180.0 80.0, 180.0 119.0, 150.0 120.0)))");
+		GeomPtr gres(wktreader.read(wktres));
+
+		OverlayResultValidator validator(*g0, *g1, *gres);
+
+		ensure ( ! validator.isValid(OverlayOp::opSYMDIFFERENCE) );
+	}
+
+
+	//
+	// TODO: add tests for other operations
+	//       and other geometry types (IFF we drop the limit of the
+	//       class to only work with areal geoms)
+
+
+} // namespace tut
+


Property changes on: trunk/tests/unit/operation/overlay/validate/OverlayResultValidatorTest.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:mergeinfo
   + 



More information about the geos-commits mailing list