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 
53 private:
54  class IntervalIndexedGeometry {
55  private:
57 
58  void init(const geom::Geometry& g);
59  void addLine(const geom::CoordinateSequence* pts);
60 
61  // To keep track of LineSegments
62  std::vector< geom::LineSegment > segments;
63 
64  public:
65  IntervalIndexedGeometry(const geom::Geometry& g);
66 
67  void query(double min, double max, index::ItemVisitor* visitor);
68  };
69 
70 
71  class SegmentVisitor : public index::ItemVisitor {
72  private:
74 
75  public:
76  SegmentVisitor(algorithm::RayCrossingCounter* p_counter)
77  : counter(p_counter)
78  { }
79 
80  ~SegmentVisitor() override
81  { }
82 
83  void visitItem(void* item) override;
84  };
85 
86 
87  const geom::Geometry& areaGeom;
88  std::unique_ptr<IntervalIndexedGeometry> index;
89 
90  void buildIndex(const geom::Geometry& g);
91 
92  // Declare type as noncopyable
94  IndexedPointInAreaLocator& operator=(const IndexedPointInAreaLocator& rhs) = delete;
95 
96 public:
105 
113  geom::Location locate(const geom::Coordinate* /*const*/ p) override;
114 
115 };
116 
117 } // geos::algorithm::locate
118 } // geos::algorithm
119 } // geos
120 
121 #endif // GEOS_ALGORITHM_LOCATE_INDEXEDPOINTINAREALOCATOR_H
Determines the location of Coordinates relative to an areal geometry, using indexing for efficiency...
Definition: IndexedPointInAreaLocator.h:52
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:51
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:33
A visitor for items in an index.
Definition: ItemVisitor.h:29
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
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