GitHub Viewer
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 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)
//
// Point Example - showing different type of points
#include
#include
#include
#include
#include
#include
#include
BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(cs::cartesian)
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
int main()
{
using namespace boost::geometry;
// Boost.Geometry contains several point types:
// 1: its own generic type
model::point pt1;
// 2: its own type targetted to Cartesian (x,y) coordinates
model::d2::point_xy pt2;
// 3: it supports Boost tuple's
boost::tuple pt3;
// 4: it supports normal arrays
double pt4[2];
// 5: it supports arrays-as-points from Boost.Array
boost::array pt5;
// 6: it supports points from Boost.Polygon
boost::polygon::point_data pt6;
// 7: in the past there was a typedef point_2d
// But users are now supposted to do that themselves:
typedef model::d2::point_xy point_2d;
point_2d pt7;
// 7: there are more variants, and you can create your own.
// (see therefore the custom_point example)
// All these types are handled the same way. We show here
// assigning them and calculating distances.
assign_values(pt1, 1, 1);
assign_values(pt2, 2, 2);
assign_values(pt3, 3, 3);
assign_values(pt4, 4, 4);
assign_values(pt5, 5, 5);
assign_values(pt6, 6, 6);
assign_values(pt7, 7, 7);
double d1 = distance(pt1, pt2);
double d2 = distance(pt3, pt4);
double d3 = distance(pt5, pt6);
std::cout