1 #ifndef SQL_GIS_SIMPLIFY_FUNCTOR_H_INCLUDED 2 #define SQL_GIS_SIMPLIFY_FUNCTOR_H_INCLUDED 3 4 // Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 5 // 6 // This program is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License, version 2.0, 8 // as published by the Free Software Foundation. 9 // 10 // This program is also distributed with certain software (including 11 // but not limited to OpenSSL) that is licensed under separate terms, 12 // as designated in a particular file or component or in included license 13 // documentation. The authors of MySQL hereby grant you an additional 14 // permission to link the program and your derivative works with the 15 // separately licensed software that they have included with MySQL. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License, version 2.0, for more details. 21 // 22 // You should have received a copy of the GNU General Public License 23 // along with this program; if not, write to the Free Software 24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 25 26 /// @file 27 /// 28 /// This file declares the simplify functor interface. 29 /// 30 /// The functor is not intended for use directly by MySQL code. It should be 31 /// used indirectly through the gis::simplify() function. 32 /// 33 /// @see gis::simplify 34 35 #include <memory> // std::unique_ptr 36 37 #include <boost/geometry.hpp> 38 39 #include "sql/gis/functor.h" 40 #include "sql/gis/geometries.h" 41 42 namespace gis { 43 44 /// Simplify functor that calls Boost.Geometry with the correct parameter types. 45 /// 46 /// The functor throws exceptions and is therefore only intended used to 47 /// implement simplify or other geographic functions. It should not be used 48 /// directly by other MySQL code. 49 class Simplify : public Unary_functor<std::unique_ptr<Geometry>> { 50 private: 51 double m_max_distance; 52 53 public: Simplify(double max_distance)54 Simplify(double max_distance) : m_max_distance(max_distance) {} 55 std::unique_ptr<Geometry> operator()(const Geometry &g) const override; 56 std::unique_ptr<Geometry> eval(const Geometry &g) const; 57 std::unique_ptr<Geometry> eval(const Cartesian_point &g) const; 58 std::unique_ptr<Geometry> eval(const Cartesian_linestring &g) const; 59 std::unique_ptr<Geometry> eval(const Cartesian_polygon &g) const; 60 std::unique_ptr<Geometry> eval(const Cartesian_geometrycollection &g) const; 61 std::unique_ptr<Geometry> eval(const Cartesian_multipoint &g) const; 62 std::unique_ptr<Geometry> eval(const Cartesian_multilinestring &g) const; 63 std::unique_ptr<Geometry> eval(const Cartesian_multipolygon &g) const; 64 }; 65 66 } // namespace gis 67 68 #endif // SQL_GIS_SIMPLIFY_FUNCTOR_H_INCLUDED 69