Merge pull request #280 from awulkiew/feature/models_docs

Feature/models docs
This commit is contained in:
Adam Wulkiewicz
2015-04-12 04:55:30 +02:00
28 changed files with 648 additions and 13 deletions

View File

@@ -82,8 +82,16 @@
[import src/examples/core/tag.cpp]
[import src/examples/core/tag_cast.cpp]
[import src/examples/geometries/point.cpp]
[import src/examples/geometries/box.cpp]
[import src/examples/geometries/linestring.cpp]
[import src/examples/geometries/multi_linestring.cpp]
[import src/examples/geometries/multi_point.cpp]
[import src/examples/geometries/multi_polygon.cpp]
[import src/examples/geometries/point_xy.cpp]
[import src/examples/geometries/point.cpp]
[import src/examples/geometries/polygon.cpp]
[import src/examples/geometries/ring.cpp]
[import src/examples/geometries/segment.cpp]
[import src/examples/geometries/adapted/c_array.cpp]
[import src/examples/geometries/adapted/boost_array.cpp]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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) 2015 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 Examples]
[linestring]
[linestring_output]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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) 2015 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 Examples]
[multi_linestring]
[multi_linestring_output]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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) 2015 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 Examples]
[multi_point]
[multi_point_output]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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) 2015 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 Examples]
[multi_polygon]
[multi_polygon_output]

View File

@@ -0,0 +1,18 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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.
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 Examples]
[point_xy]
[point_xy_output]
[include reference/geometries/point_assign_warning.qbk]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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) 2015 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 Examples]
[polygon]
[polygon_output]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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) 2015 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 Examples]
[ring]
[ring_output]

View File

@@ -0,0 +1,16 @@
[/============================================================================
Boost.Geometry (aka GGL, Generic Geometry Library)
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) 2015 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 Examples]
[segment]
[segment_output]

View File

@@ -13,8 +13,16 @@ project boost-geometry-doc-src-example-geometries
: # requirements
;
exe point : point.cpp ;
exe box : box.cpp ;
exe linestring : linestring.cpp ;
exe point : point.cpp ;
exe point_xy : point_xy.cpp ;
exe polygon : polygon.cpp ;
exe multi_linestring : multi_linestring.cpp ;
exe multi_point : multi_point.cpp ;
exe multi_polygon : multi_polygon.cpp ;
exe ring : ring.cpp ;
exe segment : segment.cpp ;
build-project adapted ;
build-project register ;

View File

@@ -21,23 +21,26 @@ int main()
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::box<point_t> box_t;
box_t box1; /*< Default-construct a box >*/
box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point >*/
box_t box1; /*< Default-construct a box. >*/
box_t box2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning min and max corner point. >*/
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
box_t box3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax >*/
box_t box3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/
#endif
bg::set<bg::min_corner, 0>(box1, 1.0); /*< Set a coordinate, generic. >*/
bg::set<bg::min_corner, 1>(box1, 2.0);
box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/
box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/
box1.max_corner().set<1>(4.0);
double x0 = bg::get<bg::min_corner, 0>(box1); /*< Get a coordinate. >*/
double y0 = bg::get<bg::min_corner, 1>(box1);
double x1 = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/
double y1 = box1.max_corner().get<1>();
double min_x = bg::get<bg::min_corner, 0>(box1); /*< Get a coordinate, generic. >*/
double min_y = bg::get<bg::min_corner, 1>(box1);
double max_x = box1.max_corner().get<0>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/
double max_y = box1.max_corner().get<1>();
std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl;
std::cout << min_x << ", " << min_y << ", " << max_x << ", " << max_y << std::endl;
return 0;
}

View File

@@ -0,0 +1,55 @@
// Boost.Geometry
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 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)
//[linestring
//` Declaration and use of the Boost.Geometry model::linestring, modelling the Linestring Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::linestring<point_t> linestring_t;
linestring_t ls1; /*< Default-construct a linestring. >*/
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
&& !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
linestring_t ls2{{0.0, 0.0}, {1.0, 0.0}, {1.0, 2.0}}; /*< Construct a linestring containing three points, using C++11 unified initialization syntax. >*/
#endif
bg::append(ls1, point_t(0.0, 0.0)); /*< Append point. >*/
bg::append(ls1, point_t(1.0, 0.0));
bg::append(ls1, point_t(1.0, 2.0));
double l = bg::length(ls1);
std::cout << l << std::endl;
return 0;
}
//]
//[linestring_output
/*`
Output:
[pre
3
]
*/
//]

