diff options
Diffstat (limited to 'libs/geometry/test/multi/algorithms')
9 files changed, 570 insertions, 2 deletions
diff --git a/libs/geometry/test/multi/algorithms/Jamfile.v2 b/libs/geometry/test/multi/algorithms/Jamfile.v2 index b0ea72667d..813d6aafa0 100644 --- a/libs/geometry/test/multi/algorithms/Jamfile.v2 +++ b/libs/geometry/test/multi/algorithms/Jamfile.v2 @@ -17,6 +17,7 @@ test-suite boost-geometry-multi-algorithms [ run multi_correct.cpp ] [ run multi_covered_by.cpp ] [ run multi_difference.cpp ] + [ run multi_disjoint.cpp ] [ run multi_distance.cpp ] [ run multi_envelope.cpp ] [ run multi_equals.cpp ] @@ -29,6 +30,7 @@ test-suite boost-geometry-multi-algorithms [ run multi_perimeter.cpp ] [ run multi_reverse.cpp ] [ run multi_simplify.cpp ] + [ run multi_touches.cpp ] [ run multi_transform.cpp ] [ run multi_union.cpp ] [ run multi_unique.cpp ] diff --git a/libs/geometry/test/multi/algorithms/multi_difference.cpp b/libs/geometry/test/multi/algorithms/multi_difference.cpp index 7bf3701e99..e5e47bc5c0 100644 --- a/libs/geometry/test/multi/algorithms/multi_difference.cpp +++ b/libs/geometry/test/multi/algorithms/multi_difference.cpp @@ -13,6 +13,11 @@ // #define BOOST_GEOMETRY_DEBUG_ASSEMBLE //#define BOOST_GEOMETRY_CHECK_WITH_SQLSERVER +//#define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER +//#define BOOST_GEOMETRY_DEBUG_FOLLOW +//#define BOOST_GEOMETRY_DEBUG_TRAVERSE + + #include <algorithms/test_difference.hpp> #include <algorithms/test_overlay.hpp> #include <multi/algorithms/overlay/multi_overlay_cases.hpp> @@ -163,6 +168,13 @@ void test_areal_linear() test_one_lp<LineString, LineString, MultiPolygon>("case_mp_ls_3", "LINESTRING(6 6,6 7,7 7,7 6,8 6,8 7,9 7,9 6)", "MULTIPOLYGON(((5 7,5 8,6 8,6 7,5 7)),((6 6,6 7,7 7,7 6,6 6)),((8 8,9 8,9 7,8 7,7 7,7 8,8 8)))", 2, 5, 3.0); + + return; + + // TODO: this case contains collinearities and should still be solved + test_one_lp<LineString, LineString, MultiPolygon>("case_mp_ls_4", + "LINESTRING(0 5,0 6,1 6,1 5,2 5,2 6,3 6,3 5,3 4,3 3,2 3,2 4,1 4,1 3,0 3,0 4)", + "MULTIPOLYGON(((0 2,0 3,1 2,0 2)),((2 5,3 6,3 5,2 5)),((1 5,1 6,2 6,2 5,1 5)),((2 3,2 4,3 4,2 3)),((0 3,1 4,1 3,0 3)),((4 3,3 3,3 5,4 5,4 4,4 3)))", 5, 11, 6.0); } @@ -183,6 +195,7 @@ int test_main(int, char* []) test_all<bg::model::d2::point_xy<double> >(); #ifdef HAVE_TTMATH + std::cout << "Testing TTMATH" << std::endl; test_all<bg::model::d2::point_xy<ttmath_big> >(); #endif diff --git a/libs/geometry/test/multi/algorithms/multi_disjoint.cpp b/libs/geometry/test/multi/algorithms/multi_disjoint.cpp new file mode 100644 index 0000000000..a1b88ce213 --- /dev/null +++ b/libs/geometry/test/multi/algorithms/multi_disjoint.cpp @@ -0,0 +1,123 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2012 Barend Gehrels, 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 <iostream> +#include <string> + + +#include <geometry_test_common.hpp> + +#include <boost/geometry/algorithms/disjoint.hpp> +#include <boost/geometry/io/wkt/read.hpp> +#include <boost/geometry/multi/io/wkt/read.hpp> +#include <boost/geometry/strategies/strategies.hpp> + +#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp> +#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp> +#include <boost/geometry/multi/algorithms/detail/point_on_border.hpp> +#include <boost/geometry/multi/algorithms/detail/for_each_range.hpp> +#include <boost/geometry/multi/algorithms/within.hpp> +#include <boost/geometry/multi/core/closure.hpp> +#include <boost/geometry/multi/core/geometry_id.hpp> +#include <boost/geometry/multi/core/ring_type.hpp> +#include <boost/geometry/multi/views/detail/range_type.hpp> + + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> +#include <boost/geometry/multi/geometries/multi_polygon.hpp> + +#include <test_common/test_point.hpp> + +#include <algorithms/test_relate.hpp> + + +template <typename G1, typename G2> +void test_disjoint(std::string const& id, + std::string const& wkt1, + std::string const& wkt2, bool expected) +{ + G1 g1; + bg::read_wkt(wkt1, g1); + + G2 g2; + bg::read_wkt(wkt2, g2); + + bool detected = bg::disjoint(g1, g2); + BOOST_CHECK_MESSAGE(detected == expected, + "disjoint: " << id + << " -> Expected: " << expected + << " detected: " << detected); +} + + + +template <typename P> +void test_all() +{ + typedef bg::model::polygon<P> polygon; + typedef bg::model::multi_polygon<polygon> mp; + + test_disjoint<mp, mp>("", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))", + false); + + // True disjoint + test_disjoint<mp, mp>("", + "MULTIPOLYGON(((0 0,0 4,4 4,4 0,0 0)))", + "MULTIPOLYGON(((6 6,6 10,10 10,10 6,6 6)))", + true); + + // Touch -> not disjoint + test_disjoint<mp, mp>("", + "MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)))", + "MULTIPOLYGON(((5 5,5 10,10 10,10 5,5 5)))", + false); + + // Not disjoint but no IP's + test_disjoint<mp, mp>("no_ips", + "MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((22 2,28 2,28 8,22 8,22 2)))", + false); + + // Not disjoint and not inside each other (in first ring) but wrapped (in second rings) + test_disjoint<mp, mp>("no_ips2", + "MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))", + "MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))", + false); + + test_disjoint<mp, mp>("no_ips2_rev", + "MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))", + "MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))", + false); +} + +int test_main(int, char* []) +{ + //test_all<bg::model::d2::point_xy<float> >(); + test_all<bg::model::d2::point_xy<double> >(); + +#ifdef HAVE_TTMATH + test_all<bg::model::d2::point_xy<ttmath_big> >(); +#endif + + return 0; +} + + +/* +with viewy as +( +select geometry::STGeomFromText('MULTIPOLYGON(((2 2,2 8,8 8,8 2,2 2)),((20 0,20 10,30 10,30 0,20 0)))',0) as p + , geometry::STGeomFromText('MULTIPOLYGON(((2 12,2 18,8 18,8 12,2 12)),((22 2,28 2,28 8,22 8,22 2)))',0) as q +) + select p from viewy union all select q from viewy +-- select p.STDisjoint(q) from viewy +*/
\ No newline at end of file diff --git a/libs/geometry/test/multi/algorithms/multi_disjoint.vcproj b/libs/geometry/test/multi/algorithms/multi_disjoint.vcproj new file mode 100644 index 0000000000..fb55ab3259 --- /dev/null +++ b/libs/geometry/test/multi/algorithms/multi_disjoint.vcproj @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="multi_disjoint" + ProjectGUID="{5DEA6558-9DF7-42D4-AF10-4D6D8BB7EAD1}" + RootNamespace="multi_disjoint" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\multi_disjoint" + ConfigurationType="1" + InheritedPropertySheets="..\..\boost.vsprops;..\..\ttmath.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="1" + /> + <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)\multi_disjoint" + ConfigurationType="1" + InheritedPropertySheets="..\..\boost.vsprops;..\..\ttmath.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=".\multi_disjoint.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/libs/geometry/test/multi/algorithms/multi_intersection.cpp b/libs/geometry/test/multi/algorithms/multi_intersection.cpp index c6a0efcede..d479f5d115 100644 --- a/libs/geometry/test/multi/algorithms/multi_intersection.cpp +++ b/libs/geometry/test/multi/algorithms/multi_intersection.cpp @@ -212,6 +212,7 @@ int test_main(int, char* []) test_all<bg::model::d2::point_xy<double> >(); #ifdef HAVE_TTMATH + std::cout << "Testing TTMATH" << std::endl; test_all<bg::model::d2::point_xy<ttmath_big> >(); #endif diff --git a/libs/geometry/test/multi/algorithms/multi_touches.cpp b/libs/geometry/test/multi/algorithms/multi_touches.cpp new file mode 100644 index 0000000000..0186c62e30 --- /dev/null +++ b/libs/geometry/test/multi/algorithms/multi_touches.cpp @@ -0,0 +1,80 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2010-2012 Barend Gehrels, 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 <algorithms/test_touches.hpp> + +#include <boost/geometry/multi/algorithms/area.hpp> +#include <boost/geometry/multi/algorithms/num_geometries.hpp> +#include <boost/geometry/multi/algorithms/within.hpp> +#include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp> +#include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp> +#include <boost/geometry/multi/algorithms/detail/for_each_range.hpp> +#include <boost/geometry/multi/core/closure.hpp> +#include <boost/geometry/multi/core/geometry_id.hpp> +#include <boost/geometry/multi/core/ring_type.hpp> +#include <boost/geometry/multi/views/detail/range_type.hpp> + +#include <boost/geometry/geometries/geometries.hpp> +#include <boost/geometry/geometries/point_xy.hpp> +#include <boost/geometry/multi/geometries/multi_polygon.hpp> + +#include <boost/geometry/multi/io/wkt/read.hpp> + + + +template <typename P> +void test_all() +{ + typedef bg::model::polygon<P> polygon; + typedef bg::model::multi_polygon<polygon> mp; + + test_self_touches<mp>("MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))", + false); + + // Exactly equal + test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))", + "MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))", + false); + + // Spatially equal + test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 100,100 100,100 0,0 0)))", + "MULTIPOLYGON(((0 0,0 100,100 100,100 80,100 20,100 0,0 0)))", + false); + + // One exactly equal, another pair touching + test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((30 10,30 20,40 20,40 10,30 10)))", + false); + + // One spatially equal (without equal segments), another pair touching + test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 5,0 10,5 10,10 10,10 5,10 0,5 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))", + "MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((30 10,30 20,40 20,40 10,30 10)))", + false); + + // Alternate touches + test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))", + "MULTIPOLYGON(((10 10,10 20,20 20,20 10,10 10)),((30 10,30 20,40 20,40 10,30 10)))", + true); + + // Touch plus inside + // TODO fix this + test_touches<mp, mp>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0,20 0)))", + "MULTIPOLYGON(((10 10,10 20,20 20,20 10,10 10)),((22 2,28 2,28 8,22 8,22 2)))", + false); +} + +int test_main( int , char* [] ) +{ + test_all<bg::model::d2::point_xy<double> >(); + +#ifdef HAVE_TTMATH + test_all<bg::model::d2::point_xy<ttmath_big> >(); +#endif + + return 0; +} diff --git a/libs/geometry/test/multi/algorithms/multi_touches.vcproj b/libs/geometry/test/multi/algorithms/multi_touches.vcproj new file mode 100644 index 0000000000..05468f6cde --- /dev/null +++ b/libs/geometry/test/multi/algorithms/multi_touches.vcproj @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="multi_touches" + ProjectGUID="{108173B8-B6F4-4366-8018-2BF282ED4881}" + RootNamespace="multi_touches" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)\multi_touches" + ConfigurationType="1" + InheritedPropertySheets="..\..\boost.vsprops;..\..\ttmath.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="1" + /> + <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)\multi_touches" + ConfigurationType="1" + InheritedPropertySheets="..\..\boost.vsprops;..\..\ttmath.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=".\multi_touches.cpp" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/libs/geometry/test/multi/algorithms/multi_union.cpp b/libs/geometry/test/multi/algorithms/multi_union.cpp index e06306254d..ffa694291a 100644 --- a/libs/geometry/test/multi/algorithms/multi_union.cpp +++ b/libs/geometry/test/multi/algorithms/multi_union.cpp @@ -105,7 +105,7 @@ void test_areal() 1, 0, 14, 100.0); // Area from SQL Server test_one<Polygon, MultiPolygon, MultiPolygon>("case_recursive_boxes_3", case_recursive_boxes_3[0], case_recursive_boxes_3[1], - 18, 0, 160, 56.5); // Area from SQL Server + 17, 0, 159, 56.5); // Area from SQL Server } template <typename P> @@ -134,6 +134,7 @@ int test_main(int, char* []) test_all<bg::model::d2::point_xy<double> >(); #ifdef HAVE_TTMATH + std::cout << "Testing TTMATH" << std::endl; test_all<bg::model::d2::point_xy<ttmath_big> >(); #endif diff --git a/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp b/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp index 6c58171042..536aa09531 100644 --- a/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp +++ b/libs/geometry/test/multi/algorithms/overlay/multi_overlay_cases.hpp @@ -293,7 +293,7 @@ static std::string case_100_multi[2] = { // for intersection "MULTIPOLYGON(((0 0,0 1,1 0,0 0)),((2 2,2 1,0 1,0 2,1 2,2 3,2 2)))", - "MULTIPOLYGON(((1 1,1 2,2 2,2 1,1 1)),((1 2,0 1,0 3,1 4,1 2))))" + "MULTIPOLYGON(((1 1,1 2,2 2,2 1,1 1)),((1 2,0 1,0 3,1 4,1 2)))" }; static std::string case_101_multi[2] = |