$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r73179 - in trunk/libs/geometry/test: algorithms algorithms/overlay multi multi/algorithms strategies
From: barend.gehrels_at_[hidden]
Date: 2011-07-17 08:28:22
Author: barendgehrels
Date: 2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
New Revision: 73179
URL: http://svn.boost.org/trac/boost/changeset/73179
Log:
Updated tests reflecting changes for within/covered_by
Added:
   trunk/libs/geometry/test/algorithms/covered_by.cpp   (contents, props changed)
   trunk/libs/geometry/test/algorithms/covered_by.vcproj   (contents, props changed)
   trunk/libs/geometry/test/algorithms/test_covered_by.hpp   (contents, props changed)
   trunk/libs/geometry/test/multi/algorithms/multi_covered_by.cpp   (contents, props changed)
   trunk/libs/geometry/test/multi/algorithms/multi_covered_by.vcproj   (contents, props changed)
Text files modified: 
   trunk/libs/geometry/test/algorithms/Jamfile.v2                              |     1                                         
   trunk/libs/geometry/test/algorithms/algorithms_tests.sln                    |     6 ++                                      
   trunk/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj |     1                                         
   trunk/libs/geometry/test/algorithms/test_within.hpp                         |    22 +------                                 
   trunk/libs/geometry/test/algorithms/within.cpp                              |   120 +++++++++++++++++++++++++++++++-------- 
   trunk/libs/geometry/test/multi/algorithms/Jamfile.v2                        |     1                                         
   trunk/libs/geometry/test/multi/algorithms/multi_within.cpp                  |    12 ++-                                     
   trunk/libs/geometry/test/multi/multi_tests.sln                              |     6 ++                                      
   trunk/libs/geometry/test/strategies/within.cpp                              |    59 +++++++++++++++++++                     
   9 files changed, 180 insertions(+), 48 deletions(-)
Modified: trunk/libs/geometry/test/algorithms/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/test/algorithms/Jamfile.v2	(original)
+++ trunk/libs/geometry/test/algorithms/Jamfile.v2	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -19,6 +19,7 @@
     [ run convex_hull.cpp ]
     [ run correct.cpp ]
     [ run convert.cpp ]
+    [ run covered_by.cpp ]
     [ run difference.cpp ]
     [ run disjoint.cpp ]
     [ run distance.cpp ]
