GEOS  3.3.3
RayCrossingCounter.h
1 /**********************************************************************
2  * $Id: RayCrossingCounter.h 2770 2009-12-03 19:27:18Z mloskot $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2006 Refractions Research Inc.
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  *
17  * Last port: algorithm/RayCrossingCounter.java rev. 1.2 (JTS-1.9)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
22 #define GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
23 
24 #include <geos/export.h>
25 
26 #include <vector>
27 
28 // forward declarations
29 namespace geos {
30  namespace geom {
31  class Coordinate;
32  class CoordinateSequence;
33  }
34 }
35 
36 
37 namespace geos {
38 namespace algorithm {
39 
67 class GEOS_DLL RayCrossingCounter
68 {
69 private:
70  const geom::Coordinate& point;
71 
72  int crossingCount;
73 
74  // true if the test point lies on an input segment
75  bool isPointOnSegment;
76 
77  // Declare type as noncopyable
79  RayCrossingCounter& operator=(const RayCrossingCounter& rhs);
80 
81 public:
90  static int locatePointInRing(const geom::Coordinate& p,
91  const geom::CoordinateSequence& ring);
92 
94  static int locatePointInRing(const geom::Coordinate& p,
95  const std::vector<const geom::Coordinate*>& ring);
96 
98  : point( point),
99  crossingCount( 0),
100  isPointOnSegment( false)
101  { }
102 
109  void countSegment(const geom::Coordinate& p1,
110  const geom::Coordinate& p2);
111 
121  bool isOnSegment()
122  {
123  return isPointOnSegment;
124  }
125 
136  int getLocation();
137 
148  bool isPointInPolygon();
149 
150 };
151 
152 } // geos::algorithm
153 } // geos
154 
155 #endif // GEOS_ALGORITHM_RAYCROSSINGCOUNTER_H
156 /**********************************************************************
157  * $Log$
158  **********************************************************************/
159