Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56594 - in sandbox/ggl/other/comparisons: cgal common geos ggl gtl
From: barend.gehrels_at_[hidden]
Date: 2009-10-05 09:32:03


Author: barendgehrels
Date: 2009-10-05 09:32:02 EDT (Mon, 05 Oct 2009)
New Revision: 56594
URL: http://svn.boost.org/trac/boost/changeset/56594

Log:
Added self-intersection test using IsValid (geos), Is_simple (cgal), intersects (ggl)
Text files modified:
   sandbox/ggl/other/comparisons/cgal/cgal_check.cpp | 68 +++++++++++++++++++++++++++------------
   sandbox/ggl/other/comparisons/common/common.hpp | 18 +++++++++-
   sandbox/ggl/other/comparisons/geos/geos_check.cpp | 24 ++++++++++++++
   sandbox/ggl/other/comparisons/ggl/ggl_check.cpp | 33 +++++++++++++++++--
   sandbox/ggl/other/comparisons/gtl/gtl_check.cpp | 35 +++++++++++---------
   5 files changed, 134 insertions(+), 44 deletions(-)

Modified: sandbox/ggl/other/comparisons/cgal/cgal_check.cpp
==============================================================================
--- sandbox/ggl/other/comparisons/cgal/cgal_check.cpp (original)
+++ sandbox/ggl/other/comparisons/cgal/cgal_check.cpp 2009-10-05 09:32:02 EDT (Mon, 05 Oct 2009)
@@ -310,6 +310,26 @@
     }
     ***/
 
+ if (compare::MEASURE_INTERSECTS)
+ {
+ int n = 0;
+
+ boost::timer t;
+ for (int i = 0; i < 1; i++)
+ {
+ for (std::vector<POLY>::const_iterator it = polygons.begin();
+ it != polygons.end();
+ ++it)
+ {
+ if (! CGAL::is_simple_2(it->vertices_begin(), it->vertices_end(), K()))
+ {
+ n++;
+ }
+ }
+ }
+ compare::report_intersects(t, polygons.size(), n);
+ }
+
 
     #ifndef SKIP_OVERLAY
     if (compare::MEASURE_OVERLAY)
@@ -320,33 +340,37 @@
 
         for (int i = 0; i < compare::OVERLAY_COUNT; i++)
         {
- int k = 0;
- std::vector<POLY>::const_iterator eit = ellipses.begin();
- for (std::vector<POLY>::iterator it = polygons.begin();
- it != polygons.end() && eit != ellipses.end();
- ++it, ++eit, ++k)
- {
- area1 += CGAL::to_double(it->area());
+ int k = 0;
+ std::vector<POLY>::const_iterator eit = ellipses.begin();
 
- std::list<HOLEY_POLY> pv;
- try
+ //std::vector<int>::const_iterator idit = ids.begin();
+
+ for (std::vector<POLY>::iterator it = polygons.begin();
+ it != polygons.end() && eit != ellipses.end();
+ ++it, ++eit, ++k) //, ++idit)
             {
- CGAL::intersection(*it, *eit, std::back_inserter(pv));
- double a = 0;
- for (std::list<HOLEY_POLY>::const_iterator pit = pv.begin(); pit != pv.end(); ++pit)
+ area1 += CGAL::to_double(it->area());
+
+ std::list<HOLEY_POLY> pv;
+ try
+ {
+ //std::cout << " " << *idit;
+ CGAL::intersection(*it, *eit, std::back_inserter(pv));
+ double a = 0;
+ for (std::list<HOLEY_POLY>::const_iterator pit = pv.begin(); pit != pv.end(); ++pit)
+ {
+ a += CGAL::to_double(pit->outer_boundary().area());
+ }
+ area2 += a;
+ }
+ catch(std::exception const& e)
+ {
+ }
+ catch(...)
                 {
- a += CGAL::to_double(pit->outer_boundary().area());
                 }
- area2 += a;
- }
- catch(std::exception const& e)
- {
- }
- catch(...)
- {
- }
 
- }
+ }
         }
         compare::report_overlay(t, polygons.size(), area1, area2);
     }