Modified: trunk/libs/geometry/test/algorithms/algorithms_tests.sln
==============================================================================
--- trunk/libs/geometry/test/algorithms/algorithms_tests.sln	(original)
+++ trunk/libs/geometry/test/algorithms/algorithms_tests.sln	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -56,6 +56,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "convert", "convert.vcproj", "{FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "covered_by", "covered_by.vcproj", "{5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -174,6 +176,10 @@
                 {FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}.Debug|Win32.Build.0 = Debug|Win32
                 {FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}.Release|Win32.ActiveCfg = Release|Win32
                 {FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}.Release|Win32.Build.0 = Release|Win32
+		{5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Debug|Win32.Build.0 = Debug|Win32
+		{5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Release|Win32.ActiveCfg = Release|Win32
+		{5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE
Added: trunk/libs/geometry/test/algorithms/covered_by.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/algorithms/covered_by.cpp	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -0,0 +1,149 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright (c) 2007-2011 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_covered_by.hpp>
+
+
+#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+
+
+template <typename P>
+void test_all()
+{
+    /*
+    // trivial case
+    test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true, false);
+
+    // on border/corner
+    test_ring<P>("POINT(0 0)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
+    test_ring<P>("POINT(0 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
+
+    // aligned to segment/vertex
+    test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", true, false);
+    test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", true, false);
+
+    // same polygon, but point on border
+    test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", false, true);
+    test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", false, true);
+
+    // holes
+    test_geometry<P, bg::model::polygon<P> >("POINT(2 2)",
+        "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1))", false);
+
+    */
+
+    typedef bg::model::box<P> box_type;
+
+    test_geometry<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", true);
+    test_geometry<P, box_type>("POINT(0 0)", "BOX(0 0,2 2)", true);
+    test_geometry<P, box_type>("POINT(2 2)", "BOX(0 0,2 2)", true);
+    test_geometry<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", true);
+    test_geometry<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", true);
+    test_geometry<P, box_type>("POINT(3 3)", "BOX(0 0,2 2)", false);
+
+    test_geometry<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
+    test_geometry<box_type, box_type>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
+    test_geometry<box_type, box_type>("BOX(0 0,2 2)", "BOX(0 0,3 3)", true);
+    test_geometry<box_type, box_type>("BOX(1 1,3 3)", "BOX(0 0,3 3)", true);
+    test_geometry<box_type, box_type>("BOX(1 2,3 3)", "BOX(0 0,3 3)", true);
+    test_geometry<box_type, box_type>("BOX(1 1,4 3)", "BOX(0 0,3 3)", false);
+
+
+    /*
+    test_within_code<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", 1);
+    test_within_code<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", 0);
+    test_within_code<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", 0);
+    test_within_code<P, box_type>("POINT(0 3)", "BOX(0 0,2 2)", -1);
+    test_within_code<P, box_type>("POINT(3 3)", "BOX(0 0,2 2)", -1);
+
+    test_within_code<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", 1);
+    test_within_code<box_type, box_type>("BOX(0 1,2 2)", "BOX(0 0,3 3)", 0);
+    test_within_code<box_type, box_type>("BOX(1 0,2 2)", "BOX(0 0,3 3)", 0);
+    test_within_code<box_type, box_type>("BOX(1 1,2 3)", "BOX(0 0,3 3)", 0);
+    test_within_code<box_type, box_type>("BOX(1 1,3 2)", "BOX(0 0,3 3)", 0);
+    test_within_code<box_type, box_type>("BOX(1 1,3 4)", "BOX(0 0,3 3)", -1);
+    */
+}
+
+
+void test_3d()
+{
+    typedef boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian> point_type;
+    typedef boost::geometry::model::box<point_type> box_type;
+    box_type box(point_type(0, 0, 0), point_type(4, 4, 4));
+    BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 2), box), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 4, 2), box), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 4), box), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 5), box), false);
+}
+
+template <typename P1, typename P2>
+void test_mixed_of()
+{
+    typedef boost::geometry::model::polygon<P1> polygon_type1;
+    typedef boost::geometry::model::polygon<P2> polygon_type2;
+    typedef boost::geometry::model::box<P1> box_type1;
+    typedef boost::geometry::model::box<P2> box_type2;
+
+    polygon_type1 poly1, poly2;
+    boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1);
+    boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2);
+
+    box_type1 box1(P1(1, 1), P1(4, 4));
+    box_type2 box2(P2(0, 0), P2(5, 5));
+    P1 p1(3, 3);
+    P2 p2(3, 3);
+
+    BOOST_CHECK_EQUAL(bg::covered_by(p1, poly2), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(p2, poly1), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(p2, box1), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(p1, box2), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(box1, box2), true);
+    BOOST_CHECK_EQUAL(bg::covered_by(box2, box1), false);
+}
+
+
+void test_mixed()
+{
+    // Mixing point types and coordinate types
+    test_mixed_of
+        <
+            boost::geometry::model::d2::point_xy<double>,
+            boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
+        >();
+    test_mixed_of
+        <
+            boost::geometry::model::d2::point_xy<float>,
+            boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
+        >();
+    test_mixed_of
+        <
+            boost::geometry::model::d2::point_xy<int>,
+            boost::geometry::model::d2::point_xy<double>
+        >();
+}
+
+
+int test_main( int , char* [] )
+{
+    test_all<bg::model::d2::point_xy<int> >();
+    test_all<bg::model::d2::point_xy<double> >();
+
+    //test_spherical<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
+
+    test_mixed();
+    test_3d();
+
+
+#if defined(HAVE_TTMATH)
+    test_all<bg::model::d2::point_xy<ttmath_big> >();
+    //test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
+#endif
+
+    return 0;
+}
Added: trunk/libs/geometry/test/algorithms/covered_by.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/algorithms/covered_by.vcproj	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="covered_by"
+	ProjectGUID="{5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}"
+	RootNamespace="covered_by"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)\covered_by"
+			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)\covered_by"
+			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=".\covered_by.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Modified: trunk/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj
==============================================================================
--- trunk/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj	(original)
+++ trunk/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -46,6 +46,7 @@
                                 ExceptionHandling="2"
                                 RuntimeLibrary="1"
                                 UsePrecompiledHeader="0"
