123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #ifndef BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
- #define BOOST_GEOMETRY_VIEWS_SEGMENT_VIEW_HPP
- #include <array>
- #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
- #include <boost/geometry/core/point_type.hpp>
- #include <boost/geometry/core/tag.hpp>
- namespace boost { namespace geometry
- {
- template <typename Segment>
- struct segment_view
- {
- using array_t = std::array<typename geometry::point_type<Segment>::type, 2>;
- using iterator = typename array_t::const_iterator;
- using const_iterator = typename array_t::const_iterator;
-
- explicit segment_view(Segment const& segment)
- {
- geometry::detail::assign_point_from_index<0>(segment, m_array[0]);
- geometry::detail::assign_point_from_index<1>(segment, m_array[1]);
- }
- const_iterator begin() const noexcept { return m_array.begin(); }
- const_iterator end() const noexcept { return m_array.end(); }
- private:
- array_t m_array;
- };
- #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
- namespace traits
- {
- template<typename Segment>
- struct tag<segment_view<Segment> >
- {
- typedef linestring_tag type;
- };
- }
- #endif
- }}
- #endif
|