]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/doc/src/examples/geometries/linestring.cpp
4 // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
12 //` Declaration and use of the Boost.Geometry model::linestring, modelling the Linestring Concept
15 #include <boost/geometry.hpp>
16 #include <boost/geometry/geometries/geometries.hpp>
18 namespace bg
= boost::geometry
;
22 typedef bg::model::point
<double, 2, bg::cs::cartesian
> point_t
;
23 typedef bg::model::linestring
<point_t
> linestring_t
;
25 linestring_t ls1
; /*< Default-construct a linestring. >*/
27 #if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \
28 && !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
30 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. >*/
34 bg::append(ls1
, point_t(0.0, 0.0)); /*< Append point. >*/
35 bg::append(ls1
, point_t(1.0, 0.0));
36 bg::append(ls1
, point_t(1.0, 2.0));
38 double l
= bg::length(ls1
);
40 std::cout
<< l
<< std::endl
;