Merge branch 'develop' of github.com:boostorg/geometry into develop

This commit is contained in:
Adam Wulkiewicz
2014-07-19 23:00:31 +02:00
63 changed files with 1667 additions and 671 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -3,7 +3,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Chapter&#160;1.&#160;Geometry</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="index.html" title="Chapter&#160;1.&#160;Geometry">
<link rel="next" href="geometry/introduction.html" title="Introduction">
</head>
@@ -100,12 +100,12 @@
</div>
<h3>
<a name="geometry.h0"></a>
<span><a name="geometry.contributions"></a></span><a class="link" href="index.html#geometry.contributions">Contributions</a>
<span class="phrase"><a name="geometry.contributions"></a></span><a class="link" href="index.html#geometry.contributions">Contributions</a>
</h3>
<p>
Boost.Geometry contains contributions by:
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Akira Takahashi (adaption of Boost.Fusion)
</li>
@@ -124,10 +124,14 @@
<li class="listitem">
Mats Taraldsvik (documentation: adapting a legacy model)
</li>
<li class="listitem">
Samuel Debionne (variant support for distance, assign, crosses, intersection,
...)
</li>
</ul></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: May 07, 2014 at 10:12:25 GMT</small></p></td>
<td align="left"><p><small>Last revised: July 17, 2014 at 20:45:09 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@@ -20,6 +20,7 @@
[import src/examples/algorithms/assign_3d_point.cpp]
[import src/examples/algorithms/assign_inverse.cpp]
[import src/examples/algorithms/assign_points.cpp]
[import src/examples/algorithms/buffer_with_strategies.cpp]
[import src/examples/algorithms/clear.cpp]
[import src/examples/algorithms/centroid.cpp]
[import src/examples/algorithms/comparable_distance.cpp]
@@ -82,7 +83,10 @@
[import src/examples/geometries/adapted/c_array.cpp]
[import src/examples/geometries/adapted/boost_array.cpp]
[import src/examples/geometries/adapted/boost_fusion.cpp]
[import src/examples/geometries/adapted/boost_polygon.cpp]
[import src/examples/geometries/adapted/boost_polygon_box.cpp]
[import src/examples/geometries/adapted/boost_polygon_point.cpp]
[import src/examples/geometries/adapted/boost_polygon_polygon.cpp]
[import src/examples/geometries/adapted/boost_polygon_ring.cpp]
[import src/examples/geometries/adapted/boost_tuple.cpp]
[import src/examples/geometries/adapted/boost_range/filtered.cpp]
@@ -110,5 +114,8 @@
[import src/examples/io/wkt.cpp]
[import src/examples/io/read_wkt.cpp]
[import src/examples/strategies/buffer_circle.cpp]
[import src/examples/strategies/buffer_square.cpp]
[import src/examples/views/box_view.cpp]
[import src/examples/views/segment_view.cpp]

View File

@@ -14,5 +14,6 @@
[import src/examples/rtree/variants_map.cpp]
[import src/examples/rtree/value_shared_ptr.cpp]
[import src/examples/rtree/value_index.cpp]
[import src/examples/rtree/iterative_query.cpp]
[import src/examples/rtree/interprocess.cpp]
[import src/examples/rtree/mapped_file.cpp]

View File

@@ -46,6 +46,12 @@
[include ../src/examples/rtree/value_index_results.qbk]
[endsect]
[section Iterative query]
[rtree_iterative_query]
[h4 Expected results]
[include ../src/examples/rtree/iterative_query.qbk]
[endsect]
[section Index stored in shared memory using Boost.Interprocess]
[rtree_interprocess]
[h4 Expected results]

View File

@@ -6,12 +6,13 @@
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
exe quick_start : quick_start.cpp ;
exe polygons_vector : polygons_vector.cpp ;
exe iterative_query : iterative_query.cpp ;
exe polygons_shared_ptr : polygons_shared_ptr.cpp ;
exe variants_map : variants_map.cpp ;
exe value_shared_ptr : value_shared_ptr.cpp ;
exe polygons_vector : polygons_vector.cpp ;
exe quick_start : quick_start.cpp ;
exe value_index : value_index.cpp ;
exe value_shared_ptr : value_shared_ptr.cpp ;
exe variants_map : variants_map.cpp ;
exe interprocess : interprocess.cpp /boost/thread//boost_thread
:

View File

@@ -0,0 +1,65 @@
// Boost.Geometry Index
//
// Quickbook Examples
//
// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
//
// 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)
//[rtree_iterative_query
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/index/rtree.hpp>
// just for output
#include <iostream>
namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;
int main(void)
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point;
typedef point value;
typedef bgi::rtree< value, bgi::linear<16> > rtree_t;
// create the rtree using default constructor
rtree_t rtree;
// create some values
for ( double f = 0 ; f < 10 ; f += 1 )
{
// insert new value
rtree.insert(point(f, f));
}
// query point
point pt(5.1, 5.1);
// iterate over nearest Values
for ( rtree_t::const_query_iterator
it = rtree.qbegin(bgi::nearest(pt, 100)) ;
it != rtree.qend() ;
++it )
{
double d = bg::distance(pt, *it);
std::cout << bg::wkt(*it) << ", distance= " << d << std::endl;
// break if the distance is too big
if ( d > 2 )
{
std::cout << "break!" << std::endl;
break;
}
}
return 0;
}
//]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry Index
Copyright (c) 2011-2014 Adam Wulkiewicz.
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)
=============================================================================/]
POINT(5 5), distance= 0.141421
POINT(6 6), distance= 1.27279
POINT(4 4), distance= 1.55563
POINT(7 7), distance= 2.68701
break!

View File

@@ -115,6 +115,7 @@ strategies = ["distance::pythagoras", "distance::pythagoras_box_box"
, "distance::cross_track", "distance::projected_point"
, "within::winding", "within::franklin", "within::crossings_multiply"
, "area::surveyor", "area::huiller"
, "buffer::buffer_circle", "buffer::buffer_square"
, "centroid::bashein_detmer", "centroid::average"
, "convex_hull::graham_andrew"
, "simplify::douglas_peucker"

View File

@@ -487,13 +487,12 @@
-->
<!-- ###### STRATEGIES ######################################################################### -->
<tgroup cols="3">
<tgroup cols="2">
<colspec colname="a"/>
<colspec colname="b"/>
<colspec colname="c"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="c">
<entry valign="center" namest="a" nameend="b">
<bridgehead renderas="sect2">Strategies</bridgehead>
</entry>
</row>
@@ -630,6 +629,37 @@
</row>
</tbody>
</tgroup>
<!-- ###### IO ########################################################################### -->
<tgroup cols="2">
<colspec colname="a"/>
<colspec colname="b"/>
<thead>
<row>
<entry valign="center" namest="a" nameend="b">
<bridgehead renderas="sect2">IO</bridgehead>
</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top">
<bridgehead renderas="sect3">WKT (Well-Known Text)</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.io.wkt.read_wkt">read_wkt</link></member>
<member><link linkend="geometry.reference.io.wkt.wkt">wkt</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">SVG (Scalable Vector Graphics)</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.io.svg.svg">svg</link></member>
<member><link linkend="geometry.reference.io.svg.svg_mapper">svg_mapper</link></member>
</simplelist>
</entry>
</row>
</tbody>
</tgroup>
<!-- ###### SPATIAL INDEXES ######################################################################### -->
<tgroup cols="3">

View File

@@ -4,7 +4,7 @@
Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Copyright (c) 2009-2012 Bruno Lalande, Paris, France.
Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
Use, modification and distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -230,6 +230,7 @@
[section:io IO (input/output)]
[section:wkt WKT (Well-Known Text)]
[include reference/io/wkt_format.qbk]
[include generated/wkt.qbk]
[endsect]
[section:svg SVG (Scalable Vector Graphics)]
@@ -299,6 +300,8 @@
[include generated/distance_cross_track.qbk]
[include generated/area_surveyor.qbk]
[include generated/area_huiller.qbk]
[include generated/buffer_buffer_circle.qbk]
[include generated/buffer_buffer_square.qbk]
[include generated/centroid_average.qbk]
[include generated/centroid_bashein_detmer.qbk]
[include generated/convex_hull_graham_andrew.qbk]

View File

@@ -0,0 +1,29 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
Copyright (c) 2014 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)
=============================================================================/]
[def __this_function__ buffer]
[heading_conformance_ogc __this_function__..Buffer]
[heading Examples]
[buffer_with_strategies]
[heading The linestring case]
[$img/algorithms/buffer_linestring.png]
[heading The multi_point case]
[$img/algorithms/buffer_multi_point.png]
[heading The multi_polygon case]
[$img/algorithms/buffer_multi_polygon.png]
[heading Available Strategies]
* PointStrategy: [link geometry.reference.strategies.strategy_buffer_buffer_circle Circle (cartesian)]
* PointStrategy: [link geometry.reference.strategies.strategy_buffer_buffer_square Square (cartesian)]

View File

@@ -1,9 +1,10 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
Use, modification and distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -29,8 +30,8 @@ algorithms from both Boost.Polygon and Boost.Geometry can be called.
__not_in_boost_geometry_hpp__
[heading Example]
[boost_polygon]
[boost_polygon_output]
[boost_polygon_point]
[boost_polygon_point_output]
[endsect]

View File

@@ -1,9 +1,10 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
Use, modification and distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +18,7 @@ Boost.Polygon's polygon type (boost::polygon::polygon_data) is adapted to the Bo
[heading Description]
Boost.Polygon's points (as well as polygons) can be used by Boost.Geometry. The
two libraries can therefore be used together. Using a boost::polygon::point_data<...>,
two libraries can therefore be used together. Using a boost::polygon::polygon_data<...>,
algorithms from both Boost.Polygon and Boost.Geometry can be called.
[heading Model of]
@@ -29,8 +30,8 @@ algorithms from both Boost.Polygon and Boost.Geometry can be called.
__not_in_boost_geometry_hpp__
[heading Example]
[boost_polygon]
[boost_polygon_output]
[boost_polygon_ring]
[boost_polygon_ring_output]
[endsect]

View File

@@ -1,9 +1,10 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
Use, modification and distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -18,7 +19,7 @@ is adapted to the Boost.Geometry Polygon Concept.
[heading Description]
Boost.Polygon's points (as well as polygons) can be used by Boost.Geometry. The
two libraries can therefore be used together. Using a boost::polygon::point_data<...>,
two libraries can therefore be used together. Using a boost::polygon::polygon_with_holes_data<...>,
algorithms from both Boost.Polygon and Boost.Geometry can be called.
[heading Model of]
@@ -30,8 +31,8 @@ algorithms from both Boost.Polygon and Boost.Geometry can be called.
__not_in_boost_geometry_hpp__
[heading Example]
[boost_polygon]
[boost_polygon_output]
[boost_polygon_polygon]
[boost_polygon_polygon_output]
[endsect]

View File

@@ -1,9 +1,10 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
Use, modification and distribution is subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +18,7 @@ Boost.Polygon's rectangle type (boost::polygon::rectangle_data) is adapted to th
[heading Description]
Boost.Polygon's points (as well as polygons) can be used by Boost.Geometry. The
two libraries can therefore be used together. Using a boost::polygon::point_data<...>,
two libraries can therefore be used together. Using a boost::polygon::rectangle_data<...>,
algorithms from both Boost.Polygon and Boost.Geometry can be called.
[heading Model of]
@@ -29,8 +30,8 @@ algorithms from both Boost.Polygon and Boost.Geometry can be called.
__not_in_boost_geometry_hpp__
[heading Example]
[boost_polygon]
[boost_polygon_output]
[boost_polygon_box]
[boost_polygon_box_output]
[endsect]

View File

