Merged updates for (small) changes for views/ranges/iterators (r71711 through r71812)

[SVN r71815]
This commit is contained in:
Barend Gehrels
2011-05-08 12:18:28 +00:00
parent f287a5e22a
commit 996ab253cb
54 changed files with 841 additions and 1037 deletions

View File

@@ -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]

View File

@@ -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<mypoint>
{
template <int D>
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 <typename P1, typename P2>
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<P> {};
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 were 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]
Weve 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 dont 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 dont want to add a function with another
name:
template <typename P, typename S>
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 <typename G1, typename G2>
double distance(G1 const& g1, G2 const& g2)
@@ -489,7 +479,7 @@ systems.
typedef pythagoras<P1, P2, D> 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 <typename G1, typename G2>
struct reverse_dispatch : detail::reverse_dispatch
<
geometry_id<G1>::type::value,
geometry_id<G2>::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 <int Id1, int Id2>
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 <G1, G2>::type::value,
dispatch::distance_reversed
<
typename tag<G1>::type,
typename tag<G2>::type,
G1, G2,
// strategy
>,
dispatch::distance
<
typename tag<G1>::type,
typename tag<G2>::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]

View File

@@ -98,7 +98,7 @@ ALIASES = qbk{1}="\xmlonly <qbk>\1</qbk> \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 \

View File

@@ -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]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -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]

View File

@@ -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]

View File

@@ -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)

View File

@@ -134,11 +134,19 @@
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_point_3d">BOOST_GEOMETRY_REGISTER_POINT_3D</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_point_3d_const">BOOST_GEOMETRY_REGISTER_POINT_3D_CONST</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_point_3d_get_set">BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_point">BOOST_GEOMETRY_REGISTER_MULTI_POINT</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_point_templated">BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED</link></member>
</simplelist>
</entry>
<entry valign="top">
<bridgehead renderas="sect3">1-dimensionial (macro's for adaption)</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_linestring">BOOST_GEOMETRY_REGISTER_LINESTRING</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_linestring_templated">BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_linestring">BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_linestring_templated">BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING_TEMPLATED</link></member>
</simplelist>
</entry>
<entry valign="top">
@@ -147,6 +155,10 @@
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_box">BOOST_GEOMETRY_REGISTER_BOX</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_box_2d_4values">BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_box_templated">BOOST_GEOMETRY_REGISTER_BOX_TEMPLATED</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_ring">BOOST_GEOMETRY_REGISTER_RING</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_ring_templated">BOOST_GEOMETRY_REGISTER_RING_TEMPLATED</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_polygon">BOOST_GEOMETRY_REGISTER_MULTI_POLYGON</link></member>
<member><link linkend="geometry.reference.adapted.register.boost_geometry_register_multi_polygon_templated">BOOST_GEOMETRY_REGISTER_MULTI_POLYGON_TEMPLATED</link></member>
</simplelist>
</entry>
</row>
@@ -248,7 +260,7 @@
</tbody>
</tgroup>
<!-- ###### ITERATORS / RANGES ##################################################### -->
<!-- ###### ITERATORS / VIEWS ##################################################### -->
<tgroup cols="2">
<colspec colname="a"/>
<colspec colname="b"/>
@@ -258,7 +270,7 @@
<bridgehead renderas="sect2">Iterators</bridgehead>
</entry>
<entry valign="center" namest="b" nameend="b">
<bridgehead renderas="sect2">Ranges</bridgehead>
<bridgehead renderas="sect2">Views</bridgehead>
</entry>
</row>
</thead>
@@ -267,19 +279,16 @@
<entry valign="top">
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.iterators.closing_iterator">closing_iterator</link></member>
<member><link linkend="geometry.reference.iterators.circular_iterator">circular_iterator</link></member>
<member><link linkend="geometry.reference.iterators.ever_circling_iterator">ever_circling_iterator</link></member>
<member><link linkend="geometry.reference.iterators.box_iterator">box_iterator</link></member>
<member><link linkend="geometry.reference.iterators.segment_range_iterator">segment_range_iterator</link></member>
</simplelist>
</entry>
<entry valign="top">
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.ranges.box_range">box_range</link></member>
<member><link linkend="geometry.reference.ranges.segment_range">segment_range</link></member>
<member><link linkend="geometry.reference.ranges.closeable_view">closeable_view</link></member>
<member><link linkend="geometry.reference.ranges.reversible_view">reversible_view</link></member>
<member><link linkend="geometry.reference.ranges.identity_view">identity_view</link></member>
<member><link linkend="geometry.reference.views.box_view">box_view</link></member>
<member><link linkend="geometry.reference.views.segment_view">segment_view</link></member>
<member><link linkend="geometry.reference.views.closeable_view">closeable_view</link></member>
<member><link linkend="geometry.reference.views.reversible_view">reversible_view</link></member>
<member><link linkend="geometry.reference.views.identity_view">identity_view</link></member>
</simplelist>
</entry>
</row>

View File

@@ -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]

