Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69581 - trunk/libs/geometry/test/geometries
From: barend.gehrels_at_[hidden]
Date: 2011-03-05 08:48:10


Author: barendgehrels
Date: 2011-03-05 08:48:08 EST (Sat, 05 Mar 2011)
New Revision: 69581
URL: http://svn.boost.org/trac/boost/changeset/69581

Log:
Added test with Boost.Polygon as asked by Luke.
Added:
   trunk/libs/geometry/test/geometries/boost_polygon_overlay.cpp (contents, props changed)
   trunk/libs/geometry/test/geometries/boost_polygon_overlay.vcproj (contents, props changed)
Text files modified:
   trunk/libs/geometry/test/geometries/geometries_tests.sln | 6 ++++++
   1 files changed, 6 insertions(+), 0 deletions(-)

Added: trunk/libs/geometry/test/geometries/boost_polygon_overlay.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/geometries/boost_polygon_overlay.cpp 2011-03-05 08:48:08 EST (Sat, 05 Mar 2011)
@@ -0,0 +1,119 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library) test file
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <geometry_test_common.hpp>
+
+
+#include<boost/geometry/geometry.hpp>
+#include<boost/geometry/geometries/adapted/boost_polygon/point.hpp>
+#include<boost/geometry/geometries/adapted/boost_polygon/box.hpp>
+#include<boost/geometry/geometries/adapted/boost_polygon/ring.hpp>
+#include<boost/geometry/geometries/adapted/boost_polygon/polygon.hpp>
+#include<boost/geometry/extensions/gis/io/wkt/wkt.hpp>
+
+#include<iostream>
+
+template <typename T>
+void test_overlay_using_bp(std::string const& case_id, std::string const& wkt_p, std::string const& wkt_q)
+{
+ typedef boost::polygon::polygon_set_data<T> polygon_set;
+
+ polygon_set p, q;
+ polygon_set out_i, out_u;
+
+ {
+ // Read it using Boost.Geometry
+ typedef boost::geometry::model::multi_polygon
+ <
+ boost::polygon::polygon_with_holes_data<T>
+ > mp_type;
+ mp_type mp, mq;
+
+ bg::read_wkt(wkt_p, mp);
+ bg::read_wkt(wkt_q, mq);
+
+ p.insert(mp.begin(), mp.end());
+ q.insert(mq.begin(), mq.end());
+ }
+
+ {
+ using namespace boost::polygon::operators;
+ out_i = p & q;
+ out_u = p | q;
+ }
+
+ double area_p = boost::polygon::area(p);
+ double area_q = boost::polygon::area(q);
+ double area_i = boost::polygon::area(out_i);
+ double area_u = boost::polygon::area(out_u);
+
+ double sum = area_p + area_q - area_u - area_i;
+ BOOST_CHECK_MESSAGE(abs(sum) < 0.001,
+ "Overlay error\n"
+ << "Boost.Polygon " << case_id
+ << " area p: " << area_p
+ << " area q: " << area_q
+ << " area i: " << area_i
+ << " area u: " << area_u
+ << " sum: " << sum
+ );
+}
+
+
+template <typename T>
+void test_overlay_using_bg(std::string const& case_id, std::string const& wkt_p, std::string const& wkt_q)
+{
+ typedef boost::geometry::model::multi_polygon
+ <
+ boost::geometry::model::polygon
+ <
+ boost::geometry::model::d2::point_xy<T>
+ >
+ > mp_type;
+
+ // Read it using Boost.Geometry
+ mp_type p, q, out_i, out_u;
+
+ boost::geometry::read_wkt(wkt_p, p);
+ boost::geometry::read_wkt(wkt_q, q);
+
+ boost::geometry::intersection(p, q, out_i);
+ boost::geometry::union_(p, q, out_u);
+
+ double area_p = boost::geometry::area(p);
+ double area_q = boost::geometry::area(q);
+ double area_i = boost::geometry::area(out_i);
+ double area_u = boost::geometry::area(out_u);
+
+ double sum = area_p + area_q - area_u - area_i;
+ BOOST_CHECK_MESSAGE(abs(sum) < 0.001,
+ "Overlay error\n"
+ << "Boost.Geometry " << case_id
+ << " area p: " << area_p
+ << " area q: " << area_q
+ << " area i: " << area_i
+ << " area u: " << area_u
+ << " sum: " << sum
+ );
+}
+
+template <typename T>
+void test_overlay(std::string const& case_id, std::string const& wkt_p, std::string const& wkt_q)
+{
+ test_overlay_using_bp<T>(case_id, wkt_p, wkt_q);
+ test_overlay_using_bg<T>(case_id, wkt_p, wkt_q);
+}
+
+
+int test_main(int, char* [])
+{
+ test_overlay<int>("case 1", "MULTIPOLYGON(((100 900,0 800,100 800,100 900)),((200 700,100 800,100 700,200 700)),((500 400,400 400,400 300,500 400)),((600 300,500 200,600 200,600 300)),((600 700,500 800,500 700,600 700)),((700 500,600 500,600 400,700 500)),((900 300,800 400,800 300,900 300)))",
+ "MULTIPOLYGON(((200 900,100 1000,100 800,200 800,200 900)),((400 500,300 600,300 500,400 500)),((500 900,400 800,500 800,500 900)),((600 800,500 700,600 700,600 800)),((700 500,600 400,700 400,700 500)),((1000 1000,900 900,1000 900,1000 1000)))");
+ test_overlay<int>("case 2", "MULTIPOLYGON(((200 400,100 400,100 300,200 400)),((300 100,200 100,200 0,300 0,300 100)),((600 700,500 700,500 600,600 700)),((700 300,600 300,600 200,700 300)),((800 500,700 600,700 500,800 500)),((900 800,800 700,900 700,900 800)),((1000 200,900 100,1000 100,1000 200)),((1000 800,900 900,900 800,1000 800)))",
+ "MULTIPOLYGON(((200 800,100 800,100 700,200 700,200 800)),((400 200,300 100,400 100,400 200)),((400 800,300 700,400 700,400 800)),((700 100,600 0,700 0,700 100)),((700 200,600 200,600 100,700 200)),((900 200,800 200,800 0,900 0,900 200)),((1000 300,900 200,1000 200,1000 300)))");
+ return 0;
+}
\ No newline at end of file

