GEOS 3.14.0dev
PolygonNodeTopology.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://libgeos.org
5 *
6 * Copyright (c) 2021 Martin Davis
7 * Copyright (C) 2022 Paul Ramsey <pramsey@cleverlephant.ca>
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#pragma once
17
18#include <geos/export.h>
19
20
21// Forward declarations
22namespace geos {
23namespace geom {
24class CoordinateXY;
25}
26}
27
28namespace geos {
29namespace algorithm { // geos::algorithm
30
38class GEOS_DLL PolygonNodeTopology {
39 using CoordinateXY = geos::geom::CoordinateXY;
40
41public:
42
43 /*
44 * Check if the segments at a node between two rings (or one ring) cross.
45 * The node is topologically valid if the rings do not cross.
46 * This function assumes that the segments are not collinear.
47 *
48 * @param nodePt the node location
49 * @param a0 the previous segment endpoint in a ring
50 * @param a1 the next segment endpoint in a ring
51 * @param b0 the previous segment endpoint in the other ring
52 * @param b1 the next segment endpoint in the other ring
53 * @return true if the rings cross at the node
54 */
55 static bool
56 isCrossing(const CoordinateXY* nodePt,
57 const CoordinateXY* a0, const CoordinateXY* a1,
58 const CoordinateXY* b0, const CoordinateXY* b1);
59
60
74 static bool isInteriorSegment(const CoordinateXY* nodePt,
75 const CoordinateXY* a0, const CoordinateXY* a1, const CoordinateXY* b);
76
87 static int compareAngle(
88 const CoordinateXY* origin,
89 const CoordinateXY* p,
90 const CoordinateXY* q);
91
92
93private:
94
107 static bool isBetween(const CoordinateXY* origin,
108 const CoordinateXY* p,
109 const CoordinateXY* e0, const CoordinateXY* e1);
110
124 static int compareBetween(const CoordinateXY* origin, const CoordinateXY* p,
125 const CoordinateXY* e0, const CoordinateXY* e1);
126
127
137 static bool isAngleGreater(const CoordinateXY* origin, const CoordinateXY* p, const CoordinateXY* q);
138
139 static int quadrant(const CoordinateXY* origin, const CoordinateXY* p);
140
141
142};
143
144
145} // namespace geos::algorithm
146} // namespace geos
147
Definition PolygonNodeTopology.h:38
static int compareAngle(const CoordinateXY *origin, const CoordinateXY *p, const CoordinateXY *q)
static bool isInteriorSegment(const CoordinateXY *nodePt, const CoordinateXY *a0, const CoordinateXY *a1, const CoordinateXY *b)
Basic namespace for all GEOS functionalities.
Definition geos.h:39