Modified: sandbox/ggl/other/comparisons/common/common.hpp
==============================================================================
--- sandbox/ggl/other/comparisons/common/common.hpp (original)
+++ sandbox/ggl/other/comparisons/common/common.hpp 2009-10-05 09:32:02 EDT (Mon, 05 Oct 2009)
@@ -128,16 +128,20 @@
 
 //#define OVERLAY_UNION
 
- const int OVERLAY_ELLIPSE_COUNT = 101;
- const double delta = boost::math::constants::pi<double>() * 2.0 / (compare::OVERLAY_ELLIPSE_COUNT - 1);
+
+ // For star-ellipse: use 1.1, 0.2, 101, 1001, 10001
+ // For normal ellipse: use 1.1, 1.1, 100, 1000, 10000
     const double OVERLAY_ELLIPSE_FACTOR1 = 1.1; // 1.1
     const double OVERLAY_ELLIPSE_FACTOR2 = 0.2; // 0.2
+ const int OVERLAY_ELLIPSE_COUNT = 101;
+
     const double CLIP_FACTOR = 0.9;
 
     const bool MEASURE_AREA = true;
     const bool MEASURE_CENTROID = true;
     const bool MEASURE_CLIP = true;
     const bool MEASURE_CONVEX_HULL = true;
+ const bool MEASURE_INTERSECTS = true;
     const bool MEASURE_OVERLAY = true;
     const bool MEASURE_SIMPLIFY = true;
     const bool MEASURE_TOUCH = false; // currently only for GEOS, not further worked out
@@ -150,6 +154,8 @@
     const bool SIMPLIFY_LENGTH = true;
 
 
+ const double delta = boost::math::constants::pi<double>() * 2.0 / (compare::OVERLAY_ELLIPSE_COUNT - 1);
+
 
     // Wait a while, after reading shapefiles/generating ellipses, etc
     // until all buffers/memory allocation/swapping is done.
@@ -242,6 +248,14 @@
         report_common(s, n, "TOUCH", count, count_box);
     }
 
+ inline void report_intersects(const boost::timer& t, int n, int count)
+ {
+ double s = t.elapsed();
+
+ report_common(s, n, "INTERSECTS", count, 0);
+ }
+
+
     inline void report_overlay(const boost::timer& t, int n, double area1, double area2)
     {
         double s = t.elapsed();

Modified: sandbox/ggl/other/comparisons/geos/geos_check.cpp
==============================================================================
--- sandbox/ggl/other/comparisons/geos/geos_check.cpp (original)
+++ sandbox/ggl/other/comparisons/geos/geos_check.cpp 2009-10-05 09:32:02 EDT (Mon, 05 Oct 2009)
@@ -212,6 +212,30 @@
         }
 
 
