diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 7725b0fab..b3d675a07 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -57,6 +57,7 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ tparam_container="container type, for example std::vector, std::deque" \ tparam_dimension_required="Dimension, this template parameter is required. Should contain \[0 .. n-1\] for an n-dimensional geometry" \ tparam_first_point="first point type" \ + tparam_functor="Function or class with operator()" \ tparam_geometry="Any type fulfilling a Geometry Concept" \ tparam_geometry{1}="A type fulfilling a \1 Concept" \ tparam_index_required="Index, this template parameter is required. For a Box: either min_corner or max_corner. For a Segment: either 0 or 1 for first or last point." \ @@ -97,8 +98,11 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ return_check{1}="Returns true if the geometry \1" \ return_check2{1}="Returns true if two geometries \1" \ return_out="The output iterator" \ + brf_for_each{1}="Applies function [*f] to each \1" \ det_envelope="envelope (also known as axis aligned bounding box, aabb, or minimum bounding rectangle, mbr)" \ det_buffer="buffer (a polygon being the spatial point set collection within a specified maximum distance from a geometry)" \ + det_for_each{1}="Applies a function [*f] (functor, having operator() defined) to each \1 making up the geometry" \ + par_for_each_f{1}="Unary function, taking a \1 as argument" \ macro_x="first (usually x)" \ macro_y="second (usually y)" \ macro_z="third (usually z)" \ diff --git a/doc/geometry.qbk b/doc/geometry.qbk index 9afc867b2..04dd78198 100644 --- a/doc/geometry.qbk +++ b/doc/geometry.qbk @@ -71,6 +71,8 @@ Simplify algorithm [link geometry.reference.algorithms.simplify.simplify_3 here] [import src/examples/quick_start.cpp] [import src/examples/algorithms/area.cpp] [import src/examples/algorithms/area_with_strategy.cpp] +[import src/examples/algorithms/for_each_point.cpp] +[import src/examples/algorithms/for_each_point_const.cpp] [import src/examples/algorithms/length.cpp] [import src/examples/algorithms/length_with_strategy.cpp] [import src/examples/algorithms/intersection_ls_ls_point.cpp] diff --git a/doc/quickref.xml b/doc/quickref.xml index 87680bf63..e5b040568 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -352,6 +352,10 @@ envelope + For Each + + for each (point, segment) + Intersection intersection diff --git a/doc/ref/algorithms/num_points.qbk b/doc/ref/algorithms/num_points.qbk index 70db18b43..d23e1d24a 100644 --- a/doc/ref/algorithms/num_points.qbk +++ b/doc/ref/algorithms/num_points.qbk @@ -18,7 +18,7 @@ [[__box__][[qbk_ret 4]]] [[__range__][[qbk_ret boost::size(geometry)]]] [[__other__][[qbk_ret the sum of the number of points of its elements]]] -[[Open geometries][[qbk_ret the sum of the number of points of its elements, it adds one for open if specified]]] +[[Open geometries][[qbk_ret the sum of the number of points of its elements, it adds one for open (per ring) if specified]]] [[Closed geometries][[qbk_ret the sum of the number of points of its elements]]] ] diff --git a/doc/reference.qbk b/doc/reference.qbk index f32cccd5e..d535ff271 100644 --- a/doc/reference.qbk +++ b/doc/reference.qbk @@ -109,9 +109,9 @@ [include reference/equals.qbk] [endsect] -[/section:for_each for_each] -[/include reference/for_each.qbk] -[/endsect] +[section:for_each for_each] +[include reference/for_each.qbk] +[endsect] [section:intersection intersection] [include reference/intersection.qbk] diff --git a/doc/reference/append.qbk b/doc/reference/append.qbk index ab03e842c..5c3e009f3 100644 --- a/doc/reference/append.qbk +++ b/doc/reference/append.qbk @@ -19,7 +19,7 @@ Appends one or more points to a linestring, ring, polygon, multi. [heading Synopsis] ``template -void append(Geometry & geometry, RoP const & range_or_point, int ring_index, int multi_index)`` +void append(Geometry & geometry, RoP const & range_or_point, int ring_index = -1, int multi_index = 0)`` [heading Parameters] diff --git a/doc/reference/buffer.qbk b/doc/reference/buffer.qbk index 800fd5e2f..4e91b81d7 100644 --- a/doc/reference/buffer.qbk +++ b/doc/reference/buffer.qbk @@ -22,7 +22,7 @@ The free function buffer calculates the buffer (a polygon being the spatial poin [heading Synopsis] ``template -void buffer(Input const & geometry_in, Output & geometry_out, Distance const & distance, Distance const & chord_length)`` +void buffer(Input const & geometry_in, Output & geometry_out, Distance const & distance, Distance const & chord_length = -1)`` [heading Parameters] @@ -58,7 +58,7 @@ The free function make_buffer calculates the buffer (a polygon being the spatial [heading Synopsis] ``template -Output make_buffer(Input const & geometry, T const & distance, T const & chord_length)`` +Output make_buffer(Input const & geometry, T const & distance, T const & chord_length = -1)`` [heading Parameters] diff --git a/doc/reference/distance_haversine.qbk b/doc/reference/distance_haversine.qbk index 890e0d2c6..58045d71e 100644 --- a/doc/reference/distance_haversine.qbk +++ b/doc/reference/distance_haversine.qbk @@ -36,7 +36,7 @@ class strategy::distance::haversine [heading Constructor(s)] [table [[Function] [Description] [Parameters] ] -[[``haversine( const & radius)`` +[[``haversine( const & radius = 1.0)`` ] [Constructor. ] [[* const &]: ['radius]: radius of the sphere, defaults to 1.0 for the unit sphere diff --git a/doc/reference/for_each.qbk b/doc/reference/for_each.qbk index 78d9dc35b..355d52ce8 100644 --- a/doc/reference/for_each.qbk +++ b/doc/reference/for_each.qbk @@ -15,7 +15,10 @@ [/ Generated from doxy/doxygen_output/xml/group__for__each.xml] [section:for_each_point_2 for_each_point] -Calls functor for geometry. +Applies function [*f] to each point. + +[heading Description] +Applies a function [*f] (functor, having operator() defined) to each point making up the geometry [heading Synopsis] ``template @@ -25,8 +28,8 @@ Functor for_each_point(Geometry & geometry, Functor f)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [] [geometry] [geometry to loop through ]] -[[Functor] [] [f] [functor to use]] +[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Functor] [Function or class with operator()] [f] [Unary function, taking a point as argument ]] ] @@ -39,12 +42,18 @@ Or `#include ` +[heading Examples] +[for_each_point] [for_each_point_output] + [endsect] -[section:for_each_point_2 for_each_point] +[section:for_each_point_2_const_version for_each_point (const version)] -Calls functor for geometry. +Applies function [*f] to each point. + +[heading Description] +Applies a function [*f] (functor, having operator() defined) to each point making up the geometry [heading Synopsis] ``template @@ -54,8 +63,8 @@ Functor for_each_point(Geometry const & geometry, Functor f)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry const &] [] [geometry] [geometry to loop through ]] -[[Functor] [] [f] [functor to use]] +[[Geometry const &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Functor] [Function or class with operator()] [f] [Unary function, taking a const point as argument ]] ] @@ -68,12 +77,18 @@ Or `#include ` +[heading Examples] +[for_each_point_const] [for_each_point_const_output] + [endsect] [section:for_each_segment_2 for_each_segment] -Calls functor for segments on linestrings, rings, polygons, ... +Applies function [*f] to each segment. + +[heading Description] +Applies a function [*f] (functor, having operator() defined) to each segment making up the geometry [heading Synopsis] ``template @@ -83,8 +98,8 @@ Functor for_each_segment(Geometry & geometry, Functor f)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry &] [] [geometry] [geometry to loop through ]] -[[Functor] [] [f] [functor to use]] +[[Geometry &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Functor] [Function or class with operator() ] [f] [Unary function, taking a segment as argument ]] ] @@ -100,9 +115,12 @@ Or [endsect] -[section:for_each_segment_2 for_each_segment] +[section:for_each_segment_2_const_version for_each_segment (const version)] -Calls functor for segments on linestrings, rings, polygons, ... +Applies function [*f] to each segment. + +[heading Description] +Applies a function [*f] (functor, having operator() defined) to each segment making up the geometry [heading Synopsis] ``template @@ -112,8 +130,8 @@ Functor for_each_segment(Geometry const & geometry, Functor f)`` [table [[Type] [Concept] [Name] [Description] ] -[[Geometry const &] [] [geometry] [geometry to loop through ]] -[[Functor] [] [f] [functor to use]] +[[Geometry const &] [Any type fulfilling a Geometry Concept ] [geometry] [A model of the specified concept ]] +[[Functor] [Function or class with operator()] [f] [Unary function, taking a const segment as argument ]] ] diff --git a/doc/reference/num_points.qbk b/doc/reference/num_points.qbk index 31f70c2cd..8d312b22b 100644 --- a/doc/reference/num_points.qbk +++ b/doc/reference/num_points.qbk @@ -22,7 +22,7 @@ The free function num_points calculates the number of points of a geometry. [heading Synopsis] ``template -std::size_t num_points(Geometry const & geometry, bool add_for_open)`` +std::size_t num_points(Geometry const & geometry, bool add_for_open = false)`` [heading Parameters] diff --git a/doc/src/docutils/tools/doxygen_xml2qbk/doxygen_xml_parser.hpp b/doc/src/docutils/tools/doxygen_xml2qbk/doxygen_xml_parser.hpp index 3bf2f2962..3f8a7b9fc 100644 --- a/doc/src/docutils/tools/doxygen_xml2qbk/doxygen_xml_parser.hpp +++ b/doc/src/docutils/tools/doxygen_xml2qbk/doxygen_xml_parser.hpp @@ -41,6 +41,7 @@ static inline void add_or_set(std::vector& parameters, parameter cons if (it->brief_description.empty()) it->brief_description = p.brief_description; if (it->type.empty()) it->type = p.type; if (it->fulltype.empty()) it->fulltype = p.fulltype; + if (it->default_value.empty()) it->default_value = p.default_value; } else { diff --git a/doc/src/examples/algorithms/Jamfile.v2 b/doc/src/examples/algorithms/Jamfile.v2 index cd2cd8b54..4469a2f94 100644 --- a/doc/src/examples/algorithms/Jamfile.v2 +++ b/doc/src/examples/algorithms/Jamfile.v2 @@ -14,6 +14,9 @@ project boost-geometry-doc-example-algorithms exe area : area.cpp ; exe area_with_strategy : area_with_strategy.cpp ; +exe for_each_point : for_each_point.cpp ; +exe for_each_point_const : for_each_point_const.cpp ; + exe intersection_ls_ls_point : intersection_ls_ls_point.cpp ; exe intersection_segment : intersection_segment.cpp ; diff --git a/doc/src/examples/algorithms/for_each_point.cpp b/doc/src/examples/algorithms/for_each_point.cpp new file mode 100644 index 000000000..02f7205ac --- /dev/null +++ b/doc/src/examples/algorithms/for_each_point.cpp @@ -0,0 +1,68 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, Amsterdam, the Netherlands +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Quickbook Example + +//[for_each_point +//` Convenient usage of for_each_point, rounding all points of a geometry + +#include + +#include +#include +#include + + + +template +class round_coordinates +{ +private : + typedef typename boost::geometry::coordinate_type::type coordinate_type; + coordinate_type factor; + + inline coordinate_type round(coordinate_type value) + { + return floor(0.5 + (value / factor)) * factor; + } + +public : + round_coordinates(coordinate_type f) + : factor(f) + {} + + inline void operator()(Point& p) + { + using boost::geometry::get; + using boost::geometry::set; + set<0>(p, round(get<0>(p))); + set<1>(p, round(get<1>(p))); + } +}; + + +int main() +{ + typedef boost::geometry::model::d2::point_xy point; + boost::geometry::model::polygon poly; + boost::geometry::read_wkt("POLYGON((0 0,1.123 9.987,8.876 2.234,0 0),(3.345 4.456,7.654 8.765,9.123 5.432,3.345 4.456))", poly); + boost::geometry::for_each_point(poly, round_coordinates(0.1)); + std::cout << "Rounded: " << boost::geometry::wkt(poly) << std::endl; + return 0; +} + +//] + + +//[for_each_point_output +/*` +Output: +[pre + Rounded: POLYGON((0 0,1.1 10,8.9 2.2,0 0),(3.3 4.5,7.7 8.8,9.1 5.4,3.3 4.5)) +] +*/ +//] diff --git a/doc/src/examples/algorithms/for_each_point_const.cpp b/doc/src/examples/algorithms/for_each_point_const.cpp new file mode 100644 index 000000000..3115d2ff7 --- /dev/null +++ b/doc/src/examples/algorithms/for_each_point_const.cpp @@ -0,0 +1,49 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright Barend Gehrels 2011, Geodan, Amsterdam, the Netherlands +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// Quickbook Example + +//[for_each_point_const +//` Sample using for_each_point, using a function to list coordinates + +#include + +#include +#include +#include + + +template +void list_coordinates(Point const& p) +{ + using boost::geometry::get; + std::cout << "x = " << get<0>(p) << " y = " << get<1>(p) << std::endl; +} + +int main() +{ + typedef boost::geometry::model::d2::point_xy point; + boost::geometry::model::polygon poly; + boost::geometry::read_wkt("POLYGON((0 0,0 4,4 0,0 0))", poly); + boost::geometry::for_each_point(poly, list_coordinates); + return 0; +} + +//] + + +//[for_each_point_const_output +/*` +Output: +[pre +x = 0 y = 0 +x = 0 y = 4 +x = 4 y = 0 +x = 0 y = 0 +] +*/ +//]