GEOS  3.9.1dev
MinimumDiameter.h
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: algorithm/MinimumDiameter.java r966
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_ALGORITHM_MINIMUMDIAMETER_H
21 #define GEOS_ALGORITHM_MINIMUMDIAMETER_H
22 
23 #include <geos/geom/Coordinate.h>
24 #include <geos/geom/LineSegment.h>
25 
26 #include <memory>
27 #include <geos/export.h>
28 
29 // Forward declarations
30 namespace geos {
31 namespace geom {
32 class Geometry;
33 class LineString;
34 class CoordinateSequence;
35 }
36 }
37 
38 
39 namespace geos {
40 namespace algorithm { // geos::algorithm
41 
64 private:
66  bool isConvex;
67 
68  std::unique_ptr<geom::CoordinateSequence> convexHullPts;
69 
72  size_t minPtIndex;
73  double minWidth;
74  void computeMinimumDiameter();
75  void computeWidthConvex(const geom::Geometry* geom);
76 
84  void computeConvexRingMinDiameter(const geom::CoordinateSequence* pts);
85 
86  unsigned int findMaxPerpDistance(const geom::CoordinateSequence* pts,
87  const geom::LineSegment* seg, unsigned int startIndex);
88 
89  static unsigned int getNextIndex(const geom::CoordinateSequence* pts,
90  unsigned int index);
91 
92  static double computeC(double a, double b, const geom::Coordinate& p);
93 
94  static geom::LineSegment computeSegmentForLine(double a, double b, double c);
95 
96 public:
97  ~MinimumDiameter() = default;
98 
104  MinimumDiameter(const geom::Geometry* newInputGeom);
105 
115  MinimumDiameter(const geom::Geometry* newInputGeom,
116  const bool newIsConvex);
117 
123  double getLength();
124 
130  const geom::Coordinate& getWidthCoordinate();
131 
137  std::unique_ptr<geom::LineString> getSupportingSegment();
138 
144  std::unique_ptr<geom::LineString> getDiameter();
145 
157  std::unique_ptr<geom::Geometry> getMinimumRectangle();
158 
165  static std::unique_ptr<geom::Geometry> getMinimumRectangle(geom::Geometry* geom);
166 
172  static std::unique_ptr<geom::Geometry> getMinimumDiameter(geom::Geometry* geom);
173 
174 };
175 
176 } // namespace geos::algorithm
177 } // namespace geos
178 
179 #endif // GEOS_ALGORITHM_MINIMUMDIAMETER_H
180 
#define GEOS_DLL
Definition: export.h:28
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
const geom::Geometry * inputGeom
Basic namespace for all GEOS functionalities.
Computes the minimum diameter of a geom::Geometry.
std::unique_ptr< geom::CoordinateSequence > convexHullPts
The internal representation of a list of coordinates inside a Geometry.