MySQL  8.0.28
Source Code Documentation
hausdorff_distance_functor.h
Go to the documentation of this file.
1 #ifndef GIS__HAUSDORFF_DISTANCE_FUNCTOR_H_INCLUDED
2 #define GIS__HAUSDORFF_DISTANCE_FUNCTOR_H_INCLUDED
3 
4 // Copyright (c) 2020, 2021, Oracle and/or its affiliates.
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 hausdorff_distance functor interface.
29 ///
30 /// The functor is not intended for use directly by MySQL code. It should be
31 /// used indirectly through the gis::hausdorff_distance() function.
32 ///
33 /// @see gis::hausdorff_distance
34 
35 #include <memory> // std::unique_ptr
36 
37 #include <boost/geometry.hpp>
38 #include "sql/gis/functor.h"
39 #include "sql/gis/geometries.h"
40 
41 namespace gis {
42 
43 /// HausdorffDistance functor that calls Boost.Geometry with the
44 /// correct parameter types.
45 ///
46 /// The functor throws exceptions and is therefore only intended used to
47 /// implement hausdorff_distance or other geographic functions.
48 /// It should not be used directly by other MySQL code.
49 class Hausdorff_distance : public Functor<double> {
50  private:
51  std::unique_ptr<boost::geometry::strategy::distance::geographic<
52  boost::geometry::strategy::andoyer,
53  boost::geometry::srs::spheroid<double>>>
55 
56  public:
57  Hausdorff_distance(double major, double minor);
58  double operator()(const Geometry *g1, const Geometry *g2) const override;
59 
60  double eval(const Geometry *g1, const Geometry *g2) const;
61 
62  double eval(const Cartesian_point *g1, const Cartesian_multipoint *g2) const;
63  double eval(const Cartesian_multipoint *g1, const Cartesian_point *g2) const;
64  double eval(const Cartesian_linestring *g1,
65  const Cartesian_linestring *g2) const;
66  double eval(const Cartesian_multipoint *g1,
67  const Cartesian_multipoint *g2) const;
68  double eval(const Cartesian_linestring *g1,
69  const Cartesian_multilinestring *g2) const;
70  double eval(const Cartesian_multilinestring *g1,
71  const Cartesian_linestring *g2) const;
72  double eval(const Cartesian_multilinestring *g1,
73  const Cartesian_multilinestring *g2) const;
74 
75  double eval(const Geographic_point *g1,
76  const Geographic_multipoint *g2) const;
77  double eval(const Geographic_multipoint *g1,
78  const Geographic_point *g2) const;
79  double eval(const Geographic_linestring *g1,
80  const Geographic_linestring *g2) const;
81  double eval(const Geographic_multipoint *g1,
82  const Geographic_multipoint *g2) const;
83  double eval(const Geographic_linestring *g1,
84  const Geographic_multilinestring *g2) const;
85  double eval(const Geographic_multilinestring *g1,
86  const Geographic_linestring *g2) const;
87  double eval(const Geographic_multilinestring *g1,
88  const Geographic_multilinestring *g2) const;
89 };
90 
91 } // namespace gis
92 
93 #endif // GIS__HAUSDORFF_DISTANCE_FUNCTOR_H_INCLUDED
A Cartesian 2d linestring.
Definition: geometries_cs.h:70
A Cartesian 2d multilinestring.
Definition: geometries_cs.h:601
A Cartesian 2d multipoint.
Definition: geometries_cs.h:500
A Cartesian 2d point.
Definition: geometries_cs.h:46
The base class of all functors that takes two geometry arguments.
Definition: functor.h:164
A geographic (ellipsoidal) 2d linestring.
Definition: geometries_cs.h:124
A geographic (ellipsoidal) 2d multilinestring.
Definition: geometries_cs.h:660
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
HausdorffDistance functor that calls Boost.Geometry with the correct parameter types.
Definition: hausdorff_distance_functor.h:49
double eval(const Geometry *g1, const Geometry *g2) const
Definition: hausdorff_distance.cc:58
double operator()(const Geometry *g1, const Geometry *g2) const override
Definition: hausdorff_distance.cc:53
std::unique_ptr< boost::geometry::strategy::distance::geographic< boost::geometry::strategy::andoyer, boost::geometry::srs::spheroid< double > > > m_geographic_strategy
Definition: hausdorff_distance_functor.h:54
Hausdorff_distance(double major, double minor)
Definition: hausdorff_distance.cc:47
This file contains the superclasses for GIS functors.
This file declares the geometry class hierarchy used by the server as the internal representation of ...
Definition: area.cc:46
std::conditional_t< !std::is_array< T >::value, std::unique_ptr< T, detail::Deleter< T > >, std::conditional_t< detail::is_unbounded_array_v< T >, std::unique_ptr< T, detail::Array_deleter< std::remove_extent_t< T > >>, void > > unique_ptr
The following is a common type that is returned by all the ut::make_unique (non-aligned) specializati...
Definition: ut0new.h:2430