From 996ab253cb16a9c3f71f33ded643f631df7d73af Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 8 May 2011 12:18:28 +0000 Subject: [PATCH] Merged updates for (small) changes for views/ranges/iterators (r71711 through r71812) [SVN r71815] --- doc/acknowledgments.qbk | 24 ++- doc/design_rationale.qbk | 133 ++++--------- doc/doxy/Doxyfile | 4 +- doc/geometry.qbk | 9 + doc/html/output_main.png | Bin 1289 -> 0 bytes doc/imports.qbk | 8 + doc/introduction.qbk | 30 +-- doc/make_qbk.py | 11 +- doc/quickref.xml | 29 ++- doc/quickstart.qbk | 78 +++++++- doc/reference.qbk | 8 +- .../geometries/adapted/boost_array.qbk | 2 +- .../geometries/adapted/boost_fusion.qbk | 2 +- .../geometries/adapted/boost_tuple.qbk | 2 +- doc/reference/geometries/adapted/c_array.qbk | 2 +- doc/src/examples/Jamfile.v2 | 4 + .../examples/geometries/register/Jamfile.v2 | 11 ++ .../geometries/register/linestring.cpp | 52 +++++ .../register/linestring_templated.cpp | 45 +++++ .../geometries/register/multi_linestring.cpp | 49 +++++ .../geometries/register/multi_point.cpp | 46 +++++ .../register/multi_point_templated.cpp | 46 +++++ .../geometries/register/multi_polygon.cpp | 49 +++++ doc/src/examples/geometries/register/ring.cpp | 49 +++++ .../geometries/register/ring_templated.cpp | 47 +++++ doc/src/examples/quick_start.cpp | 104 +++++----- doc/src/examples/views/Jamfile.v2 | 17 ++ doc/src/examples/views/box_view.cpp | 58 ++++++ doc/src/examples/views/segment_view.cpp | 57 ++++++ example/c04_a_custom_triangle_example.cpp | 5 +- example/c04_b_custom_triangle_example.cpp | 5 +- example/c06_custom_polygon_example.cpp | 8 +- example/c08_custom_non_std_example.cpp | 7 +- test/Jamfile.v2 | 1 - test/algorithms/convex_hull.cpp | 21 ++- .../detail/sections/range_by_section.cpp | 4 +- test/algorithms/within.cpp | 9 +- test/iterators/Jamfile.v2 | 3 - test/iterators/box_iterator.cpp | 54 ------ test/iterators/box_iterator.vcproj | 176 ----------------- test/iterators/circular_iterator.cpp | 113 ----------- test/iterators/circular_iterator.vcproj | 178 ------------------ test/iterators/iterators.sln | 24 --- test/iterators/segment_range_iterator.cpp | 52 ----- test/iterators/segment_range_iterator.vcproj | 176 ----------------- test/multi/algorithms/multi_convex_hull.cpp | 2 +- .../algorithms/overlay/multi_traverse.cpp | 2 +- test/util/as_range.cpp | 4 +- test/views/Jamfile.v2 | 2 + .../box_range.cpp => views/box_view.cpp} | 13 +- .../box_view.vcproj} | 10 +- .../segment_view.cpp} | 11 +- .../segment_view.vcproj} | 10 +- test/views/views.sln | 12 ++ 54 files changed, 841 insertions(+), 1037 deletions(-) delete mode 100644 doc/html/output_main.png create mode 100644 doc/src/examples/geometries/register/linestring.cpp create mode 100644 doc/src/examples/geometries/register/linestring_templated.cpp create mode 100644 doc/src/examples/geometries/register/multi_linestring.cpp create mode 100644 doc/src/examples/geometries/register/multi_point.cpp create mode 100644 doc/src/examples/geometries/register/multi_point_templated.cpp create mode 100644 doc/src/examples/geometries/register/multi_polygon.cpp create mode 100644 doc/src/examples/geometries/register/ring.cpp create mode 100644 doc/src/examples/geometries/register/ring_templated.cpp create mode 100644 doc/src/examples/views/Jamfile.v2 create mode 100644 doc/src/examples/views/box_view.cpp create mode 100644 doc/src/examples/views/segment_view.cpp delete mode 100644 test/iterators/box_iterator.cpp delete mode 100644 test/iterators/box_iterator.vcproj delete mode 100644 test/iterators/circular_iterator.cpp delete mode 100644 test/iterators/circular_iterator.vcproj delete mode 100644 test/iterators/segment_range_iterator.cpp delete mode 100644 test/iterators/segment_range_iterator.vcproj rename test/{ranges/box_range.cpp => views/box_view.cpp} (77%) rename test/{ranges/box_range.vcproj => views/box_view.vcproj} (94%) rename test/{ranges/segment_range.cpp => views/segment_view.cpp} (85%) rename test/{ranges/segment_range.vcproj => views/segment_view.vcproj} (93%) diff --git a/doc/acknowledgments.qbk b/doc/acknowledgments.qbk index 3678f49c5..842f6c520 100644 --- a/doc/acknowledgments.qbk +++ b/doc/acknowledgments.qbk @@ -12,15 +12,29 @@ [section Acknowledgments] -We like to thank all the people who helped in a way to develop this library. +We like to thank all the people who helped to develop this library. -First of all we are grateful to Hartmut Kaiser for managing the formal review of this library. Hartmut was a very good review manager, who intervented when necessary and produced the review report quickly. He has also supported the library by subscribing to the GGL mailing list and participating actively on it. +First of all we are grateful to Hartmut Kaiser for managing the formal review +of this library. Hartmut is an excellent review manager, who intervented when +necessary and produced the review report quickly. -We thank the 14 reviewers of our library, reviewed from November 5, 2009 to November 22, 2009. Reviews have been written by: Brandon Kohn, Christophe Henry, Fabio Fracassi, Gordon Woodhull, Joachim Faulhaber, Jonathan Franklin, Jose, Lucanus Simonson, Michael Caisse, Michael Fawcett, Paul Bristow, Phil Endecott, Thomas Klimpel, Tom Brinkman +We thank the 14 reviewers of our library, reviewed from November 5, 2009 to +November 22, 2009. Reviews have been written by: Brandon Kohn, Christophe +Henry, Fabio Fracassi, Gordon Woodhull, Joachim Faulhaber, Jonathan Franklin, +Jose, Lucanus Simonson, Michael Caisse, Michael Fawcett, Paul Bristow, Phil +Endecott, Thomas Klimpel, Tom Brinkman. -We also thank all people who discussed on the list about Boost.Geometry, in preview stage or in review stage or after that. We cannot mention all those names, but we like to mention those who, sometimes with a short message, did have a major influence on our design: Dave Abrahams (for the hint on tag dispatching when we were lost in SFINAE), John Fem.... TODO (for the hint on the set of metafunctions for traits), and Mathias Gaunard (for the hint on ranges instead of iterators). +We also thank all people who discussed on the mailing lists (either at boost, +or at osgeo) about __boost_geometry__, in preview stage, or in review stage, +or after that. -Finally I (Barend) would like to thank my former employer, Geodan, I've worked there for 16 years, started a geographic library in 1995 which after a number of incarnations, redesigns, refactorings, previews, a review and even more refactorings have led to the now released Boost.Geometry. [/And with them I want to thank those who were initially involved in the library, Maarten Hilfering, Valik, Anne Blankert, and later on Sjoerd Schreuder, Steven Fruitier and Paul den Dulk.] +Finally I (Barend) would like to thank my former employer, Geodan. They +allowed me to start a geographic library in 1995, which after a number of +incarnations, redesigns, refactorings, previews, a review and even more +refactorings have led to the now released __boost_geometry__. And with them I +want to thank the team initially involved in developing the library, Valik +Solorzano Barboza, Maarten Hilferink, Anne Blankert, and later Sjoerd +Schreuder, Steven Fruijtier, Paul den Dulk, and Joris Sierman. [endsect] diff --git a/doc/design_rationale.qbk b/doc/design_rationale.qbk index b718e8930..c659bee7e 100644 --- a/doc/design_rationale.qbk +++ b/doc/design_rationale.qbk @@ -8,6 +8,8 @@ http://www.boost.org/LICENSE_1_0.txt) ===============================================================================/] +[/ note the source code in this QBK is the only not (yet) checked by a compiler] + [section:design Design Rationale] Suppose you need a C++ program to calculate the distance between two points. @@ -27,9 +29,10 @@ and a function, containing the algorithm: return sqrt(dx * dx + dy * dy); } -Quite simple, and it is usable, but not generic. For a library it has to be designed way further. -The design above can only be used for 2D points, for the struct [*mypoint] (and no other struct), -in a __wiki_cs_cartesian__. A generic library should be able to calculate the distance: +Quite simple, and it is usable, but not generic. For a library it has to be +designed way further. The design above can only be used for 2D points, for the +struct [*mypoint] (and no other struct), in a Cartesian coordinate system. A +generic library should be able to calculate the distance: * for any point class or struct, not on just this [*mypoint] type * in more than two dimensions @@ -115,22 +118,6 @@ as shown in the distance algorithm at the start of this paragraph. So we wanted with methods like `x()`, and they are supported as long as there is a specialization of the access `struct` with a static `get` function returning `x()` for dimension 0, and similar for 1 and `y()`. -Alternatively we could implement, in the traits class, the dimension as a template parameter in -a member template function: - - template <> - struct access - { - template - static double get(mypoint const& p) - // either return x/y using an if-clause - // or call a detail-struct specialized - // per dimension - }; - -This alternative gives in the end the same functionality, either using an `if` statement (wihch -may be slower), or adding another level of indirection. - [heading Dimension Agnosticism] Now we can calculate the distance between points in 2D, points of any structure or class. @@ -159,7 +146,7 @@ more complex but attractive for template fans: } }; -The distance function is calling that [*pythagoras] structure, specifying the number of dimensions: +The distance function is calling that `pythagoras` structure, specifying the number of dimensions: template double distance(P1 const& a, P2 const& b) @@ -181,7 +168,8 @@ The dimension which is referred to is defined using another traits class: which has to be specialized again for the `struct mypoint`. -Because it only has to publish a value, we conveniently derive it from the __boost_mpl__ `class boost::mpl::int_`: +Because it only has to publish a value, we conveniently derive it from the +__boost_mpl__ `class boost::mpl::int_`: `` namespace traits @@ -233,7 +221,7 @@ A longer version is presented later on, the short function would look like this: struct coordinate_type : traits::coordinate_type

