// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2015-2020, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_VIEWS_DETAIL_TWO_DIMENSIONAL_VIEW_HPP #define BOOST_GEOMETRY_VIEWS_DETAIL_TWO_DIMENSIONAL_VIEW_HPP #include #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { template < typename Geometry, std::size_t Dimension1 = 0, std::size_t Dimension2 = 1, typename Tag = typename tag::type > struct two_dimensional_view : not_implemented {}; // View that enables to choose two dimensions of a point and see it as // a two-dimensional point template struct two_dimensional_view { BOOST_GEOMETRY_STATIC_ASSERT( (Dimension1 < dimension::value), "Coordinate Dimension1 is larger than Point's dimension.", std::integral_constant); BOOST_GEOMETRY_STATIC_ASSERT( (Dimension2 < dimension::value), "Coordinate Dimension2 is larger than Point's dimension.", std::integral_constant); two_dimensional_view(Point& point) : m_point(point) {} Point& m_point; }; } // namespace detail #endif // DOXYGEN_NO_DETAIL #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS namespace traits { template struct tag < geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag > > { typedef point_tag type; }; template struct coordinate_system < geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag > > : coordinate_system::type> {}; template struct coordinate_type < geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag > > : coordinate_type::type> {}; template struct dimension < geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag > > : std::integral_constant {}; template struct point_type < geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag > > { typedef typename geometry::point_type::type type; }; template struct access < geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag >, 0 > { typedef typename geometry::coordinate_type::type coordinate_type; typedef geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag > view_type; static inline coordinate_type get(view_type const& view) { return geometry::get(view.m_point); } static inline void set(view_type& view, coordinate_type const& value) { geometry::set(view.m_point, value); } }; template struct access < geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag >, 1 > { typedef typename geometry::coordinate_type::type coordinate_type; typedef geometry::detail::two_dimensional_view < Point, Dimension1, Dimension2, point_tag > view_type; static inline coordinate_type get(view_type const& view) { return geometry::get(view.m_point); } static inline void set(view_type& view, coordinate_type const& value) { geometry::set(view.m_point, value); } }; } // namespace traits #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS }} // namespace boost::geometry #endif // BOOST_GEOMETRY_VIEWS_DETAIL_TWO_DIMENSIONAL_VIEW_HPP