MySQL 8.0.39
Source Code Documentation
distance_sphere_functor.h
Go to the documentation of this file.
1// Copyright (c) 2017, 2024, 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 designed to work 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 either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24/// @file
25///
26/// Declares the Distance_sphere functor interface.
27///
28/// The functor is not intended for use directly by MySQL code. It should be
29/// used indirectly through the gis::distance_sphere() function.
30///
31/// @see gis::distance_sphere
32
33#ifndef SQL_GIS_DISTANCE_SPHERE_FUNCTOR_H_INCLUDED
34#define SQL_GIS_DISTANCE_SPHERE_FUNCTOR_H_INCLUDED
35
36#include <boost/geometry.hpp>
37
38#include "sql/gis/functor.h"
39#include "sql/gis/geometries.h" // gis::Geometry
40#include "sql/gis/geometries_cs.h" // gis::{Cartesian_*, Geographic_*}
41
42namespace gis {
43
44/// 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 geographic functions. It should not be used directly by other
48/// MySQL code.
49class Distance_sphere : public Functor<double> {
50 boost::geometry::strategy::distance::haversine<double> m_strategy;
51
52 public:
53 Distance_sphere(double sphere_radius) : m_strategy{sphere_radius} {}
54
55 double operator()(const Geometry *g1, const Geometry *g2) const override;
56
57 double eval(const Cartesian_point *g1, const Cartesian_point *g2) const;
58 double eval(const Cartesian_point *g1, const Cartesian_multipoint *g2) const;
59 double eval(const Cartesian_multipoint *g1, const Cartesian_point *g2) const;
60 double eval(const Cartesian_multipoint *g1,
61 const Cartesian_multipoint *g2) const;
62
63 double eval(const Geographic_point *g1, const Geographic_point *g2) const;
64 double eval(const Geographic_point *g1,
65 const Geographic_multipoint *g2) const;
66 double eval(const Geographic_multipoint *g1,
67 const Geographic_point *g2) const;
68 double eval(const Geographic_multipoint *g1,
69 const Geographic_multipoint *g2) const;
70
71 double eval(const Geometry *g1, const Geometry *g2) const;
72};
73
74} // namespace gis
75
76#endif // SQL_GIS_DISTANCE_SPHERE_FUNCTOR_H_INCLUDED
A Cartesian 2d multipoint.
Definition: geometries_cs.h:501
A Cartesian 2d point.
Definition: geometries_cs.h:47
Functor that calls Boost.Geometry with the correct parameter types.
Definition: distance_sphere_functor.h:49
Distance_sphere(double sphere_radius)
Definition: distance_sphere_functor.h:53
boost::geometry::strategy::distance::haversine< double > m_strategy
Definition: distance_sphere_functor.h:50
double eval(const Cartesian_point *g1, const Cartesian_point *g2) const
Definition: distance_sphere.cc:85
double operator()(const Geometry *g1, const Geometry *g2) const override
Definition: distance_sphere.cc:80
The base class of all functors that takes two geometry arguments.
Definition: functor.h:165
A geographic (ellipsoidal) 2d multipoint.
Definition: geometries_cs.h:552
A geographic (ellipsoidal) 2d point.
Definition: geometries_cs.h:58
Abstract superclass for all geometric objects.
Definition: geometries.h:100
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:47