View File

@@ -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]

View File

@@ -28,7 +28,7 @@ box, and ring
[heading Header]
`#include <boost/geometry/geometries/adapted/boost_array.hpp>`
The standard header `<boost/geometry.hpp>` does not include this header.
__not_in_boost_geometry_hpp__
[heading Example]
[boost_array]

View File

@@ -25,7 +25,7 @@ point concept. They can therefore be used in many Boost.Geometry algorithms.
[heading Header]
`#include <boost/geometry/geometries/adapted/boost_fusion.hpp>`
The standard header `<boost/geometry.hpp>` does not include this header.
__not_in_boost_geometry_hpp__
[heading Example]
[boost_fusion]

View File

@@ -37,7 +37,7 @@ box, and ring
[heading Header]
`#include <boost/geometry/geometries/adapted/boost_tuple.hpp>`
The standard header `<boost/geometry.hpp>` does not include this header.
__not_in_boost_geometry_hpp__
[heading Example]
[boost_tuple]

View File

@@ -30,7 +30,7 @@ the point type.
[heading Header]
`#include <boost/geometry/geometries/adapted/c_array.hpp>`
The standard header `<boost/geometry.hpp>` does not include this header.
__not_in_boost_geometry_hpp__
[heading Example]
[c_array]

View File

@@ -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 ;

View File

@@ -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 ;

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
typedef boost::geometry::model::d2::point_xy<double> point_2d;
BOOST_GEOMETRY_REGISTER_LINESTRING(std::vector<point_2d>)
int main()
{
// Normal usage of std::
std::vector<point_2d> 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)
]
*/
//]

View File

@@ -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 <iostream>
#include <deque>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
// Adapt any deque to Boost.Geometry Linestring Concept
BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
int main()
{
std::deque<boost::geometry::model::d2::point_xy<double> > 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))
]
*/
//]

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/geometry/multi/geometries/register/multi_linestring.hpp>
typedef boost::geometry::model::linestring
<
boost::tuple<float, float>
> linestring_type;
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
BOOST_GEOMETRY_REGISTER_MULTI_LINESTRING(std::deque<linestring_type>)
int main()
{
// Normal usage of std::
std::deque<linestring_type> 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
]
*/
//]

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/geometry/multi/geometries/register/multi_point.hpp>
typedef boost::tuple<float, float> 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<point_type> 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))
]
*/
//]

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/geometry/multi/geometries/register/multi_point.hpp>
BOOST_GEOMETRY_REGISTER_MULTI_POINT_TEMPLATED(std::deque)
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
int main()
{
// Normal usage of std::
std::deque<boost::tuple<float, float> > multi_point;
multi_point.push_back(boost::tuple<float, float>(1, 1));
multi_point.push_back(boost::tuple<float, float>(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))
]
*/
//]

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/geometry/multi/geometries/register/multi_polygon.hpp>
typedef boost::geometry::model::polygon
<
boost::tuple<float, float>
> polygon_type;
BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
BOOST_GEOMETRY_REGISTER_MULTI_POLYGON(std::vector<polygon_type>)
int main()
{
// Normal usage of std::
std::vector<polygon_type> 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
]
*/
//]

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
typedef boost::geometry::model::d2::point_xy<double> point_2d;
BOOST_GEOMETRY_REGISTER_RING(std::vector<point_2d>) /*< The magic: adapt vector to Boost.Geometry Ring Concept >*/
int main()
{
// Normal usage of std::
std::vector<point_2d> 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))
]
*/
//]

