GEOS  3.8.0dev
RayCrossingCounter.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
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/RayCrossingCounter.java rev. 1.2 (JTS-1.9)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
21 #define GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
22 
23 #include <geos/export.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 
66 class GEOS_DLL RayCrossingCounter {
67 private:
68  const geom::Coordinate& point;
69 
70  int crossingCount;
71 
72  // true if the test point lies on an input segment
73  bool isPointOnSegment;
74 
75  // Declare type as noncopyable
76  RayCrossingCounter(const RayCrossingCounter& other) = delete;
77  RayCrossingCounter& operator=(const RayCrossingCounter& rhs) = delete;
78 
79 public:
88  static int locatePointInRing(const geom::Coordinate& p,
89  const geom::CoordinateSequence& ring);
90 
92  static int locatePointInRing(const geom::Coordinate& p,
93  const std::vector<const geom::Coordinate*>& ring);
94 
107  static int orientationIndex(const geom::Coordinate& p1,
108  const geom::Coordinate& p2,
109  const geom::Coordinate& q);
110 
111  RayCrossingCounter(const geom::Coordinate& p_point)
112  : point(p_point),
113  crossingCount(0),
114  isPointOnSegment(false)
115  { }
116 
123  void countSegment(const geom::Coordinate& p1,
124  const geom::Coordinate& p2);
125 
135  bool
137  {
138  return isPointOnSegment;
139  }
140 
151  int getLocation();
152 
163  bool isPointInPolygon();
164 
165 };
166 
167 } // geos::algorithm
168 } // geos
169 
170 #endif // GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
bool isOnSegment()
Definition: RayCrossingCounter.h:136
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
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: RayCrossingCounter.h:66