View File

@@ -0,0 +1,62 @@
// Boost.Geometry
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 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)
//[multi_linestring
//` Declaration and use of the Boost.Geometry model::multi_linestring, modelling the MultiLinestring Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::linestring<point_t> linestring_t;
typedef bg::model::multi_linestring<linestring_t> mlinestring_t;
mlinestring_t mls1; /*< Default-construct a multi_linestring. >*/
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
&& !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
mlinestring_t mls2{{{0.0, 0.0}, {0.0, 1.0}, {2.0, 1.0}},
{{1.0, 0.0}, {2.0, 0.0}}}; /*< Construct a multi_linestring containing two linestrings, using C++11 unified initialization syntax. >*/
#endif
mls1.resize(2); /*< Resize a multi_linestring, store two linestrings. >*/
bg::append(mls1[0], point_t(0.0, 0.0)); /*< Append point to the first linestring. >*/
bg::append(mls1[0], point_t(0.0, 1.0));
bg::append(mls1[0], point_t(2.0, 1.0));
bg::append(mls1[1], point_t(1.0, 0.0)); /*< Append point to the second linestring. >*/
bg::append(mls1[1], point_t(2.0, 0.0));
double l = bg::length(mls1);
std::cout << l << std::endl;
return 0;
}
//]
//[multi_linestring_output
/*`
Output:
[pre
4
]
*/
//]

View File

@@ -0,0 +1,55 @@
// Boost.Geometry
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 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)
//[multi_point
//` Declaration and use of the Boost.Geometry model::multi_point, modelling the MultiPoint Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::multi_point<point_t> mpoint_t;
mpoint_t mpt1; /*< Default-construct a multi_point. >*/
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
&& !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
mpoint_t mpt2{{{0.0, 0.0}, {1.0, 1.0}, {2.0, 2.0}}}; /*< Construct a multi_point containing three points, using C++11 unified initialization syntax. >*/
#endif
bg::append(mpt1, point_t(0.0, 0.0)); /*< Append point to the multi_point. >*/
bg::append(mpt1, point_t(1.0, 1.0));
bg::append(mpt1, point_t(2.0, 2.0));
std::size_t count = bg::num_points(mpt1);
std::cout << count << std::endl;
return 0;
}
//]
//[multi_point_output
/*`
Output:
[pre
3
]
*/
//]

View File

@@ -0,0 +1,75 @@
// Boost.Geometry
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 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)
//[multi_polygon
//` Declaration and use of the Boost.Geometry model::multi_polygon, modelling the MultiPolygon Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::polygon<point_t> polygon_t; /*< Default parameters, clockwise, closed polygon. >*/
typedef bg::model::multi_polygon<polygon_t> mpolygon_t; /*< Clockwise, closed multi_polygon. >*/
mpolygon_t mpoly1; /*< Default-construct a multi_polygon. >*/
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
&& !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
mpolygon_t mpoly2{{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}},
{{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}},
{{{5.0, 5.0}, {5.0, 6.0}, {6.0, 6.0}, {6.0, 5.0}, {5.0, 5.0}}}}; /*< Construct a multi_polygon containing two polygons, using C++11 unified initialization syntax. >*/
#endif
mpoly1.resize(2); /*< Resize a multi_polygon, store two polygons. >*/
bg::append(mpoly1[0].outer(), point_t(0.0, 0.0)); /*< Append point to the exterior ring of the first polygon. >*/
bg::append(mpoly1[0].outer(), point_t(0.0, 5.0));
bg::append(mpoly1[0].outer(), point_t(5.0, 5.0));
bg::append(mpoly1[0].outer(), point_t(5.0, 0.0));
bg::append(mpoly1[0].outer(), point_t(0.0, 0.0));
mpoly1[0].inners().resize(1); /*< Resize a container of interior rings of the first polygon. >*/
bg::append(mpoly1[0].inners()[0], point_t(1.0, 1.0)); /*< Append point to the interior ring of the first polygon. >*/
bg::append(mpoly1[0].inners()[0], point_t(4.0, 1.0));
bg::append(mpoly1[0].inners()[0], point_t(4.0, 4.0));
bg::append(mpoly1[0].inners()[0], point_t(1.0, 4.0));
bg::append(mpoly1[0].inners()[0], point_t(1.0, 1.0));
bg::append(mpoly1[1].outer(), point_t(5.0, 5.0)); /*< Append point to the exterior ring of the second polygon. >*/
bg::append(mpoly1[1].outer(), point_t(5.0, 6.0));
bg::append(mpoly1[1].outer(), point_t(6.0, 6.0));
bg::append(mpoly1[1].outer(), point_t(6.0, 5.0));
bg::append(mpoly1[1].outer(), point_t(5.0, 5.0));
double a = bg::area(mpoly1);
std::cout << a << std::endl;
return 0;
}
//]
//[multi_polygon_output
/*`
Output:
[pre
17
]
*/
//]

