GEOS  3.4.2
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 {
68 private:
69  const geom::Coordinate& point;
70 
71  int crossingCount;
72 
73  // true if the test point lies on an input segment
74  bool isPointOnSegment;
75 
76  // Declare type as noncopyable
78  RayCrossingCounter& operator=(const RayCrossingCounter& rhs);
79 
80 public:
89  static int locatePointInRing(const geom::Coordinate& p,
90  const geom::CoordinateSequence& ring);
91 
93  static int locatePointInRing(const geom::Coordinate& p,
94  const std::vector<const geom::Coordinate*>& ring);
95 
97  : point( point),
98  crossingCount( 0),
99  isPointOnSegment( false)
100  { }
101 
108  void countSegment(const geom::Coordinate& p1,
109  const geom::Coordinate& p2);
110 
120  bool isOnSegment()
121  {
122  return isPointOnSegment;
123  }
124 
135  int getLocation();
136 
147  bool isPointInPolygon();
148 
149 };
150 
151 } // geos::algorithm
152 } // geos
153 
154 #endif // GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
bool isOnSegment()
Definition: RayCrossingCounter.h:120
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
Counts the number of segments crossed by a horizontal ray extending to the right from a given point...
Definition: RayCrossingCounter.h:66