GEOS  3.8.0dev
IndexedPointInAreaLocator.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
7  * Copyright (C) 2018 Daniel Baston <dbaston@gmail.com>
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 #ifndef GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H
18 #define GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H
19 
20 #include <geos/geom/LineSegment.h>
21 #include <geos/algorithm/locate/PointOnGeometryLocator.h> // inherited
22 #include <geos/index/ItemVisitor.h> // inherited
23 #include <geos/index/intervalrtree/SortedPackedIntervalRTree.h> // inherited
24 
25 #include <memory>
26 #include <vector> // composition
27 
28 namespace geos {
29 namespace algorithm {
30 class RayCrossingCounter;
31 }
32 namespace geom {
33 class Geometry;
34 class Coordinate;
35 class CoordinateSequence;
36 }
37 }
38 
39 namespace geos {
40 namespace algorithm { // geos::algorithm
41 namespace locate { // geos::algorithm::locate
42 
55 private:
56  class IntervalIndexedGeometry {
57  private:
59 
60  void init(const geom::Geometry& g);
61  void addLine(const geom::CoordinateSequence* pts);
62 
63  // To keep track of LineSegments
64  std::vector< geom::LineSegment > segments;
65 
66  public:
67  IntervalIndexedGeometry(const geom::Geometry& g);
68 
69  void query(double min, double max, index::ItemVisitor* visitor);
70  };
71 
72 
73  class SegmentVisitor : public index::ItemVisitor {
74  private:
76 
77  public:
78  SegmentVisitor(algorithm::RayCrossingCounter* p_counter)
79  : counter(p_counter)
80  { }
81 
82  ~SegmentVisitor() override
83  { }
84 
85  void visitItem(void* item) override;
86  };
87 
88 
89  const geom::Geometry& areaGeom;
90  std::unique_ptr<IntervalIndexedGeometry> index;
91 
92  void buildIndex(const geom::Geometry& g);
93 
94  // Declare type as noncopyable
96  IndexedPointInAreaLocator& operator=(const IndexedPointInAreaLocator& rhs) = delete;
97 
98 public:
107 
114  int locate(const geom::Coordinate* /*const*/ p) override;
115 
116 };
117 
118 } // geos::algorithm::locate
119 } // geos::algorithm
120 } // geos
121 
122 #endif // GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H
Determines the location of Coordinates relative to an areal geometry, using indexing for efficiency...
Definition: IndexedPointInAreaLocator.h:54
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
int locate(const geom::Coordinate *p) override
A static index on a set of 1-dimensional intervals, using an R-Tree packed based on the order of the ...
Definition: SortedPackedIntervalRTree.h:51
An interface for classes which determine the Location of points in Polygon or MultiPolygon geometries...
Definition: PointOnGeometryLocator.h:35
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
A visitor for items in an index.
Definition: ItemVisitor.h:29
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