View File

@@ -21,10 +21,10 @@ int main()
bg::model::point<double, 3, bg::cs::cartesian> point2(1.0, 2.0, 3.0); /*< Construct, assigning three coordinates >*/
bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/
point1.set<1>(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set();`). >*/
point1.set<1>(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/
double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/
double y = point1.get<1>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get();`). >*/
double y = point1.get<1>(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/
std::cout << x << ", " << y << std::endl;
return 0;

View File

@@ -0,0 +1,44 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// QuickBook Example
// Copyright (c) 2011-2012 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)
//[point_xy
//` Declaration and use of the Boost.Geometry model::d2::point_xy, modelling the Point Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
namespace bg = boost::geometry;
int main()
{
bg::model::d2::point_xy<double> point1;
bg::model::d2::point_xy<double> point2(1.0, 2.0); /*< Construct, assigning coordinates. >*/
bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/
point1.y(2.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/
double x = bg::get<0>(point1); /*< Get a coordinate, generic. >*/
double y = point1.y(); /*< Get a coordinate, class-specific ([*Note]: prefer `bg::get()`). >*/
std::cout << x << ", " << y << std::endl;
return 0;
}
//]
//[point_xy_output
/*`
Output:
[pre
1, 2
]
*/
//]

View File

@@ -0,0 +1,65 @@
// Boost.Geometry
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 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)
//[polygon
//` Declaration and use of the Boost.Geometry model::polygon, modelling the Polygon Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::polygon<point_t> polygon_t; /*< Default parameters, clockwise, closed polygon. >*/
polygon_t poly1; /*< Default-construct a polygon. >*/
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
&& !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
polygon_t polygon2{{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}},
{{1.0, 1.0}, {4.0, 1.0}, {4.0, 4.0}, {1.0, 4.0}, {1.0, 1.0}}}; /*< Construct a polygon containing an exterior and interior ring, using C++11 unified initialization syntax. >*/
#endif
bg::append(poly1.outer(), point_t(0.0, 0.0)); /*< Append point to the exterior ring. >*/
bg::append(poly1.outer(), point_t(0.0, 5.0));
bg::append(poly1.outer(), point_t(5.0, 5.0));
bg::append(poly1.outer(), point_t(5.0, 0.0));
bg::append(poly1.outer(), point_t(0.0, 0.0));
poly1.inners().resize(1); /*< Resize a container of interior rings. >*/
bg::append(poly1.inners()[0], point_t(1.0, 1.0)); /*< Append point to the interior ring. >*/
bg::append(poly1.inners()[0], point_t(4.0, 1.0));
bg::append(poly1.inners()[0], point_t(4.0, 4.0));
bg::append(poly1.inners()[0], point_t(1.0, 4.0));
bg::append(poly1.inners()[0], point_t(1.0, 1.0));
double a = bg::area(poly1);
std::cout << a << std::endl;
return 0;
}
//]
//[polygon_output
/*`
Output:
[pre
16
]
*/
//]

View File

@@ -0,0 +1,57 @@
// Boost.Geometry
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 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)
//[ring
//` Declaration and use of the Boost.Geometry model::ring, modelling the Ring Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::ring<point_t> ring_t; /*< Default parameters, clockwise, closed ring. >*/
ring_t ring1; /*< Default-construct a ring. >*/
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
&& !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
ring_t ring2{{0.0, 0.0}, {0.0, 5.0}, {5.0, 5.0}, {5.0, 0.0}, {0.0, 0.0}}; /*< Construct a ring containing four points plus one closing point, using C++11 unified initialization syntax. >*/
#endif
bg::append(ring1, point_t(0.0, 0.0)); /*< Append point. >*/
bg::append(ring1, point_t(0.0, 5.0));
bg::append(ring1, point_t(5.0, 5.0));
bg::append(ring1, point_t(5.0, 0.0));
bg::append(ring1, point_t(0.0, 0.0));
double a = bg::area(ring1);
std::cout << a << std::endl;
return 0;
}
//]
//[ring_output
/*`
Output:
[pre
25
]
*/
//]

View File

@@ -0,0 +1,59 @@
// Boost.Geometry
// QuickBook Example
// Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2015 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)
//[segment
//` Declaration and use of the Boost.Geometry model::segment, modelling the Segment Concept
#include <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/geometries.hpp>
namespace bg = boost::geometry;
int main()
{
typedef bg::model::point<double, 2, bg::cs::cartesian> point_t;
typedef bg::model::segment<point_t> segment_t;
segment_t seg1; /*< Default-construct a segment. >*/
segment_t seg2(point_t(0.0, 0.0), point_t(5.0, 5.0)); /*< Construct, assigning the first and the second point. >*/
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
segment_t seg3{{0.0, 0.0}, {5.0, 5.0}}; /*< Construct, using C++11 unified initialization syntax. >*/
#endif
bg::set<0, 0>(seg1, 1.0); /*< Set a coordinate. >*/
bg::set<0, 1>(seg1, 2.0);
bg::set<1, 0>(seg1, 3.0);
bg::set<1, 1>(seg1, 4.0);
double x0 = bg::get<0, 0>(seg1); /*< Get a coordinate. >*/
double y0 = bg::get<0, 1>(seg1);
double x1 = bg::get<1, 0>(seg1);
double y1 = bg::get<1, 1>(seg1);
std::cout << x0 << ", " << y0 << ", " << x1 << ", " << y1 << std::endl;
return 0;
}
//]
//[segment_output
/*`
Output:
[pre
1, 2, 3, 4
]
*/
//]

View File

@@ -44,6 +44,7 @@ namespace model
\tparam Container \tparam_container
\tparam Allocator \tparam_allocator
\qbk{[include reference/geometries/linestring.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_linestring Linestring Concept]

View File

@@ -41,6 +41,7 @@ namespace model
e.g. a highway (with interruptions)
\ingroup geometries
\qbk{[include reference/geometries/multi_linestring.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_multi_linestring MultiLineString Concept]

View File

@@ -43,6 +43,8 @@ namespace model
\tparam Allocator \tparam_allocator
\details Multipoint can be used to group points belonging to each other,
e.g. a constellation, or the result set of an intersection
\qbk{[include reference/geometries/multi_point.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_multi_point MultiPoint Concept]

View File

@@ -40,6 +40,7 @@ namespace model
e.g. Hawaii
\ingroup geometries
\qbk{[include reference/geometries/multi_polygon.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_multi_polygon MultiPolygon Concept]

View File

@@ -33,6 +33,7 @@ namespace model { namespace d2
\tparam CoordinateType numeric type, for example, double, float, int
\tparam CoordinateSystem coordinate system, defaults to cs::cartesian
\qbk{[include reference/geometries/point_xy.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_point Point Concept]

View File

@@ -55,6 +55,7 @@ namespace model
\note The container collecting the points in the rings can be different
from the container collecting the inner rings. They all default to vector.
\qbk{[include reference/geometries/polygon.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_polygon Polygon Concept]

View File

@@ -48,6 +48,7 @@ namespace model
\tparam Container container type, for example std::vector, std::deque
\tparam Allocator container-allocator-type
\qbk{[include reference/geometries/ring.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_ring Ring Concept]

View File

@@ -35,6 +35,12 @@ namespace model
by two distinct end points, and contains every point on the line between its end points.
\note There is also a point-referring-segment, class referring_segment,
containing point references, where points are NOT copied
\qbk{[include reference/geometries/segment.qbk]}
\qbk{before.synopsis,
[heading Model of]
[link geometry.reference.concepts.concept_segment Segment Concept]
}
*/
template<typename Point>
class segment : public std::pair<Point, Point>