GEOS  3.9.0
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>
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 
64 class GEOS_DLL RayCrossingCounterDD {
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  RayCrossingCounterDD(const RayCrossingCounterDD& other) = delete;
75  RayCrossingCounterDD& operator=(const RayCrossingCounterDD& rhs) = delete;
76 
77 public:
87  const geom::CoordinateSequence& ring);
88 
91  const std::vector<const geom::Coordinate*>& ring);
92 
105  static int orientationIndex(const geom::Coordinate& p1,
106  const geom::Coordinate& p2,
107  const geom::Coordinate& q);
108 
109  RayCrossingCounterDD(const geom::Coordinate& p_point):
110  point(p_point),
111  crossingCount(0),
112  isPointOnSegment(false)
113  { }
114 
122  const geom::Coordinate& p2);
123 
133  bool
135  {
136  return isPointOnSegment;
137  }
138 
149 
160 
161 };
162 
163 } // geos::algorithm
164 } // geos
165 
166 #endif // GEOS_ALGORITHM_RAYCROSSINGCOUNTERDD_H
geos::geom::Location
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:34
geos::algorithm::RayCrossingCounterDD::countSegment
void countSegment(const geom::Coordinate &p1, const geom::Coordinate &p2)
Counts a segment.
geos::algorithm::RayCrossingCounterDD::isOnSegment
bool isOnSegment()
Reports whether the point lies exactly on one of the supplied segments.
Definition: RayCrossingCounterDD.h:134
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
geos::algorithm::RayCrossingCounterDD::isPointInPolygon
bool isPointInPolygon()
Tests whether the point lies in or on the ring, polygon or multipolygon from which the processed segm...
geos::algorithm::RayCrossingCounterDD::getLocation
geom::Location getLocation()
Gets the Location of the point relative to the ring, polygon or multipolygon from which the processed...
geos::algorithm::RayCrossingCounterDD::locatePointInRing
static geom::Location locatePointInRing(const geom::Coordinate &p, const geom::CoordinateSequence &ring)
Determines the Location of a point in a ring. This method is an exemplar of how to use this class.
geos::algorithm::RayCrossingCounterDD::locatePointInRing
static geom::Location locatePointInRing(const geom::Coordinate &p, const std::vector< const geom::Coordinate * > &ring)
Semantically equal to the above, just different args encoding.
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
geos::algorithm::RayCrossingCounterDD::orientationIndex
static int orientationIndex(const geom::Coordinate &p1, const geom::Coordinate &p2, const geom::Coordinate &q)
Returns the index of the direction of the point q relative to a vector specified by p1-p2.
geos::algorithm::RayCrossingCounterDD
Counts the number of segments crossed by a horizontal ray extending to the right from a given point,...
Definition: RayCrossingCounterDD.h:64