+				DebugInformationFormat="1"
                         />
                         <Tool
                                 Name="VCManagedResourceCompilerTool"
Added: trunk/libs/geometry/test/algorithms/test_covered_by.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/algorithms/test_covered_by.hpp	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -0,0 +1,123 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library) 
+// Unit Test
+
+// Copyright (c) 2007-2011 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)
+
+
+#ifndef BOOST_GEOMETRY_TEST_COVERED_BY_HPP
+#define BOOST_GEOMETRY_TEST_COVERED_BY_HPP
+
+
+#include <geometry_test_common.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/algorithms/covered_by.hpp>
+#include <boost/geometry/strategies/strategies.hpp>
+#include <boost/geometry/geometries/ring.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+
+
+template <typename Geometry1, typename Geometry2>
+void test_geometry(std::string const& wkt1,
+        std::string const& wkt2, bool expected)
+{
+    Geometry1 geometry1;
+    Geometry2 geometry2;
+
+    bg::read_wkt(wkt1, geometry1);
+    bg::read_wkt(wkt2, geometry2);
+
+    bool detected = bg::covered_by(geometry1, geometry2);
+
+    BOOST_CHECK_MESSAGE(detected == expected,
+        "covered_by: " << wkt1
+        << " in " << wkt2
+        << " -> Expected: " << expected
+        << " detected: " << detected);
+}
+
+/*
+
+template <typename Point, bool Clockwise, bool Closed>
+void test_ordered_ring(std::string const& wkt_point,
+        std::string const& wkt_geometry, bool expected)
+{
+    typedef bg::model::ring<Point, Clockwise, Closed> ring_type;
+    ring_type ring;
+    Point point;
+
+    bg::read_wkt(wkt_geometry, ring);
+    if (! Clockwise)
+    {
+        std::reverse(boost::begin(ring), boost::end(ring));
+    }
+    if (! Closed)
+    {
+        ring.resize(ring.size() - 1);
+    }
+
+    bg::read_wkt(wkt_point, point);
+
+    bool detected = bg::covered_by(point, ring);
+
+    BOOST_CHECK_MESSAGE(detected == expected,
+        "covered_by: " << wkt_point
+        << " in " << wkt_geometry
+        << " -> Expected: " << expected
+        << " detected: " << detected
+        << " clockwise: " << int(Clockwise)
+        << " closed: " << int(Closed)
+        );
+
+    // other strategy (note that this one cannot detect OnBorder
+    // (without modifications)
+
+    bg::strategy::covered_by::franklin<Point> franklin;
+    detected = bg::covered_by(point, ring, franklin);
+    if (! on_border)
+    {
+        BOOST_CHECK_MESSAGE(detected == expected,
+            "covered_by: " << wkt_point
+            << " in " << wkt_geometry
+            << " -> Expected: " << expected
+            << " detected: " << detected
+            << " clockwise: " << int(Clockwise)
+            << " closed: " << int(Closed)
+            );
+    }
+
+
+    bg::strategy::covered_by::crossings_multiply<Point> cm;
+    detected = bg::covered_by(point, ring, cm);
+    if (! on_border)
+    {
+        BOOST_CHECK_MESSAGE(detected == expected,
+            "covered_by: " << wkt_point
+            << " in " << wkt_geometry
+            << " -> Expected: " << expected
+            << " detected: " << detected
+            << " clockwise: " << int(Clockwise)
+            << " closed: " << int(Closed)
+            );
+    }
+}
+
+template <typename Point>
+void test_ring(std::string const& wkt_point,
+        std::string const& wkt_geometry,
+        bool expected)
+{
+    test_ordered_ring<Point, true, true>(wkt_point, wkt_geometry, expected);
+    test_ordered_ring<Point, false, true>(wkt_point, wkt_geometry, expected);
+    test_ordered_ring<Point, true, false>(wkt_point, wkt_geometry, expected);
+    test_ordered_ring<Point, false, false>(wkt_point, wkt_geometry, expected);
+    test_geometry<Point, bg::model::polygon<Point> >(wkt_point, wkt_geometry, expected);
+}
+*/
+
+#endif
Modified: trunk/libs/geometry/test/algorithms/test_within.hpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/test_within.hpp	(original)
+++ trunk/libs/geometry/test/algorithms/test_within.hpp	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -21,6 +21,10 @@
 
 #include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
 
