mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
Doc update including adding tests for registration macro's
[SVN r71715]
This commit is contained in:
parent
98819656e8
commit
1f2b2e40c5
@ -98,7 +98,7 @@ ALIASES = qbk{1}="\xmlonly <qbk>\1</qbk> \endxmlonly" \
|
||||
details_macro{2}="The macro \1 registers a \2 such that it is recognized by Boost.Geometry and that Boost.Geometry functionality can used with the specified type." \
|
||||
details_macro_const="The const version registers only read access to the fields, the point type is therefore read-only" \
|
||||
details_macro_getset="The get/set version registers get and set methods separately and can be used for classes with protected member variables and get/set methods to change coordinates" \
|
||||
details_macro_templated{1}="The type must have one template parameter, which should be a point type, and should not be specified. Boost.Geometry takes care of inserting the template parameter. Hence all types of this templated \1 are registered, regardless of their point type." \
|
||||
details_macro_templated{2}="The type must have one template parameter, which should be a \2 type, and should not be specified. Boost.Geometry takes care of inserting the template parameter. Hence all types of this templated \1 are registered, regardless of their point type." \
|
||||
details_default_strategy="It uses the default strategy, based on the coordinate system of the geometry." \
|
||||
details_strategy_reasons="Reasons to specify a strategy include: use another coordinate system for calculations; construct the strategy beforehand (e.g. with the radius of the Earth); select a strategy when there are more than one available for a calculation." \
|
||||
details_return{1}="This version with the return_ prefix returns the \1, and a template parameter must therefore be specified in the call." \
|
||||
@ -190,6 +190,7 @@ INPUT = . .. ../../../../boost/geometry/core \
|
||||
../../../../boost/geometry/multi/algorithms/detail \
|
||||
../../../../boost/geometry/multi/core \
|
||||
../../../../boost/geometry/multi/geometries \
|
||||
../../../../boost/geometry/multi/geometries/register \
|
||||
../../../../boost/geometry/multi/geometries/concepts \
|
||||
../../../../boost/geometry/multi/iterators \
|
||||
../../../../boost/geometry/multi/strategies/cartesian \
|
||||
|
@ -93,5 +93,13 @@
|
||||
[import src/examples/geometries/register/box_templated.cpp]
|
||||
[import src/examples/geometries/register/box_2d_4values.cpp]
|
||||
[import src/examples/geometries/register/point.cpp]
|
||||
[import src/examples/geometries/register/linestring.cpp]
|
||||
[import src/examples/geometries/register/linestring_templated.cpp]
|
||||
[import src/examples/geometries/register/ring.cpp]
|
||||
[import src/examples/geometries/register/ring_templated.cpp]
|
||||
|
||||
[import src/examples/geometries/register/multi_point.cpp]
|
||||
[import src/examples/geometries/register/multi_point_templated.cpp]
|
||||
|
||||
[import src/examples/geometries/register/multi_linestring.cpp]
|
||||
[import src/examples/geometries/register/multi_polygon.cpp]
|
||||
|
@ -134,11 +134,19 @@
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_point_3d">BOOST_GEOMETRY_REGISTER_POINT_3D</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_point_3d_const">BOOST_GEOMETRY_REGISTER_POINT_3D_CONST</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_point_3d_get_set">BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET</link></member>
|
||||
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_point">BOOST_GEOMETRY_REGISTER_MULTI_POINT</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_point_templated">BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED</link></member>
|
||||
|
||||
</simplelist>
|
||||
</entry>
|
||||
<entry valign="top">
|
||||
<bridgehead renderas="sect3">1-dimensionial (macro's for adaption)</bridgehead>
|
||||
<simplelist type="vert" columns="1">
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_linestring">BOOST_GEOMETRY_REGISTER_LINESTRING</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_linestring_templated">BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_linestring">BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_linestring_templated">BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING_TEMPLATED</link></member>
|
||||
</simplelist>
|
||||
</entry>
|
||||
<entry valign="top">
|
||||
@ -147,6 +155,10 @@
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_box">BOOST_GEOMETRY_REGISTER_BOX</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_box_2d_4values">BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_box_templated">BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_ring">BOOST_GEOMETRY_REGISTER_RING</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_ring_templated">BOOST_GEOMETRY_REGISTER_RING_TEMPLATED</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_polygon">BOOST_GEOMETRY_REGISTER_MULTI_POLYGON</link></member>
|
||||
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_polygon_templated">BOOST_GEOMETRY_REGISTER_MULTI_POLYGON_TEMPLATED</link></member>
|
||||
</simplelist>
|
||||
</entry>
|
||||
</row>
|
||||
|
@ -28,7 +28,7 @@ box, and ring
|
||||
[heading Header]
|
||||
`#include <boost/geometry/geometries/adapted/boost_array.hpp>`
|
||||
|
||||
The standard header `<boost/geometry.hpp>` does not include this header.
|
||||
__not_in_boost_geometry_hpp__
|
||||
|
||||
[heading Example]
|
||||
[boost_array]
|
||||
|
@ -25,7 +25,7 @@ point concept. They can therefore be used in many Boost.Geometry algorithms.
|
||||
[heading Header]
|
||||
`#include <boost/geometry/geometries/adapted/boost_fusion.hpp>`
|
||||
|
||||
The standard header `<boost/geometry.hpp>` does not include this header.
|
||||
__not_in_boost_geometry_hpp__
|
||||
|
||||
[heading Example]
|
||||
[boost_fusion]
|
||||
|
@ -37,7 +37,7 @@ box, and ring
|
||||
[heading Header]
|
||||
`#include <boost/geometry/geometries/adapted/boost_tuple.hpp>`
|
||||
|
||||
The standard header `<boost/geometry.hpp>` does not include this header.
|
||||
__not_in_boost_geometry_hpp__
|
||||
|
||||
[heading Example]
|
||||
[boost_tuple]
|
||||
|
@ -30,7 +30,7 @@ the point type.
|
||||
[heading Header]
|
||||
`#include <boost/geometry/geometries/adapted/c_array.hpp>`
|
||||
|
||||
The standard header `<boost/geometry.hpp>` does not include this header.
|
||||
__not_in_boost_geometry_hpp__
|
||||
|
||||
[heading Example]
|
||||
[c_array]
|
||||
|
@ -17,3 +17,14 @@ exe box : box.cpp ;
|
||||
exe box_templated : box_templated.cpp ;
|
||||
exe box_2d_4values : box_2d_4values.cpp ;
|
||||
exe point : point.cpp ;
|
||||
|
||||
exe linestring : linestring.cpp ;
|
||||
exe linestring_templated : linestring_templated.cpp ;
|
||||
exe ring : ring.cpp ;
|
||||
exe ring_templated : ring_templated.cpp ;
|
||||
|
||||
exe multi_point : multi_point.cpp ;
|
||||
exe multi_point_templated : multi_point_templated.cpp ;
|
||||
|
||||
exe multi_linestring : multi_linestring.cpp ;
|
||||
exe multi_polygon : multi_polygon.cpp ;
|
||||
|
52
doc/src/examples/geometries/register/linestring.cpp
Normal file
52
doc/src/examples/geometries/register/linestring.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_linestring
|
||||
//` Show the use of BOOST_GEOMETRY_REGISTER_LINESTRING
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/linestring.hpp>
|
||||
|
||||
typedef boost::geometry::model::d2::point_xy<double> point_2d;
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_LINESTRING(std::vector<point_2d>)
|
||||
|
||||
int main()
|
||||
{
|
||||
// Normal usage of std::
|
||||
std::vector<point_2d> line;
|
||||
line.push_back(point_2d(1, 1));
|
||||
line.push_back(point_2d(2, 2));
|
||||
line.push_back(point_2d(3, 1));
|
||||
|
||||
// Usage of Boost.Geometry's length and wkt functions
|
||||
std::cout << "Length: "
|
||||
<< boost::geometry::length(line)
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "WKT: "
|
||||
<< boost::geometry::wkt(line)
|
||||
<< std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_linestring_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
Length: 2.82843
|
||||
WKT: LINESTRING(1 1,2 2,3 1)
|
||||
]
|
||||
*/
|
||||
//]
|
@ -0,0 +1,45 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_linestring_templated
|
||||
//` Show the use of the macro BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED
|
||||
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/linestring.hpp>
|
||||
|
||||
// Adapt any deque to Boost.Geometry Linestring Concept
|
||||
BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
|
||||
|
||||
int main()
|
||||
{
|
||||
std::deque<boost::geometry::model::d2::point_xy<double> > line(2);
|
||||
boost::geometry::assign_values(line[0], 1, 1);
|
||||
boost::geometry::assign_values(line[1], 2, 2);
|
||||
|
||||
// Boost.Geometry algorithms work on any deque now
|
||||
std::cout << "Length: " << boost::geometry::length(line) << std::endl;
|
||||
std::cout << "Line: " << boost::geometry::dsv(line) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_linestring_templated_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
Length: 1.41421
|
||||
Line: ((1, 1), (2, 2))
|
||||
]
|
||||
*/
|
||||
//]
|
49
doc/src/examples/geometries/register/multi_linestring.cpp
Normal file
49
doc/src/examples/geometries/register/multi_linestring.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_multi_linestring
|
||||
//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
|
||||
#include <boost/geometry/multi/geometries/register/multi_linestring.hpp>
|
||||
|
||||
typedef boost::geometry::model::linestring
|
||||
<
|
||||
boost::tuple<float, float>
|
||||
> linestring_type;
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
|
||||
BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(std::deque<linestring_type>)
|
||||
|
||||
int main()
|
||||
{
|
||||
// Normal usage of std::
|
||||
std::deque<linestring_type> lines(2);
|
||||
boost::geometry::read_wkt("LINESTRING(0 0,1 1)", lines[0]);
|
||||
boost::geometry::read_wkt("LINESTRING(2 2,3 3)", lines[1]);
|
||||
|
||||
// Usage of Boost.Geometry
|
||||
std::cout << "LENGTH: " << boost::geometry::length(lines) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_multi_linestring_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
LENGTH: 2.82843
|
||||
]
|
||||
*/
|
||||
//]
|
46
doc/src/examples/geometries/register/multi_point.cpp
Normal file
46
doc/src/examples/geometries/register/multi_point.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_multi_point
|
||||
//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_POINT
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
|
||||
#include <boost/geometry/multi/geometries/register/multi_point.hpp>
|
||||
|
||||
typedef boost::tuple<float, float> point_type;
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
|
||||
BOOST_GEOMETRY_REGISTER_MULTI_POINT(std::deque<::point_type>)
|
||||
|
||||
int main()
|
||||
{
|
||||
// Normal usage of std::
|
||||
std::deque<point_type> multi_point;
|
||||
multi_point.push_back(point_type(1, 1));
|
||||
multi_point.push_back(point_type(3, 2));
|
||||
|
||||
// Usage of Boost.Geometry
|
||||
std::cout << "WKT: " << boost::geometry::wkt(multi_point) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_multi_point_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
WKT: MULTIPOINT((1 1),(3 2))
|
||||
]
|
||||
*/
|
||||
//]
|
@ -0,0 +1,46 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_multi_point_templated
|
||||
//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
|
||||
#include <boost/geometry/multi/geometries/register/multi_point.hpp>
|
||||
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque)
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
|
||||
|
||||
int main()
|
||||
{
|
||||
// Normal usage of std::
|
||||
std::deque<boost::tuple<float, float> > multi_point;
|
||||
multi_point.push_back(boost::tuple<float, float>(1, 1));
|
||||
multi_point.push_back(boost::tuple<float, float>(3, 2));
|
||||
|
||||
// Usage of Boost.Geometry
|
||||
std::cout << "WKT: " << boost::geometry::wkt(multi_point) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_multi_point_templated_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
WKT: MULTIPOINT((1 1),(3 2))
|
||||
]
|
||||
*/
|
||||
//]
|
49
doc/src/examples/geometries/register/multi_polygon.cpp
Normal file
49
doc/src/examples/geometries/register/multi_polygon.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_multi_polygon
|
||||
//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_POLYGON
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
|
||||
#include <boost/geometry/multi/geometries/register/multi_polygon.hpp>
|
||||
|
||||
typedef boost::geometry::model::polygon
|
||||
<
|
||||
boost::tuple<float, float>
|
||||
> polygon_type;
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
|
||||
BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(std::vector<polygon_type>)
|
||||
|
||||
int main()
|
||||
{
|
||||
// Normal usage of std::
|
||||
std::vector<polygon_type> polygons(2);
|
||||
boost::geometry::read_wkt("POLYGON((0 0,0 1,1 1,1 0,0 0))", polygons[0]);
|
||||
boost::geometry::read_wkt("POLYGON((3 0,3 1,4 1,4 0,3 0))", polygons[1]);
|
||||
|
||||
// Usage of Boost.Geometry
|
||||
std::cout << "AREA: " << boost::geometry::area(polygons) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_multi_polygon_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
AREA: 2
|
||||
]
|
||||
*/
|
||||
//]
|
49
doc/src/examples/geometries/register/ring.cpp
Normal file
49
doc/src/examples/geometries/register/ring.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_ring
|
||||
//` Show the use of the macro BOOST_GEOMETRY_REGISTER_RING
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
|
||||
typedef boost::geometry::model::d2::point_xy<double> point_2d;
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_RING(std::vector<point_2d>) /*< The magic: adapt vector to Boost.Geometry Ring Concept >*/
|
||||
|
||||
int main()
|
||||
{
|
||||
// Normal usage of std::
|
||||
std::vector<point_2d> ring;
|
||||
ring.push_back(point_2d(1, 1));
|
||||
ring.push_back(point_2d(2, 2));
|
||||
ring.push_back(point_2d(2, 1));
|
||||
|
||||
|
||||
// Usage of Boost.Geometry
|
||||
boost::geometry::correct(ring);
|
||||
std::cout << "Area: " << boost::geometry::area(ring) << std::endl;
|
||||
std::cout << "WKT: " << boost::geometry::wkt(ring) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_ring_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
Area: 0.5
|
||||
WKT: POLYGON((1 1,2 2,2 1,1 1))
|
||||
]
|
||||
*/
|
||||
//]
|
47
doc/src/examples/geometries/register/ring_templated.cpp
Normal file
47
doc/src/examples/geometries/register/ring_templated.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[register_ring_templated
|
||||
//` Show the use of the macro BOOST_GEOMETRY_REGISTER_RING_TEMPLATED
|
||||
|
||||
#include <iostream>
|
||||
#include <deque>
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
|
||||
// Adapt any deque to Boost.Geometry Ring Concept
|
||||
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)
|
||||
|
||||
int main()
|
||||
{
|
||||
std::deque<boost::geometry::model::d2::point_xy<double> > ring(3);
|
||||
boost::geometry::assign_values(ring[0], 0, 0);
|
||||
boost::geometry::assign_values(ring[2], 4, 1);
|
||||
boost::geometry::assign_values(ring[1], 1, 4);
|
||||
|
||||
// Boost.Geometry algorithms work on any deque now
|
||||
boost::geometry::correct(ring);
|
||||
std::cout << "Area: " << boost::geometry::area(ring) << std::endl;
|
||||
std::cout << "Contents: " << boost::geometry::wkt(ring) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[register_ring_templated_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
Area: 7.5
|
||||
Line: ((0, 0), (1, 4), (4, 1), (0, 0))
|
||||
]
|
||||
*/
|
||||
//]
|
16
doc/src/examples/ranges/Jamfile.v2
Normal file
16
doc/src/examples/ranges/Jamfile.v2
Normal file
@ -0,0 +1,16 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
# Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
|
||||
# Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
|
||||
|
||||
# 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-ranges
|
||||
: # requirements
|
||||
;
|
||||
|
||||
exe box_range : box_range.cpp ;
|
58
doc/src/examples/ranges/box_range.cpp
Normal file
58
doc/src/examples/ranges/box_range.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// QuickBook Example
|
||||
|
||||
// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
//[box_range
|
||||
//` Shows usage of the Boost.Range compatible view on a box
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::geometry::model::box
|
||||
<
|
||||
boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
|
||||
> box_type;
|
||||
|
||||
// Define the Boost.Range compatible type:
|
||||
typedef boost::geometry::box_range<box_type> box_range;
|
||||
|
||||
box_type box;
|
||||
boost::geometry::assign_values(box, 0, 0, 4, 4);
|
||||
|
||||
box_range range(box);
|
||||
|
||||
// Iterating in clockwise direction over the points of this box
|
||||
for (boost::range_iterator<box_range const>::type it = boost::begin(range);
|
||||
it != boost::end(range); ++it)
|
||||
{
|
||||
std::cout << " " << boost::geometry::dsv(*it);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Note that a box_range is tagged as a ring, so supports area etc.
|
||||
std::cout << "Area: " << boost::geometry::area(range) << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//]
|
||||
|
||||
|
||||
//[box_range_output
|
||||
/*`
|
||||
Output:
|
||||
[pre
|
||||
(0, 0) (0, 4) (4, 4) (4, 0) (0, 0)
|
||||
Area: 16
|
||||
]
|
||||
*/
|
||||
//]
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <boost/geometry/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
#include <boost/geometry/geometries/register/linestring.hpp>
|
||||
|
||||
// To register the 'geographic' distance function to calculate distance over the earth:
|
||||
#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp>
|
||||
@ -58,11 +59,8 @@ struct gps_track : std::vector<gps_point>
|
||||
// Register this point as being a recognizable point by Boost.Geometry
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(gps_point, double, cs::geographic<degree>, longitude, latitude)
|
||||
|
||||
|
||||
// Register the track as well, as being a "linestring"
|
||||
namespace boost { namespace geometry { namespace traits {
|
||||
template <> struct tag<gps_track> { typedef ring_tag type; };
|
||||
}}}
|
||||
BOOST_GEOMETRY_REGISTER_LINESTRING(gps_track)
|
||||
|
||||
|
||||
int main()
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <boost/geometry/algorithms/area.hpp>
|
||||
#include <boost/geometry/algorithms/centroid.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/util/write_dsv.hpp>
|
||||
|
||||
@ -30,9 +31,7 @@ struct triangle : public boost::array<boost::geometry::model::d2::point_xy<doubl
|
||||
|
||||
|
||||
// Register triangle as a ring
|
||||
namespace boost { namespace geometry { namespace traits {
|
||||
template <> struct tag<triangle> { typedef ring_tag type; };
|
||||
}}}
|
||||
BOOST_GEOMETRY_REGISTER_RING(triangle)
|
||||
|
||||
|
||||
// Specializations of algorithms, where useful. If not specialized the default ones
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <boost/geometry/algorithms/area.hpp>
|
||||
#include <boost/geometry/algorithms/centroid.hpp>
|
||||
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/util/write_dsv.hpp>
|
||||
|
||||
@ -31,9 +32,7 @@ struct triangle : public boost::array<P, 3>
|
||||
|
||||
|
||||
// Register triangle<P> as a ring
|
||||
namespace boost { namespace geometry { namespace traits {
|
||||
template <typename P> struct tag<triangle<P> > { typedef ring_tag type; };
|
||||
}}}
|
||||
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(triangle)
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace dispatch {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <boost/geometry/geometry.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
|
||||
|
||||
struct my_point
|
||||
@ -48,11 +49,7 @@ struct my_polygon
|
||||
|
||||
// We can conveniently use macro's to register point and ring
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y)
|
||||
|
||||
// Register my_ring as a ring
|
||||
namespace boost { namespace geometry { namespace traits {
|
||||
template <> struct tag<my_ring> { typedef ring_tag type; };
|
||||
}}}
|
||||
BOOST_GEOMETRY_REGISTER_RING(my_ring)
|
||||
|
||||
|
||||
|
||||
@ -76,7 +73,6 @@ template<> struct interior_mutable_type<my_polygon>
|
||||
typedef boost::array<my_ring, 2>& type;
|
||||
};
|
||||
|
||||
|
||||
template<> struct exterior_ring<my_polygon>
|
||||
{
|
||||
static my_ring& get(my_polygon& p)
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <boost/geometry/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
#include <boost/geometry/util/add_const_if_c.hpp>
|
||||
|
||||
// Sample point, having x/y
|
||||
@ -215,9 +216,7 @@ template<> struct resize<my_polygon>
|
||||
// 4) register with Boost.Geometry
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y)
|
||||
|
||||
namespace boost { namespace geometry { namespace traits {
|
||||
template <> struct tag<my_polygon> { typedef ring_tag type; };
|
||||
}}}
|
||||
BOOST_GEOMETRY_REGISTER_RING(my_polygon)
|
||||
|
||||
|
||||
// end adaption
|
||||
@ -238,7 +237,7 @@ void walk_using_iterator(my_polygon const& polygon)
|
||||
|
||||
void walk_using_range(my_polygon const& polygon)
|
||||
{
|
||||
for (boost::range_iterator<const my_polygon>::type it
|
||||
for (boost::range_iterator<my_polygon const>::type it
|
||||
= boost::begin(polygon);
|
||||
it != boost::end(polygon);
|
||||
++it)
|
||||
|
Loading…
x
Reference in New Issue
Block a user