@@ -2,23 +2,13 @@
Boost.Geometry (aka GGL, Generic Geometry Library)
Copyright (c) 2009-2014 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
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)
=============================================================================/]
[heading The WKT Format]
WKT is a general markup format in ASCII.
It is described in detail on [@http://en.wikipedia.org/wiki/Well-known_text Wikipedia]
Boost Geometry supports the common formats (POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON). Because Boost.Geometry
also supports Box and Segment geometries, which are not standard OGC geometries, there are some extensions:
* a Box can be read from WKT by specifying either a polygon (with 4 points) or a specific BOX string (non OGC)
* a Segment can be read from WKT by specifying either a linestring (with 2 points) or a specific SEGMENT string (non OGC)
* a Ring can be read from WKT by specifying a polygon (with no holes)
[heading Conformance]
Other libraries refer to this functionality as [*ST_GeomFromText] or [*STGeomFromText].
That is not done here because Boost.Geometry support more text formats. The name GeomFromText

View File

@@ -0,0 +1,29 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
Copyright (c) 2009-2014 Barend Gehrels, Amsterdam, the Netherlands.
Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
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)
=============================================================================/]
WKT is a general markup format in ASCII.
It is described in detail on [@http://en.wikipedia.org/wiki/Well-known_text Wikipedia]
Boost Geometry supports the common formats (POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON).
Because Boost.Geometry also supports Box and Segment geometries, which are not standard OGC geometries, there are some extensions:
[heading Box]
* can be read from WKT by specifying either a polygon (with 4 points) or a specific BOX string (non OGC)
* streamed to WKT as a POLYGON
[heading Segment]
* can be read from WKT by specifying either a linestring (with 2 points) or a specific SEGMENT string (non OGC)
* streamed to WKT as a LINESTRING
[heading Ring]
* can be read from WKT by specifying a polygon (with no holes)
* streamed to WKT as POLYGON

View File

@@ -38,12 +38,15 @@
[*Solved tickets]
* [@https://svn.boost.org/trac/boost/ticket/9245 9245] Check for process errors in make_qbk.py
* [@https://svn.boost.org/trac/boost/ticket/9081 9081] Booleans create self-intersecting polygons from non-self-intersecting polygons
* [@https://svn.boost.org/trac/boost/ticket/8310 8310] Wrong results with overlapping polygons (fixed using point_on_surface for disjoint)
* [@https://svn.boost.org/trac/boost/ticket/9871 9871] Remove spike in polygon with only a spike
* [@https://svn.boost.org/trac/boost/ticket/9081 9081] Booleans create self-intersecting polygons from non-self-intersecting polygons
* [@https://svn.boost.org/trac/boost/ticket/9245 9245] Check for process errors in make_qbk.py
* [@https://svn.boost.org/trac/boost/ticket/9563 9563] (Sym)difference not successful, fixed by rescaling to robust type
* [@https://svn.boost.org/trac/boost/ticket/9628 9628] Wrong result of within() due to the winding strategy not working correctly for nearly-horizontal segments
* [@https://svn.boost.org/trac/boost/ticket/9871 9871] Remove spike in polygon with only a spike
* [@https://svn.boost.org/trac/boost/ticket/9947 9947] Missing info about WKT in documentation
* [@https://svn.boost.org/trac/boost/ticket/10019 10019] Difference of Linestring and Box returns their intersection
* [@https://svn.boost.org/trac/boost/ticket/10077 10077] Wrong types in concept checks in boost/geometry/arithmetic/arithmetic.hpp
[*Bugfixes]
@@ -82,7 +85,6 @@
* [@https://svn.boost.org/trac/boost/ticket/8825 8825] Patch adding member variable documentation to doxygen_xml2qbk
* [@https://svn.boost.org/trac/boost/ticket/8652 8652] Intersection fails for triangle-triangle intersection. Caused by spike, fixed
* [@https://svn.boost.org/trac/boost/ticket/9047 9047] Boost files that include themselves (strategies/intersection.hpp), fixed
* [@https://svn.boost.org/trac/boost/ticket/10077 10077] Wrong types in concept checks in boost/geometry/arithmetic/arithmetic.hpp, fixed
[*Internal changes]

View File

@@ -34,6 +34,8 @@
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/expand.hpp>
#include <boost/geometry/algorithms/for_each.hpp>
#include <boost/geometry/algorithms/is_simple.hpp>
#include <boost/geometry/algorithms/is_valid.hpp>
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/num_geometries.hpp>
#include <boost/geometry/algorithms/num_interior_rings.hpp>
@@ -121,6 +123,8 @@ DECLARE_BINARY_ALGORITHM(equals)
DECLARE_BINARY_ALGORITHM(expand)
DECLARE_UNARY_ALGORITHM(for_each_point)
DECLARE_UNARY_ALGORITHM(for_each_segment)
DECLARE_UNARY_ALGORITHM(is_simple)
DECLARE_UNARY_ALGORITHM(is_valid)
DECLARE_UNARY_ALGORITHM(length)
DECLARE_UNARY_ALGORITHM(num_geometries)
DECLARE_UNARY_ALGORITHM(num_interior_rings)
@@ -257,10 +261,12 @@ void support_status()
test_binary_algorithm<expand, all_types, all_types, OutputFactory>("expand");
test_unary_algorithm<for_each_point, all_types, OutputFactory>("for_each_point");
test_unary_algorithm<for_each_segment, all_types, OutputFactory>("for_each_segment");
test_unary_algorithm<is_simple, all_types, OutputFactory>("is_simple");
test_unary_algorithm<is_valid, all_types, OutputFactory>("is_valid");
test_unary_algorithm<length, all_types, OutputFactory>("length");
test_unary_algorithm<num_geometries, all_types, OutputFactory>("num_geometries");
test_unary_algorithm<num_interior_rings, all_types, OutputFactory>("num_interior_rings");
test_unary_algorithm<num_interior_rings, all_types, OutputFactory>("num_points");
test_unary_algorithm<num_points, all_types, OutputFactory>("num_points");
test_binary_algorithm<overlaps, all_types, all_types, OutputFactory>("overlaps");
test_unary_algorithm<perimeter, all_types, OutputFactory>("perimeter");
test_unary_algorithm<reverse, all_types, OutputFactory>("reverse");

View File

@@ -19,4 +19,5 @@ build-project algorithms ;
build-project core ;
build-project geometries ;
build-project io ;
build-project strategies ;
build-project views ;

View File

@@ -27,6 +27,7 @@ exe assign_points : assign_points.cpp ;
# exe assign_point_from_index : assign_point_from_index.cpp ;
# exe assign_point_to_index : assign_point_to_index.cpp ;
exe buffer_with_strategies : buffer_with_strategies.cpp ;
exe centroid : centroid.cpp ;
exe clear : clear.cpp ;
exe comparable_distance : comparable_distance.cpp ;

View File

@@ -0,0 +1,70 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2013, 2014 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)
//[buffer_with_strategies
//` Shows how the buffer algorithm can be used to create a buffer of a linestring
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/geometries.hpp>
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
int main()
{
typedef double coordinate_type;
typedef boost::geometry::model::d2::point_xy<coordinate_type> point;
typedef boost::geometry::model::polygon<point> polygon;
// Declare strategies
const double buffer_distance = 1.0;
const int points_per_circle = 36;
boost::geometry::strategy::buffer::distance_symmetric<coordinate_type> distance_strategy(buffer_distance);
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
boost::geometry::strategy::buffer::buffer_circle circle_strategy(points_per_circle);
boost::geometry::strategy::buffer::buffer_side side_strategy;
// Declare output
boost::geometry::model::multi_polygon<polygon> result;
// Declare/fill a linestring
boost::geometry::model::linestring<point> ls;
boost::geometry::read_wkt("LINESTRING(0 0,4 5,7 4,10 6)", ls);
// Create the buffer of a linestring
boost::geometry::buffer(ls, result,
distance_strategy, side_strategy,
join_strategy, end_strategy, circle_strategy);
/*<-*/ create_svg_buffer("buffer_linestring.svg", ls, result); /*->*/
// Declare/fill a multi point
boost::geometry::model::multi_point<point> mp;
boost::geometry::read_wkt("MULTIPOINT((3 3),(4 4))", mp);
// Create the buffer of a multi point
boost::geometry::buffer(mp, result,
distance_strategy, side_strategy,
join_strategy, end_strategy, circle_strategy);
/*<-*/ create_svg_buffer("buffer_multi_point.svg", mp, result); /*->*/
// Declare/fill a multi_polygon
boost::geometry::model::multi_polygon<polygon> mpol;
boost::geometry::read_wkt("MULTIPOLYGON(((0 1,2 5,5 3,0 1)),((1 1,5 2,5 0,1 1)))", mpol);
// Create the buffer of a multi polygon
boost::geometry::buffer(mpol, result,
distance_strategy, side_strategy,
join_strategy, end_strategy, circle_strategy);
/*<-*/ create_svg_buffer("buffer_multi_polygon.svg", mpol, result); /*->*/
return 0;
}
//]

View File

@@ -0,0 +1,49 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2014 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)
// Code to create SVG for buffer examples
#ifndef CREATE_SVG_BUFFER_HPP
#define CREATE_SVG_BUFFER_HPP
#include <fstream>
#if defined(HAVE_SVG)
# include <boost/geometry/io/svg/svg_mapper.hpp>
#endif
template <typename Geometry1, typename Geometry2>
void create_svg_buffer(std::string const& filename, Geometry1 const& original, Geometry2 const& buffer)
{
#if defined(HAVE_SVG)
typedef typename boost::geometry::point_type<Geometry1>::type point_type;
std::ofstream svg(filename.c_str());
boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);
mapper.add(original);
mapper.add(buffer);
// Draw buffer at bottom
mapper.map(buffer, "fill-opacity:0.6;fill:rgb(255,255,64);stroke:rgb(255,128,0);stroke-width:5;stroke-dasharray:1,7;stroke-linecap:round");
// Draw original on top
mapper.map(original, "fill-opacity:0.6;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:3");
#else
boost::ignore_unused_variable_warning(filename);
boost::ignore_unused_variable_warning(original);
boost::ignore_unused_variable_warning(buffer);
#endif
}
// NOTE: convert manually from svg to png using Inkscape ctrl-shift-E
// and copy png to html/img/...
#endif // CREATE_SVG_BUFFER_HPP

View File

@@ -16,7 +16,10 @@ project boost-geometry-doc-src-example-geometries-adapted
exe c_array : c_array.cpp ;
exe boost_array : boost_array.cpp ;
exe boost_fusion : boost_fusion.cpp ;
exe boost_polygon : boost_polygon.cpp ;
exe boost_polygon_box : boost_polygon_box.cpp ;
exe boost_polygon_point : boost_polygon_point.cpp ;
exe boost_polygon_polygon : boost_polygon_polygon.cpp ;
exe boost_polygon_ring : boost_polygon_ring.cpp ;
exe boost_tuple : boost_tuple.cpp ;
build-project boost_range ;

View File

@@ -0,0 +1,42 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// 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)
//[boost_polygon_box
//`Shows how to use Boost.Polygon rectangle_data within Boost.Geometry
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon.hpp>
int main()
{
typedef boost::polygon::rectangle_data<int> rect;
rect b = boost::polygon::construct<rect>(1, 2, 3, 4);
std::cout << "Area (using Boost.Geometry): "
<< boost::geometry::area(b) << std::endl;
std::cout << "Area (using Boost.Polygon): "
<< boost::polygon::area(b) << std::endl;
return 0;
}
//]
//[boost_polygon_box_output
/*`
Output:
[pre
Area (using Boost.Geometry): 4
Area (using Boost.Polygon): 4
]
*/
//]

View File

@@ -2,13 +2,14 @@
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// 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)
//[boost_polygon
//`Shows how to use Boost.Polygon points within Boost.Geometry
//[boost_polygon_point
//`Shows how to use Boost.Polygon point_data within Boost.Geometry
#include <iostream>
#include <boost/geometry.hpp>
@@ -27,7 +28,7 @@ int main()
//]
//[boost_polygon_output
//[boost_polygon_point_output
/*`
Output:
[pre

View File

@@ -0,0 +1,64 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// 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)
//[boost_polygon_polygon
//`Shows how to use Boost.Polygon polygon_with_holes_data within Boost.Geometry
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon.hpp>
int main()
{
typedef boost::polygon::polygon_with_holes_data<int> polygon;
typedef boost::polygon::polygon_traits<polygon>::point_type point;
typedef boost::polygon::polygon_with_holes_traits<polygon>::hole_type hole;
point pts[5] = {
boost::polygon::construct<point>(0, 0),
boost::polygon::construct<point>(0, 10),
boost::polygon::construct<point>(10, 10),
boost::polygon::construct<point>(10, 0),
boost::polygon::construct<point>(0, 0)
};
point hole_pts[5] = {
boost::polygon::construct<point>(1, 1),
boost::polygon::construct<point>(9, 1),
boost::polygon::construct<point>(9, 9),
boost::polygon::construct<point>(1, 9),
boost::polygon::construct<point>(1, 1)
};
hole hls[1];
boost::polygon::set_points(hls[0], hole_pts, hole_pts+5);
polygon poly;
boost::polygon::set_points(poly, pts, pts+5);
boost::polygon::set_holes(poly, hls, hls+1);
std::cout << "Area (using Boost.Geometry): "
<< boost::geometry::area(poly) << std::endl;
std::cout << "Area (using Boost.Polygon): "
<< boost::polygon::area(poly) << std::endl;
return 0;
}
//]
//[boost_polygon_polygon_output
/*`
Output:
[pre
Area (using Boost.Geometry): 36
Area (using Boost.Polygon): 36
]
*/
//]

View File

@@ -0,0 +1,52 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
// 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)
//[boost_polygon_ring
//`Shows how to use Boost.Polygon polygon_data within Boost.Geometry
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon.hpp>
int main()
{
typedef boost::polygon::polygon_data<int> polygon;
typedef boost::polygon::polygon_traits<polygon>::point_type point;
point pts[5] = {
boost::polygon::construct<point>(0, 0),
boost::polygon::construct<point>(0, 10),
boost::polygon::construct<point>(10, 10),
boost::polygon::construct<point>(10, 0),
boost::polygon::construct<point>(0, 0)
};
polygon poly;
boost::polygon::set_points(poly, pts, pts+5);
std::cout << "Area (using Boost.Geometry): "
<< boost::geometry::area(poly) << std::endl;
std::cout << "Area (using Boost.Polygon): "
<< boost::polygon::area(poly) << std::endl;
return 0;
}
//]
//[boost_polygon_ring_output
/*`
Output:
[pre
Area (using Boost.Geometry): 100
Area (using Boost.Polygon): 100
]
*/
//]

View File

@@ -0,0 +1,15 @@
# Boost.Geometry (aka GGL, Generic Geometry Library)
#
# Copyright (c) 2007-2014 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)
project boost-geometry-doc-example-strategies
: # requirements
;
exe buffer_circle : buffer_circle.cpp ;
exe buffer_square : buffer_square.cpp ;

View File

@@ -0,0 +1,53 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2014 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)
//[buffer_circle
//` Shows how the buffer_circle strategy can be used as a PointStrategy to create circular buffers around points
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/geometries.hpp>
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
int main()
{
typedef double coordinate_type;
typedef boost::geometry::model::d2::point_xy<coordinate_type> point;
typedef boost::geometry::model::polygon<point> polygon;
// Declare the buffer_circle strategy
const int points_per_circle = 360;
boost::geometry::strategy::buffer::buffer_circle circle_strategy(points_per_circle);
// Declare other strategies
const double buffer_distance = 0.7;
boost::geometry::strategy::buffer::distance_symmetric<coordinate_type> distance_strategy(buffer_distance);
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
boost::geometry::strategy::buffer::buffer_side side_strategy;
// Declare output
boost::geometry::model::multi_polygon<polygon> result;
// Declare/fill of a multi point
boost::geometry::model::multi_point<point> mp;
boost::geometry::read_wkt("MULTIPOINT((3 3),(3 4),(4 4),(7 3))", mp);
// Create the buffer of a multi point
boost::geometry::buffer(mp, result,
distance_strategy, side_strategy,
join_strategy, end_strategy, circle_strategy);
/*<-*/ create_svg_buffer("buffer_circle.svg", mp, result); /*->*/
return 0;
}
//]

View File

@@ -0,0 +1,53 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2014 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)
//[buffer_square
//` Shows how the buffer_square strategy can be used as a PointStrategy to create square buffers where the original point lies in the center
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/geometries.hpp>
/*<-*/ #include "../examples_utils/create_svg_buffer.hpp" /*->*/
int main()
{
typedef double coordinate_type;
typedef boost::geometry::model::d2::point_xy<coordinate_type> point;
typedef boost::geometry::model::polygon<point> polygon;
// Declare the buffer_square strategy
boost::geometry::strategy::buffer::buffer_square square_strategy;
// Declare other strategies
const int points_per_circle = 36;
const double buffer_distance = 0.5;
boost::geometry::strategy::buffer::distance_symmetric<coordinate_type> distance_strategy(buffer_distance);
boost::geometry::strategy::buffer::join_round join_strategy(points_per_circle);
boost::geometry::strategy::buffer::end_round end_strategy(points_per_circle);
boost::geometry::strategy::buffer::buffer_side side_strategy;
// Declare output
boost::geometry::model::multi_polygon<polygon> result;
// Declare/fill of a multi point
boost::geometry::model::multi_point<point> mp;
boost::geometry::read_wkt("MULTIPOINT((3 3),(3 4),(4 4),(7 3))", mp);
// Create the buffer of a multi point
boost::geometry::buffer(mp, result,
distance_strategy, side_strategy,
join_strategy, end_strategy, square_strategy);
/*<-*/ create_svg_buffer("buffer_square.svg", mp, result); /*->*/
return 0;
}
//]

View File

@@ -28,6 +28,7 @@
#include <boost/geometry/geometries/segment.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp>
namespace boost { namespace geometry
{
@@ -99,11 +100,6 @@ struct buffer<BoxIn, BoxOut, box_tag, box_tag>
}
};
// Many things to do. Point is easy, other geometries require self intersections
// For point, note that it should output as a polygon (like the rest). Buffers
// of a set of geometries are often lateron combined using a "dissolve" operation.
// Two points close to each other get a combined kidney shaped buffer then.
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
@@ -174,7 +170,6 @@ struct buffer<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
\param geometry_out \param_geometry
\param distance The distance to be used for the buffer
\param chord_length (optional) The length of the chord's in the generated arcs around points or bends
\note Currently only implemented for box, the trivial case, but still useful
\qbk{[include reference/algorithms/buffer.qbk]}
*/
@@ -198,7 +193,7 @@ inline void buffer(Input const& geometry_in, Output& geometry_out,
\param geometry \param_geometry
\param distance The distance to be used for the buffer
\param chord_length (optional) The length of the chord's in the generated arcs
around points or bends
around points or bends (RESERVED, NOT YET USED)
\return \return_calc{buffer}
*/
template <typename Output, typename Input, typename Distance>
@@ -214,6 +209,68 @@ Output return_buffer(Input const& geometry, Distance const& distance, Distance c
return geometry_out;
}
/*!
\brief \brief_calc{buffer}
\ingroup buffer
\details \details_calc{buffer, \det_buffer}.
\tparam GeometryIn \tparam_geometry
\tparam MultiPolygon \tparam_geometry
\tparam DistanceStrategy A strategy defining distance behaviour (symmetric, asymetric)
\tparam SideStrategy A strategy defining creation of buffer along sides
\tparam JoinStrategy A strategy defining creation of buffer around convex joins (round, miter)
\tparam EndStrategy A strategy defining creation of buffer at linestring ends (round, flat)
\tparam PointStrategy A strategy defining creation of buffer around points
\param geometry_in \param_geometry
\param geometry_out output multi polygon (or std:: collection of polygons), contains buffer of input geometry
\param distance_strategy The distance strategy to be used
\param side_strategy The side strategy to be used
\param join_strategy The join strategy to be used
\param end_strategy The end strategy to be used
\param point_strategy The point strategy to be used
\qbk{distinguish,with strategies}
\qbk{[include reference/algorithms/buffer_with_strategies.qbk]}
*/
template
<
typename GeometryIn,
typename MultiPolygon,
typename DistanceStrategy,
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy
>
inline void buffer(GeometryIn const& geometry_in,
MultiPolygon& geometry_out,
DistanceStrategy const& distance_strategy,
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy)
{
typedef typename boost::range_value<MultiPolygon>::type polygon_type;
concept::check<GeometryIn const>();
concept::check<polygon_type>();
typedef typename point_type<GeometryIn>::type point_type;
typedef typename rescale_policy_type<point_type>::type rescale_policy_type;
geometry_out.clear();
rescale_policy_type rescale_policy
= boost::geometry::get_rescale_policy<rescale_policy_type>(geometry_in);
detail::buffer::buffer_inserter<polygon_type>(geometry_in, std::back_inserter(geometry_out),
distance_strategy,
side_strategy,
join_strategy,
end_strategy,
point_strategy,
rescale_policy);
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_ALGORITHMS_BUFFER_HPP

View File

@@ -29,6 +29,10 @@
#include <boost/geometry/algorithms/simplify.hpp>
#if defined(BOOST_GEOMETRY_BUFFER_SIMPLIFY_WITH_AX)
#include <boost/geometry/strategies/cartesian/distance_projected_point_ax.hpp>
#endif
namespace boost { namespace geometry
{
@@ -51,10 +55,41 @@ inline void simplify_input(Range const& range,
// sensitive to small scale input features, however the result will
// look better.
// It also get rid of duplicate points
#if ! defined(BOOST_GEOMETRY_BUFFER_SIMPLIFY_WITH_AX)
geometry::simplify(range, simplified, distance.simplify_distance());
//simplified = range;
#else
typedef typename boost::range_value<Range>::type point_type;
typedef strategy::distance::detail::projected_point_ax<> ax_type;
typedef typename strategy::distance::services::return_type
<
strategy::distance::detail::projected_point_ax<>,
point_type,
point_type
>::type return_type;
typedef strategy::distance::detail::projected_point_ax_less
<
return_type
> comparator_type;
typedef strategy::simplify::detail::douglas_peucker
<
point_type,
strategy::distance::detail::projected_point_ax<>,
comparator_type
> dp_ax;
return_type max_distance(distance.simplify_distance() * 2.0,
distance.simplify_distance());
comparator_type comparator(max_distance);
dp_ax strategy(comparator);
geometry::simplify(range, simplified, max_distance, strategy);
#endif
}
template <typename RingOutput>
struct buffer_range
{
@@ -72,7 +107,6 @@ struct buffer_range
>
static inline
void add_join(Collection& collection,
int phase,
Point const& penultimate_input,
Point const& previous_input,
output_point_type const& prev_perp1,
@@ -110,7 +144,6 @@ struct buffer_range
previous_input, prev_perp2, perp1);
return;
case strategy::buffer::join_spike :
//if (phase == 0) avoid duplicate joins at spikes? this still causes other issues
{
// For linestrings, only add spike at one side to avoid
// duplicates
@@ -124,7 +157,7 @@ struct buffer_range
}
// The corner is convex, we create a join
// TODO - try to avoid a separate vector, add the piece directly
// TODO (future) - avoid a separate vector, add the piece directly
std::vector<output_point_type> range_out;
join_strategy.apply(intersection_point,
previous_input, prev_perp2, perp1,
@@ -168,7 +201,6 @@ struct buffer_range
typename RobustPolicy
>
static inline void iterate(Collection& collection,
int phase, // 0/1 for left/right of rings. For polygons: 0
Iterator begin, Iterator end,
strategy::buffer::buffer_side_selector side,
DistanceStrategy const& distance_strategy,
@@ -235,7 +267,7 @@ struct buffer_range
if (! first)
{
add_join(collection, phase,
add_join(collection,
penultimate_point,
*prev, last_p1, last_p2,
*it, generated_side.front(), generated_side.back(),
@@ -265,85 +297,6 @@ struct buffer_range
}
};
template
<
typename Point,
typename RingOutput
>
struct buffer_point
{
typedef typename point_type<RingOutput>::type output_point_type;
typedef typename coordinate_type<RingOutput>::type coordinate_type;
typedef typename geometry::select_most_precise
<
typename geometry::select_most_precise
<
typename geometry::coordinate_type<Point>::type,
typename geometry::coordinate_type<output_point_type>::type
>::type,
double
>::type promoted_type;
template <typename RangeOut>
static inline void generate_points(Point const& point,
promoted_type const& buffer_distance,
RangeOut& range_out)
{
promoted_type two = 2.0;
promoted_type two_pi = two * geometry::math::pi<promoted_type>();
int point_buffer_count = 88; // 88 gives now fixed problem (collinear opposite / robustness. TODO: make this value flexible
promoted_type diff = two_pi / promoted_type(point_buffer_count);
promoted_type a = 0;
output_point_type first;
for (int i = 0; i < point_buffer_count; i++, a -= diff)
{
output_point_type p;
set<0>(p, get<0>(point) + buffer_distance * cos(a));
set<1>(p, get<1>(point) + buffer_distance * sin(a));
range_out.push_back(p);
if (i == 0)
{
first = p;
}
}
// Close it:
range_out.push_back(first);
}
template
<
typename Collection,
typename DistanceStrategy,
typename JoinStrategy,
typename EndStrategy,
typename RobustPolicy
>
static inline void generate_circle(Point const& point,
Collection& collection,
DistanceStrategy const& distance,
JoinStrategy const& ,
EndStrategy const& ,
RobustPolicy const& )
{
std::vector<output_point_type> range_out;
generate_points(point,
distance.apply(point, point, strategy::buffer::buffer_side_left),
range_out);
collection.add_piece(strategy::buffer::buffered_circle, range_out, false);
}
};
template
<
typename Multi,
@@ -359,14 +312,16 @@ struct buffer_multi
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
static inline void apply(Multi const& multi,
Collection& collection,
DistanceStrategy const& distance,
DistanceStrategy const& distance_strategy,
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
RobustPolicy const& robust_policy)
{
for (typename boost::range_iterator<Multi const>::type
@@ -374,7 +329,10 @@ struct buffer_multi
it != boost::end(multi);
++it)
{
Policy::apply(*it, collection, distance, side_strategy, join_strategy, end_strategy, robust_policy);
Policy::apply(*it, collection,
distance_strategy, side_strategy,
join_strategy, end_strategy, point_strategy,
robust_policy);
}
}
};
@@ -411,7 +369,6 @@ template
typename RingOutput
>
struct buffer_inserter<point_tag, Point, RingOutput>
: public detail::buffer::buffer_point<Point, RingOutput>
{
template
<
@@ -420,18 +377,23 @@ struct buffer_inserter<point_tag, Point, RingOutput>
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
static inline void apply(Point const& point, Collection& collection,
DistanceStrategy const& distance,
DistanceStrategy const& distance_strategy,
SideStrategy const& ,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
RobustPolicy const& robust_policy)
JoinStrategy const& ,
EndStrategy const& ,
PointStrategy const& point_strategy,
RobustPolicy const& )
{
typedef typename point_type<RingOutput>::type output_point_type;
collection.start_new_ring();
typedef detail::buffer::buffer_point<Point, RingOutput> base;
base::generate_circle(point, collection, distance, join_strategy, end_strategy, robust_policy);
std::vector<output_point_type> range_out;
point_strategy.apply(point, distance_strategy, range_out);
collection.add_piece(strategy::buffer::buffered_point, range_out, false);
collection.finish_ring();
}
};
@@ -469,13 +431,13 @@ struct buffer_inserter<ring_tag, RingInput, RingOutput>
typedef detail::buffer::buffer_range<RingOutput> buffer_range;
buffer_range::iterate(collection, 0, begin, end,
buffer_range::iterate(collection, begin, end,
side,
distance_strategy, side_strategy, join_strategy, end_strategy, robust_policy,
first_p1, first_p2, last_p1, last_p2);
// Generate closing join
buffer_range::add_join(collection, 0,
buffer_range::add_join(collection,
*(end - 2),
*(end - 1), last_p1, last_p2,
*(begin + 1), first_p1, first_p2,
@@ -484,7 +446,6 @@ struct buffer_inserter<ring_tag, RingInput, RingOutput>
robust_policy);
// Buffer is closed automatically by last closing corner
// (OPEN IT FOR OPEN POLYGONS - TODO)
}
template
@@ -494,6 +455,7 @@ struct buffer_inserter<ring_tag, RingInput, RingOutput>
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
static inline void apply(RingInput const& ring,
@@ -502,6 +464,7 @@ struct buffer_inserter<ring_tag, RingInput, RingOutput>
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& ,
RobustPolicy const& robust_policy)
{
if (boost::size(ring) > 3)
@@ -564,7 +527,7 @@ struct buffer_inserter<linestring_tag, Linestring, Polygon>
typename EndStrategy,
typename RobustPolicy
>
static inline void iterate(Collection& collection, int phase,
static inline void iterate(Collection& collection,
Iterator begin, Iterator end,
strategy::buffer::buffer_side_selector side,
DistanceStrategy const& distance_strategy,
@@ -589,7 +552,7 @@ struct buffer_inserter<linestring_tag, Linestring, Polygon>
output_point_type first_p2, last_p1, last_p2;
detail::buffer::buffer_range<output_ring_type>::iterate(collection,
phase, begin, end, side,
begin, end, side,
distance_strategy, side_strategy, join_strategy, end_strategy, robust_policy,
first_p1, first_p2, last_p1, last_p2);
@@ -605,6 +568,7 @@ struct buffer_inserter<linestring_tag, Linestring, Polygon>
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
static inline void apply(Linestring const& linestring, Collection& collection,
@@ -612,6 +576,7 @@ struct buffer_inserter<linestring_tag, Linestring, Polygon>
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& ,
RobustPolicy const& robust_policy)
{
if (boost::size(linestring) > 1)
@@ -621,17 +586,21 @@ struct buffer_inserter<linestring_tag, Linestring, Polygon>
collection.start_new_ring();
output_point_type first_p1;
iterate(collection, 0, boost::begin(simplified), boost::end(simplified),
iterate(collection, boost::begin(simplified), boost::end(simplified),
strategy::buffer::buffer_side_left,
distance, side_strategy, join_strategy, end_strategy, robust_policy,
first_p1);
iterate(collection, 1, boost::rbegin(simplified), boost::rend(simplified),
iterate(collection, boost::rbegin(simplified), boost::rend(simplified),
strategy::buffer::buffer_side_right,
distance, side_strategy, join_strategy, end_strategy, robust_policy,
first_p1);
collection.finish_ring();
}
else
{
// Use point_strategy to buffer degenerated linestring
}
}
};
@@ -658,6 +627,7 @@ private:
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
static inline
@@ -667,12 +637,15 @@ private:
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
RobustPolicy const& robust_policy)
{
for (Iterator it = begin; it != end; ++it)
{
collection.start_new_ring();
policy::apply(*it, collection, distance, side_strategy, join_strategy, end_strategy, robust_policy);
policy::apply(*it, collection, distance, side_strategy,
join_strategy, end_strategy, point_strategy,
robust_policy);
collection.finish_ring();
}
}
@@ -685,6 +658,7 @@ private:
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
static inline
@@ -694,10 +668,13 @@ private:
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
RobustPolicy const& robust_policy)
{
iterate(boost::begin(interior_rings), boost::end(interior_rings),
collection, distance, side_strategy, join_strategy, end_strategy, robust_policy);
collection, distance, side_strategy,
join_strategy, end_strategy, point_strategy,
robust_policy);
}
public:
@@ -708,6 +685,7 @@ public:
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
static inline void apply(PolygonInput const& polygon,
@@ -716,17 +694,22 @@ public:
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
RobustPolicy const& robust_policy)
{
{
collection.start_new_ring();
policy::apply(exterior_ring(polygon), collection,
distance, side_strategy, join_strategy, end_strategy, robust_policy);
distance, side_strategy,
join_strategy, end_strategy, point_strategy,
robust_policy);
collection.finish_ring();
}
apply_interior_rings(interior_rings(polygon),
collection, distance, side_strategy, join_strategy, end_strategy, robust_policy);
collection, distance, side_strategy,
join_strategy, end_strategy, point_strategy,
robust_policy);
}
};
@@ -757,6 +740,10 @@ struct buffer_inserter<multi_tag, Multi, PolygonOutput>
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace buffer
{
template
<
typename GeometryOutput,
@@ -766,6 +753,7 @@ template
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy,
typename VisitPiecesPolicy
>
@@ -774,6 +762,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
RobustPolicy const& robust_policy,
VisitPiecesPolicy& visit_pieces_policy
)
@@ -795,7 +784,10 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
>::type,
GeometryInput,
GeometryOutput
>::apply(geometry_input, collection, distance_strategy, side_strategy, join_strategy, end_strategy, robust_policy);
>::apply(geometry_input, collection,
distance_strategy, side_strategy, join_strategy,
end_strategy, point_strategy,
robust_policy);
collection.get_turns(geometry_input, distance_strategy);
@@ -836,6 +828,7 @@ template
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy,
typename PointStrategy,
typename RobustPolicy
>
inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator out,
@@ -843,13 +836,18 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
PointStrategy const& point_strategy,
RobustPolicy const& robust_policy)
{
detail::buffer::visit_pieces_default_policy visitor;
buffer_inserter<GeometryOutput>(geometry_input, out,
distance_strategy, side_strategy, join_strategy, end_strategy,
distance_strategy, side_strategy, join_strategy,
end_strategy, point_strategy,
robust_policy, visitor);
}
#endif // DOXYGEN_NO_DETAIL
}} // namespace detail::buffer
}} // namespace boost::geometry

View File

@@ -23,6 +23,8 @@
#include <boost/geometry/strategies/buffer.hpp>
#include <boost/geometry/geometries/ring.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffered_ring.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffer_policies.hpp>
#include <boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp>
@@ -571,7 +573,7 @@ struct buffered_piece_collection
inline void finish_ring()
{
BOOST_ASSERT(m_first_piece_index != -1);
if (m_first_piece_index < boost::size(m_pieces))
if (m_first_piece_index < static_cast<int>(boost::size(m_pieces)))
{
// If piece was added
// Reassign left-of-first and right-of-last

View File

@@ -11,6 +11,7 @@
#include <boost/range.hpp>
#include <boost/geometry/arithmetic/dot_product.hpp>
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/expand.hpp>
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>

View File

@@ -104,10 +104,10 @@ public:
if (first || cdist < min_cdist)
{
min_cdist = cdist;
}
if ( geometry::math::equals(min_cdist, 0) )
{
break;
if ( geometry::math::equals(min_cdist, 0) )
{
break;
}
}
}

View File

@@ -111,10 +111,10 @@ public:
if (first || cdist < min_cdist)
{
min_cdist = cdist;
}
if ( geometry::math::equals(min_cdist, 0) )
{
break;
if ( geometry::math::equals(min_cdist, 0) )
{
break;
}
}
}

View File

@@ -18,6 +18,7 @@
#include <boost/geometry/strategies/buffer.hpp>
#include <boost/geometry/strategies/agnostic/buffer_distance_asymmetric.hpp>
#include <boost/geometry/strategies/agnostic/buffer_end_skip.hpp>
#include <boost/geometry/strategies/cartesian/buffer_side.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/geometries/segment.hpp>
@@ -39,43 +40,48 @@ template
typename RangeOut
>
struct offset_range
: public geometry::detail::buffer::buffer_range
<
RangeOut,
linestring_tag
>
{
typedef geometry::detail::buffer::buffer_range
<
RangeOut,
linestring_tag
> super;
Range
> per_range;
template
<
typename Collection,
typename DistanceStrategy,
typename SideStrategy,
typename JoinStrategy,
typename EndStrategy
typename EndStrategy,
typename RobustPolicy
>
static inline void apply(Collection& collection, Range const& range,
DistanceStrategy const& distance_strategy,
SideStrategy const& side_strategy,
JoinStrategy const& join_strategy,
EndStrategy const& end_strategy,
RobustPolicy const& robust_policy,
bool reverse)
{
collection.start_new_ring();
typedef typename point_type<RangeOut>::type output_point_type;
output_point_type first_p1, first_p2, last_p1, last_p2;
if (reverse)
{
super::iterate(collection, boost::rbegin(range), boost::rend(range),
buffer_side_left,
distance_strategy, join_strategy, end_strategy);
per_range::iterate(collection, 0, boost::rbegin(range), boost::rend(range),
strategy::buffer::buffer_side_left,
distance_strategy, side_strategy, join_strategy, end_strategy, robust_policy,
first_p1, first_p2, last_p1, last_p2);
}
else
{
super::iterate(collection, boost::begin(range), boost::end(range),
buffer_side_left,
distance_strategy, join_strategy, end_strategy);
per_range::iterate(collection, 0, boost::begin(range), boost::end(range),
strategy::buffer::buffer_side_left,
distance_strategy, side_strategy, join_strategy, end_strategy, robust_policy,
first_p1, first_p2, last_p1, last_p2);
}
collection.finish_ring();
}
};
@@ -160,6 +166,8 @@ inline void offset(Geometry const& geometry, GeometryOut& out,
point_type
> end_strategy;
strategy::buffer::buffer_side side_strategy;
dispatch::offset
<
typename tag<Geometry>::type,
@@ -169,11 +177,13 @@ inline void offset(Geometry const& geometry, GeometryOut& out,
>::apply(collection,
geometry,
distance_strategy,
side_strategy,
join_strategy,
end_strategy,
robust_policy,
reverse);
collection.assign_offsetted_rings(out);
// TODO collection.template assign<GeometryOut>(out);
}

View File

@@ -15,6 +15,7 @@
#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP
#define BOOST_GEOMETRY_MULTI_ALGORITHMS_NUM_POINTS_HPP
#include <cstddef>
#include <boost/range.hpp>
@@ -34,7 +35,8 @@ namespace detail { namespace num_points
struct multi_count
{
template <typename MultiGeometry>
static inline size_t apply(MultiGeometry const& geometry, bool add_for_open)
static inline
std::size_t apply(MultiGeometry const& geometry, bool add_for_open)
{
typedef typename boost::range_value<MultiGeometry>::type geometry_type;
typedef typename boost::range_iterator

View File

@@ -1,54 +0,0 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2012-2014 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_STRATEGIES_AGNOSTIC_BUFFER_END_SKIP_HPP
#define BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_END_SKIP_HPP
#include <boost/geometry/strategies/buffer.hpp>
namespace boost { namespace geometry
{
namespace strategy { namespace buffer
{
template
<
typename PointIn,
typename PointOut
>
class end_skip
{
public :
template <typename RangeOut, typename DistanceStrategy>
inline void apply(PointIn const& ,
PointIn const& ,
PointIn const& ,
PointIn const& ,
buffer_side_selector ,
DistanceStrategy const& ,
RangeOut& ) const
{
}
static inline piece_type get_piece_type()
{
return buffered_flat_end;
}
};
}} // namespace strategy::buffer
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_AGNOSTIC_BUFFER_END_SKIP_HPP

View File

@@ -33,6 +33,78 @@ namespace boost { namespace geometry
namespace strategy { namespace within
{
// Fix for https://svn.boost.org/trac/boost/ticket/9628
// For floating point coordinates, the <1> coordinate of a point is compared
// with the segment's points using some EPS. If the coordinates are "equal"
// the sides are calculated. Therefore we can treat a segment as a long areal
// geometry having some width. There is a small ~triangular area somewhere
// between the segment's effective area and a segment's line used in sides
// calculation where the segment is on the one side of the line but on the
// other side of a segment (due to the width).
// For the s1 of a segment going NE the real side is RIGHT but the point may
// be detected as LEFT, like this:
// RIGHT
// ___----->
// ^ O Pt __ __
// EPS __ __
// v__ __ BUT DETECTED AS LEFT OF THIS LINE
// _____7
// _____/
// _____/
template <typename CSTag>
struct winding_side_equal
{
typedef typename strategy::side::services::default_strategy
<
CSTag
>::type strategy_side_type;
template <size_t D, typename Point, typename PointOfSegment>
static inline int apply(Point const& point,
PointOfSegment const& se,
int count)
{
// Create a vertical segment intersecting the original segment's endpoint
// equal to the point, with the derived direction (UP/DOWN).
// Set only the 2 first coordinates, the other ones are ignored
PointOfSegment ss1, ss2;
set<1-D>(ss1, get<1-D>(se));
set<1-D>(ss2, get<1-D>(se));
if ( count > 0 ) // UP
{
set<D>(ss1, 0);
set<D>(ss2, 1);
}
else // DOWN
{
set<D>(ss1, 1);
set<D>(ss2, 0);
}
// Check the side using this vertical segment
return strategy_side_type::apply(ss1, ss2, point);
}
};
// The optimization for cartesian
template <>
struct winding_side_equal<cartesian_tag>
{
template <size_t D, typename Point, typename PointOfSegment>
static inline int apply(Point const& point,
PointOfSegment const& se,
int count)
{
return math::equals(get<1-D>(point), get<1-D>(se)) ?
0 :
get<1-D>(point) < get<1-D>(se) ?
// assuming count is equal to 1 or -1
count : // ( count > 0 ? 1 : -1) :
-count; // ( count > 0 ? -1 : 1) ;
}
};
/*!
\brief Within detection using winding rule
\ingroup strategies
@@ -112,21 +184,21 @@ class winding
template <size_t D>
static inline int check_segment(Point const& point,
PointOfSegment const& seg1, PointOfSegment const& seg2,
counter& state)
counter& state, bool& eq1, bool& eq2)
{
calculation_type const p = get<D>(point);
calculation_type const s1 = get<D>(seg1);
calculation_type const s2 = get<D>(seg2);
// Check if one of segment endpoints is at same level of point
bool eq1 = math::equals(s1, p);
bool eq2 = math::equals(s2, p);
eq1 = math::equals(s1, p);
eq2 = math::equals(s2, p);
if (eq1 && eq2)
{
// Both equal p -> segment is horizontal (or vertical for D=0)
// The only thing which has to be done is check if point is ON segment
return check_touch<1 - D>(point, seg1, seg2,state);
return check_touch<1 - D>(point, seg1, seg2, state);
}
return
@@ -138,8 +210,6 @@ class winding
}
public :
// Typedefs and static methods to fulfill the concept
@@ -151,10 +221,24 @@ public :
PointOfSegment const& s1, PointOfSegment const& s2,
counter& state)
{
int count = check_segment<1>(point, s1, s2, state);
bool eq1 = false;
bool eq2 = false;
boost::ignore_unused(eq2);
int count = check_segment<1>(point, s1, s2, state, eq1, eq2);
if (count != 0)
{
int side = strategy_side_type::apply(s1, s2, point);
int side = 0;
if ( count == 1 || count == -1 )
{
side = winding_side_equal<typename cs_tag<Point>::type>
::template apply<1>(point, eq1 ? s1 : s2, count);
}
else
{
side = strategy_side_type::apply(s1, s2, point);
}
if (side == 0)
{
// Point is lying on segment

View File

@@ -65,7 +65,7 @@ enum piece_type
buffered_join,
buffered_round_end,
buffered_flat_end,
buffered_circle,
buffered_point,
buffered_concave // always on the inside
};

View File

@@ -0,0 +1,109 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2012-2014 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_STRATEGIES_CARTESIAN_BUFFER_CIRCLE_HPP
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_CIRCLE_HPP
#include <cstddef>
#include <boost/range.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/strategies/buffer.hpp>
namespace boost { namespace geometry
{
namespace strategy { namespace buffer
{
/*!
\brief Create a circular buffer around a point
\ingroup strategies
\details This strategy can be used as PointStrategy for the buffer algorithm.
It creates a circular buffer around a point. It can be applied
for points and multi_points, but also for a linestring (if it is degenerate,
so consisting of only one point) and for polygons (if it is degenerate).
This strategy is only applicable for Cartesian coordinate systems.
\qbk{
[heading Example]
[buffer_circle]
[heading Output]
[$img/strategies/buffer_circle.png]
[heading See also]
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
}
*/
class buffer_circle
{
public :
//! Constructs the strategy with default number of points (90)
buffer_circle()
: m_count(90)
{}
//! Constructs the strategy specifying the nuber of points
explicit buffer_circle(std::size_t count)
: m_count(count)
{}
//! Fills output_range with a circle around point using distance_strategy
template
<
typename Point,
typename OutputRange,
typename DistanceStrategy
>
inline void apply(Point const& point,
DistanceStrategy const& distance_strategy,
OutputRange& output_range) const
{
typedef typename boost::range_value<OutputRange>::type output_point_type;
typedef typename geometry::select_most_precise
<
typename geometry::select_most_precise
<
typename geometry::coordinate_type<Point>::type,
typename geometry::coordinate_type<output_point_type>::type
>::type,
double
>::type promoted_type;
promoted_type const buffer_distance = distance_strategy.apply(point, point,
strategy::buffer::buffer_side_left);
promoted_type const two = 2.0;
promoted_type const two_pi = two * geometry::math::pi<promoted_type>();
promoted_type const diff = two_pi / promoted_type(m_count);
promoted_type a = 0;
for (std::size_t i = 0; i < m_count; i++, a -= diff)
{
output_point_type p;
set<0>(p, get<0>(point) + buffer_distance * cos(a));
set<1>(p, get<1>(point) + buffer_distance * sin(a));
output_range.push_back(p);
}
// Close it:
output_range.push_back(output_range.front());
}
private :
std::size_t m_count;
};
}} // namespace strategy::buffer
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_CIRCLE_HPP

View File

@@ -27,38 +27,28 @@ namespace strategy { namespace buffer
{
template
<
typename PointIn,
typename PointOut
>
class end_flat
{
typedef typename strategy::side::services::default_strategy<typename cs_tag<PointIn>::type>::type side;
typedef typename coordinate_type<PointOut>::type coordinate_type;
typedef typename geometry::select_most_precise
<
typename geometry::select_most_precise
<
typename geometry::coordinate_type<PointIn>::type,
typename geometry::coordinate_type<PointOut>::type
>::type,
double
>::type promoted_type;
public :
template <typename RangeOut, typename DistanceStrategy>
inline void apply(PointIn const& penultimate_point,
PointIn const& perp_left_point,
PointIn const& ultimate_point,
PointIn const& perp_right_point,
template <typename Point, typename RangeOut, typename DistanceStrategy>
inline void apply(Point const& penultimate_point,
Point const& perp_left_point,
Point const& ultimate_point,
Point const& perp_right_point,
buffer_side_selector side,
DistanceStrategy const& distance,
RangeOut& range_out) const
{
typedef typename coordinate_type<Point>::type coordinate_type;
typedef typename geometry::select_most_precise
<
coordinate_type,
double
>::type promoted_type;
promoted_type const dist_left = distance.apply(penultimate_point, ultimate_point, buffer_side_left);
promoted_type const dist_right = distance.apply(penultimate_point, ultimate_point, buffer_side_right);

View File

@@ -11,13 +11,13 @@
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/strategies/tags.hpp>
#include <boost/geometry/strategies/side.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/select_most_precise.hpp>
#include <boost/geometry/strategies/buffer.hpp>
#include <boost/geometry/io/wkt/wkt.hpp>
namespace boost { namespace geometry
{
@@ -27,40 +27,29 @@ namespace strategy { namespace buffer
{
template
<
typename PointIn,
typename PointOut
>
class end_round
{
typedef typename strategy::side::services::default_strategy<typename cs_tag<PointIn>::type>::type side;
typedef typename coordinate_type<PointOut>::type coordinate_type;
typedef typename geometry::select_most_precise
<
typename geometry::select_most_precise
<
typename geometry::coordinate_type<PointIn>::type,
typename geometry::coordinate_type<PointOut>::type
>::type,
double
>::type promoted_type;
private :
int m_steps_per_circle;
template <typename RangeOut>
inline void generate_points(PointIn const& point,
promoted_type alpha,
promoted_type const& buffer_distance,
template
<
typename Point,
typename PromotedType,
typename DistanceType,
typename RangeOut
>
inline void generate_points(Point const& point,
PromotedType alpha, // by value
DistanceType const& buffer_distance,
RangeOut& range_out) const
{
promoted_type const two = 2.0;
promoted_type const two_pi = two * geometry::math::pi<promoted_type>();
PromotedType const two = 2.0;
PromotedType const two_pi = two * geometry::math::pi<PromotedType>();
int point_buffer_count = m_steps_per_circle;
promoted_type const diff = two_pi / promoted_type(point_buffer_count);
PromotedType const diff = two_pi / PromotedType(point_buffer_count);
// For half circle:
point_buffer_count /= 2;
@@ -89,16 +78,24 @@ public :
: m_steps_per_circle(steps_per_circle)
{}
template <typename RangeOut, typename DistanceStrategy>
inline void apply(PointIn const& penultimate_point,
PointIn const& perp_left_point,
PointIn const& ultimate_point,
PointIn const& ,
template <typename Point, typename RangeOut, typename DistanceStrategy>
inline void apply(Point const& penultimate_point,
Point const& perp_left_point,
Point const& ultimate_point,
Point const& ,
buffer_side_selector side,
DistanceStrategy const& distance,
RangeOut& range_out) const
{
promoted_type alpha = calculate_angle<promoted_type>(perp_left_point, ultimate_point);
typedef typename coordinate_type<Point>::type coordinate_type;
typedef typename geometry::select_most_precise
<
coordinate_type,
double
>::type promoted_type;
promoted_type const alpha = calculate_angle<promoted_type>(perp_left_point, ultimate_point);
promoted_type const dist_left = distance.apply(penultimate_point, ultimate_point, buffer_side_left);
promoted_type const dist_right = distance.apply(penultimate_point, ultimate_point, buffer_side_right);
@@ -116,7 +113,7 @@ public :
dist_half_diff = -dist_half_diff;
}
PointIn shifted_point;
Point shifted_point;
set<0>(shifted_point, get<0>(ultimate_point) + dist_half_diff * cos(alpha));
set<1>(shifted_point, get<1>(ultimate_point) + dist_half_diff * sin(alpha));
generate_points(shifted_point, alpha, (dist_left + dist_right) / two, range_out);

View File

@@ -9,8 +9,9 @@
#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_MITER_HPP
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_MITER_HPP
#include <boost/assert.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/strategies/tags.hpp>
#include <boost/geometry/policies/compare.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/select_most_precise.hpp>
@@ -25,42 +26,51 @@ namespace strategy { namespace buffer
// TODO: condider merging/baseclassing join strategies to avoid duplicate code
template
<
typename PointIn,
typename PointOut
>
struct join_miter
{
typedef typename coordinate_type<PointIn>::type coordinate_type;
// Constructor compatible with other join strategies:
inline join_miter(int = 0)
{}
template <typename RangeOut>
inline bool apply(PointIn const& ip, PointIn const& vertex,
PointIn const& perp1, PointIn const& perp2,
coordinate_type const& buffer_distance,
template <typename Point, typename DistanceType, typename RangeOut>
inline bool apply(Point const& ip, Point const& vertex,
Point const& perp1, Point const& perp2,
DistanceType const& buffer_distance,
RangeOut& range_out) const
{
PointIn p = ip;
geometry::equal_to<Point> equals;
if (equals(ip, vertex))
{
return false;
}
typedef typename coordinate_type<Point>::type coordinate_type;
typedef typename geometry::select_most_precise
<
coordinate_type,
double
>::type promoted_type;
Point p = ip;
// Normalize it and give it X*dist.
coordinate_type dx = get<0>(ip) - get<0>(vertex);
coordinate_type dy = get<1>(ip) - get<1>(vertex);
coordinate_type const dx = get<0>(ip) - get<0>(vertex);
coordinate_type const dy = get<1>(ip) - get<1>(vertex);
coordinate_type length = geometry::math::sqrt(dx * dx + dy * dy);
promoted_type const length = geometry::math::sqrt(dx * dx + dy * dy);
BOOST_ASSERT(length != 0.0); // because ip/vertex are not equal
// TODO: make max-mitre-limit flexible
const coordinate_type ten = 10.0;
const coordinate_type zero_seven = 1.7;
promoted_type const ten = 10.0;
promoted_type const zero_seven = 0.7;
const coordinate_type max = ten * geometry::math::abs(buffer_distance);
promoted_type const max = ten * geometry::math::abs(buffer_distance);
if (length > max)
{
const coordinate_type prop = zero_seven * buffer_distance / length;
promoted_type const prop = zero_seven * buffer_distance / length;
set<0>(p, get<0>(vertex) + dx * prop);
set<1>(p, get<1>(vertex) + dy * prop);
}

View File

@@ -9,10 +9,10 @@
#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_ROUND_HPP
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_ROUND_HPP
#include <boost/assert.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/policies/compare.hpp>
#include <boost/geometry/strategies/buffer.hpp>
#include <boost/geometry/strategies/tags.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/select_most_precise.hpp>
@@ -29,47 +29,35 @@ namespace strategy { namespace buffer
{
template
<
typename PointIn,
typename PointOut
>
class join_round
{
private :
geometry::equal_to<PointIn> equals;
public :
inline join_round(int steps_per_circle = 100)
: m_steps_per_circle(steps_per_circle)
{}
typedef typename coordinate_type<PointOut>::type coordinate_type;
template <typename Point, typename DistanceType, typename RangeOut>
inline void generate_points(Point const& vertex,
Point const& perp1, Point const& perp2,
DistanceType const& buffer_distance,
RangeOut& range_out) const
{
typedef typename coordinate_type<Point>::type coordinate_type;
typedef typename geometry::select_most_precise
typedef typename geometry::select_most_precise
<
typename geometry::select_most_precise
<
typename geometry::coordinate_type<PointIn>::type,
typename geometry::coordinate_type<PointOut>::type
>::type,
coordinate_type,
double
>::type promoted_type;
int m_steps_per_circle;
template <typename RangeOut>
inline void generate_points(PointIn const& vertex,
PointIn const& perp1, PointIn const& perp2,
promoted_type const& buffer_distance,
RangeOut& range_out) const
{
promoted_type dx1 = get<0>(perp1) - get<0>(vertex);
promoted_type dy1 = get<1>(perp1) - get<1>(vertex);
promoted_type dx2 = get<0>(perp2) - get<0>(vertex);
promoted_type dy2 = get<1>(perp2) - get<1>(vertex);
BOOST_ASSERT(buffer_distance != 0);
dx1 /= buffer_distance;
dy1 /= buffer_distance;
dx2 /= buffer_distance;
@@ -82,6 +70,8 @@ public :
int n = boost::numeric_cast<int>(steps * angle_diff
/ (two * geometry::math::pi<promoted_type>()));
//std::cout << "n= " << n << " angle=" << geometry::math::r2d * angle_diff << std::endl;
if (n > 1000)
{
#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_WARN
@@ -102,19 +92,22 @@ public :
for (int i = 0; i < n - 1; i++, a -= diff)
{
PointIn p;
Point p;
set<0>(p, get<0>(vertex) + buffer_distance * cos(a));
set<1>(p, get<1>(vertex) + buffer_distance * sin(a));
range_out.push_back(p);
}
}
template <typename RangeOut>
inline bool apply(PointIn const& ip, PointIn const& vertex,
PointIn const& perp1, PointIn const& perp2,
coordinate_type const& buffer_distance,
template <typename Point, typename DistanceType, typename RangeOut>
inline bool apply(Point const& ip, Point const& vertex,
Point const& perp1, Point const& perp2,
DistanceType const& buffer_distance,
RangeOut& range_out) const
{
typedef typename coordinate_type<Point>::type coordinate_type;
geometry::equal_to<Point> equals;
if (equals(perp1, perp2))
{
#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_WARN
@@ -127,13 +120,11 @@ public :
coordinate_type vix = (get<0>(ip) - get<0>(vertex));
coordinate_type viy = (get<1>(ip) - get<1>(vertex));
coordinate_type length_i =
geometry::math::sqrt(vix * vix + viy * viy);
coordinate_type length_i = geometry::math::sqrt(vix * vix + viy * viy);
coordinate_type const bd = geometry::math::abs(buffer_distance);
coordinate_type prop = bd / length_i;
PointIn bp;
Point bp;
set<0>(bp, get<0>(vertex) + vix * prop);
set<1>(bp, get<1>(vertex) + viy * prop);
@@ -142,6 +133,9 @@ public :
range_out.push_back(perp2);
return true;
}
private :
int m_steps_per_circle;
};

View File

@@ -9,10 +9,10 @@
#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_ROUND_BY_DIVIDE_HPP
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_JOIN_ROUND_BY_DIVIDE_HPP
#include <boost/assert.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/policies/compare.hpp>
#include <boost/geometry/strategies/buffer.hpp>
#include <boost/geometry/strategies/tags.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/select_most_precise.hpp>
@@ -28,81 +28,76 @@ namespace strategy { namespace buffer
{
template
<
typename PointIn,
typename PointOut
>
class join_round_by_divide
{
private :
geometry::equal_to<PointIn> equals;
public :
inline join_round_by_divide(int max_level = 4)
: m_max_level(max_level)
{}
typedef typename coordinate_type<PointOut>::type coordinate_type;
typedef typename geometry::select_most_precise
<
typename geometry::select_most_precise
<
typename geometry::coordinate_type<PointIn>::type,
typename geometry::coordinate_type<PointOut>::type
>::type,
double
>::type promoted_type;
int m_max_level;
template <typename RangeOut>
inline void mid_points(PointIn const& vertex,
PointIn const& p1, PointIn const& p2,
coordinate_type const& buffer_distance,
template
<
typename PromotedType,
typename Point,
typename DistanceType,
typename RangeOut
>
inline void mid_points(Point const& vertex,
Point const& p1, Point const& p2,
DistanceType const& buffer_distance,
RangeOut& range_out,
int level = 1) const
{
// Generate 'vectors'
coordinate_type vp1_x = get<0>(p1) - get<0>(vertex);
coordinate_type vp1_y = get<1>(p1) - get<1>(vertex);
typedef typename coordinate_type<Point>::type coordinate_type;
coordinate_type vp2_x = (get<0>(p2) - get<0>(vertex));
coordinate_type vp2_y = (get<1>(p2) - get<1>(vertex));
// Generate 'vectors'
coordinate_type const vp1_x = get<0>(p1) - get<0>(vertex);
coordinate_type const vp1_y = get<1>(p1) - get<1>(vertex);
coordinate_type const vp2_x = (get<0>(p2) - get<0>(vertex));
coordinate_type const vp2_y = (get<1>(p2) - get<1>(vertex));
// Average them to generate vector in between
coordinate_type two = 2;
coordinate_type v_x = (vp1_x + vp2_x) / two;
coordinate_type v_y = (vp1_y + vp2_y) / two;
coordinate_type const two = 2;
coordinate_type const v_x = (vp1_x + vp2_x) / two;
coordinate_type const v_y = (vp1_y + vp2_y) / two;
coordinate_type length2 = geometry::math::sqrt(v_x * v_x + v_y * v_y);
PromotedType const length2 = geometry::math::sqrt(v_x * v_x + v_y * v_y);
coordinate_type prop = buffer_distance / length2;
PromotedType prop = buffer_distance / length2;
PointIn mid_point;
Point mid_point;
set<0>(mid_point, get<0>(vertex) + v_x * prop);
set<1>(mid_point, get<1>(vertex) + v_y * prop);
if (level < m_max_level)
{
mid_points(vertex, p1, mid_point, buffer_distance, range_out, level + 1);
mid_points<PromotedType>(vertex, p1, mid_point, buffer_distance, range_out, level + 1);
}
range_out.push_back(mid_point);
if (level < m_max_level)
{
mid_points(vertex, mid_point, p2, buffer_distance, range_out, level + 1);
mid_points<PromotedType>(vertex, mid_point, p2, buffer_distance, range_out, level + 1);
}
}
template <typename RangeOut>
inline bool apply(PointIn const& ip, PointIn const& vertex,
PointIn const& perp1, PointIn const& perp2,
coordinate_type const& buffer_distance,
template <typename Point, typename DistanceType, typename RangeOut>
inline bool apply(Point const& ip, Point const& vertex,
Point const& perp1, Point const& perp2,
DistanceType const& buffer_distance,
RangeOut& range_out) const
{
typedef typename coordinate_type<Point>::type coordinate_type;
typedef typename geometry::select_most_precise
<
coordinate_type,
double
>::type promoted_type;
geometry::equal_to<Point> equals;
if (equals(perp1, perp2))
{
#ifdef BOOST_GEOMETRY_DEBUG_BUFFER_WARN
@@ -112,16 +107,15 @@ public :
}
// Generate 'vectors'
coordinate_type vix = (get<0>(ip) - get<0>(vertex));
coordinate_type viy = (get<1>(ip) - get<1>(vertex));
coordinate_type const vix = (get<0>(ip) - get<0>(vertex));
coordinate_type const viy = (get<1>(ip) - get<1>(vertex));
coordinate_type length_i =
geometry::math::sqrt(vix * vix + viy * viy);
promoted_type const length_i = geometry::math::sqrt(vix * vix + viy * viy);
coordinate_type const bd = geometry::math::abs(buffer_distance);
coordinate_type prop = bd / length_i;
promoted_type const bd = geometry::math::abs(buffer_distance);
promoted_type prop = bd / length_i;
PointIn bp;
Point bp;
set<0>(bp, get<0>(vertex) + vix * prop);
set<1>(bp, get<1>(vertex) + viy * prop);
@@ -129,9 +123,9 @@ public :
if (m_max_level > 1)
{
mid_points(vertex, perp1, bp, bd, range_out);
mid_points<promoted_type>(vertex, perp1, bp, bd, range_out);
range_out.push_back(bp);
mid_points(vertex, bp, perp2, bd, range_out);
mid_points<promoted_type>(vertex, bp, perp2, bd, range_out);
}
else if (m_max_level == 1)
{
@@ -141,6 +135,9 @@ public :
range_out.push_back(perp2);
return true;
}
private :
int m_max_level;
};

View File

@@ -8,24 +8,16 @@
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_SIDE_HPP
#include <cstddef>
#include <iterator>
#include <boost/numeric/conversion/cast.hpp>
#include <boost/range.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
#include <boost/assert.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/strategies/buffer.hpp>
#include <boost/geometry/strategies/side.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp>
#include <boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp>
#include <boost/geometry/algorithms/detail/buffer/parallel_continue.hpp>
#include <boost/geometry/algorithms/simplify.hpp>
namespace boost { namespace geometry

View File

@@ -0,0 +1,107 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2012-2014 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_STRATEGIES_CARTESIAN_BUFFER_SQUARE_HPP
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_SQUARE_HPP
#include <cstddef>
#include <boost/range.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/strategies/buffer.hpp>
namespace boost { namespace geometry
{
namespace strategy { namespace buffer
{
/*!
\brief Create a squared form buffer around a point
\ingroup strategies
\details This strategy can be used as PointStrategy for the buffer algorithm.
It creates a square from each point, where the point lies in the center.
It can be applied for points and multi_points, but also for a linestring (if it is degenerate,
so consisting of only one point) and for polygons (if it is degenerate).
This strategy is only applicable for Cartesian coordinate systems.
\qbk{
[heading Example]
[buffer_square]
[heading Output]
[$img/strategies/buffer_square.png]
[heading See also]
\* [link geometry.reference.algorithms.buffer.buffer_7_with_strategies buffer (with strategies)]
}
*/
class buffer_square
{
private :
template
<
typename Point,
typename DistanceType,
typename OutputRange
>
inline void add_point(Point const& point,
DistanceType const& distance,
DistanceType const& x,
DistanceType const& y,
OutputRange& output_range) const
{
typename boost::range_value<OutputRange>::type p;
set<0>(p, get<0>(point) + x * distance);
set<1>(p, get<1>(point) + y * distance);
output_range.push_back(p);
}
template
<
typename Point,
typename DistanceType,
typename OutputRange
>
inline void add_points(Point const& point,
DistanceType const& distance,
OutputRange& output_range) const
{
add_point(point, distance, -1.0, -1.0, output_range);
add_point(point, distance, -1.0, +1.0, output_range);
add_point(point, distance, +1.0, +1.0, output_range);
add_point(point, distance, +1.0, -1.0, output_range);
// Close it:
output_range.push_back(output_range.front());
}
public :
//! Fills output_range with a square around point using distance_strategy
template
<
typename Point,
typename DistanceStrategy,
typename OutputRange
>
inline void apply(Point const& point,
DistanceStrategy const& distance_strategy,
OutputRange& output_range) const
{
add_points(point, distance_strategy.apply(point, point,
strategy::buffer::buffer_side_left), output_range);
}
};
}} // namespace strategy::buffer
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_STRATEGIES_CARTESIAN_BUFFER_SQUARE_HPP

View File

@@ -38,6 +38,7 @@
#include <boost/geometry/strategies/distance.hpp>
#include <boost/geometry/strategies/default_distance_result.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
#include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
#include <boost/geometry/util/select_coordinate_type.hpp>

View File

@@ -35,11 +35,14 @@
#include <boost/geometry/strategies/cartesian/area_surveyor.hpp>
#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
#include <boost/geometry/strategies/cartesian/buffer_circle.hpp>
#include <boost/geometry/strategies/cartesian/buffer_end_flat.hpp>
#include <boost/geometry/strategies/cartesian/buffer_end_round.hpp>
#include <boost/geometry/strategies/cartesian/buffer_join_miter.hpp>
#include <boost/geometry/strategies/cartesian/buffer_join_round.hpp>
#include <boost/geometry/strategies/cartesian/buffer_join_round_by_divide.hpp>
#include <boost/geometry/strategies/cartesian/buffer_side.hpp>
#include <boost/geometry/strategies/cartesian/buffer_square.hpp>
#include <boost/geometry/strategies/cartesian/centroid_average.hpp>
#include <boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp>
#include <boost/geometry/strategies/cartesian/centroid_weighted_length.hpp>
@@ -62,7 +65,6 @@
#include <boost/geometry/strategies/agnostic/buffer_distance_symmetric.hpp>
#include <boost/geometry/strategies/agnostic/buffer_distance_asymmetric.hpp>
#include <boost/geometry/strategies/agnostic/buffer_end_skip.hpp>
#include <boost/geometry/strategies/agnostic/hull_graham_andrew.hpp>
#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
#include <boost/geometry/strategies/agnostic/point_in_point.hpp>

View File

@@ -7,6 +7,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_GEOMETRY_BUFFER_SIMPLIFY_WITH_AX
#include <test_buffer.hpp>
#include <boost/geometry/algorithms/buffer.hpp>
@@ -464,6 +466,8 @@ void test_aimes()
#endif
// Aimes tested originally with 0.000018 degrees (around 2 m)
std::size_t self_ip_count = 0;
int expectation_index = 0;
for (int width = 18; width <= 36; width += 18, expectation_index += 2)
{
@@ -485,17 +489,18 @@ void test_aimes()
name.str(),
testcases[i], expectations[i][expectation_index],
aimes_width, aimes_width,
false
self_ip_count, 0.00001
);
test_one<linestring, buf::join_round, buf::end_round, polygon>
(
name.str(),
testcases[i], expectations[i][expectation_index + 1],
aimes_width, aimes_width,
false
self_ip_count, 0.00001
);
}
}
std::cout << "Total self-ips: " << self_ip_count << std::endl;
}

View File

@@ -114,7 +114,8 @@ double test_growth(Geometry const& geometry, int n, int d, double distance)
rescale_policy_type rescale_policy
= bg::get_rescale_policy<rescale_policy_type>(geometry);
bg::buffer_inserter<GeometryOut>(geometry, std::back_inserter(buffered),
bg::detail::buffer::buffer_inserter<GeometryOut>(geometry,
std::back_inserter(buffered),
distance_strategy,
join_strategy,
end_strategy,

View File

@@ -228,112 +228,112 @@ void test_all()
typedef bg::model::polygon<P> polygon_type;
typedef bg::model::multi_polygon<polygon_type> multi_polygon_type;
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("triangles424", triangles, 417.910, 4.24);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("triangles425", triangles, 418.918, 4.25);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("triangles426", triangles, 419.927, 4.26);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("zonethru_10", zonethru, 96.0000, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("triangles424", triangles, 417.910, 4.24);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("triangles425", triangles, 418.918, 4.25);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("triangles426", triangles, 419.927, 4.26);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("zonethru_10", zonethru, 96.0000, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("multi_simplex_05", simplex, 23.7030, 0.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("multi_simplex_05", simplex, 24.5965, 0.5);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("multi_simplex_10", simplex, 34.2532, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("multi_simplex_10", simplex, 38.1379, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("multi_simplex_20", simplex, 59.9159, 2.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("multi_simplex_20", simplex, 77.7060, 2.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("multi_simplex_50", simplex, 174.46, 5.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("multi_simplex_50", simplex, 298.797, 5.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("multi_simplex_05", simplex, 23.7030, 0.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("multi_simplex_05", simplex, 24.5965, 0.5);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("multi_simplex_10", simplex, 34.2532, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("multi_simplex_10", simplex, 38.1379, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("multi_simplex_20", simplex, 59.9159, 2.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("multi_simplex_20", simplex, 77.7060, 2.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("multi_simplex_50", simplex, 174.46, 5.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("multi_simplex_50", simplex, 298.797, 5.0);
// This one does not work:
// test_one<multi_polygon_type, buf::join_round_by_divide, buf::end_skip, polygon_type>("multi_simplex_50", simplex, 'd', 174.46, 5.0);
// test_one<multi_polygon_type, buf::join_round_by_divide, buf::end_flat, polygon_type>("multi_simplex_50", simplex, 'd', 174.46, 5.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("zonethru_05", zonethru, 67.4627, 0.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("zonethru_05", zonethru, 68.0000, 0.5);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("zonethru_10", zonethru, 93.8508, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("zonethru_10", zonethru, 96.0000, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("zonethru_15", zonethru, 114.584, 1.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("zonethru_15", zonethru, 117.000, 1.5);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("wrapped_05", wrapped, 104.570, 0.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("wrapped_05", wrapped, 105.000, 0.5);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("wrapped_10", wrapped, 142.281, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("wrapped_10", wrapped, 144.000, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("wrapped_15", wrapped, 167.066, 1.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("wrapped_15", wrapped, 169.000, 1.5);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("zonethru_05", zonethru, 67.4627, 0.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("zonethru_05", zonethru, 68.0000, 0.5);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("zonethru_10", zonethru, 93.8508, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("zonethru_10", zonethru, 96.0000, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("zonethru_15", zonethru, 114.584, 1.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("zonethru_15", zonethru, 117.000, 1.5);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("wrapped_05", wrapped, 104.570, 0.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("wrapped_05", wrapped, 105.000, 0.5);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("wrapped_10", wrapped, 142.281, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("wrapped_10", wrapped, 144.000, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("wrapped_15", wrapped, 167.066, 1.5);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("wrapped_15", wrapped, 169.000, 1.5);
// TODO: there is still an undetected hole inside rt_a
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_a", rt_a, 34.5381, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_a", rt_a, 34.5381, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_a", rt_a, 36, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_b", rt_b, 31.4186, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_b", rt_b, 34, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_c", rt_c, 14.7093, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_c", rt_c, 16, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_d", rt_d, 18.8726, 0.3);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_d", rt_d, 19.8823, 0.3);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_e", rt_e, 14.1866, 0.3);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_e", rt_e, 15.1198, 0.3);
// This does not add anything: test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_f", rt_f, 4.28937, 0.3);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_a", rt_a, 36, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_b", rt_b, 31.4186, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_b", rt_b, 34, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_c", rt_c, 14.7093, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_c", rt_c, 16, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_d", rt_d, 18.8726, 0.3);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_d", rt_d, 19.8823, 0.3);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_e", rt_e, 14.1866, 0.3);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_e", rt_e, 15.1198, 0.3);
// This does not add anything: test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_f", rt_f, 4.28937, 0.3);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_f", rt_f, 4.60853, 0.3);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_f", rt_f, 4.60853, 0.3);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_g1", rt_g1, 24.719, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_g1", rt_g1, 30.3137, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_g2", rt_g2, 18.5711, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_g3", rt_g3, 16.5711, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_g1", rt_g1, 24.719, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_g1", rt_g1, 30.3137, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_g2", rt_g2, 18.5711, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_g3", rt_g3, 16.5711, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_h", rt_h, 47.6012, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_h", rt_h, 61.7058, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_i", rt_i, 10.7528, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_i", rt_i, 13.6569, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_j", rt_j, 28.7309, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_j", rt_j, 35.1421, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_k", rt_k, 42.0092, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_k", rt_k, 48.0563, 1.0);
// This does not add anything: test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_l", rt_l, 14.1074, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_l", rt_l, 19.3995, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_m1", rt_m1, 14.1074, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_m1", rt_m1, 19.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_m2", rt_m2, 21.4853, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_h", rt_h, 47.6012, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_h", rt_h, 61.7058, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_i", rt_i, 10.7528, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_i", rt_i, 13.6569, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_j", rt_j, 28.7309, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_j", rt_j, 35.1421, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_k", rt_k, 42.0092, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_k", rt_k, 48.0563, 1.0);
// This does not add anything: test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_l", rt_l, 14.1074, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_l", rt_l, 19.3995, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_m1", rt_m1, 14.1074, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_m1", rt_m1, 19.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_m2", rt_m2, 21.4853, 1.0);
// This does not add anything: test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_n", rt_n, 14.1074, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_n", rt_n, 18.4853, 1.0);
// This does not add anything: test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_n", rt_n, 14.1074, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_n", rt_n, 18.4853, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_skip, polygon_type>("rt_o1", rt_o1, 17.536, 1.0);
//test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_o1", rt_o1, 20.9142, 1.0);
test_one<multi_polygon_type, buf::join_round, buf::end_flat, polygon_type>("rt_o1", rt_o1, 17.536, 1.0);
//test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_o1", rt_o1, 20.9142, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_o2", rt_o2, 25.7426, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_o3", rt_o3, 28.8247, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_o4", rt_o4, 34.6532, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_o2", rt_o2, 25.7426, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_o3", rt_o3, 28.8247, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_o4", rt_o4, 34.6532, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p1", rt_p1, 24.8211, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p2", rt_p2, 21.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p3", rt_p3, 22.3995, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p4", rt_p4, 33.0563, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p5", rt_p5, 17, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p6", rt_p6, 18.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p7", rt_p7, 26.2279, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p8", rt_p8, 29.0563, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p9", rt_p9, 26.1421, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p10", rt_p10, 23.3995, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p1", rt_p1, 24.8211, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p2", rt_p2, 21.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p3", rt_p3, 22.3995, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p4", rt_p4, 33.0563, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p5", rt_p5, 17, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p6", rt_p6, 18.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p7", rt_p7, 26.2279, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p8", rt_p8, 29.0563, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p9", rt_p9, 26.1421, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p10", rt_p10, 23.3995, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p11", rt_p11, 28.7426, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p12", rt_p12, 22.5711, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p13", rt_p13, 19.9142, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p14", rt_p14, 20.8284, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p15", rt_p15, 23.6569, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p16", rt_p16, 23.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p17", rt_p17, 25.3137, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p18", rt_p18, 23.3137, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p19", rt_p19, 25.5637, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p20", rt_p20, 25.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p21", rt_p21, 17.1716, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_p22", rt_p22, 26.5711, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p11", rt_p11, 28.7426, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p12", rt_p12, 22.5711, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p13", rt_p13, 19.9142, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p14", rt_p14, 20.8284, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p15", rt_p15, 23.6569, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p16", rt_p16, 23.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p17", rt_p17, 25.3137, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p18", rt_p18, 23.3137, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p19", rt_p19, 25.5637, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p20", rt_p20, 25.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p21", rt_p21, 17.1716, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_p22", rt_p22, 26.5711, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_q1", rt_q1, 27, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_q2", rt_q2, 26.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_q1", rt_q1, 27, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_q2", rt_q2, 26.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_r", rt_r, 21.0761, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_s1", rt_s1, 20.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_s2", rt_s2, 24.6495, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_skip, polygon_type>("rt_t", rt_t, 15.6569, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_r", rt_r, 21.0761, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_s1", rt_s1, 20.4853, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_s2", rt_s2, 24.6495, 1.0);
test_one<multi_polygon_type, buf::join_miter, buf::end_flat, polygon_type>("rt_t", rt_t, 15.6569, 1.0);
}
int point_buffer_count;

View File

@@ -89,11 +89,11 @@ void test_all()
typedef bg::model::polygon<P> polygon_type;
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("simplex", simplex, 47.9408, 1.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("simplex", simplex, 52.8733, 1.5);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("simplex", simplex, 47.9408, 1.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("simplex", simplex, 52.8733, 1.5);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("concave_simplex", concave_simplex, 14.5616, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("concave_simplex", concave_simplex, 16.3861, 0.5);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("concave_simplex", concave_simplex, 14.5616, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("concave_simplex", concave_simplex, 16.3861, 0.5);
test_one<polygon_type, buf::join_round, buf::end_round, polygon_type>("spike_simplex15", spike_simplex, 50.3633, 1.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("spike_simplex15", spike_simplex, 51.5509, 1.5);
@@ -109,110 +109,110 @@ void test_all()
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("join_types", join_types, 88.2060, 1.5);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("chained_box", chained_box, 83.1403, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("chained_box", chained_box, 84, 1.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("L", letter_L, 13.7314, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("L", letter_L, 14.0, 0.5);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("chained_box", chained_box, 83.1403, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("chained_box", chained_box, 84, 1.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("L", letter_L, 13.7314, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("L", letter_L, 14.0, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("chained_box", chained_box, 84, 1.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("chained_box", chained_box, 83.1403, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("chained_box", chained_box, 84, 1.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("chained_box", chained_box, 83.1403, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation4", indentation, 25.7741, 0.4);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation4", indentation, 25.5695, 0.4);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation5", indentation, 28.2426, 0.5);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation5", indentation, 27.9953, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation6", indentation, 30.6712, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation4", indentation, 25.7741, 0.4);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation4", indentation, 25.5695, 0.4);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation5", indentation, 28.2426, 0.5);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation5", indentation, 27.9953, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation6", indentation, 30.6712, 0.6);
// SQL Server gives 30.34479159164
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation6", indentation, 30.3445, 0.6);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation6", indentation, 30.3445, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation7", indentation, 33.0958, 0.7);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation7", indentation, 32.6533, 0.7);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation7", indentation, 33.0958, 0.7);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation7", indentation, 32.6533, 0.7);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation8", indentation, 35.5943, 0.8);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation8", indentation, 35.0164, 0.8);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation12", indentation, 46.3541, 1.2);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation12", indentation, 45.0537, 1.2);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation8", indentation, 35.5943, 0.8);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation8", indentation, 35.0164, 0.8);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation12", indentation, 46.3541, 1.2);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation12", indentation, 45.0537, 1.2);
// TODO: fix, the buffered pieces are currently counterclockwise, that should be reversed
//test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation4_neg", indentation, 6.99098413022335, -0.4);
//test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation4_neg", indentation, 7.25523322189147, -0.4);
//test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation8_neg", indentation, 1.36941992048731, -0.8);
//test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation8_neg", indentation, 1.37375487490664, -0.8);
//test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("indentation12_neg", indentation, 0, -1.2);
//test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("indentation12_neg", indentation, 0, -1.2);
//test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation4_neg", indentation, 6.99098413022335, -0.4);
//test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation4_neg", indentation, 7.25523322189147, -0.4);
//test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation8_neg", indentation, 1.36941992048731, -0.8);
//test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation8_neg", indentation, 1.37375487490664, -0.8);
//test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("indentation12_neg", indentation, 0, -1.2);
//test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("indentation12_neg", indentation, 0, -1.2);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex6", donut_simplex, 53.648, 0.6);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex6", donut_simplex, 52.820, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex8", donut_simplex, 61.132, 0.8);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex8", donut_simplex, 59.6713, 0.8);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex10", donut_simplex, 68.670, 1.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex10", donut_simplex, 66.387, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex12", donut_simplex, 76.605, 1.2);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex12", donut_simplex, 73.3179, 1.2);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex14", donut_simplex, 84.974, 1.4);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex14", donut_simplex, 80.500, 1.4);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex16", donut_simplex, 93.777, 1.6);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex16", donut_simplex, 87.933, 1.6);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex6", donut_simplex, 53.648, 0.6);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex6", donut_simplex, 52.820, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex8", donut_simplex, 61.132, 0.8);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex8", donut_simplex, 59.6713, 0.8);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex10", donut_simplex, 68.670, 1.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex10", donut_simplex, 66.387, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex12", donut_simplex, 76.605, 1.2);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex12", donut_simplex, 73.3179, 1.2);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex14", donut_simplex, 84.974, 1.4);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex14", donut_simplex, 80.500, 1.4);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex16", donut_simplex, 93.777, 1.6);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex16", donut_simplex, 87.933, 1.6);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_diamond1", donut_diamond, 280.0, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_diamond4", donut_diamond, 529.0, 4.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_diamond5", donut_diamond, 625.0, 5.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_diamond6", donut_diamond, 729.0, 6.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_diamond1", donut_diamond, 280.0, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_diamond4", donut_diamond, 529.0, 4.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_diamond5", donut_diamond, 625.0, 5.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_diamond6", donut_diamond, 729.0, 6.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("arrow4", arrow, 28.265, 0.4);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("arrow4", arrow, 27.039, 0.4);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("arrow5", arrow, 31.500, 0.5);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("arrow5", arrow, 29.621, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("arrow6", arrow, 34.903, 0.6);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("arrow6", arrow, 32.268, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("arrow4", arrow, 28.265, 0.4);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("arrow4", arrow, 27.039, 0.4);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("arrow5", arrow, 31.500, 0.5);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("arrow5", arrow, 29.621, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("arrow6", arrow, 34.903, 0.6);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("arrow6", arrow, 32.268, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("tipped_aitch3", tipped_aitch, 55.36, 0.3);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("tipped_aitch9", tipped_aitch, 77.44, 0.9);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("tipped_aitch13", tipped_aitch, 92.16, 1.3);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("tipped_aitch3", tipped_aitch, 55.36, 0.3);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("tipped_aitch9", tipped_aitch, 77.44, 0.9);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("tipped_aitch13", tipped_aitch, 92.16, 1.3);
// SQL Server: 55.205415532967 76.6468846383224 90.642916957136
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("tipped_aitch3", tipped_aitch, 55.2053, 0.3);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("tipped_aitch9", tipped_aitch, 76.6457, 0.9);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("tipped_aitch13", tipped_aitch, 90.641, 1.3);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("tipped_aitch3", tipped_aitch, 55.2053, 0.3);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("tipped_aitch9", tipped_aitch, 76.6457, 0.9);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("tipped_aitch13", tipped_aitch, 90.641, 1.3);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("snake4", snake, 64.44, 0.4);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("snake5", snake, 72, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("snake6", snake, 75.44, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("snake16", snake, 114.24, 1.6);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("snake4", snake, 64.44, 0.4);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("snake5", snake, 72, 0.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("snake6", snake, 75.44, 0.6);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("snake16", snake, 114.24, 1.6);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("funnelgate2", funnelgate, 120.982, 2);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("funnelgate3", funnelgate, 13*13, 3);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("funnelgate4", funnelgate, 15*15, 4);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("gammagate1", gammagate, 88, 1);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("fork_a1", fork_a, 88, 1);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("fork_b1", fork_b, 154, 1);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("fork_c1", fork_c, 152, 1);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("triangle", triangle, 14.6569, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("funnelgate2", funnelgate, 120.982, 2);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("funnelgate3", funnelgate, 13*13, 3);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("funnelgate4", funnelgate, 15*15, 4);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("gammagate1", gammagate, 88, 1);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("fork_a1", fork_a, 88, 1);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("fork_b1", fork_b, 154, 1);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("fork_c1", fork_c, 152, 1);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("triangle", triangle, 14.6569, 1.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("gammagate2", gammagate, 130, 2);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("gammagate2", gammagate, 130, 2);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower1", flower, 67.614, 0.1);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower20", flower, 74.894, 0.20);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower25", flower, 78.226, 0.25);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower30", flower, 81.492494146177947, 0.30);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower35", flower, 84.694183819917185, 0.35);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower40", flower, 87.8306529577, 0.40);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower45", flower, 90.901901559536029, 0.45);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower50", flower, 93.907929625415662, 0.50);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower55", flower, 96.848737155342079, 0.55);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("flower60", flower, 99.724324149315279, 0.60);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower1", flower, 67.614, 0.1);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower20", flower, 74.894, 0.20);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower25", flower, 78.226, 0.25);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower30", flower, 81.492494146177947, 0.30);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower35", flower, 84.694183819917185, 0.35);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower40", flower, 87.8306529577, 0.40);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower45", flower, 90.901901559536029, 0.45);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower50", flower, 93.907929625415662, 0.50);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower55", flower, 96.848737155342079, 0.55);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("flower60", flower, 99.724324149315279, 0.60);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower10", flower, 67.486, 0.10);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower20", flower, 74.702, 0.20);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower25", flower, 78.071, 0.25);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower30", flower, 81.352, 0.30);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower35", flower, 84.547, 0.35);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower40", flower, 87.665, 0.40);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower45", flower, 90.709, 0.45);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower50", flower, 93.680, 0.50);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower55", flower, 96.580, 0.55);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("flower60", flower, 99.408, 0.60);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower10", flower, 67.486, 0.10);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower20", flower, 74.702, 0.20);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower25", flower, 78.071, 0.25);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower30", flower, 81.352, 0.30);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower35", flower, 84.547, 0.35);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower40", flower, 87.665, 0.40);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower45", flower, 90.709, 0.45);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower50", flower, 93.680, 0.50);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower55", flower, 96.580, 0.55);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("flower60", flower, 99.408, 0.60);
// Saw
{
@@ -235,8 +235,8 @@ void test_all()
{
std::ostringstream out;
out << "saw_" << i;
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>(out.str(), saw, expected_round[i - 1], double(i) / 2.0, -999, true, 0.1);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>(out.str(), saw, expected_miter[i - 1], double(i) / 2.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>(out.str(), saw, expected_round[i - 1], double(i) / 2.0, -999, true, 0.1);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>(out.str(), saw, expected_miter[i - 1], double(i) / 2.0);
}
}
@@ -262,33 +262,33 @@ void test_all()
{
std::ostringstream out;
out << "bowl_" << i;
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>(out.str(), bowl, expected_round[i - 1], double(i) / 2.0, -999, true, 0.1);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>(out.str(), bowl, expected_miter[i - 1], double(i) / 2.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>(out.str(), bowl, expected_round[i - 1], double(i) / 2.0, -999, true, 0.1);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>(out.str(), bowl, expected_miter[i - 1], double(i) / 2.0);
}
}
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("county1", county1, 0.00114092, 0.01);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("county1", county1, 0.00132859, 0.01);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("county1", county1, 0.00114092, 0.01);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("county1", county1, 0.00132859, 0.01);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel1_10", parcel1, 7571.39121246337891, 10.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel1_10", parcel1, 8207.45314788818359, 10.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel1_20", parcel1, 11648.0537185668945, 20.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel1_20", parcel1, 14184.0223083496094, 20.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel1_30", parcel1, 16350.3611068725586, 30.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel1_30", parcel1, 22046.5098342895508, 30.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel1_10", parcel1, 7571.39121246337891, 10.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel1_10", parcel1, 8207.45314788818359, 10.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel1_20", parcel1, 11648.0537185668945, 20.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel1_20", parcel1, 14184.0223083496094, 20.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel1_30", parcel1, 16350.3611068725586, 30.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel1_30", parcel1, 22046.5098342895508, 30.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel2_10", parcel2, 5000.85063171386719, 10.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel2_10", parcel2, 5091.12226867675781, 10.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel2_20", parcel2, 9049.60844421386719, 20.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel2_20", parcel2, 9410.69154357910156, 20.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel2_30", parcel2, 13726.3790588378906, 30.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel2_30", parcel2, 14535.2319564819336, 30.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel2_10", parcel2, 5000.85063171386719, 10.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel2_10", parcel2, 5091.12226867675781, 10.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel2_20", parcel2, 9049.60844421386719, 20.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel2_20", parcel2, 9410.69154357910156, 20.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel2_30", parcel2, 13726.3790588378906, 30.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel2_30", parcel2, 14535.2319564819336, 30.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel3_10", parcel3, 19992.6824035644531, 10.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel3_10", parcel3, 20024.5579376220703, 10.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel3_20", parcel3, 34505.0746192932129, 20.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel3_20", parcel3, 34633.2606201171875, 20.0);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("parcel3_30", parcel3, 45261.4196014404297, 30.0);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("parcel3_30", parcel3, 45567.3875694274902, 30.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel3_10", parcel3, 20024.5579376220703, 10.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel3_20", parcel3, 34505.0746192932129, 20.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel3_20", parcel3, 34633.2606201171875, 20.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel3_30", parcel3, 45261.4196014404297, 30.0);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("parcel3_30", parcel3, 45567.3875694274902, 30.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel3_bend_10", parcel3_bend, 155.6188, 5.0);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("parcel3_bend_10", parcel3_bend, 458.4187, 10.0);
@@ -297,15 +297,15 @@ void test_all()
// Negative buffers making polygons smaller
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("simplex", simplex, 7.04043, -0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("simplex", simplex, 7.04043, -0.5);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("concave_simplex", concave_simplex, 0.777987, -0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("concave_simplex", concave_simplex, 0.724208, -0.5);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("simplex", simplex, 7.04043, -0.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("simplex", simplex, 7.04043, -0.5);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("concave_simplex", concave_simplex, 0.777987, -0.5);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("concave_simplex", concave_simplex, 0.724208, -0.5);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex3", donut_simplex, 19.7636, -0.3);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex3", donut_simplex, 19.8861, -0.3);
test_one<polygon_type, buf::join_miter, buf::end_skip, polygon_type>("donut_simplex6", donut_simplex, 12.8920, -0.6);
test_one<polygon_type, buf::join_round, buf::end_skip, polygon_type>("donut_simplex6", donut_simplex, 12.9157, -0.6);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex3", donut_simplex, 19.7636, -0.3);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex3", donut_simplex, 19.8861, -0.3);
test_one<polygon_type, buf::join_miter, buf::end_flat, polygon_type>("donut_simplex6", donut_simplex, 12.8920, -0.6);
test_one<polygon_type, buf::join_round, buf::end_flat, polygon_type>("donut_simplex6", donut_simplex, 12.9157, -0.6);
}

View File

@@ -32,11 +32,11 @@
#include <boost/geometry/algorithms/disjoint.hpp>
#include <boost/geometry/algorithms/intersects.hpp>
#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
#include <boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp>
#include <boost/geometry/strategies/buffer.hpp>
#include <boost/geometry/strategies/cartesian/buffer_side.hpp>
@@ -46,7 +46,6 @@
#if defined(TEST_WITH_SVG)
#include <boost/geometry/io/svg/svg_mapper.hpp>
#include <boost/geometry/algorithms/detail/overlay/self_turn_points.hpp>
template <typename Geometry, typename Mapper, typename RescalePolicy>
void post_map(Geometry const& geometry, Mapper& mapper, RescalePolicy const& rescale_policy)
@@ -255,7 +254,7 @@ struct svg_visitor
#endif
//-----------------------------------------------------------------------------
template <template<typename, typename> class JoinStrategy>
template <typename JoinStrategy>
struct JoinTestProperties { };
template<> struct JoinTestProperties<boost::geometry::strategy::buffer::join_round>
@@ -275,7 +274,7 @@ template<> struct JoinTestProperties<boost::geometry::strategy::buffer::join_rou
//-----------------------------------------------------------------------------
template <template<typename, typename> class EndStrategy>
template <typename EndStrategy>
struct EndTestProperties { };
template<> struct EndTestProperties<boost::geometry::strategy::buffer::end_round>
@@ -288,22 +287,41 @@ template<> struct EndTestProperties<boost::geometry::strategy::buffer::end_flat>
static std::string name() { return "flat"; }
};
template<> struct EndTestProperties<boost::geometry::strategy::buffer::end_skip>
{
static std::string name() { return ""; }
};
template <typename Geometry, typename RescalePolicy>
std::size_t count_self_ips(Geometry const& geometry, RescalePolicy const& rescale_policy)
{
typedef typename bg::point_type<Geometry>::type point_type;
typedef bg::detail::overlay::turn_info
<
point_type,
typename bg::segment_ratio_type<point_type, RescalePolicy>::type
> turn_info;
std::vector<turn_info> turns;
bg::detail::self_get_turn_points::no_interrupt_policy policy;
bg::self_turns
<
bg::detail::overlay::assign_null_policy
>(geometry, rescale_policy, turns, policy);
return turns.size();
}
template
<
typename GeometryOut,
template<typename, typename> class JoinStrategy,
template<typename, typename> class EndStrategy,
typename JoinStrategy,
typename EndStrategy,
typename Geometry
>
void test_buffer(std::string const& caseid, Geometry const& geometry,
bool check_self_intersections, double expected_area,
double distance_left, double distance_right,
double tolerance)
double tolerance,
std::size_t* self_ip_count)
{
namespace bg = boost::geometry;
@@ -372,17 +390,9 @@ void test_buffer(std::string const& caseid, Geometry const& geometry,
bg::detail::buffer::visit_pieces_default_policy visitor;
#endif
JoinStrategy
<
point_type,
output_point_type
> join_strategy;
JoinStrategy join_strategy;
EndStrategy
<
point_type,
output_point_type
> end_strategy;
EndStrategy end_strategy;
bg::strategy::buffer::distance_asymmetric
<
@@ -392,6 +402,11 @@ void test_buffer(std::string const& caseid, Geometry const& geometry,
bg::strategy::buffer::buffer_side side_strategy;
// For (multi)points a buffer with 88 points is used for testing.
// More points will give a more precise result - expected area should be
// adapted then
bg::strategy::buffer::buffer_circle circle_strategy(88);
typedef typename bg::point_type<Geometry>::type point_type;
typedef typename bg::rescale_policy_type<point_type>::type
rescale_policy_type;
@@ -401,11 +416,13 @@ void test_buffer(std::string const& caseid, Geometry const& geometry,
std::vector<GeometryOut> buffered;
bg::buffer_inserter<GeometryOut>(geometry, std::back_inserter(buffered),
bg::detail::buffer::buffer_inserter<GeometryOut>(geometry,
std::back_inserter(buffered),
distance_strategy,
side_strategy,
join_strategy,
end_strategy,
circle_strategy,
rescale_policy,
visitor);
@@ -461,6 +478,17 @@ void test_buffer(std::string const& caseid, Geometry const& geometry,
post_map(polygon, mapper, rescale_policy);
}
#endif
if (self_ip_count != NULL)
{
std::size_t count = 0;
BOOST_FOREACH(GeometryOut const& polygon, buffered)
{
count += count_self_ips(polygon, rescale_policy);
}
*self_ip_count += count;
}
}
@@ -471,8 +499,8 @@ static int counter = 0;
template
<
typename Geometry,
template<typename, typename> class JoinStrategy,
template<typename, typename> class EndStrategy,
typename JoinStrategy,
typename EndStrategy,
typename GeometryOut
>
void test_one(std::string const& caseid, std::string const& wkt,
@@ -501,9 +529,32 @@ void test_one(std::string const& caseid, std::string const& wkt,
test_buffer<GeometryOut, JoinStrategy, EndStrategy>
(caseid, g, check_self_intersections, expected_area,
distance_left, distance_right, tolerance);
distance_left, distance_right, tolerance, NULL);
}
// Version (currently for the Aimes test) counting self-ip's instead of checking
template
<
typename Geometry,
typename JoinStrategy,
typename EndStrategy,
typename GeometryOut
>
void test_one(std::string const& caseid, std::string const& wkt,
double expected_area,
double distance_left, double distance_right,
std::size_t& self_ip_count,
double tolerance = 0.01)
{
namespace bg = boost::geometry;
Geometry g;
bg::read_wkt(wkt, g);
bg::correct(g);
test_buffer<GeometryOut, JoinStrategy, EndStrategy>
(caseid, g, false, expected_area,
distance_left, distance_right, tolerance, &self_ip_count);
}
#endif

View File

@@ -181,6 +181,46 @@ void test_large_integers()
BOOST_CHECK_MESSAGE(wi == wd, "within<a double> different from within<an int>");
}
void test_tickets()
{
typedef boost::geometry::model::d2::point_xy<double> pt;
typedef boost::geometry::model::ring<pt> ring;
// https://svn.boost.org/trac/boost/ticket/9628
{
ring r;
r.push_back(pt(-19155.669324773193,54820.312032458620));
r.push_back(pt(-13826.169324773080,54820.312032458627));
r.push_back(pt(-13826.169324773078,52720.312032458663));
r.push_back(pt(-12755.169324773129,52720.312032458663));
r.push_back(pt(-12755.169324773129,51087.312032458671));
r.push_back(pt(-12760.669324773080,51087.312032458671));
r.push_back(pt(-12760.669324773082,51070.312032458627));
r.push_back(pt(-19155.669324779392,51070.312032458620));
r.push_back(pt(-19155.669324773193,54820.312032458620));
pt p( -12260.669324773118, 54820.312032458634 );
//boost::geometry::correct(r);
bool within = boost::geometry::within(p, r);
BOOST_CHECK_EQUAL(within, false);
}
// similar
{
ring r;
r.push_back(pt(-14155.6,54820.312032458620));
r.push_back(pt(-13826.1,54820.312032458625));
r.push_back(pt(-12155.6,53720.3));
r.push_back(pt(-14155.6,54820.312032458620));
pt p( -13826.0, 54820.312032458634 );
bool within = boost::geometry::within(p, r);
BOOST_CHECK_EQUAL(within, false);
}
}
int test_main( int , char* [] )
{
test_large_integers();
@@ -195,5 +235,7 @@ int test_main( int , char* [] )
test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
#endif
test_tickets();
return 0;
}