linestring.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
  6. // Copyright (c) 2020, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (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)
  13. #ifndef BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP
  14. #define BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP
  15. #include <memory>
  16. #include <vector>
  17. #include <boost/concept/assert.hpp>
  18. #include <boost/config.hpp>
  19. #include <boost/geometry/core/tag.hpp>
  20. #include <boost/geometry/core/tags.hpp>
  21. #include <boost/geometry/geometries/concepts/point_concept.hpp>
  22. #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  23. #include <initializer_list>
  24. #endif
  25. namespace boost { namespace geometry
  26. {
  27. namespace model
  28. {
  29. /*!
  30. \brief A linestring (named so by OGC) is a collection (default a vector) of points.
  31. \ingroup geometries
  32. \tparam Point \tparam_point
  33. \tparam Container \tparam_container
  34. \tparam Allocator \tparam_allocator
  35. \qbk{[include reference/geometries/linestring.qbk]}
  36. \qbk{before.synopsis,
  37. [heading Model of]
  38. [link geometry.reference.concepts.concept_linestring Linestring Concept]
  39. }
  40. */
  41. template
  42. <
  43. typename Point,
  44. template<typename,typename> class Container = std::vector,
  45. template<typename> class Allocator = std::allocator
  46. >
  47. class linestring : public Container<Point, Allocator<Point> >
  48. {
  49. BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
  50. typedef Container<Point, Allocator<Point> > base_type;
  51. public :
  52. /// \constructor_default{linestring}
  53. inline linestring()
  54. : base_type()
  55. {}
  56. /// \constructor_begin_end{linestring}
  57. template <typename Iterator>
  58. inline linestring(Iterator begin, Iterator end)
  59. : base_type(begin, end)
  60. {}
  61. #ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
  62. /// \constructor_initializer_list{linestring}
  63. inline linestring(std::initializer_list<Point> l)
  64. : base_type(l.begin(), l.end())
  65. {}
  66. // Commented out for now in order to support Boost.Assign
  67. // Without this assignment operator first the object should be created
  68. // from initializer list, then it should be moved.
  69. //// Without this workaround in MSVC the assignment operator is ambiguous
  70. //#ifndef BOOST_MSVC
  71. // /// \assignment_initializer_list{linestring}
  72. // inline linestring & operator=(std::initializer_list<Point> l)
  73. // {
  74. // base_type::assign(l.begin(), l.end());
  75. // return *this;
  76. // }
  77. //#endif
  78. #endif
  79. };
  80. } // namespace model
  81. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  82. namespace traits
  83. {
  84. template
  85. <
  86. typename Point,
  87. template<typename,typename> class Container,
  88. template<typename> class Allocator
  89. >
  90. struct tag<model::linestring<Point, Container, Allocator> >
  91. {
  92. typedef linestring_tag type;
  93. };
  94. } // namespace traits
  95. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  96. }} // namespace boost::geometry
  97. #endif // BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP