GEOS 3.9.1
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
42namespace geos {
43namespace algorithm {
44//class RayCrossingCounter;
45}
46namespace geom {
47class Geometry;
48class Coordinate;
49//class CoordinateSequence;
50}
51namespace index {
52namespace intervalrtree {
53//class SortedPackedIntervalRTree;
54}
55}
56}
57
58namespace geos {
59namespace algorithm { // geos::algorithm
60namespace distance { // geos::algorithm::distance
61
107public:
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
133 setDensifyFraction(double dFrac)
134 {
135 if(dFrac > 1.0 || dFrac <= 0.0) {
137 "Fraction is not in range (0.0 - 1.0]");
138 }
139
140 densifyFrac = dFrac;
141 }
142
143 double
144 distance()
145 {
146 compute(g0, g1);
147 return ptDist.getDistance();
148 }
149
150 const std::array<geom::Coordinate, 2>
151 getCoordinates() const
152 {
153 return ptDist.getCoordinates();
154 }
155
156private:
157 geom::Coordinate getSegementAt(const geom::CoordinateSequence& seq, size_t index);
158
159 PointPairDistance& getFrecheDistance(std::vector< std::vector<PointPairDistance> >& ca, size_t i, size_t j,
161
162 void compute(const geom::Geometry& discreteGeom, const geom::Geometry& geom);
163
164 const geom::Geometry& g0;
165
166 const geom::Geometry& g1;
167
168 PointPairDistance ptDist;
169
171 double densifyFrac; // = 0.0;
172
173 // Declare type as noncopyable
174 DiscreteFrechetDistance(const DiscreteFrechetDistance& other) = delete;
175 DiscreteFrechetDistance& operator=(const DiscreteFrechetDistance& rhs) = delete;
176};
177
178} // geos::algorithm::distance
179} // geos::algorithm
180} // geos
181
182#ifdef _MSC_VER
183#pragma warning(pop)
184#endif
185
186#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
void setDensifyFraction(double dFrac)
Definition DiscreteFrechetDistance.h:133
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
Indicates one or more illegal arguments.
Definition IllegalArgumentException.h:34
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26