[geos-commits] r3224 - in trunk: include/geos/operation/overlay/snap src/operation/overlay/snap

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Feb 21 07:03:25 EST 2011


Author: strk
Date: 2011-02-21 04:03:25 -0800 (Mon, 21 Feb 2011)
New Revision: 3224

Modified:
   trunk/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h
   trunk/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp
Log:
Fix SnapIfNeededOverlayOp to throw the originating exception, which contains meaningful coordinates, and update port info.

Modified: trunk/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h
===================================================================
--- trunk/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h	2011-02-18 18:25:32 UTC (rev 3223)
+++ trunk/include/geos/operation/overlay/snap/SnapIfNeededOverlayOp.h	2011-02-21 12:03:25 UTC (rev 3224)
@@ -4,7 +4,7 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net
  *
- * Copyright (C) 2009  Sandro Santilli <strk at keybit.net>
+ * Copyright (C) 2009 2011  Sandro Santilli <strk at keybit.net>
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
@@ -13,8 +13,7 @@
  *
  ***********************************************************************
  *
- * Last port: operation/overlay/snap/SnapIfNeededOverlayOp.java rev 1.1
- * (JTS-1.10)
+ * Last port: operation/overlay/snap/SnapIfNeededOverlayOp.java r320 (JTS-1.12)
  *
  **********************************************************************/
 

Modified: trunk/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp
===================================================================
--- trunk/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp	2011-02-18 18:25:32 UTC (rev 3223)
+++ trunk/src/operation/overlay/snap/SnapIfNeededOverlayOp.cpp	2011-02-21 12:03:25 UTC (rev 3224)
@@ -4,7 +4,7 @@
  * GEOS - Geometry Engine Open Source
  * http://geos.refractions.net
  *
- * Copyright (C) 2009  Sandro Santilli <strk at keybit.net>
+ * Copyright (C) 2009 2011 Sandro Santilli <strk at keybit.net>
  *
  * This is free software; you can redistribute and/or modify it under
  * the terms of the GNU Lesser General Public Licence as published
@@ -13,8 +13,7 @@
  *
  ***********************************************************************
  *
- * Last port: operation/overlay/snap/SnapIfNeededOverlayOp.java rev 1.1
- * (JTS-1.10)
+ * Last port: operation/overlay/snap/SnapIfNeededOverlayOp.java r320 (JTS-1.12)
  *
  **********************************************************************/
 
@@ -44,35 +43,36 @@
 auto_ptr<Geometry>
 SnapIfNeededOverlayOp::getResultGeometry(OverlayOp::OpCode opCode)
 {
+	using geos::util::TopologyException;
+
 	auto_ptr<Geometry> result;
 
-	bool isSuccess = false;
+	TopologyException origEx;
 
+	// Try with original input
 	try {
 		result.reset( OverlayOp::overlayOp(&geom0, &geom1, opCode) );
-		bool isValid = true;
-
-		// not needed if noding validation is used
-		// bool isValid = OverlayResultValidator::isValid(
-		//                     geom0, geom1, OverlayOp::INTERSECTION,
-		//                     result);
-
-		if (isValid) isSuccess = true;
-
+		return result;
 	}
-	catch (std::exception& ex) {
-        ::geos::ignore_unused_variable_warning(ex);
+	catch (const TopologyException& ex) {
+		origEx = ex; // save original exception
 #if GEOS_DEBUG
 		std::cerr << "Overlay op threw " << ex.what() << ". Will try snapping now" << std::endl;
 #endif
 	}
 
-	if (! isSuccess) {
-		// this may still throw an exception - just let it go if it does
+	// Try snapping
+	try {
 		result = SnapOverlayOp::overlayOp(geom0, geom1, opCode);
+		return result;
 	}
-
-	return result;
+	catch (const TopologyException& ex) {
+		::geos::ignore_unused_variable_warning(ex);
+#if GEOS_DEBUG
+		std::cerr << "Overlay op on snapped geoms threw " << ex.what() << ". Will try snapping now" << std::endl;
+#endif
+	 	throw origEx;
+	}
 }
 
 



More information about the geos-commits mailing list