GEOS  3.7.2
CGAlgorithms.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  * Copyright (C) 2001-2002 Vivid Solutions Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: algorithm/CGAlgorithms.java r378 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_ALGORITHM_CGALGORITHM_H
22 #define GEOS_ALGORITHM_CGALGORITHM_H
23 
24 #include <geos/export.h>
25 #include <vector>
26 
27 // Forward declarations
28 namespace geos {
29  namespace geom {
30  class Coordinate;
31  class CoordinateSequence;
32  }
33 }
34 
35 
36 namespace geos {
37 namespace algorithm { // geos::algorithm
38 
47 class GEOS_DLL CGAlgorithms {
48 
49 public:
50 
51  enum {
52  CLOCKWISE=-1,
53  COLLINEAR,
54  COUNTERCLOCKWISE
55  };
56 
57  enum {
58  RIGHT=-1,
59  LEFT,
60  STRAIGHT
61  };
62 
63  CGAlgorithms(){}
64 
81  static bool isPointInRing(const geom::Coordinate& p,
82  const geom::CoordinateSequence* ring);
83 
85  static bool isPointInRing(const geom::Coordinate& p,
86  const std::vector<const geom::Coordinate*>& ring);
87 
102  static int locatePointInRing(const geom::Coordinate& p,
103  const geom::CoordinateSequence& ring);
104 
106  static int locatePointInRing(const geom::Coordinate& p,
107  const std::vector<const geom::Coordinate*>& ring);
108 
116  static bool isOnLine(const geom::Coordinate& p,
117  const geom::CoordinateSequence* pt);
118 
134  static bool isCCW(const geom::CoordinateSequence* ring);
135 
148  static int computeOrientation(const geom::Coordinate& p1,
149  const geom::Coordinate& p2,
150  const geom::Coordinate& q);
151 
162  static double distancePointLine(const geom::Coordinate& p,
163  const geom::Coordinate& A,
164  const geom::Coordinate& B);
165 
176  const geom::Coordinate& A,
177  const geom::Coordinate& B);
178 
189  static double distanceLineLine(const geom::Coordinate& A,
190  const geom::Coordinate& B,
191  const geom::Coordinate& C,
192  const geom::Coordinate& D);
193 
198  static double signedArea(const geom::CoordinateSequence* ring);
199 
207  static double length(const geom::CoordinateSequence* pts);
208 
221  static int orientationIndex(const geom::Coordinate& p1,
222  const geom::Coordinate& p2,
223  const geom::Coordinate& q);
224 
225 };
226 
227 } // namespace geos::algorithm
228 } // namespace geos
229 
230 #endif // GEOS_ALGORITHM_CGALGORITHM_H
geos::algorithm::CGAlgorithms::distancePointLine
static double distancePointLine(const geom::Coordinate &p, const geom::Coordinate &A, const geom::Coordinate &B)
Computes the distance from a point p to a line segment AB.
geos::algorithm::CGAlgorithms::locatePointInRing
static int locatePointInRing(const geom::Coordinate &p, const geom::CoordinateSequence &ring)
Determines whether a point lies in the interior, on the boundary, or in the exterior of a ring.
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::algorithm::CGAlgorithms::isOnLine
static bool isOnLine(const geom::Coordinate &p, const geom::CoordinateSequence *pt)
Test whether a point lies on the given line segment.
geos::algorithm::CGAlgorithms::distancePointLinePerpendicular
static double distancePointLinePerpendicular(const geom::Coordinate &p, const geom::Coordinate &A, const geom::Coordinate &B)
Computes the perpendicular distance from a point p to the (infinite) line containing the points AB.
geos::algorithm::CGAlgorithms::distanceLineLine
static double distanceLineLine(const geom::Coordinate &A, const geom::Coordinate &B, const geom::Coordinate &C, const geom::Coordinate &D)
Computes the distance from a line segment AB to a line segment CD.
geos::algorithm::CGAlgorithms::locatePointInRing
static int locatePointInRing(const geom::Coordinate &p, const std::vector< const geom::Coordinate * > &ring)
Same as above, but taking a vector of const Coordinates.
geos::algorithm::CGAlgorithms
Specifies and implements various fundamental Computational Geometric algorithms. The algorithms suppl...
Definition: CGAlgorithms.h:47
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::algorithm::CGAlgorithms::computeOrientation
static int computeOrientation(const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q)
Computes the orientation of a point q to the directed line segment p1-p2.
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
geos::algorithm::CGAlgorithms::orientationIndex
static int orientationIndex(const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q)
Returns the index of the direction of the point q relative to a vector specified by p1-p2.
geos::algorithm::CGAlgorithms::isPointInRing
static bool isPointInRing(const geom::Coordinate &p, const geom::CoordinateSequence *ring)
Tests whether a point lies inside a ring.
geos::algorithm::CGAlgorithms::length
static double length(const geom::CoordinateSequence *pts)
Computes the length of a linestring specified by a sequence of points.
geos::algorithm::CGAlgorithms::signedArea
static double signedArea(const geom::CoordinateSequence *ring)
Returns the signed area for a ring. The area is positive if the ring is oriented CW.
geos::algorithm::CGAlgorithms::isPointInRing
static bool isPointInRing(const geom::Coordinate &p, const std::vector< const geom::Coordinate * > &ring)
Same as above, but taking a vector of const Coordinates (faster)
geos::algorithm::CGAlgorithms::isCCW
static bool isCCW(const geom::CoordinateSequence *ring)
Computes whether a ring defined by an array of Coordinate is oriented counter-clockwise.