+ if (compare::MEASURE_INTERSECTS)
+ {
+ int n = 0;
+
+ boost::timer t;
+ for (int i = 0; i < 1; i++)
+ {
+ for (std::vector<Geometry*>::const_iterator it = polygons.begin();
+ it != polygons.end();
+ ++it)
+ {
+ Geometry* poly = *it;
+
+ if (! poly->isValid())
+ {
+ n++;
+ }
+ }
+ }
+ compare::report_intersects(t, polygons.size(), n);
+ }
+
+
+
         if (compare::MEASURE_OVERLAY)
         {
             bool first = true;

Modified: sandbox/ggl/other/comparisons/ggl/ggl_check.cpp
==============================================================================
--- sandbox/ggl/other/comparisons/ggl/ggl_check.cpp (original)
+++ sandbox/ggl/other/comparisons/ggl/ggl_check.cpp 2009-10-05 09:32:02 EDT (Mon, 05 Oct 2009)
@@ -11,7 +11,7 @@
 //#define GGL_DEBUG_INTERSECTION
 // #define OUTPUT_POSTGIS
 // #define OUTPUT_SQLSERVER
-//#define OUTPUT_ORACLE
+//#define OUTPUT_ORACLE do not use this, does not work yet / is not yet checked in
 //#define OUTPUT_WKT
 
 
@@ -22,7 +22,9 @@
 #include <ggl/ggl.hpp>
 #include <ggl/geometries/geometries.hpp>
 
-#include <ggl/io/oracle/write_oracle.hpp>
+#if defined(OUTPUT_ORACLE)
+# include <ggl/io/oracle/write_oracle.hpp>
+#endif
 
 
 
@@ -297,14 +299,14 @@
         for (std::vector<POLY>::const_iterator it = polygons.begin(); it != polygons.end(); ++it)
         {
             POLY::ring_type ring;
- //std::cout << ggl::as_wkt<POLY>(*it) << std::endl;
+ //std::cout << ggl::wkt<POLY>(*it) << std::endl;
             ggl::convex_hull(*it, std::back_inserter(ring));
             if (compare::HULL_AREA)
             {
                 area += fabs(ggl::area(ring));
                 /*POLY p;
                 p.outer() = ring;
- std::cout << ggl::as_wkt<POLY>(p) << " ";
+ std::cout << ggl::wkt<POLY>(p) << " ";
                 std::cout << ggl::area(it->outer()) << " -> " << ggl::area(ring) << std::endl;
                 */
             }
@@ -313,6 +315,29 @@
         compare::report_hull(t, polygons.size(), area);
     }
 
+
+ if (compare::MEASURE_INTERSECTS)
+ {
+ int n = 0;
+
+ boost::timer t;
+ for (int i = 0; i < 1; i++)
+ {
+ for (std::vector<POLY>::const_iterator it = polygons.begin();
+ it != polygons.end();
+ ++it)
+ {
+ if (ggl::intersects(*it))
+ {
+ //std::cout << ggl::wkt<POLY>(*it) << std::endl;
+ n++;
+ }
+ }
+ }
+ compare::report_intersects(t, polygons.size(), n);
+ }
+
+
     if (compare::MEASURE_OVERLAY)
     {
         bool first = true;

Modified: sandbox/ggl/other/comparisons/gtl/gtl_check.cpp
==============================================================================
--- sandbox/ggl/other/comparisons/gtl/gtl_check.cpp (original)
+++ sandbox/ggl/other/comparisons/gtl/gtl_check.cpp 2009-10-05 09:32:02 EDT (Mon, 05 Oct 2009)
@@ -161,25 +161,28 @@
         std::vector<INT_POLY> integer_polygons;
         std::vector<INT_POLY> integer_ellipses;
 
- for (std::vector<POLY>::const_iterator it = polygons.begin();
- it != polygons.end();
- ++it)
+ if (compare::MEASURE_OVERLAY)
         {
- INT_POLY ip;
- convert_polygon(*it, ip);
- integer_polygons.push_back(ip);
+ for (std::vector<POLY>::const_iterator it = polygons.begin();
+ it != polygons.end();
+ ++it)
+ {
+ INT_POLY ip;
+ convert_polygon(*it, ip);
+ integer_polygons.push_back(ip);
 
- // To check if conversion is OK
- //std::cout << boost::polygon::area(*it) << " " << (boost::polygon::area(ip) / GTL_INTEGER_FACTOR_SQR) << std::endl;
- }
+ // To check if conversion is OK
+ //std::cout << boost::polygon::area(*it) << " " << (boost::polygon::area(ip) / GTL_INTEGER_FACTOR_SQR) << std::endl;
+ }
 
- for (std::vector<POLY>::const_iterator it = ellipses.begin();
- it != ellipses.end();
- ++it)
- {
- INT_POLY ip;
- convert_polygon(*it, ip);
- integer_ellipses.push_back(ip);
+ for (std::vector<POLY>::const_iterator it = ellipses.begin();
+ it != ellipses.end();
+ ++it)
+ {
+ INT_POLY ip;
+ convert_polygon(*it, ip);
+ integer_ellipses.push_back(ip);
+ }
         }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk