GEOS  3.11.1
RayCrossingCounterDD.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2018 Paul Ramsey <pramsey@cleverelephant.ca>
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  *
16  * Last port: algorithm/RayCrossingCounterDD.java rev. 1.2 (JTS-1.9)
17  *
18  **********************************************************************/
19 
20 #pragma once
21 
22 #include <geos/export.h>
23 #include <geos/geom/Location.h>
24 
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 {
38 
63 class GEOS_DLL RayCrossingCounterDD {
64 private:
65  const geom::Coordinate& point;
66 
67  int crossingCount;
68 
69  // true if the test point lies on an input segment
70  bool isPointOnSegment;
71 
72  // Declare type as noncopyable
73  RayCrossingCounterDD(const RayCrossingCounterDD& other) = delete;
74  RayCrossingCounterDD& operator=(const RayCrossingCounterDD& rhs) = delete;
75 
76 public:
85  static geom::Location locatePointInRing(const geom::Coordinate& p,
86  const geom::CoordinateSequence& ring);
87 
89  static geom::Location locatePointInRing(const geom::Coordinate& p,
90  const std::vector<const geom::Coordinate*>& ring);
91 
104  static int orientationIndex(const geom::Coordinate& p1,
105  const geom::Coordinate& p2,
106  const geom::Coordinate& q);
107 
108  RayCrossingCounterDD(const geom::Coordinate& p_point):
109  point(p_point),
110  crossingCount(0),
111  isPointOnSegment(false)
112  { }
113 
120  void countSegment(const geom::Coordinate& p1,
121  const geom::Coordinate& p2);
122 
132  bool
134  {
135  return isPointOnSegment;
136  }
137 
147  geom::Location getLocation();
148 
158  bool isPointInPolygon();
159 
160 };
161 
162 } // geos::algorithm
163 } // geos
164 
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:32
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25
bool isOnSegment()
Reports whether the point lies exactly on one of the supplied segments.
Definition: RayCrossingCounterDD.h:133
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:44
Counts the number of segments crossed by a horizontal ray extending to the right from a given point...
Definition: RayCrossingCounterDD.h:63