GEOS  3.9.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 
56 private:
57  class IntervalIndexedGeometry {
58  private:
60  bool isEmpty;
61 
62  void init(const geom::Geometry& g);
63  void addLine(const geom::CoordinateSequence* pts);
64 
65  // To keep track of LineSegments
66  std::vector< geom::LineSegment > segments;
67 
68  public:
69  IntervalIndexedGeometry(const geom::Geometry& g);
70 
71  void query(double min, double max, index::ItemVisitor* visitor);
72  };
73 
74 
75  class SegmentVisitor : public index::ItemVisitor {
76  private:
78 
79  public:
80  SegmentVisitor(algorithm::RayCrossingCounter* p_counter)
81  : counter(p_counter)
82  { }
83 
84  ~SegmentVisitor() override
85  { }
86 
87  void visitItem(void* item) override;
88  };
89 
90 
91  const geom::Geometry& areaGeom;
92  std::unique_ptr<IntervalIndexedGeometry> index;
93 
94  void buildIndex(const geom::Geometry& g);
95 
96  // Declare type as noncopyable
98  IndexedPointInAreaLocator& operator=(const IndexedPointInAreaLocator& rhs) = delete;
99 
100 public:
109 
110  const geom::Geometry& getGeometry() const {
111  return areaGeom;
112  }
113 
121  geom::Location locate(const geom::Coordinate* /*const*/ p) override;
122 
123 };
124 
125 } // geos::algorithm::locate
126 } // geos::algorithm
127 } // geos
128 
129 #endif // GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H
Determines the location of Coordinates relative to an areal geometry, using indexing for efficiency...
Definition: IndexedPointInAreaLocator.h:55
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
A static index on a set of 1-dimensional intervals, using an R-Tree packed based on the order of the ...
Definition: SortedPackedIntervalRTree.h:52
An interface for classes which determine the Location of points in Polygon or MultiPolygon geometries...
Definition: PointOnGeometryLocator.h:37
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:34
A visitor for items in an index.
Definition: ItemVisitor.h:29
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26
geom::Location locate(const geom::Coordinate *p) override
Determines the Location of a point in an areal Geometry.
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:65