#ifndef SQL_GIS_GEOMETRIES_TRAITS_H_INCLUDED #define SQL_GIS_GEOMETRIES_TRAITS_H_INCLUDED // Copyright (c) 2017, 2024, Oracle and/or its affiliates. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License, version 2.0, // as published by the Free Software Foundation. // // This program is designed to work with certain software (including // but not limited to OpenSSL) that is licensed under separate terms, // as designated in a particular file or component or in included license // documentation. The authors of MySQL hereby grant you an additional // permission to link the program and your derivative works with the // separately licensed software that they have either included with // the program or referenced in the documentation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License, version 2.0, for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. /// @file /// /// This file contains Boost.Geometry type traits declarations for Cartesian and /// geographic geometries. /// /// @see geometries_cs.h #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "sql/gis/geometries_cs.h" #include "sql/malloc_allocator.h" namespace boost { namespace geometry { namespace traits { //////////////////////////////////////////////////////////////////////////////// // Cartesian // Point template <> struct tag { typedef boost::geometry::point_tag type; }; template <> struct coordinate_type { typedef double type; }; template <> struct coordinate_system { typedef boost::geometry::cs::cartesian type; }; template <> struct dimension : boost::mpl::int_<2> {}; template struct access { static inline double get(gis::Cartesian_point const &p) { return p.get(); } static inline void set(gis::Cartesian_point &p, double const &value) { p.set(value); } }; // Linestring template <> struct tag { typedef boost::geometry::linestring_tag type; }; // Linearring template <> struct tag { typedef boost::geometry::ring_tag type; }; template <> struct point_order { static const order_selector value = counterclockwise; }; template <> struct closure { static const closure_selector value = closed; }; // Polygon template <> struct tag { typedef boost::geometry::polygon_tag type; }; template <> struct ring_const_type { typedef gis::Cartesian_linearring const &type; }; template <> struct ring_mutable_type { typedef gis::Cartesian_linearring &type; }; template <> struct interior_const_type { typedef std::vector> const &type; }; template <> struct interior_mutable_type { typedef std::vector> &type; }; template <> struct exterior_ring { static inline gis::Cartesian_linearring &get(gis::Cartesian_polygon &py) { return py.cartesian_exterior_ring(); } static inline gis::Cartesian_linearring const &get( gis::Cartesian_polygon const &py) { return py.cartesian_exterior_ring(); } }; template <> struct interior_rings { static inline std::vector> &get(gis::Cartesian_polygon &py) { return py.interior_rings(); } static inline std::vector> const & get(gis::Cartesian_polygon const &py) { return py.const_interior_rings(); } }; // Multipoint template <> struct tag { typedef boost::geometry::multi_point_tag type; }; // Multilinestring template <> struct tag { typedef boost::geometry::multi_linestring_tag type; }; // Multipolygon template <> struct tag { typedef boost::geometry::multi_polygon_tag type; }; //////////////////////////////////////////////////////////////////////////////// // Geographic // Point template <> struct tag { typedef boost::geometry::point_tag type; }; template <> struct coordinate_type { typedef double type; }; template <> struct coordinate_system { typedef boost::geometry::cs::geographic type; }; template <> struct dimension : boost::mpl::int_<2> {}; template struct access { static inline double get(gis::Geographic_point const &p) { return p.get(); } static inline void set(gis::Geographic_point &p, double const &value) { p.set(value); } }; // Linestring template <> struct tag { typedef boost::geometry::linestring_tag type; }; // Linearring template <> struct tag { typedef boost::geometry::ring_tag type; }; template <> struct point_order { static const order_selector value = counterclockwise; }; template <> struct closure { static const closure_selector value = closed; }; // Polygon template <> struct tag { typedef boost::geometry::polygon_tag type; }; template <> struct ring_const_type { typedef gis::Geographic_linearring const &type; }; template <> struct ring_mutable_type { typedef gis::Geographic_linearring &type; }; template <> struct interior_const_type { typedef std::vector> const &type; }; template <> struct interior_mutable_type { typedef std::vector> &type; }; template <> struct exterior_ring { static inline gis::Geographic_linearring &get(gis::Geographic_polygon &py) { return py.geographic_exterior_ring(); } static inline gis::Geographic_linearring const &get( gis::Geographic_polygon const &py) { return py.geographic_exterior_ring(); } }; template <> struct interior_rings { static inline std::vector> &get(gis::Geographic_polygon &py) { return py.interior_rings(); } static inline std::vector> const & get(gis::Geographic_polygon const &py) { return py.const_interior_rings(); } }; // Multipoint template <> struct tag { typedef boost::geometry::multi_point_tag type; }; // Multilinestring template <> struct tag { typedef boost::geometry::multi_linestring_tag type; }; // Multipolygon template <> struct tag { typedef boost::geometry::multi_polygon_tag type; }; } // namespace traits } // namespace geometry } // namespace boost #endif // SQL_GIS_GEOMETRIES_TRAITS_H_INCLUDED