diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index 92098767d..3aa8b86f4 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -89,6 +89,7 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ param_x="First coordinate (usually x-coordinate)" \ param_y="Second coordinate (usually y-coordinate)" \ param_z="Third coordinate (usually z-coordinate)" \ + constructor_default_no_init="Default constructor, no initialization" \ constructor_default{1}="Default constructor, creating an empty \1" \ constructor_begin_end{1}="Constructor with begin and end, filling the \1" \ constructor_initializer_list{1}="Constructor taking std::initializer_list, filling the \1" \ diff --git a/doc/imports.qbk b/doc/imports.qbk index eb49aef9c..3625fc2e8 100644 --- a/doc/imports.qbk +++ b/doc/imports.qbk @@ -82,7 +82,17 @@ [import src/examples/core/tag.cpp] [import src/examples/core/tag_cast.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] [import src/examples/geometries/adapted/boost_fusion.cpp] diff --git a/doc/reference/geometries/box.qbk b/doc/reference/geometries/box.qbk new file mode 100644 index 000000000..100db1387 --- /dev/null +++ b/doc/reference/geometries/box.qbk @@ -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] +[box] +[box_output] diff --git a/doc/reference/geometries/linestring.qbk b/doc/reference/geometries/linestring.qbk new file mode 100644 index 000000000..b22e8d2ea --- /dev/null +++ b/doc/reference/geometries/linestring.qbk @@ -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] diff --git a/doc/reference/geometries/multi_linestring.qbk b/doc/reference/geometries/multi_linestring.qbk new file mode 100644 index 000000000..b2ee9b155 --- /dev/null +++ b/doc/reference/geometries/multi_linestring.qbk @@ -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] diff --git a/doc/reference/geometries/multi_point.qbk b/doc/reference/geometries/multi_point.qbk new file mode 100644 index 000000000..342242f86 --- /dev/null +++ b/doc/reference/geometries/multi_point.qbk @@ -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] diff --git a/doc/reference/geometries/multi_polygon.qbk b/doc/reference/geometries/multi_polygon.qbk new file mode 100644 index 000000000..1397dba17 --- /dev/null +++ b/doc/reference/geometries/multi_polygon.qbk @@ -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] diff --git a/doc/reference/geometries/point_xy.qbk b/doc/reference/geometries/point_xy.qbk new file mode 100644 index 000000000..ead56d36f --- /dev/null +++ b/doc/reference/geometries/point_xy.qbk @@ -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] + diff --git a/doc/reference/geometries/polygon.qbk b/doc/reference/geometries/polygon.qbk new file mode 100644 index 000000000..7b6909088 --- /dev/null +++ b/doc/reference/geometries/polygon.qbk @@ -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] diff --git a/doc/reference/geometries/ring.qbk b/doc/reference/geometries/ring.qbk new file mode 100644 index 000000000..746466a44 --- /dev/null +++ b/doc/reference/geometries/ring.qbk @@ -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] diff --git a/doc/reference/geometries/segment.qbk b/doc/reference/geometries/segment.qbk new file mode 100644 index 000000000..1336dcaac --- /dev/null +++ b/doc/reference/geometries/segment.qbk @@ -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] diff --git a/doc/reference/status/disjoint_status.qbk b/doc/reference/status/disjoint_status.qbk index f4fd4c77b..4c7b59ce1 100644 --- a/doc/reference/status/disjoint_status.qbk +++ b/doc/reference/status/disjoint_status.qbk @@ -4,11 +4,11 @@ [[Point][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] [[Segment][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] [[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] [[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] [[Polygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] -[[MultiPoint][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] -[[MultiLinestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] +[[MultiPoint][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]] +[[MultiLinestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] [[MultiPolygon][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] [[Variant][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]] ] diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 8c28368f2..66fef803e 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -25,6 +25,8 @@ [*Additional functionality] * Added rtree const_iterator, begin(), end() and the support for Boost.Range. +* The support for C++11 `std::initializer_list` in geometries models. +* Disjoint and intersects support the following geometry combinations: multipoint/linestring, multipoint/multilinestring [*Improvements] @@ -33,6 +35,7 @@ [*Solved tickets] * [@https://svn.boost.org/trac/boost/ticket/11113 11113] Support easy enumeration of all elements with BOOST_FOREACH +* [@https://svn.boost.org/trac/boost/ticket/11236 11236] Invalid result of centroid() for integer coordinate type [/=================] [heading Boost 1.58] diff --git a/doc/src/examples/geometries/Jamfile.v2 b/doc/src/examples/geometries/Jamfile.v2 index 68a99b57a..cd0e71e6d 100644 --- a/doc/src/examples/geometries/Jamfile.v2 +++ b/doc/src/examples/geometries/Jamfile.v2 @@ -13,7 +13,16 @@ project boost-geometry-doc-src-example-geometries : # requirements ; +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 ; diff --git a/doc/src/examples/geometries/box.cpp b/doc/src/examples/geometries/box.cpp new file mode 100644 index 000000000..0dfecc83d --- /dev/null +++ b/doc/src/examples/geometries/box.cpp @@ -0,0 +1,58 @@ +// 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) + +//[box +//` Declaration and use of the Boost.Geometry model::box, modelling the Box Concept + +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::box 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. >*/ + +#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. >*/ + +#endif + + bg::set(box1, 1.0); /*< Set a coordinate, generic. >*/ + bg::set(box1, 2.0); + box1.max_corner().set<0>(3.0); /*< Set a coordinate, class-specific ([*Note]: prefer `bg::set()`). >*/ + box1.max_corner().set<1>(4.0); + + double min_x = bg::get(box1); /*< Get a coordinate, generic. >*/ + double min_y = bg::get(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 << min_x << ", " << min_y << ", " << max_x << ", " << max_y << std::endl; + + return 0; +} + +//] + + +//[box_output +/*` +Output: +[pre +1, 2, 3, 4 +] +*/ +//] diff --git a/doc/src/examples/geometries/linestring.cpp b/doc/src/examples/geometries/linestring.cpp new file mode 100644 index 000000000..b2ba1ae8b --- /dev/null +++ b/doc/src/examples/geometries/linestring.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::linestring 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 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_linestring.cpp b/doc/src/examples/geometries/multi_linestring.cpp new file mode 100644 index 000000000..b7a039cf9 --- /dev/null +++ b/doc/src/examples/geometries/multi_linestring.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::linestring linestring_t; + typedef bg::model::multi_linestring 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 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_point.cpp b/doc/src/examples/geometries/multi_point.cpp new file mode 100644 index 000000000..89d63d737 --- /dev/null +++ b/doc/src/examples/geometries/multi_point.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::multi_point 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 +] +*/ +//] diff --git a/doc/src/examples/geometries/multi_polygon.cpp b/doc/src/examples/geometries/multi_polygon.cpp new file mode 100644 index 000000000..d5414868f --- /dev/null +++ b/doc/src/examples/geometries/multi_polygon.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::polygon polygon_t; /*< Default parameters, clockwise, closed polygon. >*/ + typedef bg::model::multi_polygon 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 +] +*/ +//] diff --git a/doc/src/examples/geometries/point.cpp b/doc/src/examples/geometries/point.cpp index 82774cd83..6373217c8 100644 --- a/doc/src/examples/geometries/point.cpp +++ b/doc/src/examples/geometries/point.cpp @@ -19,11 +19,12 @@ int main() { bg::model::point point1; bg::model::point point2(1.0, 2.0, 3.0); /*< Construct, assigning three coordinates >*/ - point1.set<0>(1.0); /*< Set a coordinate. [*Note]: prefer using `bg::set<0>(point1, 1.0);` >*/ - point1.set<1>(2.0); - double x = point1.get<0>(); /*< Get a coordinate. [*Note]: prefer using `x = bg::get<0>(point1);` >*/ - double y = point1.get<1>(); + bg::set<0>(point1, 1.0); /*< Set a coordinate, generic. >*/ + 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()`). >*/ std::cout << x << ", " << y << std::endl; return 0; diff --git a/doc/src/examples/geometries/point_xy.cpp b/doc/src/examples/geometries/point_xy.cpp new file mode 100644 index 000000000..96eedf82b --- /dev/null +++ b/doc/src/examples/geometries/point_xy.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + bg::model::d2::point_xy point1; + bg::model::d2::point_xy 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 +] +*/ +//] diff --git a/doc/src/examples/geometries/polygon.cpp b/doc/src/examples/geometries/polygon.cpp new file mode 100644 index 000000000..199a00824 --- /dev/null +++ b/doc/src/examples/geometries/polygon.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::polygon 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 +] +*/ +//] diff --git a/doc/src/examples/geometries/ring.cpp b/doc/src/examples/geometries/ring.cpp new file mode 100644 index 000000000..1818ee127 --- /dev/null +++ b/doc/src/examples/geometries/ring.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::ring 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 +] +*/ +//] diff --git a/doc/src/examples/geometries/segment.cpp b/doc/src/examples/geometries/segment.cpp new file mode 100644 index 000000000..3cbb4453c --- /dev/null +++ b/doc/src/examples/geometries/segment.cpp @@ -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 +#include +#include + +namespace bg = boost::geometry; + +int main() +{ + typedef bg::model::point point_t; + typedef bg::model::segment 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 +] +*/ +//] diff --git a/extensions/test/gis/Jamfile.v2 b/extensions/test/gis/Jamfile.v2 index 13dafde28..ac76bde76 100644 --- a/extensions/test/gis/Jamfile.v2 +++ b/extensions/test/gis/Jamfile.v2 @@ -3,11 +3,13 @@ # 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. +# 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) +build-project io ; build-project latlong ; build-project projections ; diff --git a/extensions/test/gis/io/Jamfile.v2 b/extensions/test/gis/io/Jamfile.v2 new file mode 100644 index 000000000..7ca605b7b --- /dev/null +++ b/extensions/test/gis/io/Jamfile.v2 @@ -0,0 +1,13 @@ +# 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. +# 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) + +build-project wkb ; + diff --git a/extensions/test/gis/io/wkb/Jamfile.v2 b/extensions/test/gis/io/wkb/Jamfile.v2 new file mode 100644 index 000000000..1d9c6870e --- /dev/null +++ b/extensions/test/gis/io/wkb/Jamfile.v2 @@ -0,0 +1,17 @@ +# 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. +# 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) + +test-suite boost-geometry-extensions-gis-io-wkb + : + [ run read_wkb.cpp ] + [ run write_wkb.cpp ] + ; + diff --git a/extensions/test/gis/io/wkb/read_wkb.cpp b/extensions/test/gis/io/wkb/read_wkb.cpp index 815fc78a5..eae9301e8 100644 --- a/extensions/test/gis/io/wkb/read_wkb.cpp +++ b/extensions/test/gis/io/wkb/read_wkb.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -22,6 +23,10 @@ #include #include +#include +#include +#include + namespace bg = boost::geometry; namespace { // anonymous @@ -34,11 +39,11 @@ void test_geometry_wrong_wkb(std::string const& wkbhex, std::string const& wkt) byte_vector wkb; BOOST_CHECK( bg::hex2wkb(wkbhex, std::back_inserter(wkb)) ); Geometry g_wkb; - std::cout << bg::read_wkb(wkb.begin(), wkb.end(), g_wkb) << std::endl; + BOOST_MESSAGE("read_wkb: " << bg::read_wkb(wkb.begin(), wkb.end(), g_wkb)); } template -void test_geometry_equals(std::string const& wkbhex, std::string const& wkt) +void test_geometry_equals_old(std::string const& wkbhex, std::string const& wkt) { byte_vector wkb; BOOST_CHECK( bg::hex2wkb(wkbhex, std::back_inserter(wkb)) ); @@ -47,9 +52,25 @@ void test_geometry_equals(std::string const& wkbhex, std::string const& wkt) Geometry g_expected; bg::read_wkt(wkt, g_expected); + BOOST_CHECK( bg::equals(g_wkb, g_expected) == IsEqual ); } +template +void test_geometry_equals(Geometry const& g_expected, std::string const& wkbhex) +{ + byte_vector wkb; + BOOST_CHECK( bg::hex2wkb(wkbhex, std::back_inserter(wkb))); + + Geometry g_wkb; + bg::read_wkb(wkb.begin(), wkb.end(), g_wkb); + + BOOST_CHECK_MESSAGE( bg::equals(g_wkb, g_expected) == IsEqual, + "{bg::equals(g_wkb, g_expected) == IsEqual} failed for" << + " EXPECTED: " << bg::wkt(g_expected) << + ", ACTUAL : " << bg::wkt(g_wkb) ); +} + //template //void test_polygon_wkt(std::string const& wkt) //{ @@ -64,45 +85,190 @@ void test_geometry_equals(std::string const& wkbhex, std::string const& wkt) int test_main(int, char* []) { - typedef bg::model::point point_type; - typedef bg::model::linestring linestring_type; + { + typedef bg::model::point point_type; + typedef bg::model::point point3d_type; - // - // POINT - // + // + // POINT + // - test_geometry_equals( - "01010000005839B4C876BEF33F83C0CAA145B61640", "POINT (1.234 5.678)"); + test_geometry_equals_old( + "01010000005839B4C876BEF33F83C0CAA145B61640", "POINT (1.234 5.678)"); - // XYZ - POINT(1.234 5.678 99) - Z coordinate ignored - test_geometry_equals( - "01010000805839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT(1.234 5.678)"); + test_geometry_equals_old( + "01E90300005839B4C876BEF33F83C0CAA145B616404F401361C3332240", "POINT(1.234 5.678 9.1011)"); - // SRID=32632;POINT(1.234 5.678) - PostGIS EWKT - test_geometry_equals( - "0101000020787F00005839B4C876BEF33F83C0CAA145B61640", "POINT (1.234 5.678)"); + // // XYZ - POINT(1.234 5.678 99) - Z coordinate ignored + // test_geometry_equals( + // "01010000805839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT(1.234 5.678)"); + // + // // SRID=32632;POINT(1.234 5.678) - PostGIS EWKT + // test_geometry_equals( + // "0101000020787F00005839B4C876BEF33F83C0CAA145B61640", "POINT (1.234 5.678)"); + // + // // SRID=4326;POINT(1.234 5.678 99) - PostGIS EWKT + // test_geometry_equals( + // "01010000A0E61000005839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT(1.234 5.678)"); + // + // // POINTM(1.234 5.678 99) - XYM with M compound ignored + // test_geometry_equals( + // "01010000405839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT (1.234 5.678)"); + // + // // SRID=32632;POINTM(1.234 5.678 99) + // test_geometry_equals( + // "0101000060787F00005839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT (1.234 5.678)"); + // + // // POINT(1.234 5.678 15 79) - XYZM - Z and M compounds ignored + // test_geometry_equals( + // "01010000C05839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340", + // "POINT (1.234 5.678)"); + // + // // SRID=4326;POINT(1.234 5.678 15 79) - XYZM + SRID + // test_geometry_equals( + // "01010000E0E61000005839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340", + // "POINT (1.234 5.678)"); - // SRID=4326;POINT(1.234 5.678 99) - PostGIS EWKT - test_geometry_equals( - "01010000A0E61000005839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT(1.234 5.678)"); + } - // POINTM(1.234 5.678 99) - XYM with M compound ignored - test_geometry_equals( - "01010000405839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT (1.234 5.678)"); + { + typedef bg::model::point point_type; + typedef bg::model::point point3d_type; - // SRID=32632;POINTM(1.234 5.678 99) - test_geometry_equals( - "0101000060787F00005839B4C876BEF33F83C0CAA145B616400000000000C05840", "POINT (1.234 5.678)"); + typedef bg::model::linestring linestring_type; + //typedef bg::model::linestring linestring3d_type; - // POINT(1.234 5.678 15 79) - XYZM - Z and M compounds ignored - test_geometry_equals( - "01010000C05839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340", - "POINT (1.234 5.678)"); + typedef bg::model::polygon polygon_type; + //typedef bg::model::polygon polygon3d_type; - // SRID=4326;POINT(1.234 5.678 15 79) - XYZM + SRID - test_geometry_equals( - "01010000E0E61000005839B4C876BEF33F83C0CAA145B616400000000000002E400000000000C05340", - "POINT (1.234 5.678)"); + // + // POINT + // + + { + point_type point(1.0, 2.0); + + test_geometry_equals + ( + point, + "0101000000000000000000F03F0000000000000040" + ); + } + + { + point3d_type point(1.0, 2.0, 3.0); + + test_geometry_equals + ( + point, + "01E9030000000000000000F03F00000000000000400000000000000840" + ); + } + + // + // LINESTRING + // + + { + linestring_type linestring; + + bg::append(linestring, + boost::assign::list_of + (point_type(1.0, 2.0)) + (point_type(2.0, 3.0)) + (point_type(4.0, 5.0)) + ); + + test_geometry_equals + ( + linestring, + "010200000003000000000000000000F03F00000000000000400000000000000040000000000000084000000000000010400000000000001440" + ); + } + +// { +// linestring3d_type linestring; +// +// bg::append(linestring, +// boost::assign::list_of +// (point3d_type(1.0, 2.0, 3.0)) +// (point3d_type(2.0, 3.0, 4.0)) +// (point3d_type(4.0, 5.0, 6.0)) +// ); +// +// test_geometry_equals +// ( +// linestring, +// "01EA03000003000000000000000000F03F00000000000000400000000000000840000000000000004000000000000008400000000000001040000000000000104000000000000014400000000000001840" +// ); +// } + + // + // POLYGON + // + + { + polygon_type polygon; + + bg::append(polygon, + boost::assign::list_of + (point_type(50.0, 50.0)) + (point_type(50.0, 100.0)) + (point_type(100.0, 100.0)) + (point_type(100.0, 50.0)) + (point_type(50.0, 50.0)) + ); + + test_geometry_equals + ( + polygon, + "010300000001000000050000000000000000004940000000000000494000000000000049400000000000005940000000000000594000000000000059400000000000005940000000000000494000000000000049400000000000004940" + ); + } + +// { +// polygon3d_type polygon; +// +// bg::append(polygon, boost::assign::list_of(point3d_type(50.0, 50.0, 5.0))(point3d_type(50.0, 100.0, 10.0))(point3d_type(100.0, 100.0, 5.0))(point3d_type(100.0, 50.0, 10.0))(point3d_type(50.0, 50.0, 5.0))); +// +// test_geometry_equals +// ( +// polygon, +// "01EB0300000100000005000000000000000000494000000000000049400000000000001440000000000000494000000000000059400000000000002440000000000000594000000000000059400000000000001440000000000000594000000000000049400000000000002440000000000000494000000000000049400000000000001440" +// ); +// } + + { + polygon_type polygon; + + bg::append(polygon, + boost::assign::list_of + (point_type(35, 10)) + (point_type(45, 45)) + (point_type(15, 40)) + (point_type(10, 20)) + (point_type(35, 10)) + ); + + // Create an interior ring (append does not do this automatically) + boost::geometry::interior_rings(polygon).resize(1); + + bg::append(polygon, + boost::assign::list_of + (point_type(20, 30)) + (point_type(35, 35)) + (point_type(30, 20)) + (point_type(20, 30)) + , 0); + + test_geometry_equals + ( + polygon, + "0103000000020000000500000000000000008041400000000000002440000000000080464000000000008046400000000000002E40000000000000444000000000000024400000000000003440000000000080414000000000000024400400000000000000000034400000000000003E40000000000080414000000000008041400000000000003E40000000000000344000000000000034400000000000003E40" + ); + } + + } return 0; } diff --git a/extensions/test/gis/io/wkb/write_wkb.cpp b/extensions/test/gis/io/wkb/write_wkb.cpp new file mode 100644 index 000000000..3b71c0f17 --- /dev/null +++ b/extensions/test/gis/io/wkb/write_wkb.cpp @@ -0,0 +1,195 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// 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) + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace bg = boost::geometry; + +namespace { // anonymous + +template +void test_geometry_equals(Geometry const& geometry, std::string const& wkbhex) +{ + std::string wkb_out; + bg::write_wkb(geometry, std::back_inserter(wkb_out)); + + std::string hex_out; + BOOST_CHECK( bg::wkb2hex(wkb_out.begin(), wkb_out.end(), hex_out) ); + + BOOST_CHECK_EQUAL( wkbhex, hex_out); +} + +} // namespace anonymous + +int test_main(int, char* []) +{ + typedef bg::model::point point_type; + typedef bg::model::point point3d_type; + typedef bg::model::linestring linestring_type; + typedef bg::model::linestring linestring3d_type; + typedef bg::model::polygon polygon_type; + typedef bg::model::polygon polygon3d_type; + + // + // POINT + // + + { + point_type point(1.0, 2.0); + + test_geometry_equals + ( + point, + "0101000000000000000000F03F0000000000000040" + ); + } + + { + point3d_type point(1.0, 2.0, 3.0); + + test_geometry_equals + ( + point, + "01E9030000000000000000F03F00000000000000400000000000000840" + ); + } + + // + // LINESTRING + // + + { + linestring_type linestring; + + bg::append(linestring, + boost::assign::list_of + (point_type(1.0, 2.0)) + (point_type(2.0, 3.0)) + (point_type(4.0, 5.0)) + ); + + test_geometry_equals + ( + linestring, + "010200000003000000000000000000F03F00000000000000400000000000000040000000000000084000000000000010400000000000001440" + ); + } + + { + linestring3d_type linestring; + + bg::append(linestring, + boost::assign::list_of + (point3d_type(1.0, 2.0, 3.0)) + (point3d_type(2.0, 3.0, 4.0)) + (point3d_type(4.0, 5.0, 6.0)) + ); + + test_geometry_equals + ( + linestring, + "01EA03000003000000000000000000F03F00000000000000400000000000000840000000000000004000000000000008400000000000001040000000000000104000000000000014400000000000001840" + ); + } + + // + // POLYGON + // + + { + polygon_type polygon; + + bg::append(polygon, + boost::assign::list_of + (point_type(50.0, 50.0)) + (point_type(50.0, 100.0)) + (point_type(100.0, 100.0)) + (point_type(100.0, 50.0)) + (point_type(50.0, 50.0)) + ); + + test_geometry_equals + ( + polygon, + "010300000001000000050000000000000000004940000000000000494000000000000049400000000000005940000000000000594000000000000059400000000000005940000000000000494000000000000049400000000000004940" + ); + } + + { + polygon3d_type polygon; + + bg::append(polygon, + boost::assign::list_of + (point3d_type(50.0, 50.0, 5.0)) + (point3d_type(50.0, 100.0, 10.0)) + (point3d_type(100.0, 100.0, 5.0)) + (point3d_type(100.0, 50.0, 10.0)) + (point3d_type(50.0, 50.0, 5.0)) + ); + + test_geometry_equals + ( + polygon, + "01EB0300000100000005000000000000000000494000000000000049400000000000001440000000000000494000000000000059400000000000002440000000000000594000000000000059400000000000001440000000000000594000000000000049400000000000002440000000000000494000000000000049400000000000001440" + ); + } + + { + polygon_type polygon; + + bg::append(polygon, + boost::assign::list_of + (point_type(35, 10)) + (point_type(45, 45)) + (point_type(15, 40)) + (point_type(10, 20)) + (point_type(35, 10)) + ); + + // Create an interior ring (append does not do this automatically) + boost::geometry::interior_rings(polygon).resize(1); + + bg::append(polygon, + boost::assign::list_of + (point_type(20, 30)) + (point_type(35, 35)) + (point_type(30, 20)) + (point_type(20, 30)) + , 0); + + test_geometry_equals + ( + polygon, + "0103000000020000000500000000000000008041400000000000002440000000000080464000000000008046400000000000002E40000000000000444000000000000024400000000000003440000000000080414000000000000024400400000000000000000034400000000000003E40000000000080414000000000008041400000000000003E40000000000000344000000000000034400000000000003E40" + ); + } + + return 0; +} diff --git a/extensions/test/gis/projections/Jamfile.v2 b/extensions/test/gis/projections/Jamfile.v2 index b57c8ebf5..8e68c39a3 100644 --- a/extensions/test/gis/projections/Jamfile.v2 +++ b/extensions/test/gis/projections/Jamfile.v2 @@ -12,5 +12,7 @@ test-suite boost-geometry-extensions-gis-projections : [ run projection.cpp ] [ run projections.cpp ] + [ run projections_combined.cpp ] + [ run projections_static.cpp ] [ run projection_epsg.cpp ] ; diff --git a/extensions/test/gis/projections/projections.cpp b/extensions/test/gis/projections/projections.cpp index 097539d2c..6b7e2f6fc 100644 --- a/extensions/test/gis/projections/projections.cpp +++ b/extensions/test/gis/projections/projections.cpp @@ -42,16 +42,8 @@ inline void check(double v, double ve, std::string const& name, std::string const& axis) { - //BOOST_CHECK_CLOSE(v, ve, 0.001); - // Instead of (non-existing) BOOST_CHECK_CLOSE_MESSAGE(v, ve, 0.001, bla bla) - - if (! boost::test_tools::check_is_close(v, ve, boost::test_tools::fpc::percent_tolerance(0.001))) - { - std::ostringstream out; - out << "\n" << name << " " << axis << " -> " << v << " != " << ve; - BOOST_ERROR(out.str()); - } - + // (non-existing) BOOST_CHECK_CLOSE_MESSAGE(v, ve, 0.001, "\n" << name << " " << axis << " -> " << v << " != " << ve); + BOOST_CHECK_CLOSE(v, ve, 0.001); } template @@ -140,6 +132,7 @@ void test_all() test_forward

("eck6", 4.897000, 52.371000, 342737.885307, 6363364.830847, "+proj=eck6 +ellps=WGS84 +units=m"); test_forward

("eqc", 4.897000, 52.371000, 545131.546415, 5829913.052335, "+proj=eqc +ellps=WGS84 +units=m"); test_forward

("eqdc", 4.897000, 52.371000, 307874.536263, 5810915.646438, "+proj=eqdc +ellps=WGS84 +units=m +lat_1=60 +lat_2=0"); + test_forward

("etmerc", 4.897000, 52.371000, 333425.492123, 5815921.814393, "+proj=etmerc +ellps=WGS84 +units=m"); test_forward

("euler", 4.897000, 52.371000, 338753.024859, 5836825.984893, "+proj=euler +ellps=WGS84 +units=m +lat_1=60 +lat_2=0"); test_forward

("fahey", 4.897000, 52.371000, 388824.354103, 5705638.873094, "+proj=fahey +ellps=WGS84 +units=m"); test_forward

("fouc", 4.897000, 52.371000, 268017.369817, 6272855.564674, "+proj=fouc +ellps=WGS84 +units=m"); @@ -157,6 +150,7 @@ void test_all() test_forward

("hammer", 4.897000, 52.371000, 370843.923425, 5630047.232233, "+proj=hammer +ellps=WGS84 +units=m"); test_forward

("hatano", 4.897000, 52.371000, 383644.128560, 6290117.704632, "+proj=hatano +ellps=WGS84 +units=m"); test_forward

("imw_p", 4.897000, 52.371000, 318784.808056, 3594184.939568, "+proj=imw_p +ellps=WGS84 +units=m +lat_1=20n +lat_2=60n +lon_1=5"); + test_forward

("isea", 4.897000, 52.371000, -413613.639976, 9218173.701546, "+proj=isea +ellps=WGS84 +units=m"); test_forward

("kav5", 4.897000, 52.371000, 383646.088858, 5997047.888175, "+proj=kav5 +ellps=WGS84 +units=m"); test_forward

("kav7", 4.897000, 52.371000, 407769.043907, 5829913.052335, "+proj=kav7 +ellps=WGS84 +units=m"); test_forward

("krovak", 14.416667, 50.083333, -743286.779768, -1043498.912060, "+proj=krovak +ellps=WGS84 +units=m"); @@ -199,6 +193,7 @@ void test_all() test_forward

("ortel", 4.897000, 52.371000, 360906.947408, 5829913.052335, "+proj=ortel +ellps=WGS84 +units=m"); test_forward

("ortho", 4.897000, 52.371000, 332422.874291, 5051361.531375, "+proj=ortho +ellps=WGS84 +units=m"); test_forward

("pconic", -70.400000, -23.650000, -2240096.398139, -6940342.146955, "+proj=pconic +ellps=WGS84 +units=m +lat_1=20n +lat_2=60n +lon_0=60W"); + test_forward

("qsc", 4.897000, 52.371000, 543871.545186, 7341888.620371, "+proj=qsc +ellps=WGS84 +units=m"); test_forward

("poly", 4.897000, 52.371000, 333274.269648, 5815908.957562, "+proj=poly +ellps=WGS84 +units=m"); test_forward

("putp1", 4.897000, 52.371000, 375730.931178, 5523551.121434, "+proj=putp1 +ellps=WGS84 +units=m"); test_forward

("putp2", 4.897000, 52.371000, 351480.997939, 5942668.547355, "+proj=putp2 +ellps=WGS84 +units=m"); @@ -210,7 +205,7 @@ void test_all() test_forward

("putp6", 4.897000, 52.371000, 324931.055842, 5842588.644796, "+proj=putp6 +ellps=WGS84 +units=m"); test_forward

("putp6p", 4.897000, 52.371000, 338623.512107, 6396742.919679, "+proj=putp6p +ellps=WGS84 +units=m"); test_forward

("qua_aut", 4.897000, 52.371000, 370892.621714, 5629072.862494, "+proj=qua_aut +ellps=WGS84 +units=m"); - test_forward

("robin", 4.897000, 52.371000, 394576.507489, 5571243.439235, "+proj=robin +ellps=WGS84 +units=m"); + test_forward

("robin", 4.897000, 52.371000, 394576.507489, 5570940.631371, "+proj=robin +ellps=WGS84 +units=m"); test_forward

("rouss", 4.897000, 52.371000, 412826.227669, 6248368.849775, "+proj=rouss +ellps=WGS84 +units=m"); test_forward

("rpoly", 4.897000, 52.371000, 332447.130797, 5841164.662431, "+proj=rpoly +ellps=WGS84 +units=m"); test_forward

("sinu", 4.897000, 52.371000, 333528.909809, 5804625.044313, "+proj=sinu +ellps=WGS84 +units=m"); @@ -246,6 +241,7 @@ void test_all() test_inverse

("aea", 334609.583974, 5218502.503686, 4.897000, 52.371000, "+proj=aea +ellps=WGS84 +units=m +lat_1=55 +lat_2=65"); test_inverse

("aeqd", 384923.723428, 5809986.497118, 4.898398, 52.378890, "+proj=aeqd +ellps=WGS84 +units=m"); // F/I: 883.080918 + test_inverse

("aitoff", 384096.182830, 5831239.274680, 4.897000, 52.371000, "+proj=aitoff +ellps=WGS84 +units=m"); test_inverse

("alsk", 7002185.416415, -3700467.546545, -84.389819, 33.754911, "+proj=alsk +ellps=WGS84 +units=m +lon_0=-150W"); // F/I: 19.398478 test_inverse

("bipc", 3693973.674143, -8459972.647559, 4.897000, 52.371000, "+proj=bipc +ellps=WGS84 +units=m"); test_inverse

("bonne", 333291.091896, 274683.016972, 4.897000, 52.371000, "+proj=bonne +ellps=WGS84 +units=m +lat_1=50"); @@ -262,6 +258,7 @@ void test_all() test_inverse

("eck6", 342737.885307, 6363364.830847, 4.897000, 52.371000, "+proj=eck6 +ellps=WGS84 +units=m"); test_inverse

("eqc", 545131.546415, 5829913.052335, 4.897000, 52.371000, "+proj=eqc +ellps=WGS84 +units=m"); test_inverse

("eqdc", 307874.536263, 5810915.646438, 4.897000, 52.371000, "+proj=eqdc +ellps=WGS84 +units=m +lat_1=60 +lat_2=0"); + test_inverse

("etmerc", 333425.492123, 5815921.814393, 4.897000, 52.371000, "+proj=etmerc +ellps=WGS84 +units=m"); test_inverse

("euler", 338753.024859, 5836825.984893, 4.897000, 52.371000, "+proj=euler +ellps=WGS84 +units=m +lat_1=60 +lat_2=0"); test_inverse

("fahey", 388824.354103, 5705638.873094, 4.897000, 52.371000, "+proj=fahey +ellps=WGS84 +units=m"); test_inverse

("fouc", 268017.369817, 6272855.564674, 4.897000, 52.371000, "+proj=fouc +ellps=WGS84 +units=m"); @@ -314,6 +311,7 @@ void test_all() test_inverse

("omerc", 1009705.329154, 5829437.254923, 4.897000, 52.371000, "+proj=omerc +ellps=WGS84 +units=m +lat_1=20n +lat_2=60n +lon_1=1e +lon_2=30e"); test_inverse

("ortho", 332422.874291, 5051361.531375, 4.897000, 52.371000, "+proj=ortho +ellps=WGS84 +units=m"); test_inverse

("pconic", -2240096.398139, -6940342.146955, -70.400000, -23.650000, "+proj=pconic +ellps=WGS84 +units=m +lat_1=20n +lat_2=60n +lon_0=60W"); // F/I: 4424863.377843 + test_inverse

("qsc", 543871.545186, 7341888.620371, 4.897000, 52.371000, "+proj=qsc +ellps=WGS84 +units=m"); test_inverse

("poly", 333274.269648, 5815908.957562, 4.897000, 52.371000, "+proj=poly +ellps=WGS84 +units=m"); test_inverse

("putp1", 375730.931178, 5523551.121434, 4.897000, 52.371000, "+proj=putp1 +ellps=WGS84 +units=m"); test_inverse

("putp2", 351480.997939, 5942668.547355, 4.897000, 52.371000, "+proj=putp2 +ellps=WGS84 +units=m"); @@ -325,7 +323,7 @@ void test_all() test_inverse

("putp6", 324931.055842, 5842588.644796, 4.897000, 52.371000, "+proj=putp6 +ellps=WGS84 +units=m"); test_inverse

("putp6p", 338623.512107, 6396742.919679, 4.897000, 52.371000, "+proj=putp6p +ellps=WGS84 +units=m"); test_inverse

("qua_aut", 370892.621714, 5629072.862494, 4.897000, 52.371000, "+proj=qua_aut +ellps=WGS84 +units=m"); - test_inverse

("robin", 394576.507489, 5571243.439235, 4.897000, 52.371000, "+proj=robin +ellps=WGS84 +units=m"); + test_inverse

("robin", 394576.507489, 5570940.631371, 4.897000, 52.371000, "+proj=robin +ellps=WGS84 +units=m"); test_inverse

("rouss", 412826.227669, 6248368.849775, 4.959853, 52.433747, "+proj=rouss +ellps=WGS84 +units=m"); // F/I: 8188.459174 test_inverse

("sinu", 333528.909809, 5804625.044313, 4.897000, 52.371000, "+proj=sinu +ellps=WGS84 +units=m"); test_inverse

("somerc", 545131.546415, 6833623.829215, 4.897000, 52.371000, "+proj=somerc +ellps=WGS84 +units=m"); diff --git a/extensions/test/gis/projections/projections_combined.cpp b/extensions/test/gis/projections/projections_combined.cpp new file mode 100644 index 000000000..9cec9b905 --- /dev/null +++ b/extensions/test/gis/projections/projections_combined.cpp @@ -0,0 +1,134 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2015 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) + + +#if defined(_MSC_VER) +#pragma warning( disable : 4305 ) // truncation double -> float +#endif // defined(_MSC_VER) + +#include + +#include +#include + +#include +#include +#include + + +#include +#include + +#include +#include +#include +#include + + +template