+#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
+#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
+
 
 template <typename Geometry1, typename Geometry2>
 void test_geometry(std::string const& wkt1,
@@ -41,24 +45,6 @@
         << " detected: " << detected);
 }
 
-template <typename Geometry1, typename Geometry2>
-void test_within_code(std::string const& wkt1,
-        std::string const& wkt2, int expected)
-{
-    Geometry1 geometry1;
-    Geometry2 geometry2;
-
-    bg::read_wkt(wkt1, geometry1);
-    bg::read_wkt(wkt2, geometry2);
-
-    int detected = bg::detail::within_code(geometry1, geometry2);
-
-    BOOST_CHECK_MESSAGE(detected == expected,
-        "within_code: " << wkt1
-        << " in " << wkt2
-        << " -> Expected: " << expected
-        << " detected: " << detected);
-}
 
 
 template <typename Point, bool Clockwise, bool Closed>
Modified: trunk/libs/geometry/test/algorithms/within.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/within.cpp	(original)
+++ trunk/libs/geometry/test/algorithms/within.cpp	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -37,10 +37,15 @@
     typedef bg::model::box<P> box_type;
 
     test_geometry<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", true);
+    test_geometry<P, box_type>("POINT(0 0)", "BOX(0 0,2 2)", false);
+    test_geometry<P, box_type>("POINT(2 2)", "BOX(0 0,2 2)", false);
+    test_geometry<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", false);
+    test_geometry<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", false);
 
     test_geometry<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
     test_geometry<box_type, box_type>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
 
+    /*
     test_within_code<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", 1);
     test_within_code<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", 0);
     test_within_code<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", 0);
@@ -53,15 +58,7 @@
     test_within_code<box_type, box_type>("BOX(1 1,2 3)", "BOX(0 0,3 3)", 0);
     test_within_code<box_type, box_type>("BOX(1 1,3 2)", "BOX(0 0,3 3)", 0);
     test_within_code<box_type, box_type>("BOX(1 1,3 4)", "BOX(0 0,3 3)", -1);
-
-
-    // Mixed point types
-    test_geometry
-        <
-            bg::model::d2::point_xy<float>,
-            bg::model::polygon<P>
-        >("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
-
+    */
 
     // Real-life problem (solved now), point is in the middle, 409623 is also a coordinate
     // on the border, has been wrong in the past (2009)
@@ -119,46 +116,119 @@
     BOOST_CHECK_EQUAL(bg::within(Point(7, 52.5), triangle), true);
     BOOST_CHECK_EQUAL(bg::within(Point(8.0, 51.5), triangle), false);
     BOOST_CHECK_EQUAL(bg::within(Point(6.0, 51.0), triangle), false);
+
+    // Test spherical boxes
+    // See also http://www.gcmap.com/mapui?P=1E45N-19E45N-19E55N-1E55N-1E45N,10E55.1N,10E45.1N
+    bg::model::box<Point> box;
+    bg::read_wkt("POLYGON((1 45,19 55))", box);
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 55.1), box), true);
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 55.2), box), true);
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 55.3), box), true);
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 55.4), box), false);
+
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 45.1), box), false);
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 45.2), box), false);
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 45.3), box), false);
+    BOOST_CHECK_EQUAL(bg::within(Point(10, 45.4), box), true);
+
+    // Crossing the dateline (Near Tuvalu)
+    // http://www.gcmap.com/mapui?P=178E10S-178W10S-178W6S-178E6S-178E10S,180W5.999S,180E9.999S
+    // http://en.wikipedia.org/wiki/Tuvalu
+
+    bg::model::box<Point> tuvalu(Point(178, -10), Point(-178, -6));
+    BOOST_CHECK_EQUAL(bg::within(Point(180, -8), tuvalu), true);
+    BOOST_CHECK_EQUAL(bg::within(Point(-180, -8), tuvalu), true);
+    BOOST_CHECK_EQUAL(bg::within(Point(180, -5.999), tuvalu), false);
+    BOOST_CHECK_EQUAL(bg::within(Point(180, -10.001), tuvalu), true);
 }
 
