MySQL  8.0.28
Source Code Documentation
area_functor.h
Go to the documentation of this file.
1 // Copyright (c) 2018, 2021, Oracle and/or its affiliates.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License, version 2.0,
5 // as published by the Free Software Foundation.
6 //
7 // This program is also distributed with certain software (including
8 // but not limited to OpenSSL) that is licensed under separate terms,
9 // as designated in a particular file or component or in included license
10 // documentation. The authors of MySQL hereby grant you an additional
11 // permission to link the program and your derivative works with the
12 // separately licensed software that they have included with MySQL.
13 //
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License, version 2.0, for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 
23 /// @file
24 ///
25 /// Declares the area functor interface.
26 ///
27 /// The functor is not intended for use directly by MySQL code. It should be
28 /// used indirectly through the gis::area() function.
29 ///
30 /// @see gis::area
31 
32 #ifndef SQL_GIS_AREA_FUNCTOR_H_INCLUDED
33 #define SQL_GIS_AREA_FUNCTOR_H_INCLUDED
34 
35 #include <boost/geometry.hpp> // boost::geometry
36 
37 #include "sql/gis/functor.h" // gis::Unary_functor
38 #include "sql/gis/geometries.h" // gis::Geometry
39 #include "sql/gis/geometries_cs.h" // gis::{Cartesian_*,Geographic_*}
40 
41 namespace gis {
42 
43 /// Area functor that calls boost::geometry::area with the correct parameter
44 /// types.
45 ///
46 /// The functor may throw exceptions. It is intended for implementing geographic
47 /// functions. It should not be used directly by other MySQL code.
48 class Area : public Unary_functor<double> {
49  double m_semi_major;
50  double m_semi_minor;
51 
52  boost::geometry::strategy::area::geographic<> m_geographic_strategy;
53 
54  public:
55  Area();
56  Area(double semi_major, double semi_minor);
57 
58  double operator()(const Geometry &g) const override;
59 
60  double eval(const Cartesian_polygon &g) const;
61  double eval(const Cartesian_multipolygon &g) const;
62 
63  double eval(const Geographic_polygon &g) const;
64  double eval(const Geographic_multipolygon &g) const;
65 
66  double eval(const Geometry &g) const;
67 };
68 
69 } // namespace gis
70 
71 #endif // SQL_GIS_AREA_FUNCTOR_H_INCLUDED
Area functor that calls boost::geometry::area with the correct parameter types.
Definition: area_functor.h:48
double eval(const Cartesian_polygon &g) const
Definition: area.cc:58
boost::geometry::strategy::area::geographic m_geographic_strategy
Definition: area_functor.h:52
double operator()(const Geometry &g) const override
Definition: area.cc:56
double m_semi_minor
Definition: area_functor.h:50
double m_semi_major
Definition: area_functor.h:49
A Cartesian 2d multipolygon.
Definition: geometries_cs.h:719
A Cartesian 2d polygon.
Definition: geometries_cs.h:268
A geographic (ellipsoidal) 2d multipolygon.
Definition: geometries_cs.h:773
A geographic (ellipsoidal) 2d polygon.
Definition: geometries_cs.h:321
Abstract superclass for all geometric objects.
Definition: geometries.h:99
The base class of all functors that take one geometry argument.
Definition: functor.h:614
This file contains the superclasses for GIS functors.
This file declares the geometry class hierarchy used by the server as the internal representation of ...
This file declares the coordinate system specific subclasses of the geometry class hierarchy.
Definition: area.cc:46