View File

@@ -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 <iostream>
#include <deque>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
// Adapt any deque to Boost.Geometry Ring Concept
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(std::deque)
int main()
{
std::deque<boost::geometry::model::d2::point_xy<double> > 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))
]
*/
//]

View File

@@ -13,23 +13,33 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/tuple/tuple.hpp>
#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 <boost/geometry.hpp>
#include <boost/geometry/algorithms/overlaps.hpp>
#include <boost/geometry/geometries/geometries.hpp>
using namespace boost::geometry;
//]
#include <boost/geometry/geometries/register/point.hpp>
//[quickstart_register_c_array
#include <boost/geometry/geometries/adapted/c_array.hpp>
BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
//]
//[quickstart_register_boost_tuple
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
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<QRect, C, D>
}}}
void example_for_main_page()
int main(void)
{
//[quickstart_distance
model::d2::point_xy<int> 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<model::d2::point_xy<double> > poly;
append(poly, points);
boost::tuple<double, double> 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<boost::geometry::degree>
> 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<double, 3, cs::cartesian> XYZ;
typedef model::point<double, 3, cs::spherical<degree> > 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<double> XY;
typedef model::d2::point_xy<int> PIXEL;
XY xy(50, 50);
strategy::transform::map_transformer<XY, PIXEL, false> 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;
}

View File

@@ -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 ;

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
int main()
{
typedef boost::geometry::model::box
<
boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
> box_type;
// Define the Boost.Range compatible type:
typedef boost::geometry::box_view<box_type> 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<box_view const>::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
]
*/
//]

View File

@@ -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 <iostream>
#include <boost/geometry.hpp>
int main()
{
typedef boost::geometry::model::segment
<
boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
> segment_type;
typedef boost::geometry::segment_view<segment_type> 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<segment_view const>::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
]
*/
//]

View File

@@ -16,6 +16,7 @@
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/util/write_dsv.hpp>
@@ -30,9 +31,7 @@ struct triangle : public boost::array<boost::geometry::model::d2::point_xy<doubl
// Register triangle as a ring
namespace boost { namespace geometry { namespace traits {
template <> struct tag<triangle> { typedef ring_tag type; };
}}}
BOOST_GEOMETRY_REGISTER_RING(triangle)
// Specializations of algorithms, where useful. If not specialized the default ones

View File