{}; We now can modify our distance algorithm again. Because it still returns double, we only -modify the [*pythagoras] computation class. It should return the coordinate type of its input. +modify the `pythagoras` computation class. It should return the coordinate type of its input. But, it has two input, possibly different, point types. They might also differ in their coordinate types. Not that that is very likely, but we’re designing a generic library and we should handle those strange cases. We have to choose one of the coordinate types and of course @@ -261,28 +249,30 @@ So our computation class becomes: [heading Different Geometries] -We’ve designed a dimension agnostic system supporting any point type of any coordinate type. -There are still some tweaks but they will be worked out later. Now we will see how we calculate -the distance between a point and a polygon, or between a point and a line-segment. These formulae -are more complex, and the influence on design is even larger. We don’t want to add a function -with another name: +We have designed a dimension agnostic system supporting any point type of any +coordinate type. There are still some tweaks but they will be worked out later. +Now we will see how we calculate the distance between a point and a polygon, or +between a point and a line-segment. These formulae are more complex, and the +influence on design is even larger. We don’t want to add a function with another +name: template double distance_point_segment(P const& p, S const& s) -We want to be generic, the distance function has to be called from code not knowing the type -of geometry it handles, so it has to be named distance. We also cannot create an overload because -that would be ambiguous, having the same template signature. There are two solutions: +We want to be generic, the distance function has to be called from code not +knowing the type of geometry it handles, so it has to be named distance. We also +cannot create an overload because that would be ambiguous, having the same +template signature. There are two solutions: * tag dispatching * SFINAE -We select tag dispatching because it fits into the traits system. The earlier versions (previews) of -Boost.Geometry used SFINAE but we found it had several drawbacks for such a big design, so the switch -to tag dispatching was made. +We select tag dispatching because it fits into the traits system. The earlier +versions (previews) of Boost.Geometry used SFINAE but we found it had several +drawbacks for such a big design, so the switch to tag dispatching was made. -With tag dispatching the distance algorithm inspects the type of geometry of the input parameters. The distance function will be changed -into this: +With tag dispatching the distance algorithm inspects the type of geometry of the +input parameters. The distance function will be changed into this: template double distance(G1 const& g1, G2 const& g2) @@ -489,7 +479,7 @@ systems. typedef pythagoras type; }; -So, here is our [*pythagoras] again, now defined as a strategy. The distance dispatch function just +So, here is our `pythagoras` again, now defined as a strategy. The distance dispatch function just calls its apply method. So this is an important step: for spherical or geographical coordinate systems, another @@ -582,7 +572,7 @@ concepts. This is handled in the upcoming section Concept Checking. We promised that calling `std::sqrt` was not always necessary. So we define a distance result `struct` that contains the squared value and is convertible to a double value. This, however, only has to -be done for [*pythagoras]. The spherical distance functions do not take the square root so for them +be done for `pythagoras`. The spherical distance functions do not take the square root so for them it is not necessary to avoid the expensive square root call; they can just return their distance. So the distance result struct is dependant on strategy, therefore made a member type of @@ -608,9 +598,9 @@ Each strategy should define its return type, within the strategy class, for exam or: - typedef double return_type + typedef double return_type; -for [*pythagoras] and spherical, respectively. +for cartesian (pythagoras) and spherical, respectively. Again our distance function will be modified, as expected, to reflect the new return type. For the overload with a strategy it is not complex: @@ -647,64 +637,15 @@ and modify our distance function: Of course also the apply functions in the dispatch specializations will return a result like this. They have a strategy as a template parameter everywhere, making the less verbose version possible. -[heading Reversibility] +[heading Summary] -Our `dispatch::distance` class was specialized for <`point_tag`, `segment_tag`>. -Library users can also call the distance function with a segment and a point, in that order. -Actually, there are many geometry types (polygon, box, linestring), how to implement all those -without duplicating all tag dispatching functions? The answer is that we automatically -reverse the arguments, if appropriate. For distance it is appropriate because distance is a -commutative function. We add a meta-function `geometry_id`, which has specializations for each -geometry type, just derived from `boost::mpl::int_`, such that it can be ordered. Point is 1, -segment is e.g. 2. +In this design rationale, __boost_geometry__ is step by step designed using tag dispatching, +concepts, traits, and metaprogramming. We used the well-known distance function +to show the design. -Then we add a meta-function reverse_dispatch: - - template - struct reverse_dispatch : detail::reverse_dispatch - < - geometry_id::type::value, - geometry_id::type::value - > - {}; - -Because of the order in geometry_id, we can arrange (template) parameters in that order, -in specializations. So the detail structure looks like: - - namespace detail - { - template - struct reverse_dispatch : boost::mpl::if_c - < - (Id1 > Id2), - boost::true_type, - boost::false_type - > - {}; - } - -and our distance function will be modified again with some template meta-programming: We get - - return boost::mpl::if_c - < - boost::geometry::reverse_dispatch ::type::value, - dispatch::distance_reversed - < - typename tag::type, - typename tag::type, - G1, G2, - // strategy - >, - dispatch::distance - < - typename tag::type, - typename tag::type, - G1, G2, - // strategy - > - >::type::apply(g1, g2, s); - -Where the `dispatch::distance_reversed` is a specific struct, forwarding its call to -`dispatch::distance`, reversing all its template arguments and function arguments. +__boost_geometry__ is designed like described here, with +some more techniques as automatically reversing template arguments, tag casting, +and reusing implementation classes or dispatch classes as policies in other +dispatch classes. [endsect] [/ end of section Design Rationale] diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile index f1183a74e..f6eda4d2c 100644 --- a/doc/doxy/Doxyfile +++ b/doc/doxy/Doxyfile @@ -98,7 +98,7 @@ ALIASES = qbk{1}="\xmlonly \1 \endxmlonly" \ details_macro{2}="The macro \1 registers a \2 such that it is recognized by Boost.Geometry and that Boost.Geometry functionality can used with the specified type." \ details_macro_const="The const version registers only read access to the fields, the point type is therefore read-only" \ details_macro_getset="The get/set version registers get and set methods separately and can be used for classes with protected member variables and get/set methods to change coordinates" \ - details_macro_templated{1}="The type must have one template parameter, which should be a point type, and should not be specified. Boost.Geometry takes care of inserting the template parameter. Hence all types of this templated \1 are registered, regardless of their point type." \ + details_macro_templated{2}="The type must have one template parameter, which should be a \2 type, and should not be specified. Boost.Geometry takes care of inserting the template parameter. Hence all types of this templated \1 are registered, regardless of their point type." \ details_default_strategy="It uses the default strategy, based on the coordinate system of the geometry." \ details_strategy_reasons="Reasons to specify a strategy include: use another coordinate system for calculations; construct the strategy beforehand (e.g. with the radius of the Earth); select a strategy when there are more than one available for a calculation." \ details_return{1}="This version with the return_ prefix returns the \1, and a template parameter must therefore be specified in the call." \ @@ -190,12 +190,12 @@ INPUT = . .. ../../../../boost/geometry/core \ ../../../../boost/geometry/multi/algorithms/detail \ ../../../../boost/geometry/multi/core \ ../../../../boost/geometry/multi/geometries \ + ../../../../boost/geometry/multi/geometries/register \ ../../../../boost/geometry/multi/geometries/concepts \ ../../../../boost/geometry/multi/iterators \ ../../../../boost/geometry/multi/strategies/cartesian \ ../../../../boost/geometry/policies \ ../../../../boost/geometry/policies/relate \ - ../../../../boost/geometry/ranges \ ../../../../boost/geometry/strategies \ ../../../../boost/geometry/strategies/concepts \ ../../../../boost/geometry/strategies/agnostic \ diff --git a/doc/geometry.qbk b/doc/geometry.qbk index 4e2d304c0..b42891feb 100644 --- a/doc/geometry.qbk +++ b/doc/geometry.qbk @@ -66,8 +66,16 @@ All algorithms in Boost.Geometry will check any geometry arguments against the c [def __boost_geometry__ Boost.Geometry] +[def __boost_array__ Boost.Array] +[def __boost_fusion__ Boost.Fusion] +[def __boost_mpl__ Boost.MPL] +[def __boost_range__ Boost.Range] +[def __boost_tuple__ Boost.Tuple] [def __boost_gil__ [@http://www.boost.org/libs/gil/ Boost.GIL]] +[def __ttmath__ [@http://www.ttmath.org/ ttmath]] +[def __ogc__ [@http://www.opengeospatial.org OGC]] + [heading Contributions] Boost.Geometry contains contributions by: @@ -86,3 +94,4 @@ Boost.Geometry contains contributions by: [include matrix.qbk] [include reference.qbk] [include about_documentation.qbk] +[include acknowledgments.qbk] diff --git a/doc/html/output_main.png b/doc/html/output_main.png deleted file mode 100644 index 184ba5965ed321a90ed0f86d0ade58989a23b64c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1289 zcmeAS@N?(olHy`uVBq!ia0y~yU<_nnU~uGMVqjo+zLmj>fq~_Mr;B4q#jUqqmw#VQdsWhVwBRIbQ`g>W!TCLm%^Zps=L#{P1D8*ib!zwD|2cpC_0^gI z)9rf>^WD>)yWRgDtC+2ArKA7nSF>W{Mfz^C^w#*FJe?T-FIe^8myf^eKb_lF{%0R^9ozK-5^=sf=7%@&{5;q9o9&BX{DUZG zF=4;Y0qZX;vOl`Eu{V9?@|G=^t$!Sr7h6@#{`=Eq>k0m>U$+EI;W+ea$|dXaXWLtU z-D#Ss_2ygQOUcR8<#(JdtD9EZWHyiK_oI2wXFqvefBmja*!7-O-rE+ly_wv^Re zsW1ClJ@Gdu8|oPhlkF_k4NLoESKM;S*&Fyx@Z0(8whB6HW20DOj_QXV+Hrp|-*V@) zN%Q7u{MFuYWBCOC|K|>G-S$kaM$tY^*zN1)!sE|hSFez~l9`qL>f~Ry(s+lw{%rpB z&(~i&)V^eC7vt|6Q@^~?JW>62S(&Xr3pj8atP?&xzr3m9Q`Vwe#s5lspYqL(SwBZR z&|t%QM(qoq-(Gj!mbd$C9lPGi9Q$K$QWBkQCX+xnmA=D z)6I)l{9XIco7)+*RM4Uapr%U)oZBa+o{{z3c85s6SWzOsOJu@Ta694*i*Xf^m zK1ldjT2AL@ct3CEod3oDjL;W=^pQoH(WZ>>sV*5~3yG_r*@q@YXrCGKGk?HSmK8(8BzFqRc zJddB>_Li@;ulW2SzU}=g&L)UF5qT%RL;ne)fr6`yeX z@u%wEpZ_=AUwtb2O>%hB#`H~VuZF5NX*~{Q$l<&!Ytv)9FTY;YCmWn$PzZ(3(j2?$ USJ;PtR0fHAy85}Sb4q9e0I7P1DF6Tf diff --git a/doc/imports.qbk b/doc/imports.qbk index 675dd4be2..7f44713fd 100644 --- a/doc/imports.qbk +++ b/doc/imports.qbk @@ -93,5 +93,13 @@ [import src/examples/geometries/register/box_templated.cpp] [import src/examples/geometries/register/box_2d_4values.cpp] [import src/examples/geometries/register/point.cpp] +[import src/examples/geometries/register/linestring.cpp] +[import src/examples/geometries/register/linestring_templated.cpp] +[import src/examples/geometries/register/ring.cpp] +[import src/examples/geometries/register/ring_templated.cpp] +[import src/examples/geometries/register/multi_point.cpp] +[import src/examples/geometries/register/multi_point_templated.cpp] +[import src/examples/geometries/register/multi_linestring.cpp] +[import src/examples/geometries/register/multi_polygon.cpp] diff --git a/doc/introduction.qbk b/doc/introduction.qbk index c1a155240..266997946 100644 --- a/doc/introduction.qbk +++ b/doc/introduction.qbk @@ -15,15 +15,14 @@ __boost_geometry__ (aka Generic Geometry Library, GGL), part of collection of the Boost C++ Libraries, defines concepts, primitives and algorithms for solving -computational geometry problems. +geometry problems. __boost_geometry__ contains a dimension-agnostic, coordinate-system-agnostic -and scalable kernel, based on concepts, meta-functions and tag- dispatching. +and scalable kernel, based on concepts, meta-functions and tag dispatching. On top of that kernel, algorithms are built: area, length, perimeter, centroid, convex hull, intersection (clipping), within (point in polygon), distance, -envelope (bounding box), simplify, transform, convert, and more. -The library is also designed to support high precision arithmetic numbers, -such as __gmp__. +envelope (bounding box), simplify, transform, and much more. +The library supports high precision arithmetic numbers, such as __ttmath__. __boost_geometry__ contains instantiable geometry classes, but library users can also use their own. Using registration macros or traits classes their geometries @@ -32,11 +31,7 @@ can be adapted to fulfil __boost_geometry__ concepts. __boost_geometry__ might be used in all domains where geometry plays a role: mapping and GIS, game development, computer graphics and widgets, robotics, astronomy and more. The core is designed to be as generic as possible and support -those domains. However, for now the development has been mostly GIS-oriented. - -__boost_geometry__ supports the extension model, the same way as __boost_gil__ -also applies it. An extension is (mostly) something more specific to -like mentioned above. +those domains. For now, the development has been mostly GIS-oriented. The library follows existing conventions: @@ -44,9 +39,18 @@ The library follows existing conventions: * conventions from the std library * conventions and names from one of the __ogc__ standards on geometry -The library can be downloaded from the Boost Sandbox, go to the download page -for more information. +The library can be downloaded from [@http://svn.boost.org/svn/boost/trunk Boost.Trunk], +from [@http://svn.boost.org/svn/boost/branches/release Boost.Release], or will come +to you by the normal Boost distribution process. Note that [*extensions] are +only distributed in Boost.Trunk, and that they are subject to change. -__boost_geometry__ bug tracker and Wiki are available at http://trac.osgeo.org/ggl/ +__boost_geometry__ was accepted by Boost at November 28, 2009 +([@http://permalink.gmane.org/gmane.comp.lib.boost.announce/246 review report]). + +There are two mailing lists +where __boost_geometry__ is discussed: the boost developers list, and also the +[@http://lists.osgeo.org/mailman/listinfo/ggl GGL mailing list] at osgeo, at which, at the moment of writing, more than 70 people +are subscribed. The mailing list is also accessible from +[@http://boost-geometry.203548.n3.nabble.com/ Nabble] as Boost Geometry. [endsect] diff --git a/doc/make_qbk.py b/doc/make_qbk.py index c57c66b40..8cdcfc919 100755 --- a/doc/make_qbk.py +++ b/doc/make_qbk.py @@ -88,14 +88,13 @@ core = ["closure", "coordinate_system", "coordinate_type", "cs_tag" exceptions = ["exception", "centroid_exception"]; -iterators = ["box_iterator", "circular_iterator", "closing_iterator" - , "ever_circling_iterator", "segment_range_iterator"] +iterators = ["circular_iterator", "closing_iterator" + , "ever_circling_iterator"] models = ["point", "linestring", "box" , "polygon", "segment", "ring" , "multi_linestring", "multi_point", "multi_polygon", "referring_segment"] -ranges = ["box_range", "segment_range"]; strategies = ["distance::pythagoras", "distance::haversine" , "distance::cross_track", "distance::projected_point" @@ -110,7 +109,8 @@ strategies = ["distance::pythagoras", "distance::haversine" , "transform::translate_transformer", "transform::ublas_transformer" ] -views = ["closeable_view", "reversible_view", "identity_view"] +views = ["box_view", "segment_view" + , "closeable_view", "reversible_view", "identity_view"] @@ -135,9 +135,6 @@ for i in iterators: for i in models: model_to_quickbook(i) -for i in ranges: - class_to_quickbook(i) - for i in strategies: strategy_to_quickbook(i) diff --git a/doc/quickref.xml b/doc/quickref.xml index 3c0a1cf00..3d596993f 100644 --- a/doc/quickref.xml +++ b/doc/quickref.xml @@ -134,11 +134,19 @@ BOOST_GEOMETRY_REGISTER_POINT_3D BOOST_GEOMETRY_REGISTER_POINT_3D_CONST BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET + + BOOST_GEOMETRY_REGISTER_MULTI_POINT + BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED + 1-dimensionial (macro's for adaption) + BOOST_GEOMETRY_REGISTER_LINESTRING + BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED + BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING + BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING_TEMPLATED @@ -147,6 +155,10 @@ BOOST_GEOMETRY_REGISTER_BOX BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED + BOOST_GEOMETRY_REGISTER_RING + BOOST_GEOMETRY_REGISTER_RING_TEMPLATED + BOOST_GEOMETRY_REGISTER_MULTI_POLYGON + BOOST_GEOMETRY_REGISTER_MULTI_POLYGON_TEMPLATED @@ -248,7 +260,7 @@ - + @@ -258,7 +270,7 @@ Iterators - Ranges + Views @@ -267,19 +279,16 @@ closing_iterator - circular_iterator ever_circling_iterator - box_iterator - segment_range_iterator - box_range - segment_range - closeable_view - reversible_view - identity_view + box_view + segment_view + closeable_view + reversible_view + identity_view diff --git a/doc/quickstart.qbk b/doc/quickstart.qbk index 98893fc8c..0b46f810e 100644 --- a/doc/quickstart.qbk +++ b/doc/quickstart.qbk @@ -12,26 +12,84 @@ [section:quickstart Quick Start] -It is not possible to present all features of the whole library at a glance. -However, a few very small examples are shown below. +This Quick Start section shows some of the features of __boost_geometry__ +in the form of annotated, relatively simple, code snippets. -[main1] +The code below assumes that `boost/geometry.hpp` is included, and that `namespace +boost::geometry` is used. __boost_geometry__ is header only, so including +headerfiles is enough. There is no linking with any library necessary. -The pieces above generate this output: +[quickstart_include] -[$output_main.png] +[h3 Cartesian] + +It is possible to use only a small part of the library. For example: the +distance between two points is a common use case. __boost_geometry__ can calculate +it from various types. Using one of its own types: + +[quickstart_distance] + +If the right headers are included and the types are bound to a coordinate +system, various other types can be used as points: plain C array's, __boost_array__'s, +__boost_tuple__'s, __boost_fusion__ imported structs, your own classes... + +Registering and using a C array: +[quickstart_register_c_array] +[quickstart_distance_c_array] + +Another often used algorithm is point-in-polygon. It is implemented in __boost_geometry__ +under the name `within`. We show its usage here checking a __boost_tuple__ (as a point) +located within a polygon, filled with C Array point pairs. + +But it is first necessary to register a __boost_tuple__, like the C array: +[quickstart_register_boost_tuple] +[quickstart_point_in_polygon] + +We can calculate the area of a polygon: +[quickstart_area] + +By the nature of a template library, it is possible to mix point types. +We calculate distance again, now using a C array point and a __boost_tuple__ point: +[quickstart_distance_mixed] + +The snippets listed above generate the following output: + +[pre +Distance p1-p2 is: 1.41421 +Distance a-b is: 2.23607 +Point p is in polygon? true +Area: 3.015 +Distance a-p is: 2.87924 +] + + +[h3 Non-Cartesian] It is also possible to use non-Cartesian points. For example: points on a sphere. When then an algorithm such as distance is used the library "inspects" that it is handling spherical points and calculates the distance over the sphere, instead of applying the Pythagorean theorem. -Finally an example from a totally different domain: developing window-based applications, -for example using QtWidgets. We check if two rectangles overlap and if so, move the second -one to another place: +[note __boost_geometry__ supports a geographical coordinate system, but that is +in an extension and not released in the current Boost release.] -[main3] +We approximate the Earth as a sphere and calculate the distance between Amsterdam +and Paris: +[quick_start_spherical] -More examples are on the page Examples +It writes: [pre Distance in miles: 267.02] + +[h3 Adapted structs] + +Finally an example from a totally different domain: developing window-based +applications, for example using QtWidgets. As soon as Qt classes are registered +in __boost_geometry__ we can use them. We can, for example, check if two +rectangles overlap and if so, move the second one to another place: + +[quickstart_qt] + + +[h3 More] +In the reference many more examples can be found. [endsect] diff --git a/doc/reference.qbk b/doc/reference.qbk index 335b78614..db995b8d4 100644 --- a/doc/reference.qbk +++ b/doc/reference.qbk @@ -211,10 +211,8 @@ [section:iterators Iterators] [include generated/closing_iterator.qbk] -[include generated/box_iterator.qbk] [include generated/circular_iterator.qbk] [include generated/ever_circling_iterator.qbk] -[include generated/segment_range_iterator.qbk] [endsect] @@ -259,9 +257,9 @@ [endsect] -[section:ranges Ranges] -[include generated/box_range.qbk] -[include generated/segment_range.qbk] +[section:views Views] +[include generated/box_view.qbk] +[include generated/segment_view.qbk] [include generated/closeable_view.qbk] [include generated/reversible_view.qbk] [include generated/identity_view.qbk] diff --git a/doc/reference/geometries/adapted/boost_array.qbk b/doc/reference/geometries/adapted/boost_array.qbk index 6c1e96078..18af141a7 100644 --- a/doc/reference/geometries/adapted/boost_array.qbk +++ b/doc/reference/geometries/adapted/boost_array.qbk @@ -28,7 +28,7 @@ box, and ring [heading Header] `#include ` -The standard header `` does not include this header. +__not_in_boost_geometry_hpp__ [heading Example] [boost_array] diff --git a/doc/reference/geometries/adapted/boost_fusion.qbk b/doc/reference/geometries/adapted/boost_fusion.qbk index a55ae232b..9cde090cb 100644 --- a/doc/reference/geometries/adapted/boost_fusion.qbk +++ b/doc/reference/geometries/adapted/boost_fusion.qbk @@ -25,7 +25,7 @@ point concept. They can therefore be used in many Boost.Geometry algorithms. [heading Header] `#include ` -The standard header `` does not include this header. +__not_in_boost_geometry_hpp__ [heading Example] [boost_fusion] diff --git a/doc/reference/geometries/adapted/boost_tuple.qbk b/doc/reference/geometries/adapted/boost_tuple.qbk index 32b0ddbeb..9d3bedaae 100644 --- a/doc/reference/geometries/adapted/boost_tuple.qbk +++ b/doc/reference/geometries/adapted/boost_tuple.qbk @@ -37,7 +37,7 @@ box, and ring [heading Header] `#include ` -The standard header `` does not include this header. +__not_in_boost_geometry_hpp__ [heading Example] [boost_tuple] diff --git a/doc/reference/geometries/adapted/c_array.qbk b/doc/reference/geometries/adapted/c_array.qbk index be560a870..15cdc15bb 100644 --- a/doc/reference/geometries/adapted/c_array.qbk +++ b/doc/reference/geometries/adapted/c_array.qbk @@ -30,7 +30,7 @@ the point type. [heading Header] `#include ` -The standard header `` does not include this header. +__not_in_boost_geometry_hpp__ [heading Example] [c_array] diff --git a/doc/src/examples/Jamfile.v2 b/doc/src/examples/Jamfile.v2 index 527b07c19..a7d966bfc 100644 --- a/doc/src/examples/Jamfile.v2 +++ b/doc/src/examples/Jamfile.v2 @@ -13,5 +13,9 @@ project boost-geometry-doc-src-example : # requirements ; +exe quick_start : quick_start.cpp ; + build-project algorithms ; +build-project core ; build-project geometries ; +build-project views ; diff --git a/doc/src/examples/geometries/register/Jamfile.v2 b/doc/src/examples/geometries/register/Jamfile.v2 index cb87e3a0e..111ebfbac 100644 --- a/doc/src/examples/geometries/register/Jamfile.v2 +++ b/doc/src/examples/geometries/register/Jamfile.v2 @@ -17,3 +17,14 @@ exe box : box.cpp ; exe box_templated : box_templated.cpp ; exe box_2d_4values : box_2d_4values.cpp ; exe point : point.cpp ; + +exe linestring : linestring.cpp ; +exe linestring_templated : linestring_templated.cpp ; +exe ring : ring.cpp ; +exe ring_templated : ring_templated.cpp ; + +exe multi_point : multi_point.cpp ; +exe multi_point_templated : multi_point_templated.cpp ; + +exe multi_linestring : multi_linestring.cpp ; +exe multi_polygon : multi_polygon.cpp ; diff --git a/doc/src/examples/geometries/register/linestring.cpp b/doc/src/examples/geometries/register/linestring.cpp new file mode 100644 index 000000000..bbbbe0b48 --- /dev/null +++ b/doc/src/examples/geometries/register/linestring.cpp @@ -0,0 +1,52 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_linestring +//` Show the use of BOOST_GEOMETRY_REGISTER_LINESTRING + +#include +#include +#include + +typedef boost::geometry::model::d2::point_xy point_2d; + +BOOST_GEOMETRY_REGISTER_LINESTRING(std::vector) + +int main() +{ + // Normal usage of std:: + std::vector line; + line.push_back(point_2d(1, 1)); + line.push_back(point_2d(2, 2)); + line.push_back(point_2d(3, 1)); + + // Usage of Boost.Geometry's length and wkt functions + std::cout << "Length: " + << boost::geometry::length(line) + << std::endl; + + std::cout << "WKT: " + << boost::geometry::wkt(line) + << std::endl; + + return 0; +} + +//] + + +//[register_linestring_output +/*` +Output: +[pre +Length: 2.82843 +WKT: LINESTRING(1 1,2 2,3 1) +] +*/ +//] diff --git a/doc/src/examples/geometries/register/linestring_templated.cpp b/doc/src/examples/geometries/register/linestring_templated.cpp new file mode 100644 index 000000000..221c61a58 --- /dev/null +++ b/doc/src/examples/geometries/register/linestring_templated.cpp @@ -0,0 +1,45 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_linestring_templated +//` Show the use of the macro BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED + +#include +#include +#include +#include + +// Adapt any deque to Boost.Geometry Linestring Concept +BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque) + +int main() +{ + std::deque > line(2); + boost::geometry::assign_values(line[0], 1, 1); + boost::geometry::assign_values(line[1], 2, 2); + + // Boost.Geometry algorithms work on any deque now + std::cout << "Length: " << boost::geometry::length(line) << std::endl; + std::cout << "Line: " << boost::geometry::dsv(line) << std::endl; + + return 0; +} + +//] + + +//[register_linestring_templated_output +/*` +Output: +[pre +Length: 1.41421 +Line: ((1, 1), (2, 2)) +] +*/ +//] diff --git a/doc/src/examples/geometries/register/multi_linestring.cpp b/doc/src/examples/geometries/register/multi_linestring.cpp new file mode 100644 index 000000000..ab72a92cf --- /dev/null +++ b/doc/src/examples/geometries/register/multi_linestring.cpp @@ -0,0 +1,49 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_multi_linestring +//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING + +#include +#include +#include +#include + +typedef boost::geometry::model::linestring + < + boost::tuple + > linestring_type; + +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(std::deque) + +int main() +{ + // Normal usage of std:: + std::deque lines(2); + boost::geometry::read_wkt("LINESTRING(0 0,1 1)", lines[0]); + boost::geometry::read_wkt("LINESTRING(2 2,3 3)", lines[1]); + + // Usage of Boost.Geometry + std::cout << "LENGTH: " << boost::geometry::length(lines) << std::endl; + + return 0; +} + +//] + + +//[register_multi_linestring_output +/*` +Output: +[pre +LENGTH: 2.82843 +] +*/ +//] diff --git a/doc/src/examples/geometries/register/multi_point.cpp b/doc/src/examples/geometries/register/multi_point.cpp new file mode 100644 index 000000000..fa8ad3308 --- /dev/null +++ b/doc/src/examples/geometries/register/multi_point.cpp @@ -0,0 +1,46 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_multi_point +//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_POINT + +#include +#include +#include +#include + +typedef boost::tuple point_type; + +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_MULTI_POINT(std::deque< ::point_type >) + +int main() +{ + // Normal usage of std:: + std::deque multi_point; + multi_point.push_back(point_type(1, 1)); + multi_point.push_back(point_type(3, 2)); + + // Usage of Boost.Geometry + std::cout << "WKT: " << boost::geometry::wkt(multi_point) << std::endl; + + return 0; +} + +//] + + +//[register_multi_point_output +/*` +Output: +[pre +WKT: MULTIPOINT((1 1),(3 2)) +] +*/ +//] diff --git a/doc/src/examples/geometries/register/multi_point_templated.cpp b/doc/src/examples/geometries/register/multi_point_templated.cpp new file mode 100644 index 000000000..b1738432d --- /dev/null +++ b/doc/src/examples/geometries/register/multi_point_templated.cpp @@ -0,0 +1,46 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_multi_point_templated +//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED + +#include +#include +#include +#include + + +BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque) + +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) + +int main() +{ + // Normal usage of std:: + std::deque > multi_point; + multi_point.push_back(boost::tuple(1, 1)); + multi_point.push_back(boost::tuple(3, 2)); + + // Usage of Boost.Geometry + std::cout << "WKT: " << boost::geometry::wkt(multi_point) << std::endl; + + return 0; +} + +//] + + +//[register_multi_point_templated_output +/*` +Output: +[pre +WKT: MULTIPOINT((1 1),(3 2)) +] +*/ +//] diff --git a/doc/src/examples/geometries/register/multi_polygon.cpp b/doc/src/examples/geometries/register/multi_polygon.cpp new file mode 100644 index 000000000..db6a3130d --- /dev/null +++ b/doc/src/examples/geometries/register/multi_polygon.cpp @@ -0,0 +1,49 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_multi_polygon +//` Show the use of the macro BOOST_GEOMETRY_REGISTER_MULTI_POLYGON + +#include +#include +#include +#include + +typedef boost::geometry::model::polygon + < + boost::tuple + > polygon_type; + +BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) +BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(std::vector) + +int main() +{ + // Normal usage of std:: + std::vector polygons(2); + boost::geometry::read_wkt("POLYGON((0 0,0 1,1 1,1 0,0 0))", polygons[0]); + boost::geometry::read_wkt("POLYGON((3 0,3 1,4 1,4 0,3 0))", polygons[1]); + + // Usage of Boost.Geometry + std::cout << "AREA: " << boost::geometry::area(polygons) << std::endl; + + return 0; +} + +//] + + +//[register_multi_polygon_output +/*` +Output: +[pre +AREA: 2 +] +*/ +//] diff --git a/doc/src/examples/geometries/register/ring.cpp b/doc/src/examples/geometries/register/ring.cpp new file mode 100644 index 000000000..bad0e3a54 --- /dev/null +++ b/doc/src/examples/geometries/register/ring.cpp @@ -0,0 +1,49 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_ring +//` Show the use of the macro BOOST_GEOMETRY_REGISTER_RING + +#include +#include +#include + +typedef boost::geometry::model::d2::point_xy point_2d; + +BOOST_GEOMETRY_REGISTER_RING(std::vector) /*< The magic: adapt vector to Boost.Geometry Ring Concept >*/ + +int main() +{ + // Normal usage of std:: + std::vector ring; + ring.push_back(point_2d(1, 1)); + ring.push_back(point_2d(2, 2)); + ring.push_back(point_2d(2, 1)); + + + // Usage of Boost.Geometry + boost::geometry::correct(ring); + std::cout << "Area: " << boost::geometry::area(ring) << std::endl; + std::cout << "WKT: " << boost::geometry::wkt(ring) << std::endl; + + return 0; +} + +//] + + +//[register_ring_output +/*` +Output: +[pre +Area: 0.5 +WKT: POLYGON((1 1,2 2,2 1,1 1)) +] +*/ +//] diff --git a/doc/src/examples/geometries/register/ring_templated.cpp b/doc/src/examples/geometries/register/ring_templated.cpp new file mode 100644 index 000000000..13308ef3d --- /dev/null +++ b/doc/src/examples/geometries/register/ring_templated.cpp @@ -0,0 +1,47 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[register_ring_templated +//` Show the use of the macro BOOST_GEOMETRY_REGISTER_RING_TEMPLATED + +#include +#include +#include +#include + +// Adapt any deque to Boost.Geometry Ring Concept +BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque) + +int main() +{ + std::deque > ring(3); + boost::geometry::assign_values(ring[0], 0, 0); + boost::geometry::assign_values(ring[2], 4, 1); + boost::geometry::assign_values(ring[1], 1, 4); + + // Boost.Geometry algorithms work on any deque now + boost::geometry::correct(ring); + std::cout << "Area: " << boost::geometry::area(ring) << std::endl; + std::cout << "Contents: " << boost::geometry::wkt(ring) << std::endl; + + return 0; +} + +//] + + +//[register_ring_templated_output +/*` +Output: +[pre +Area: 7.5 +Line: ((0, 0), (1, 4), (4, 1), (0, 0)) +] +*/ +//] diff --git a/doc/src/examples/quick_start.cpp b/doc/src/examples/quick_start.cpp index 8b2beb4d2..b246afad0 100644 --- a/doc/src/examples/quick_start.cpp +++ b/doc/src/examples/quick_start.cpp @@ -13,23 +13,33 @@ // http://www.boost.org/LICENSE_1_0.txt) // -#include #if defined(_MSC_VER) // We deliberately mix float/double's here so turn off warning //#pragma warning( disable : 4244 ) #endif // defined(_MSC_VER) +//[quickstart_include + #include -#include -#include + +using namespace boost::geometry; +//] + #include + + +//[quickstart_register_c_array #include +BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) +//] + +//[quickstart_register_boost_tuple +#include BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian) -BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian) - +//] // Small QRect simulations following http://doc.trolltech.com/4.4/qrect.html // Todo: once work the traits out further, would be nice if there is a real example of this. @@ -89,33 +99,48 @@ struct indexed_access }}} -void example_for_main_page() +int main(void) { + //[quickstart_distance + model::d2::point_xy p1(1, 1), p2(2, 2); + std::cout << "Distance p1-p2 is: " << distance(p1, p2) << std::endl; + //] - //[main1 - //` Snippets below assume the namespace boost::geometry is known - using namespace boost::geometry; - - //` It should be possible to use a very small part of the library, for example only the distance between two points. + //[quickstart_distance_c_array int a[2] = {1,1}; int b[2] = {2,3}; double d = distance(a, b); - std::cout << "Distance a-b is:" << d << std::endl; - - //` Other often used algorithms are point-in-polygon: + std::cout << "Distance a-b is: " << d << std::endl; + //] + + //[quickstart_point_in_polygon double points[][2] = {{2.0, 1.3}, {4.1, 3.0}, {5.3, 2.6}, {2.9, 0.7}, {2.0, 1.3}}; model::polygon > poly; append(poly, points); boost::tuple p = boost::make_tuple(3.7, 2.0); - std::cout << "Point p is in polygon? " << (within(p, poly) ? "YES" : "NO") << std::endl; - - //` or area: + std::cout << "Point p is in polygon? " << std::boolalpha << within(p, poly) << std::endl; + //] + + //[quickstart_area std::cout << "Area: " << area(poly) << std::endl; + //] - //` It is possible, by the nature of a template library, to mix the point types declared above: + //[quickstart_distance_mixed double d2 = distance(a, p); - std::cout << "Distance a-p is:" << d2 << std::endl; - + std::cout << "Distance a-p is: " << d2 << std::endl; + //] + + //[quick_start_spherical + typedef boost::geometry::model::point + < + double, 2, boost::geometry::cs::spherical + > spherical_point; + + spherical_point amsterdam(4.90, 52.37); + spherical_point paris(2.35, 48.86); + + double const earth_radius = 3959; // miles + std::cout << "Distance in miles: " << distance(amsterdam, paris) * earth_radius << std::endl; //] /*** @@ -126,7 +151,7 @@ void example_for_main_page() std::cout << "Distance A'dam-Paris: " << distance(amsterdam, paris) / 1000.0 << " kilometers " << std::endl; ***/ - //[main3 + //[quickstart_qt QRect r1(100, 200, 15, 15); QRect r2(110, 210, 20, 20); if (overlaps(r1, r2)) @@ -134,40 +159,7 @@ void example_for_main_page() assign_values(r2, 200, 300, 220, 320); } //] -} - - -void example_for_transform() -{ - using namespace boost::geometry; - - typedef model::point XYZ; - typedef model::point > SPH; - XYZ p; - - SPH sph1, sph2; - assign_values(sph1, 12.5, 41.90, 1.0); - // Go from spherical to Cartesian-3D: - transform(sph1, p); - // Go back from Cartesian 3D to spherical: - transform(p, sph2); - - std::cout << dsv(p) << " <-> " << dsv(sph2) << std::endl; - - typedef model::d2::point_xy XY; - typedef model::d2::point_xy PIXEL; - XY xy(50, 50); - strategy::transform::map_transformer map(0, 0, 100, 100, 1024, 768); - PIXEL pix; - transform(xy, pix, map); - std::cout << pix.x() << "," << pix.y() << std::endl; - -} - - -int main(void) -{ - example_for_main_page(); - example_for_transform(); + return 0; } + diff --git a/doc/src/examples/views/Jamfile.v2 b/doc/src/examples/views/Jamfile.v2 new file mode 100644 index 000000000..becef4037 --- /dev/null +++ b/doc/src/examples/views/Jamfile.v2 @@ -0,0 +1,17 @@ +# Boost.Geometry (aka GGL, Generic Geometry Library) +# +# Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +# Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +# Copyright (c) 2009-2011 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) + + +project boost-geometry-doc-example-views + : # requirements + ; + +exe box_view : box_view.cpp ; +exe segment_view : segment_view.cpp ; diff --git a/doc/src/examples/views/box_view.cpp b/doc/src/examples/views/box_view.cpp new file mode 100644 index 000000000..e280ec428 --- /dev/null +++ b/doc/src/examples/views/box_view.cpp @@ -0,0 +1,58 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[box_view +//` Shows usage of the Boost.Range compatible view on a box + +#include + +#include + + +int main() +{ + typedef boost::geometry::model::box + < + boost::geometry::model::point + > box_type; + + // Define the Boost.Range compatible type: + typedef boost::geometry::box_view box_view; + + box_type box; + boost::geometry::assign_values(box, 0, 0, 4, 4); + + box_view view(box); + + // Iterating in clockwise direction over the points of this box + for (boost::range_iterator::type it = boost::begin(view); + it != boost::end(view); ++it) + { + std::cout << " " << boost::geometry::dsv(*it); + } + std::cout << std::endl; + + // Note that a box_view is tagged as a ring, so supports area etc. + std::cout << "Area: " << boost::geometry::area(view) << std::endl; + + return 0; +} + +//] + + +//[box_view_output +/*` +Output: +[pre + (0, 0) (0, 4) (4, 4) (4, 0) (0, 0) +Area: 16 +] +*/ +//] diff --git a/doc/src/examples/views/segment_view.cpp b/doc/src/examples/views/segment_view.cpp new file mode 100644 index 000000000..53a20c369 --- /dev/null +++ b/doc/src/examples/views/segment_view.cpp @@ -0,0 +1,57 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// QuickBook Example + +// Copyright (c) 2011 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) + +//[segment_view +//` Shows usage of the Boost.Range compatible view on a box + +#include + +#include + + +int main() +{ + typedef boost::geometry::model::segment + < + boost::geometry::model::point + > segment_type; + + typedef boost::geometry::segment_view segment_view; + + segment_type segment; + boost::geometry::assign_values(segment, 0, 0, 1, 1); + + segment_view view(segment); + + // Iterating over the points of this segment + for (boost::range_iterator::type it = boost::begin(view); + it != boost::end(view); ++it) + { + std::cout << " " << boost::geometry::dsv(*it); + } + std::cout << std::endl; + + // Note that a segment_view is tagged as a linestring, so supports length etc. + std::cout << "Length: " << boost::geometry::length(view) << std::endl; + + return 0; +} + +//] + + +//[segment_view_output +/*` +Output: +[pre + (0, 0) (0, 4) (4, 4) (4, 0) (0, 0) +Area: 16 +] +*/ +//] diff --git a/example/c04_a_custom_triangle_example.cpp b/example/c04_a_custom_triangle_example.cpp index 8c4b7d6d8..ce2a53e15 100644 --- a/example/c04_a_custom_triangle_example.cpp +++ b/example/c04_a_custom_triangle_example.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -30,9 +31,7 @@ struct triangle : public boost::array struct tag { typedef ring_tag type; }; -}}} +BOOST_GEOMETRY_REGISTER_RING(triangle) // Specializations of algorithms, where useful. If not specialized the default ones diff --git a/example/c04_b_custom_triangle_example.cpp b/example/c04_b_custom_triangle_example.cpp index 1e41c5f9b..41e93f14e 100644 --- a/example/c04_b_custom_triangle_example.cpp +++ b/example/c04_b_custom_triangle_example.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -31,9 +32,7 @@ struct triangle : public boost::array // Register triangle

