mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-02 21:02:13 +00:00
Merge pull request #280 from awulkiew/feature/models_docs
Feature/models docs
This commit is contained in:
@@ -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]
|
||||
|
||||
16
doc/reference/geometries/linestring.qbk
Normal file
16
doc/reference/geometries/linestring.qbk
Normal 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]
|
||||
16
doc/reference/geometries/multi_linestring.qbk
Normal file
16
doc/reference/geometries/multi_linestring.qbk
Normal 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]
|
||||
16
doc/reference/geometries/multi_point.qbk
Normal file
16
doc/reference/geometries/multi_point.qbk
Normal 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]
|
||||
16
doc/reference/geometries/multi_polygon.qbk
Normal file
16
doc/reference/geometries/multi_polygon.qbk
Normal 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]
|
||||
18
doc/reference/geometries/point_xy.qbk
Normal file
18
doc/reference/geometries/point_xy.qbk
Normal 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]
|
||||
|
||||
16
doc/reference/geometries/polygon.qbk
Normal file
16
doc/reference/geometries/polygon.qbk
Normal 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]
|
||||
16
doc/reference/geometries/ring.qbk
Normal file
16
doc/reference/geometries/ring.qbk
Normal 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]
|
||||
16
doc/reference/geometries/segment.qbk
Normal file
16
doc/reference/geometries/segment.qbk
Normal 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]
|
||||
@@ -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 ;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
55
doc/src/examples/geometries/linestring.cpp
Normal file
55
doc/src/examples/geometries/linestring.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
62
doc/src/examples/geometries/multi_linestring.cpp
Normal file
62
doc/src/examples/geometries/multi_linestring.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
55
doc/src/examples/geometries/multi_point.cpp
Normal file
55
doc/src/examples/geometries/multi_point.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
75
doc/src/examples/geometries/multi_polygon.cpp
Normal file
75
doc/src/examples/geometries/multi_polygon.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
@@ -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;
|
||||
|
||||
44
doc/src/examples/geometries/point_xy.cpp
Normal file
44
doc/src/examples/geometries/point_xy.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
65
doc/src/examples/geometries/polygon.cpp
Normal file
65
doc/src/examples/geometries/polygon.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
57
doc/src/examples/geometries/ring.cpp
Normal file
57
doc/src/examples/geometries/ring.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
59
doc/src/examples/geometries/segment.cpp
Normal file
59
doc/src/examples/geometries/segment.cpp
Normal 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
|
||||
]
|
||||
*/
|
||||
//]
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user