@@ -18,6 +18,7 @@
#include <boost/geometry/algorithms/area.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/util/write_dsv.hpp>
@@ -31,9 +32,7 @@ struct triangle : public boost::array<P, 3>
// Register triangle<P> as a ring
namespace boost { namespace geometry { namespace traits {
template <typename P> struct tag<triangle<P> > { typedef ring_tag type; };
}}}
BOOST_GEOMETRY_REGISTER_RING_TEMPLATED(triangle)
namespace boost { namespace geometry { namespace dispatch {

View File

@@ -14,6 +14,7 @@
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
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<my_ring> { typedef ring_tag type; };
}}}
BOOST_GEOMETRY_REGISTER_RING(my_ring)
@@ -76,7 +73,6 @@ template<> struct interior_mutable_type<my_polygon>
typedef boost::array<my_ring, 2>& type;
};
template<> struct exterior_ring<my_polygon>
{
static my_ring& get(my_polygon& p)

View File

@@ -20,6 +20,7 @@
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/ring.hpp>
#include <boost/geometry/util/add_const_if_c.hpp>
// Sample point, having x/y
@@ -215,9 +216,7 @@ template<> struct resize<my_polygon>
// 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<my_polygon> { 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<const my_polygon>::type it
for (boost::range_iterator<my_polygon const>::type it
= boost::begin(polygon);
it != boost::end(polygon);
++it)

View File

@@ -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 ;

View File

@@ -21,26 +21,29 @@
template <typename P>
void test_all(bool do_rectangular = true)
void test_all()
{
// from sample linestring
test_geometry<bg::model::linestring<P> >(
"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<bg::model::polygon<P> >(
"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<bg::model::polygon<P> >(
"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<bg::model::polygon<P> >(
"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<bg::model::ring<P> >(
"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<bg::model::box<P> >("box(0 0,2 2)", 5, 5, 4);
}
int test_main(int, char* [])

View File

@@ -15,7 +15,7 @@
#include <boost/geometry/algorithms/detail/sections/sectionalize.hpp>
#include <boost/geometry/algorithms/detail/sections/range_by_section.hpp>
#include <boost/geometry/iterators/range_type.hpp>
#include <boost/geometry/views/detail/range_type.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
@@ -35,7 +35,7 @@ void test_sectionalize(std::string const caseid, Geometry const& geometry, std::
typedef typename bg::closeable_view
<
typename bg::range_type<Geometry>::type const,
typename bg::detail::range_type<Geometry>::type const,
bg::closure<Geometry>::value
>::type cview_type;
typedef typename bg::reversible_view

View File

@@ -33,8 +33,13 @@ void test_all()
test_geometry<P, bg::model::polygon<P> >("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<P> box_type;
test_geometry<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", true);
test_geometry<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
test_geometry<box_type, box_type>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
test_geometry<P, bg::model::box<P> >("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<P>("POINT(146383 409623)",
"POLYGON((146351 410597,146521 410659,147906 410363,148088 410420"
",148175 410296,148281 409750,148215 409623,148154 409666,148154 409666"

View File

@@ -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 ]
;

View File

@@ -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 <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <geometry_test_common.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/iterators/box_iterator.hpp>
#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
#include <test_geometries/custom_segment.hpp>
template <typename Box>
void test_geometry(std::string const& wkt, std::string const& expected)
{
Box box;
bg::read_wkt(wkt, box);
{
std::ostringstream out;
bg::box_iterator<Box> 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 <typename P>
void test_all()
{
test_geometry<bg::model::box<P> >("polygon((1 1,2 2))", " 11 12 22 21 11");
test_geometry<bg::model::box<P> >("polygon((3 3,5 5))", " 33 35 55 53 33");
}
int test_main(int, char* [])
{
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -1,176 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="box_iterator"
ProjectGUID="{CD4B14B2-ED74-4111-B8BF-093FA3930A5C}"
RootNamespace="box_iterator"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\box_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\box_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\box_iterator.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -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 <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <geometry_test_common.hpp>
#include <boost/geometry/iterators/circular_iterator.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
#include <boost/geometry/geometries/geometries.hpp>
template <typename Geometry, typename CircularIterator>
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 <typename Geometry, typename CircularIterator>
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 <typename G>
void test_geometry(std::string const& wkt)
{
G geo;
bg::read_wkt(wkt, geo);
typedef typename boost::range_const_iterator<G>::type normal_iterator;
typedef bg::circular_iterator<normal_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<circular_iterator>(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 <typename P>
void test_all()
{
test_geometry<bg::model::linestring<P> >("linestring(1 1,2 2,3 3,4 4,5 5)");
}
int test_main(int, char* [])
{
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -1,178 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="circular_iterator"
ProjectGUID="{46571A34-B68D-4854-90C0-56D29EE63FFE}"
RootNamespace="circular_iterator"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\circular_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\circular_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
WarningLevel="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\circular_iterator.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -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

View File

@@ -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 <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <geometry_test_common.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/iterators/segment_range_iterator.hpp>
#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
#include <test_geometries/custom_segment.hpp>
template <typename Segment>
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<Segment> 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 <typename P>
void test_all()
{
test_geometry<test::custom_segment>("linestring(1 1,2 2)", " 11 22");
test_geometry<test::custom_segment>("linestring(4 4,3 3)", " 44 33");
}
int test_main(int, char* [])
{
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -1,176 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="segment_range_iterator"
ProjectGUID="{887E64C9-6786-44E2-AE09-B02B855486DE}"
RootNamespace="segment_range_iterator"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
ExceptionHandling="2"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
DebugInformationFormat="1"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range_iterator"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../..;.."
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="2"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\segment_range_iterator.cpp"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -25,7 +25,7 @@
#include <boost/geometry/multi/core/point_order.hpp>
#include <boost/geometry/multi/core/point_type.hpp>
#include <boost/geometry/multi/iterators/range_type.hpp>
#include <boost/geometry/multi/views/detail/range_type.hpp>
#include <boost/geometry/multi/algorithms/num_points.hpp>
#include <boost/geometry/multi/algorithms/detail/for_each_range.hpp>

View File

@@ -32,7 +32,7 @@
#include <boost/geometry/multi/geometries/multi_linestring.hpp>
#include <boost/geometry/multi/geometries/multi_polygon.hpp>
#include <boost/geometry/multi/iterators/range_type.hpp>
#include <boost/geometry/multi/views/detail/range_type.hpp>
#include <boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp>

View File

@@ -16,7 +16,7 @@
#include <geometry_test_common.hpp>
#include <boost/geometry/iterators/range_type.hpp>
#include <boost/geometry/views/detail/range_type.hpp>
#include <boost/geometry/util/as_range.hpp>
#include <boost/geometry/core/cs.hpp>
@@ -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<G>::type range_type;
typedef typename bg::detail::range_type<G>::type range_type;
bg::read_wkt(wkt, geometry);

View File

@@ -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 ]

View File

@@ -16,19 +16,19 @@
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/ranges/box_range.hpp>
#include <boost/geometry/views/box_view.hpp>
#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
template <typename Box>
template <typename Box, bool Reverse>
void test_geometry(std::string const& wkt, std::string const& expected)
{
Box box;
bg::read_wkt(wkt, box);
typedef bg::box_range<Box> range_type;
typedef bg::box_view<Box, Reverse> 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<range_type>) );
BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<range_type>) );
}
template <typename P>
void test_all()
{
test_geometry<bg::model::box<P> >("polygon((1 1,2 2))", " 11 12 22 21 11");
test_geometry<bg::model::box<P> >("polygon((3 3,5 5))", " 33 35 55 53 33");
test_geometry<bg::model::box<P>, true> ("polygon((1 1,2 2))", " 11 12 22 21 11");
test_geometry<bg::model::box<P>, false>("polygon((1 1,2 2))", " 11 21 22 12 11");
test_geometry<bg::model::box<P>, true> ("polygon((3 3,5 5))", " 33 35 55 53 33");
}

View File

@@ -2,9 +2,9 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="box_range"
Name="box_view"
ProjectGUID="{34A1F53A-DA46-41E6-9E26-740D22D662DC}"
RootNamespace="box_range"
RootNamespace="box_view"
Keyword="Win32Proj"
>
<Platforms>
@@ -18,7 +18,7 @@
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\box_range"
IntermediateDirectory="$(ConfigurationName)\box_view"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
@@ -93,7 +93,7 @@
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\box_range"
IntermediateDirectory="$(ConfigurationName)\box_view"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
@@ -169,7 +169,7 @@
</References>
<Files>
<File
RelativePath=".\box_range.cpp"
RelativePath=".\box_view.cpp"
>
</File>
</Files>

View File

@@ -15,7 +15,7 @@
#include <geometry_test_common.hpp>
#include <boost/geometry/geometries/geometries.hpp>
#include <boost/geometry/ranges/segment_range.hpp>
#include <boost/geometry/views/segment_view.hpp>
#include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
@@ -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<Segment> range_type;
typedef bg::segment_view<Segment> 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<range_type>) );
BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<range_type>) );
}
@@ -75,6 +75,11 @@ void test_all()
int test_main(int, char* [])
{
std::vector<int> a;
a.push_back(1);
boost::range_iterator<std::vector<int> const>::type it = a.end();
--it;
std::cout << *it << std::endl;
test_all<bg::model::d2::point_xy<double> >();
return 0;
}

View File

@@ -2,9 +2,9 @@
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="segment_range"
Name="segment_view"
ProjectGUID="{B49AC3E2-3497-465B-88C2-BCADA4B4ADAF}"
RootNamespace="segment_range"
RootNamespace="segment_view"
Keyword="Win32Proj"
>
<Platforms>
@@ -18,7 +18,7 @@
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range"
IntermediateDirectory="$(ConfigurationName)\segment_view"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
@@ -93,7 +93,7 @@
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\segment_range"
IntermediateDirectory="$(ConfigurationName)\segment_view"
ConfigurationType="1"
InheritedPropertySheets="..\boost.vsprops"
CharacterSet="1"
@@ -169,7 +169,7 @@
</References>
<Files>
<File
RelativePath=".\segment_range.cpp"
RelativePath=".\segment_view.cpp"
>
</File>
</Files>

View File

@@ -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