Added: trunk/libs/geometry/test/geometries/boost_polygon_overlay.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/geometries/boost_polygon_overlay.vcproj 2011-03-05 08:48:08 EST (Sat, 05 Mar 2011)
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="boost_polygon_overlay"
+ ProjectGUID="{93C4EB19-8A0C-437E-9F82-A0DB4A4A5C32}"
+ RootNamespace="boost_polygon_overlay"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\boost_polygon_overlay"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\boost.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../..;.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ ExceptionHandling="2"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)\boost_polygon_overlay"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\boost.vsprops"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../..;.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ ExceptionHandling="2"
+ UsePrecompiledHeader="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\boost_polygon_overlay.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Modified: trunk/libs/geometry/test/geometries/geometries_tests.sln
==============================================================================
--- trunk/libs/geometry/test/geometries/geometries_tests.sln (original)
+++ trunk/libs/geometry/test/geometries/geometries_tests.sln 2011-03-05 08:48:08 EST (Sat, 05 Mar 2011)
@@ -14,6 +14,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_fusion", "boost_fusion.vcproj", "{C218C979-890F-4690-84E0-837DC661CE57}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_polygon_overlay", "boost_polygon_overlay.vcproj", "{93C4EB19-8A0C-437E-9F82-A0DB4A4A5C32}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -48,6 +50,10 @@
                 {C218C979-890F-4690-84E0-837DC661CE57}.Debug|Win32.Build.0 = Debug|Win32
                 {C218C979-890F-4690-84E0-837DC661CE57}.Release|Win32.ActiveCfg = Release|Win32
                 {C218C979-890F-4690-84E0-837DC661CE57}.Release|Win32.Build.0 = Release|Win32
+ {93C4EB19-8A0C-437E-9F82-A0DB4A4A5C32}.Debug|Win32.ActiveCfg = Debug|Win32
+ {93C4EB19-8A0C-437E-9F82-A0DB4A4A5C32}.Debug|Win32.Build.0 = Debug|Win32
+ {93C4EB19-8A0C-437E-9F82-A0DB4A4A5C32}.Release|Win32.ActiveCfg = Release|Win32
+ {93C4EB19-8A0C-437E-9F82-A0DB4A4A5C32}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE


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