GEOS  3.10.0
DiscreteFrechetDistance.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2016 Shinichi SUGIYAMA (shin.sugi@gmail.com)
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: original work
16  *
17  * Developed by Shinichi SUGIYAMA (shin.sugi@gmail.com)
18  * based on http://www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf
19  *
20  **********************************************************************/
21 
22 #ifndef GEOS_ALGORITHM_DISTANCE_DISCRETEFRECHETDISTANCE_H
23 #define GEOS_ALGORITHM_DISTANCE_DISCRETEFRECHETDISTANCE_H
24 
25 #include <geos/export.h>
26 #include <geos/algorithm/distance/PointPairDistance.h> // for composition
27 #include <geos/algorithm/distance/DistanceToPoint.h> // for composition
28 #include <geos/util/IllegalArgumentException.h> // for inlines
29 #include <geos/geom/Geometry.h> // for inlines
30 #include <geos/util/math.h> // for inlines
31 #include <geos/geom/CoordinateFilter.h> // for inheritance
32 #include <geos/geom/CoordinateSequence.h> // for inheritance
33 
34 #include <cstddef>
35 #include <vector>
36 
37 #ifdef _MSC_VER
38 #pragma warning(push)
39 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
40 #endif
41 
42 namespace geos {
43 namespace algorithm {
44 //class RayCrossingCounter;
45 }
46 namespace geom {
47 class Geometry;
48 class Coordinate;
49 //class CoordinateSequence;
50 }
51 namespace index {
52 namespace intervalrtree {
53 //class SortedPackedIntervalRTree;
54 }
55 }
56 }
57 
58 namespace geos {
59 namespace algorithm { // geos::algorithm
60 namespace distance { // geos::algorithm::distance
61 
106 class GEOS_DLL DiscreteFrechetDistance {
107 public:
108 
109  static double distance(const geom::Geometry& g0,
110  const geom::Geometry& g1);
111 
112  static double distance(const geom::Geometry& g0,
113  const geom::Geometry& g1, double densifyFrac);
114 
116  const geom::Geometry& p_g1)
117  :
118  g0(p_g0),
119  g1(p_g1),
120  ptDist(),
121  densifyFrac(0.0)
122  {}
123 
132  void setDensifyFraction(double dFrac);
133 
134  double
135  distance()
136  {
137  compute(g0, g1);
138  return ptDist.getDistance();
139  }
140 
141  const std::array<geom::Coordinate, 2>
142  getCoordinates() const
143  {
144  return ptDist.getCoordinates();
145  }
146 
147 private:
148  geom::Coordinate getSegmentAt(const geom::CoordinateSequence& seq, std::size_t index);
149 
150  PointPairDistance& getFrecheDistance(std::vector< std::vector<PointPairDistance> >& ca, std::size_t i, std::size_t j,
152 
153  void compute(const geom::Geometry& discreteGeom, const geom::Geometry& geom);
154 
155  const geom::Geometry& g0;
156 
157  const geom::Geometry& g1;
158 
159  PointPairDistance ptDist;
160 
162  double densifyFrac; // = 0.0;
163 
164  // Declare type as noncopyable
165  DiscreteFrechetDistance(const DiscreteFrechetDistance& other) = delete;
166  DiscreteFrechetDistance& operator=(const DiscreteFrechetDistance& rhs) = delete;
167 };
168 
169 } // geos::algorithm::distance
170 } // geos::algorithm
171 } // geos
172 
173 #ifdef _MSC_VER
174 #pragma warning(pop)
175 #endif
176 
177 #endif // GEOS_ALGORITHM_DISTANCE_DISCRETEFRECHETDISTANCE_H
An algorithm for computing a distance metric which is an approximation to the Frechet Distance based ...
Definition: DiscreteFrechetDistance.h:106
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26