MySQL 8.0.30
Source Code Documentation
distance_sphere_functor.h
Go to the documentation of this file.
1// Copyright (c) 2017, 2022, 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 Distance_sphere functor interface.
26///
27/// The functor is not intended for use directly by MySQL code. It should be
28/// used indirectly through the gis::distance_sphere() function.
29///
30/// @see gis::distance_sphere
31
32#ifndef SQL_GIS_DISTANCE_SPHERE_FUNCTOR_H_INCLUDED
33#define SQL_GIS_DISTANCE_SPHERE_FUNCTOR_H_INCLUDED
34
35#include <boost/geometry.hpp>
36
37#include "sql/gis/functor.h"
38#include "sql/gis/geometries.h" // gis::Geometry
39#include "sql/gis/geometries_cs.h" // gis::{Cartesian_*, Geographic_*}
40
41namespace gis {
42
43/// Functor that calls Boost.Geometry with the correct parameter types.
44///
45/// The functor throws exceptions and is therefore only intended used to
46/// implement geographic functions. It should not be used directly by other
47/// MySQL code.
48class Distance_sphere : public Functor<double> {
49 boost::geometry::strategy::distance::haversine<double> m_strategy;
50
51 public:
52 Distance_sphere(double sphere_radius) : m_strategy{sphere_radius} {}
53
54 double operator()(const Geometry *g1, const Geometry *g2) const override;
55
56 double eval(const Cartesian_point *g1, const Cartesian_point *g2) const;
57 double eval(const Cartesian_point *g1, const Cartesian_multipoint *g2) const;
58 double eval(const Cartesian_multipoint *g1, const Cartesian_point *g2) const;
59 double eval(const Cartesian_multipoint *g1,
60 const Cartesian_multipoint *g2) const;
61
62 double eval(const Geographic_point *g1, const Geographic_point *g2) const;
63 double eval(const Geographic_point *g1,
64 const Geographic_multipoint *g2) const;
65 double eval(const Geographic_multipoint *g1,
66 const Geographic_point *g2) const;
67 double eval(const Geographic_multipoint *g1,
68 const Geographic_multipoint *g2) const;
69
70 double eval(const Geometry *g1, const Geometry *g2) const;
71};
72
73} // namespace gis
74
75#endif // SQL_GIS_DISTANCE_SPHERE_FUNCTOR_H_INCLUDED
A Cartesian 2d multipoint.
Definition: geometries_cs.h:500
A Cartesian 2d point.
Definition: geometries_cs.h:46
Functor that calls Boost.Geometry with the correct parameter types.
Definition: distance_sphere_functor.h:48
Distance_sphere(double sphere_radius)
Definition: distance_sphere_functor.h:52
boost::geometry::strategy::distance::haversine< double > m_strategy
Definition: distance_sphere_functor.h:49
double eval(const Cartesian_point *g1, const Cartesian_point *g2) const
Definition: distance_sphere.cc:84
double operator()(const Geometry *g1, const Geometry *g2) const override
Definition: distance_sphere.cc:79
The base class of all functors that takes two geometry arguments.
Definition: functor.h:164
A geographic (ellipsoidal) 2d multipoint.
Definition: geometries_cs.h:551
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:57
Abstract superclass for all geometric objects.
Definition: geometries.h:99
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