-void test_mixed()
+void test_3d()
 {
-    typedef boost::geometry::model::d2::point_xy<double> point_type1;
-    typedef boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian> point_type2;
+    typedef boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian> point_type;
+    typedef boost::geometry::model::box<point_type> box_type;
+    box_type box(point_type(0, 0, 0), point_type(4, 4, 4));
+    BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 2), box), true);
+    BOOST_CHECK_EQUAL(bg::within(point_type(2, 4, 2), box), false);
+    BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 4), box), false);
+    BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 5), box), false);
+}
 
-    typedef boost::geometry::model::polygon<point_type1> polygon_type1;
-    typedef boost::geometry::model::polygon<point_type2> polygon_type2;
-    typedef boost::geometry::model::box<point_type1> box_type1;
-    typedef boost::geometry::model::box<point_type2> box_type2;
+template <typename P1, typename P2>
+void test_mixed_of()
+{
+    typedef boost::geometry::model::polygon<P1> polygon_type1;
+    typedef boost::geometry::model::polygon<P2> polygon_type2;
+    typedef boost::geometry::model::box<P1> box_type1;
+    typedef boost::geometry::model::box<P2> box_type2;
 
-    polygon_type1 poly1;
+    polygon_type1 poly1, poly2;
     boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1);
-    polygon_type2 poly2;
     boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2);
-    
-    box_type1 box1(point_type1(1, 1), point_type1(4, 4));
-    box_type2 box2(point_type2(0, 0), point_type2(5, 5));
 
-    point_type1 p1(3, 3);
-    point_type2 p2(3, 3);
+    box_type1 box1(P1(1, 1), P1(4, 4));
+    box_type2 box2(P2(0, 0), P2(5, 5));
+    P1 p1(3, 3);
+    P2 p2(3, 3);
 
     BOOST_CHECK_EQUAL(bg::within(p1, poly2), true);
     BOOST_CHECK_EQUAL(bg::within(p2, poly1), true);
     BOOST_CHECK_EQUAL(bg::within(p2, box1), true);
     BOOST_CHECK_EQUAL(bg::within(p1, box2), true);
     BOOST_CHECK_EQUAL(bg::within(box1, box2), true);
+    BOOST_CHECK_EQUAL(bg::within(box2, box1), false);
 }
 
 
