GEOS  3.8.0dev
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 #ifndef GEOS_ALGORITHM_RAYCROSSINGCOUNTERDD_H
21 #define GEOS_ALGORITHM_RAYCROSSINGCOUNTERDD_H
22 
23 #include <geos/export.h>
24 #include <geos/geom/Location.h>
26 
27 #include <vector>
28 
29 // forward declarations
30 namespace geos {
31 namespace geom {
32 class Coordinate;
33 class CoordinateSequence;
34 }
35 }
36 
37 
38 namespace geos {
39 namespace algorithm {
40 
65 class GEOS_DLL RayCrossingCounterDD {
66 private:
67  const geom::Coordinate& point;
68 
69  int crossingCount;
70 
71  // true if the test point lies on an input segment
72  bool isPointOnSegment;
73 
74  // Declare type as noncopyable
75  RayCrossingCounterDD(const RayCrossingCounterDD& other) = delete;
76  RayCrossingCounterDD& operator=(const RayCrossingCounterDD& rhs) = delete;
77 
78 public:
87  static geom::Location locatePointInRing(const geom::Coordinate& p,
88  const geom::CoordinateSequence& ring);
89 
91  static geom::Location locatePointInRing(const geom::Coordinate& p,
92  const std::vector<const geom::Coordinate*>& ring);
93 
106  static int orientationIndex(const geom::Coordinate& p1,
107  const geom::Coordinate& p2,
108  const geom::Coordinate& q);
109 
110  RayCrossingCounterDD(const geom::Coordinate& p_point):
111  point(p_point),
112  crossingCount(0),
113  isPointOnSegment(false)
114  { }
115 
122  void countSegment(const geom::Coordinate& p1,
123  const geom::Coordinate& p2);
124 
134  bool
136  {
137  return isPointOnSegment;
138  }
139 
149  geom::Location getLocation();
150 
160  bool isPointInPolygon();
161 
162 };
163 
164 } // geos::algorithm
165 } // geos
166 
167 #endif // GEOS_ALGORITHM_RAYCROSSINGCOUNTERDD_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:33
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
bool isOnSegment()
Reports whether the point lies exactly on one of the supplied segments.
Definition: RayCrossingCounterDD.h:135
Mathematics functions.
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Counts the number of segments crossed by a horizontal ray extending to the right from a given point...
Definition: RayCrossingCounterDD.h:65