GEOS  3.13.0dev
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 #pragma once
23 
24 #include <geos/export.h>
25 #include <geos/algorithm/distance/PointPairDistance.h> // for composition
26 #include <geos/algorithm/distance/DistanceToPoint.h> // for composition
27 #include <geos/util/IllegalArgumentException.h> // for inlines
28 #include <geos/geom/Geometry.h> // for inlines
29 #include <geos/util/math.h> // for inlines
30 #include <geos/geom/CoordinateFilter.h> // for inheritance
31 #include <geos/geom/CoordinateSequence.h> // for inheritance
32 
33 #include <cstddef>
34 #include <vector>
35 
36 #ifdef _MSC_VER
37 #pragma warning(push)
38 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
39 #endif
40 
41 namespace geos {
42 namespace algorithm {
43 //class RayCrossingCounter;
44 }
45 namespace geom {
46 class Geometry;
47 class Coordinate;
48 //class CoordinateSequence;
49 }
50 namespace index {
51 namespace intervalrtree {
52 //class SortedPackedIntervalRTree;
53 }
54 }
55 }
56 
57 namespace geos {
58 namespace algorithm { // geos::algorithm
59 namespace distance { // geos::algorithm::distance
60 
105 class GEOS_DLL DiscreteFrechetDistance {
106 public:
107 
108  static double distance(const geom::Geometry& g0,
109  const geom::Geometry& g1);
110 
111  static double distance(const geom::Geometry& g0,
112  const geom::Geometry& g1, double densifyFrac);
113 
115  const geom::Geometry& p_g1)
116  :
117  g0(p_g0),
118  g1(p_g1),
119  ptDist(),
120  densifyFrac(0.0)
121  {}
122 
131  void setDensifyFraction(double dFrac);
132 
133  double
134  distance()
135  {
136  compute(g0, g1);
137  return ptDist.getDistance();
138  }
139 
140  const std::array<geom::CoordinateXY, 2>
141  getCoordinates() const
142  {
143  return ptDist.getCoordinates();
144  }
145 
146 private:
147  geom::Coordinate getSegmentAt(const geom::CoordinateSequence& seq, std::size_t index);
148 
149  PointPairDistance& getFrechetDistance(std::vector< std::vector<PointPairDistance> >& ca, std::size_t i, std::size_t j,
151 
152  void compute(const geom::Geometry& discreteGeom, const geom::Geometry& geom);
153 
154  const geom::Geometry& g0;
155 
156  const geom::Geometry& g1;
157 
158  PointPairDistance ptDist;
159 
161  double densifyFrac; // = 0.0;
162 
163  // Declare type as noncopyable
164  DiscreteFrechetDistance(const DiscreteFrechetDistance& other) = delete;
165  DiscreteFrechetDistance& operator=(const DiscreteFrechetDistance& rhs) = delete;
166 };
167 
168 } // geos::algorithm::distance
169 } // geos::algorithm
170 } // geos
171 
172 #ifdef _MSC_VER
173 #pragma warning(pop)
174 #endif
175 
An algorithm for computing a distance metric which is an approximation to the Frechet Distance based ...
Definition: DiscreteFrechetDistance.h:105
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:56
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:216
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25