-int test_main( int , char* [] )
+void test_mixed()
 {
-    test_mixed();
+    // Mixing point types and coordinate types
+    test_mixed_of
+        <
+            boost::geometry::model::d2::point_xy<double>,
+            boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
+        >();
+    test_mixed_of
+        <
+            boost::geometry::model::d2::point_xy<float>,
+            boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
+        >();
+    test_mixed_of
+        <
+            boost::geometry::model::d2::point_xy<int>,
+            boost::geometry::model::d2::point_xy<double>
+        >();
+}
+
+void test_strategy()
+{
+    // Test by explicitly specifying a strategy
+    typedef bg::model::d2::point_xy<double> point_type;
+    typedef bg::model::box<point_type> box_type;
+    point_type p(3, 3);
+    box_type b(point_type(0, 0), point_type(5, 5));
+
+    bool r = bg::within(p, b, 
+        bg::strategy::within::point_in_box<point_type, box_type>());
+
+    r = bg::within(b, b, 
+        bg::strategy::within::box_in_box<box_type, box_type>());
 
+    r = bg::within(p, b, 
+        bg::strategy::within::point_in_box_by_side<point_type, box_type>());
+}
+
+
+int test_main( int , char* [] )
+{
     test_all<bg::model::d2::point_xy<int> >();
     test_all<bg::model::d2::point_xy<double> >();
 
     test_spherical<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
 
+    test_mixed();
+    test_3d();
+    test_strategy();
+
 
 #if defined(HAVE_TTMATH)
     test_all<bg::model::d2::point_xy<ttmath_big> >();
Modified: trunk/libs/geometry/test/multi/algorithms/Jamfile.v2
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/Jamfile.v2	(original)
+++ trunk/libs/geometry/test/multi/algorithms/Jamfile.v2	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -14,6 +14,7 @@
     [ run multi_centroid.cpp ]
     [ run multi_convex_hull.cpp ]
     [ run multi_correct.cpp ]
+    [ run multi_covered_by.cpp ]
     [ run multi_difference.cpp ]
     [ run multi_envelope.cpp ]
     [ run multi_equals.cpp ]
Added: trunk/libs/geometry/test/multi/algorithms/multi_covered_by.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/multi/algorithms/multi_covered_by.cpp	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -0,0 +1,58 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright (c) 2007-2011 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 <geometry_test_common.hpp>
+
+#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
+
+#include <boost/geometry/algorithms/correct.hpp>
+#include <boost/geometry/algorithms/covered_by.hpp>
+
+#include <boost/geometry/geometries/box.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+
+#include <boost/geometry/multi/core/point_order.hpp>
+#include <boost/geometry/multi/algorithms/covered_by.hpp>
+
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/multi/geometries/multi_polygon.hpp>
+
+#include <algorithms/test_covered_by.hpp>
+
+
+template <typename P>
+void test_all()
+{
+    typedef bg::model::multi_polygon<bg::model::polygon<P> > mp;
+
+    // test multi-with-one-polygon (trivial case)
+    test_geometry<P, mp>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
+    test_geometry<P, mp>("POINT(3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
+    test_geometry<P, mp>("POINT(0 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
+    test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
+
+    // test if it is in one of them
+    std::string multi("MULTIPOLYGON("
+        "((0 0,0 2,2 2,2 0,0 0))"
+        "((3 3,3 6,6 6,6 3,3 3))"
+        ")");
+    test_geometry<P, mp>("POINT(4 4)", multi, true);
+    test_geometry<P, mp>("POINT(1 1)", multi, true);
+    test_geometry<P, mp>("POINT(0 1)", multi, true);
+}
+
+int test_main( int , char* [] )
+{
+    //test_all<bg::model::d2::point_xy<int> >();
+    test_all<bg::model::d2::point_xy<double> >();
+
+#if defined(HAVE_TTMATH)
+    test_all<bg::model::d2::point_xy<ttmath_big> >();
+#endif
+
+    return 0;
+}
Added: trunk/libs/geometry/test/multi/algorithms/multi_covered_by.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/geometry/test/multi/algorithms/multi_covered_by.vcproj	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="multi_covered_by"
+	ProjectGUID="{680E56F0-229C-4377-BDC0-80EB9B59314B}"
+	RootNamespace="multi_covered_by"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)\multi_covered_by"
+			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_covered_by"
+			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_covered_by.cpp"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Modified: trunk/libs/geometry/test/multi/algorithms/multi_within.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/multi_within.cpp	(original)
+++ trunk/libs/geometry/test/multi/algorithms/multi_within.cpp	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -29,16 +29,20 @@
 {
     typedef bg::model::multi_polygon<bg::model::polygon<P> > mp;
 
-    // trivial cases
+    // test multi-with-one-polygon (trivial case)
     test_geometry<P, mp>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
     test_geometry<P, mp>("POINT(3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
+    test_geometry<P, mp>("POINT(0 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
+    test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
 
     // test if it is in one of them
-    test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON("
+    std::string multi("MULTIPOLYGON("
         "((0 0,0 2,2 2,2 0,0 0))"
         "((3 3,3 6,6 6,6 3,3 3))"
-        ")",
-        true);
+        ")");
+    test_geometry<P, mp>("POINT(4 4)", multi, true);
+    test_geometry<P, mp>("POINT(1 1)", multi, true);
+    test_geometry<P, mp>("POINT(0 1)", multi, false);
 }
 
 int test_main( int , char* [] )
Modified: trunk/libs/geometry/test/multi/multi_tests.sln
==============================================================================
--- trunk/libs/geometry/test/multi/multi_tests.sln	(original)
+++ trunk/libs/geometry/test/multi/multi_tests.sln	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -42,6 +42,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_transform", "algorithms\multi_transform.vcproj", "{64985954-0A74-46F5-908F-865E905C3414}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_covered_by", "algorithms\multi_covered_by.vcproj", "{680E56F0-229C-4377-BDC0-80EB9B59314B}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -132,6 +134,10 @@
                 {64985954-0A74-46F5-908F-865E905C3414}.Debug|Win32.Build.0 = Debug|Win32
                 {64985954-0A74-46F5-908F-865E905C3414}.Release|Win32.ActiveCfg = Release|Win32
                 {64985954-0A74-46F5-908F-865E905C3414}.Release|Win32.Build.0 = Release|Win32
+		{680E56F0-229C-4377-BDC0-80EB9B59314B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{680E56F0-229C-4377-BDC0-80EB9B59314B}.Debug|Win32.Build.0 = Debug|Win32
+		{680E56F0-229C-4377-BDC0-80EB9B59314B}.Release|Win32.ActiveCfg = Release|Win32
+		{680E56F0-229C-4377-BDC0-80EB9B59314B}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE
Modified: trunk/libs/geometry/test/strategies/within.cpp
==============================================================================
--- trunk/libs/geometry/test/strategies/within.cpp	(original)
+++ trunk/libs/geometry/test/strategies/within.cpp	2011-07-17 08:28:21 EDT (Sun, 17 Jul 2011)
@@ -11,16 +11,21 @@
 
 #include <geometry_test_common.hpp>
 
+#include <boost/geometry/algorithms/covered_by.hpp>
 #include <boost/geometry/algorithms/within.hpp>
 
 #include <boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp>
 #include <boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp>
 #include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
+#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
+#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
 
 #include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
 
 
 #include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
 #include <boost/geometry/geometries/polygon.hpp>
 
 #include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
@@ -36,7 +41,7 @@
             Strategy const& strategy, std::string const& strategy_id,
             bool expected)
 {
-    BOOST_CONCEPT_ASSERT( (bg::concept::WithinStrategy<Strategy>) );
+    BOOST_CONCEPT_ASSERT( (bg::concept::WithinStrategyPolygonal<Strategy>) );
     bool detected = bg::within(point, polygon, strategy);
 
     BOOST_CHECK_MESSAGE(detected == expected,
@@ -68,11 +73,63 @@
         "cross.mult", boost::contains(deviations, "c") ? !expected : expected);
 }
 
+template <typename Point>
+void test_box_of(std::string const& wkt_point, std::string const& wkt_box, 
+              bool expected_within, bool expected_covered_by)
+{
+    typedef bg::model::box<Point> box_type;
+
+    Point point;
+    box_type box;
+    bg::read_wkt(wkt_point, point);
+    bg::read_wkt(wkt_box, box);
+
+    bool detected_within = bg::within(point, box);
+    bool detected_covered_by = bg::covered_by(point, box);
+    BOOST_CHECK_EQUAL(detected_within, expected_within);
+    BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+
+    // Also test with the non-default agnostic side version
+    namespace wi = bg::strategy::within;
+    wi::point_in_box_by_side<Point, box_type> within_strategy;
+    wi::point_in_box_by_side<Point, box_type, wi::decide_covered_by> covered_by_strategy;
+
+    detected_within = bg::within(point, box, within_strategy);
+    detected_covered_by = bg::covered_by(point, box, covered_by_strategy);
+    BOOST_CHECK_EQUAL(detected_within, expected_within);
+    BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+
+    // We might exchange strategies between within/covered by.
+    // So the lines below might seem confusing, but are as intended
+    detected_within = bg::covered_by(point, box, within_strategy);
+    detected_covered_by = bg::within(point, box, covered_by_strategy);
+    BOOST_CHECK_EQUAL(detected_within, expected_within);
+    BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+
+    // Finally we call the strategies directly
+    detected_within = within_strategy.apply(point, box);
+    detected_covered_by = covered_by_strategy.apply(point, box);
+    BOOST_CHECK_EQUAL(detected_within, expected_within);
+    BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+}
+
+template <typename Point>
+void test_box()
+{
+    test_box_of<Point>("POINT(1 1)", "BOX(0 0,2 2)", true, true);
+    test_box_of<Point>("POINT(0 0)", "BOX(0 0,2 2)", false, true);
+    test_box_of<Point>("POINT(2 2)", "BOX(0 0,2 2)", false, true);
+    test_box_of<Point>("POINT(0 1)", "BOX(0 0,2 2)", false, true);
+    test_box_of<Point>("POINT(1 0)", "BOX(0 0,2 2)", false, true);
+    test_box_of<Point>("POINT(3 3)", "BOX(0 0,2 2)", false, false);
+}
 
 
 template <typename Point>
 void test_all()
 {
+    test_box<Point>();
+
     typedef bg::model::polygon<Point> polygon;
 
     std::string const box = "POLYGON((0 0,0 2,2 2,2 0,0 0))";