as a ring -namespace boost { namespace geometry { namespace traits { -template struct tag > { typedef ring_tag type; }; -}}} +BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(triangle) namespace boost { namespace geometry { namespace dispatch { diff --git a/example/c06_custom_polygon_example.cpp b/example/c06_custom_polygon_example.cpp index da4a978de..b2c486fa8 100644 --- a/example/c06_custom_polygon_example.cpp +++ b/example/c06_custom_polygon_example.cpp @@ -14,6 +14,7 @@ #include #include +#include struct my_point @@ -48,11 +49,7 @@ struct my_polygon // We can conveniently use macro's to register point and ring BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y) - -// Register my_ring as a ring -namespace boost { namespace geometry { namespace traits { -template <> struct tag { typedef ring_tag type; }; -}}} +BOOST_GEOMETRY_REGISTER_RING(my_ring) @@ -76,7 +73,6 @@ template<> struct interior_mutable_type typedef boost::array& type; }; - template<> struct exterior_ring { static my_ring& get(my_polygon& p) diff --git a/example/c08_custom_non_std_example.cpp b/example/c08_custom_non_std_example.cpp index 874917d8e..6df1ff3d9 100644 --- a/example/c08_custom_non_std_example.cpp +++ b/example/c08_custom_non_std_example.cpp @@ -20,6 +20,7 @@ #include #include +#include #include // Sample point, having x/y @@ -215,9 +216,7 @@ template<> struct resize // 4) register with Boost.Geometry BOOST_GEOMETRY_REGISTER_POINT_2D(my_point, double, cs::cartesian, x, y) -namespace boost { namespace geometry { namespace traits { -template <> struct tag { typedef ring_tag type; }; -}}} +BOOST_GEOMETRY_REGISTER_RING(my_polygon) // end adaption @@ -238,7 +237,7 @@ void walk_using_iterator(my_polygon const& polygon) void walk_using_range(my_polygon const& polygon) { - for (boost::range_iterator::type it + for (boost::range_iterator::type it = boost::begin(polygon); it != boost::end(polygon); ++it) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6a26f8729..3ea87d102 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -25,7 +25,6 @@ build-project geometries ; build-project arithmetic ; build-project algorithms ; build-project iterators ; -build-project ranges ; build-project strategies ; build-project policies ; build-project util ; diff --git a/test/algorithms/convex_hull.cpp b/test/algorithms/convex_hull.cpp index 53c0e246a..d520a9afc 100644 --- a/test/algorithms/convex_hull.cpp +++ b/test/algorithms/convex_hull.cpp @@ -21,26 +21,29 @@ template -void test_all(bool do_rectangular = true) +void test_all() { // from sample linestring - test_geometry >( "linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", 5, 4, 3.8); - if (do_rectangular) - { - // rectangular, with concavity - test_geometry >( - "polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))", - 9, 5, 12.0); - } + // rectangular, with concavity + test_geometry >( + "polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))", + 9, 5, 12.0); // from sample polygon, with concavity test_geometry >( "polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0" ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))", 12, 8, 5.245); + + test_geometry >( + "polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0" + ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))", + 12, 8, 5.245); + + // Waits for next cycle test_geometry >("box(0 0,2 2)", 5, 5, 4); } int test_main(int, char* []) diff --git a/test/algorithms/detail/sections/range_by_section.cpp b/test/algorithms/detail/sections/range_by_section.cpp index 4ac576f2a..920e95e82 100644 --- a/test/algorithms/detail/sections/range_by_section.cpp +++ b/test/algorithms/detail/sections/range_by_section.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include @@ -35,7 +35,7 @@ void test_sectionalize(std::string const caseid, Geometry const& geometry, std:: typedef typename bg::closeable_view < - typename bg::range_type::type const, + typename bg::detail::range_type::type const, bg::closure::value >::type cview_type; typedef typename bg::reversible_view diff --git a/test/algorithms/within.cpp b/test/algorithms/within.cpp index f91e24054..9020c364d 100644 --- a/test/algorithms/within.cpp +++ b/test/algorithms/within.cpp @@ -33,8 +33,13 @@ void test_all() test_geometry >("POINT(2 2)", "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1))", false); + typedef bg::model::box

box_type; + + test_geometry("POINT(1 1)", "BOX(0 0,2 2)", true); + + test_geometry("BOX(1 1,2 2)", "BOX(0 0,3 3)", true); + test_geometry("BOX(0 0,3 3)", "BOX(1 1,2 2)", false); - test_geometry >("POINT(1 1)", "BOX(0 0,2 2)", true); // Mixed point types test_geometry @@ -45,7 +50,7 @@ void test_all() // Real-life problem (solved now), point is in the middle, 409623 is also a coordinate - // on the border, it was wrong first. + // on the border, has been wrong in the past (2009) test_ring

("POINT(146383 409623)", "POLYGON((146351 410597,146521 410659,147906 410363,148088 410420" ",148175 410296,148281 409750,148215 409623,148154 409666,148154 409666" diff --git a/test/iterators/Jamfile.v2 b/test/iterators/Jamfile.v2 index ad7a0368d..345065098 100644 --- a/test/iterators/Jamfile.v2 +++ b/test/iterators/Jamfile.v2 @@ -10,9 +10,6 @@ test-suite boost-geometry-iterators : - [ run box_iterator.cpp ] - [ run circular_iterator.cpp ] [ run closing_iterator.cpp ] [ run ever_circling_iterator.cpp ] - [ run segment_range_iterator.cpp ] ; diff --git a/test/iterators/box_iterator.cpp b/test/iterators/box_iterator.cpp deleted file mode 100644 index db059fcc5..000000000 --- a/test/iterators/box_iterator.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Box Library) -// -// Copyright (c) 2010 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) - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - - -template -void test_geometry(std::string const& wkt, std::string const& expected) -{ - Box box; - bg::read_wkt(wkt, box); - - { - std::ostringstream out; - bg::box_iterator it(box), end(box, true); - for ( ; it != end; ++it) - { - out << " " << bg::get<0>(*it) << bg::get<1>(*it); - } - BOOST_CHECK_EQUAL(out.str(), expected); - } -} - - -template -void test_all() -{ - test_geometry >("polygon((1 1,2 2))", " 11 12 22 21 11"); - test_geometry >("polygon((3 3,5 5))", " 33 35 55 53 33"); -} - - -int test_main(int, char* []) -{ - test_all >(); - - return 0; -} diff --git a/test/iterators/box_iterator.vcproj b/test/iterators/box_iterator.vcproj deleted file mode 100644 index 6f01f7be5..000000000 --- a/test/iterators/box_iterator.vcproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/iterators/circular_iterator.cpp b/test/iterators/circular_iterator.cpp deleted file mode 100644 index c6224867c..000000000 --- a/test/iterators/circular_iterator.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// Unit Test - -// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. - -// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library -// (geolib/GGL), copyright (c) 1995-2010 Geodan, 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) - -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - - -template -void test_forward(Geometry const& geometry, CircularIterator end, - int offset, std::string const& expected) -{ - CircularIterator it(boost::begin(geometry), boost::end(geometry), - boost::begin(geometry) + offset); - - std::ostringstream out; - for (; it != end; ++it) - { - out << bg::get<0>(*it); - } - BOOST_CHECK_EQUAL(out.str(), expected); -} - - -template -void test_backward(Geometry const& geometry, CircularIterator end, - int offset, std::string const& expected) -{ - CircularIterator it(boost::begin(geometry), boost::end(geometry), - boost::begin(geometry) + offset); - - std::ostringstream out; - for (; it != end; --it) - { - out << bg::get<0>(*it); - } - BOOST_CHECK_EQUAL(out.str(), expected); -} - - - -template -void test_geometry(std::string const& wkt) -{ - G geo; - bg::read_wkt(wkt, geo); - typedef typename boost::range_const_iterator::type normal_iterator; - typedef bg::circular_iterator circular_iterator; - - circular_iterator end(boost::end(geo)); - - // 2: start somewhere in the middle (first == test before) - test_forward(geo, end, 0, "12345"); - test_forward(geo, end, 1, "23451"); - test_forward(geo, end, 2, "34512"); - test_forward(geo, end, 3, "45123"); - test_forward(geo, end, 4, "51234"); - - test_backward(geo, end, 0, "15432"); - test_backward(geo, end, 1, "21543"); - test_backward(geo, end, 2, "32154"); - test_backward(geo, end, 3, "43215"); - test_backward(geo, end, 4, "54321"); - - // 4: check copy behaviour - G copy; - - normal_iterator start = boost::begin(geo) + 2; - circular_iterator it(boost::begin(geo), boost::end(geo), start); - std::copy(it, end, std::back_inserter(copy)); - - std::ostringstream out; - for (normal_iterator cit = boost::begin(copy); cit != boost::end(copy); ++cit) - { - out << bg::get<0>(*cit); - } - BOOST_CHECK_EQUAL(out.str(), "34512"); -} - - -template -void test_all() -{ - test_geometry >("linestring(1 1,2 2,3 3,4 4,5 5)"); -} - - -int test_main(int, char* []) -{ - test_all >(); - - return 0; -} diff --git a/test/iterators/circular_iterator.vcproj b/test/iterators/circular_iterator.vcproj deleted file mode 100644 index 24210a2a0..000000000 --- a/test/iterators/circular_iterator.vcproj +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/iterators/iterators.sln b/test/iterators/iterators.sln index ec406dc9a..8b1e55c7e 100644 --- a/test/iterators/iterators.sln +++ b/test/iterators/iterators.sln @@ -2,16 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual C++ Express 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ever_circling_iterator", "ever_circling_iterator.vcproj", "{73F8C969-FA1E-4D9D-81F9-35B1206F0C14}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "circular_iterator", "circular_iterator.vcproj", "{46571A34-B68D-4854-90C0-56D29EE63FFE}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "closing_iterator", "closing_iterator.vcproj", "{04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "segment_range_iterator", "segment_range_iterator.vcproj", "{887E64C9-6786-44E2-AE09-B02B855486DE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "box_iterator", "box_iterator.vcproj", "{CD4B14B2-ED74-4111-B8BF-093FA3930A5C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "segment_returning_iterator", "segment_returning_iterator.vcproj", "{A38B1CA8-5194-4FAD-B85E-55697BEECCB7}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -22,26 +14,10 @@ Global {73F8C969-FA1E-4D9D-81F9-35B1206F0C14}.Debug|Win32.Build.0 = Debug|Win32 {73F8C969-FA1E-4D9D-81F9-35B1206F0C14}.Release|Win32.ActiveCfg = Release|Win32 {73F8C969-FA1E-4D9D-81F9-35B1206F0C14}.Release|Win32.Build.0 = Release|Win32 - {46571A34-B68D-4854-90C0-56D29EE63FFE}.Debug|Win32.ActiveCfg = Debug|Win32 - {46571A34-B68D-4854-90C0-56D29EE63FFE}.Debug|Win32.Build.0 = Debug|Win32 - {46571A34-B68D-4854-90C0-56D29EE63FFE}.Release|Win32.ActiveCfg = Release|Win32 - {46571A34-B68D-4854-90C0-56D29EE63FFE}.Release|Win32.Build.0 = Release|Win32 {04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Debug|Win32.ActiveCfg = Debug|Win32 {04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Debug|Win32.Build.0 = Debug|Win32 {04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Release|Win32.ActiveCfg = Release|Win32 {04C31A2D-BE88-4FDB-AFFE-EFDFFA9D9C39}.Release|Win32.Build.0 = Release|Win32 - {887E64C9-6786-44E2-AE09-B02B855486DE}.Debug|Win32.ActiveCfg = Debug|Win32 - {887E64C9-6786-44E2-AE09-B02B855486DE}.Debug|Win32.Build.0 = Debug|Win32 - {887E64C9-6786-44E2-AE09-B02B855486DE}.Release|Win32.ActiveCfg = Release|Win32 - {887E64C9-6786-44E2-AE09-B02B855486DE}.Release|Win32.Build.0 = Release|Win32 - {CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Debug|Win32.ActiveCfg = Debug|Win32 - {CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Debug|Win32.Build.0 = Debug|Win32 - {CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Release|Win32.ActiveCfg = Release|Win32 - {CD4B14B2-ED74-4111-B8BF-093FA3930A5C}.Release|Win32.Build.0 = Release|Win32 - {A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Debug|Win32.ActiveCfg = Debug|Win32 - {A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Debug|Win32.Build.0 = Debug|Win32 - {A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Release|Win32.ActiveCfg = Release|Win32 - {A38B1CA8-5194-4FAD-B85E-55697BEECCB7}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/test/iterators/segment_range_iterator.cpp b/test/iterators/segment_range_iterator.cpp deleted file mode 100644 index 501e7f78c..000000000 --- a/test/iterators/segment_range_iterator.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Segment Library) -// -// Copyright (c) 2010 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) - -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - - -template -void test_geometry(std::string const& wkt, std::string const& expected) -{ - Segment segment; - bg::read_wkt(wkt, segment); - - std::ostringstream out; - bg::segment_range_iterator it(segment), end(segment, true); - for ( ; it != end; ++it) - { - out << " " << bg::get<0>(*it) << bg::get<1>(*it); - } - BOOST_CHECK_EQUAL(out.str(), expected); -} - - -template -void test_all() -{ - test_geometry("linestring(1 1,2 2)", " 11 22"); - test_geometry("linestring(4 4,3 3)", " 44 33"); -} - - -int test_main(int, char* []) -{ - test_all >(); - - return 0; -} diff --git a/test/iterators/segment_range_iterator.vcproj b/test/iterators/segment_range_iterator.vcproj deleted file mode 100644 index b6264af2a..000000000 --- a/test/iterators/segment_range_iterator.vcproj +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/multi/algorithms/multi_convex_hull.cpp b/test/multi/algorithms/multi_convex_hull.cpp index 7112eab8d..c649c0b90 100644 --- a/test/multi/algorithms/multi_convex_hull.cpp +++ b/test/multi/algorithms/multi_convex_hull.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/test/multi/algorithms/overlay/multi_traverse.cpp b/test/multi/algorithms/overlay/multi_traverse.cpp index 19f296223..0199504b1 100644 --- a/test/multi/algorithms/overlay/multi_traverse.cpp +++ b/test/multi/algorithms/overlay/multi_traverse.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/test/util/as_range.cpp b/test/util/as_range.cpp index 3b51d4687..9f8ac6d9b 100644 --- a/test/util/as_range.cpp +++ b/test/util/as_range.cpp @@ -16,7 +16,7 @@ #include -#include +#include #include #include @@ -43,7 +43,7 @@ void test_geometry(std::string const& wkt, double expected_x, double expected_y) // Declare a range-type, compatible with boost::range, // such that range_iterator etc could be called - typedef typename bg::range_type::type range_type; + typedef typename bg::detail::range_type::type range_type; bg::read_wkt(wkt, geometry); diff --git a/test/views/Jamfile.v2 b/test/views/Jamfile.v2 index e28d498c8..b56703140 100644 --- a/test/views/Jamfile.v2 +++ b/test/views/Jamfile.v2 @@ -10,6 +10,8 @@ test-suite boost-geometry-views : + [ run segment_view.cpp ] + [ run box_view.cpp ] [ run reversible_view.cpp ] [ run closeable_view.cpp ] [ run reversible_closeable.cpp ] diff --git a/test/ranges/box_range.cpp b/test/views/box_view.cpp similarity index 77% rename from test/ranges/box_range.cpp rename to test/views/box_view.cpp index 6acfccda8..610804f4d 100644 --- a/test/ranges/box_range.cpp +++ b/test/views/box_view.cpp @@ -16,19 +16,19 @@ #include #include -#include +#include #include -template +template void test_geometry(std::string const& wkt, std::string const& expected) { Box box; bg::read_wkt(wkt, box); - typedef bg::box_range range_type; + typedef bg::box_view range_type; range_type range(box); { @@ -56,15 +56,16 @@ void test_geometry(std::string const& wkt, std::string const& expected) } // Check Boost.Range concept - BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept) ); + BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); } template void test_all() { - test_geometry >("polygon((1 1,2 2))", " 11 12 22 21 11"); - test_geometry >("polygon((3 3,5 5))", " 33 35 55 53 33"); + test_geometry, true> ("polygon((1 1,2 2))", " 11 12 22 21 11"); + test_geometry, false>("polygon((1 1,2 2))", " 11 21 22 12 11"); + test_geometry, true> ("polygon((3 3,5 5))", " 33 35 55 53 33"); } diff --git a/test/ranges/box_range.vcproj b/test/views/box_view.vcproj similarity index 94% rename from test/ranges/box_range.vcproj rename to test/views/box_view.vcproj index 61627ae0a..ab1036bee 100644 --- a/test/ranges/box_range.vcproj +++ b/test/views/box_view.vcproj @@ -2,9 +2,9 @@ @@ -18,7 +18,7 @@ diff --git a/test/ranges/segment_range.cpp b/test/views/segment_view.cpp similarity index 85% rename from test/ranges/segment_range.cpp rename to test/views/segment_view.cpp index 1d48199c6..a56188771 100644 --- a/test/ranges/segment_range.cpp +++ b/test/views/segment_view.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include @@ -27,7 +27,7 @@ void test_geometry(std::string const& wkt, std::string const& expected) Segment segment; bg::read_wkt(wkt, segment); - typedef bg::segment_range range_type; + typedef bg::segment_view range_type; range_type range(segment); { @@ -60,7 +60,7 @@ void test_geometry(std::string const& wkt, std::string const& expected) } // Check Boost.Range concept - BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept) ); + BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); } @@ -75,6 +75,11 @@ void test_all() int test_main(int, char* []) { + std::vector a; + a.push_back(1); + boost::range_iterator const>::type it = a.end(); + --it; + std::cout << *it << std::endl; test_all >(); return 0; } diff --git a/test/ranges/segment_range.vcproj b/test/views/segment_view.vcproj similarity index 93% rename from test/ranges/segment_range.vcproj rename to test/views/segment_view.vcproj index 6f03d21cb..9b8840193 100644 --- a/test/ranges/segment_range.vcproj +++ b/test/views/segment_view.vcproj @@ -2,9 +2,9 @@ @@ -18,7 +18,7 @@ diff --git a/test/views/views.sln b/test/views/views.sln index abe1a9eef..7fcf73665 100644 --- a/test/views/views.sln +++ b/test/views/views.sln @@ -6,6 +6,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reversible_closeable", "rev EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "reversible_view", "reversible_view.vcproj", "{BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "box_view", "box_view.vcproj", "{34A1F53A-DA46-41E6-9E26-740D22D662DC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "segment_view", "segment_view.vcproj", "{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -24,6 +28,14 @@ Global {BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}.Debug|Win32.Build.0 = Debug|Win32 {BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}.Release|Win32.ActiveCfg = Release|Win32 {BFB08FEE-76D6-4F3D-9184-BE03CC3F7968}.Release|Win32.Build.0 = Release|Win32 + {34A1F53A-DA46-41E6-9E26-740D22D662DC}.Debug|Win32.ActiveCfg = Debug|Win32 + {34A1F53A-DA46-41E6-9E26-740D22D662DC}.Debug|Win32.Build.0 = Debug|Win32 + {34A1F53A-DA46-41E6-9E26-740D22D662DC}.Release|Win32.ActiveCfg = Release|Win32 + {34A1F53A-DA46-41E6-9E26-740D22D662DC}.Release|Win32.Build.0 = Release|Win32 + {B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Debug|Win32.ActiveCfg = Debug|Win32 + {B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Debug|Win32.Build.0 = Debug|Win32 + {B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Release|Win32.ActiveCfg = Release|Win32 + {B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE