GEOS  3.11.1
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 #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 
64 class GEOS_DLL RayCrossingCounter {
65 private:
66  const geom::Coordinate& point;
67 
68  int crossingCount;
69 
70  // true if the test point lies on an input segment
71  bool isPointOnSegment;
72 
73  // Declare type as noncopyable
74  RayCrossingCounter(const RayCrossingCounter& other) = delete;
75  RayCrossingCounter& operator=(const RayCrossingCounter& rhs) = delete;
76 
77 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 
94  RayCrossingCounter(const geom::Coordinate& p_point)
95  : point(p_point),
96  crossingCount(0),
97  isPointOnSegment(false)
98  { }
99 
106  void countSegment(const geom::Coordinate& p1,
107  const geom::Coordinate& p2);
108 
118  bool
119  isOnSegment() const
120  {
121  return isPointOnSegment;
122  }
123 
134  geom::Location getLocation() const;
135 
145  bool isPointInPolygon() const;
146 
147 };
148 
149 } // geos::algorithm
150 } // geos
bool isOnSegment() const
Reports whether the point lies exactly on one of the supplied segments.
Definition: RayCrossingCounter.h:119
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
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: RayCrossingCounter.h:64