|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69944 - in trunk/libs/geometry/test: algorithms/detail algorithms/detail/sections multi/algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-03-13 10:48:02
Author: barendgehrels
Date: 2011-03-13 10:48:00 EDT (Sun, 13 Mar 2011)
New Revision: 69944
URL: http://svn.boost.org/trac/boost/changeset/69944
Log:
Updates in test for partition addition
Text files modified:
trunk/libs/geometry/test/algorithms/detail/partition.cpp | 107 +++++++++++++++++++++++++++++++++++----
trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.cpp | 5 +
trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.sln | 1
trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp | 2
4 files changed, 99 insertions(+), 16 deletions(-)
Modified: trunk/libs/geometry/test/algorithms/detail/partition.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/detail/partition.cpp (original)
+++ trunk/libs/geometry/test/algorithms/detail/partition.cpp 2011-03-13 10:48:00 EDT (Sun, 13 Mar 2011)
@@ -12,19 +12,22 @@
#include <boost/range/algorithm/copy.hpp>
#include <boost/geometry/geometry.hpp>
+#include <boost/geometry/multi/geometries/multi_point.hpp>
+#include <boost/geometry/geometries/register/point.hpp>
+
#include <boost/geometry/algorithms/detail/overlay/select_rings.hpp>
#include <boost/geometry/algorithms/detail/overlay/assign_parents.hpp>
#include <boost/geometry/algorithms/detail/partition.hpp>
-#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
template <typename Box>
-struct sample_item
+struct box_item
{
int id;
Box box;
- sample_item(int i = 0, std::string const& wkt = "")
+ box_item(int i = 0, std::string const& wkt = "")
: id(i)
{
if (! wkt.empty())
@@ -55,12 +58,12 @@
template <typename Box>
-struct sample_visitor
+struct box_visitor
{
int count;
typename bg::area_result<Box>::type area;
- sample_visitor()
+ box_visitor()
: count(0)
, area(0)
{}
@@ -81,13 +84,13 @@
template <typename Box>
-void test_geometry(std::string const& wkt_box_list, double expected_area, int expected_count)
+void test_boxes(std::string const& wkt_box_list, double expected_area, int expected_count)
{
std::vector<std::string> wkt_boxes;
boost::split(wkt_boxes, wkt_box_list, boost::is_any_of(";"), boost::token_compress_on);
- typedef sample_item<Box> sample;
+ typedef box_item<Box> sample;
std::vector<sample> boxes;
int index = 1;
@@ -96,11 +99,11 @@
boxes.push_back(sample(index++, wkt));
}
- sample_visitor<Box> visitor;
+ box_visitor<Box> visitor;
bg::partition
<
Box, get_box, ovelaps_box
- >::apply(boxes, visitor);
+ >::apply(boxes, visitor, 1);
BOOST_CHECK_CLOSE(visitor.area, expected_area, 0.001);
BOOST_CHECK_EQUAL(visitor.count, expected_count);
@@ -108,27 +111,107 @@
+struct point_item
+{
+ point_item()
+ : id(0)
+ {}
+
+ int id;
+ double x;
+ double y;
+};
+
+BOOST_GEOMETRY_REGISTER_POINT_2D(point_item, double, cs::cartesian, x, y)
+
+
+struct get_point
+{
+ template <typename Box, typename InputItem>
+ static inline void apply(Box& total, InputItem const& item)
+ {
+ bg::expand(total, item);
+ }
+};
+
+struct ovelaps_point
+{
+ template <typename Box, typename InputItem>
+ static inline bool apply(Box const& box, InputItem const& item)
+ {
+ return ! bg::disjoint(item, box);
+ }
+};
+
+
+struct point_visitor
+{
+ int count;
+
+ point_visitor()
+ : count(0)
+ {}
+
+ template <typename Item>
+ inline void apply(Item const& item1, Item const& item2)
+ {
+ if (bg::equals(item1, item2))
+ {
+ count++;
+ }
+ }
+};
+
+
+
+void test_points(std::string const& wkt1, std::string const& wkt2, int expected_count)
+{
+ bg::model::multi_point<point_item> mp1, mp2;
+ bg::read_wkt(wkt1, mp1);
+ bg::read_wkt(wkt2, mp2);
+
+ int id = 1;
+ BOOST_FOREACH(point_item& p, mp1)
+ { p.id = id++; }
+ id = 1;
+ BOOST_FOREACH(point_item& p, mp2)
+ { p.id = id++; }
+
+ point_visitor visitor;
+ bg::partition
+ <
+ bg::model::box<point_item>, get_point, ovelaps_point
+ >::apply(mp1, mp2, visitor, 1);
+
+ BOOST_CHECK_EQUAL(visitor.count, expected_count);
+}
+
+
template <typename P>
void test_all()
{
typedef bg::model::box<P> box;
- test_geometry<box>(
+ test_boxes<box>(
// 1 2 3 4 5 6 7
"box(0 0,1 1); box(0 0,2 2); box(9 9,10 10); box(8 8,9 9); box(4 4,6 6); box(2 4,6 8); box(7 1,8 2)",
5, // Area(Intersection(1,2)) + A(I(5,6))
3);
- test_geometry<box>(
+ test_boxes<box>(
"box(0 0,10 10); box(4 4,6 6); box(3 3,7 7)",
4 + 16 + 4, // A(I(1,2)) + A(I(1,3)) + A(I(2,3))
3);
- test_geometry<box>(
+ test_boxes<box>(
"box(0 2,10 3); box(3 1,4 5); box(7 1,8 5)",
1 + 1, // A(I(1,2)) + A(I(1,3))
2);
+
+ test_points("multipoint((1 1))", "multipoint((1 1))", 1);
+ test_points("multipoint((0 0),(1 1),(7 3),(10 10))", "multipoint((1 1),(2 2),(7 3))", 2);
+
}
Modified: trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.cpp
==============================================================================
--- trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.cpp (original)
+++ trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.cpp 2011-03-13 10:48:00 EDT (Sun, 13 Mar 2011)
@@ -51,13 +51,14 @@
Geometry geometry;
geometry.push_back(bg::make<point_type>(1, 1));
+ bg::ring_identifier ring_id;
int index = 0;
int ndi = 0;
- sectionalize_part::apply(sections, section, index, ndi, geometry);
+ sectionalize_part::apply(sections, section, index, ndi, geometry, ring_id);
// There should not yet be anything generated, because it is only ONE point
geometry.push_back(bg::make<point_type>(2, 2));
- sectionalize_part::apply(sections, section, index, ndi, geometry);
+ sectionalize_part::apply(sections, section, index, ndi, geometry, ring_id);
}
Modified: trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.sln
==============================================================================
--- trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.sln (original)
+++ trunk/libs/geometry/test/algorithms/detail/sections/sectionalize.sln 2011-03-13 10:48:00 EDT (Sun, 13 Mar 2011)
@@ -1,4 +1,3 @@
-
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sectionalize", "sectionalize.vcproj", "{50410F81-7B83-49D9-BDAE-FA3F0ADB2ADC}"
Modified: trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp
==============================================================================
--- trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp (original)
+++ trunk/libs/geometry/test/multi/algorithms/multi_intersection.cpp 2011-03-13 10:48:00 EDT (Sun, 13 Mar 2011)
@@ -73,7 +73,7 @@
5, 33, 9);
test_one<Polygon, MultiPolygon, MultiPolygon>("case_78_multi",
case_78_multi[0], case_78_multi[1],
- 1, 17, 22);
+ 1, 16, 22); // In "get_turns" using partitioning, #points went from 17 to 16
test_one<Polygon, MultiPolygon, MultiPolygon>("case_101_multi",
case_101_multi[0], case_101_multi[1],
4, 22, 4.75);
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