1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
4 // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
16 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
19 #include <boost/concept_check.hpp>
20 #include <boost/range/concepts.hpp>
21 #include <boost/type_traits/remove_const.hpp>
23 #include <boost/geometry/core/access.hpp>
24 #include <boost/geometry/core/mutable_range.hpp>
25 #include <boost/geometry/core/point_type.hpp>
27 #include <boost/geometry/geometries/concepts/point_concept.hpp>
31 namespace boost { namespace geometry { namespace concepts
36 \brief Linestring concept
38 \par Formal definition:
39 The linestring concept is defined as following:
40 - there must be a specialization of traits::tag defining linestring_tag as type
41 - it must behave like a Boost.Range
42 - it must implement a std::back_insert_iterator
43 - either by implementing push_back
44 - or by specializing std::back_insert_iterator
46 \note to fulfill the concepts, no traits class has to be specialized to
47 define the point type.
51 A custom linestring, defining the necessary specializations to fulfill to the concept.
53 Suppose that the following linestring is defined:
54 \dontinclude doxygen_5.cpp
55 \skip custom_linestring1
58 It can then be adapted to the concept as following:
59 \dontinclude doxygen_5.cpp
60 \skip adapt custom_linestring1
64 - There is also the registration macro BOOST_GEOMETRY_REGISTER_LINESTRING
65 - For registration of std::vector<P> (and deque, and list) it is enough to
66 include the header-file geometries/adapted/std_as_linestring.hpp. That registers
67 a vector as a linestring (so it cannot be registered as a linear ring then,
68 in the same source code).
73 template <typename Geometry>
76 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
77 typedef typename point_type<Geometry>::type point_type;
79 BOOST_CONCEPT_ASSERT( (concepts::Point<point_type>) );
80 BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
84 BOOST_CONCEPT_USAGE(Linestring)
87 traits::clear<Geometry>::apply(*ls);
88 traits::resize<Geometry>::apply(*ls, 0);
89 point_type* point = 0;
90 traits::push_back<Geometry>::apply(*ls, *point);
97 \brief Linestring concept (const version)
98 \ingroup const_concepts
99 \details The ConstLinestring concept check the same as the Linestring concept,
100 but does not check write access.
102 template <typename Geometry>
103 class ConstLinestring
105 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
106 typedef typename point_type<Geometry>::type point_type;
108 BOOST_CONCEPT_ASSERT( (concepts::ConstPoint<point_type>) );
109 //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
110 // Relaxed the concept.
111 BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept<Geometry>) );
116 BOOST_CONCEPT_USAGE(ConstLinestring)
122 }}} // namespace boost::geometry::concepts
125 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP