GEOS 3.8.1
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
28namespace geos {
29namespace algorithm {
30class RayCrossingCounter;
31}
32namespace geom {
33class Geometry;
34class Coordinate;
35class CoordinateSequence;
36}
37}
38
39namespace geos {
40namespace algorithm { // geos::algorithm
41namespace locate { // geos::algorithm::locate
42
53private:
54 class IntervalIndexedGeometry {
55 private:
57 bool isEmpty;
58
59 void init(const geom::Geometry& g);
60 void addLine(const geom::CoordinateSequence* pts);
61
62 // To keep track of LineSegments
63 std::vector< geom::LineSegment > segments;
64
65 public:
66 IntervalIndexedGeometry(const geom::Geometry& g);
67
68 void query(double min, double max, index::ItemVisitor* visitor);
69 };
70
71
72 class SegmentVisitor : public index::ItemVisitor {
73 private:
75
76 public:
77 SegmentVisitor(algorithm::RayCrossingCounter* p_counter)
78 : counter(p_counter)
79 { }
80
81 ~SegmentVisitor() override
82 { }
83
84 void visitItem(void* item) override;
85 };
86
87
88 const geom::Geometry& areaGeom;
89 std::unique_ptr<IntervalIndexedGeometry> index;
90
91 void buildIndex(const geom::Geometry& g);
92
93 // Declare type as noncopyable
95 IndexedPointInAreaLocator& operator=(const IndexedPointInAreaLocator& rhs) = delete;
96
97public:
106
114 geom::Location 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
Counts the number of segments crossed by a horizontal ray extending to the right from a given point,...
Definition: RayCrossingCounter.h:65
Determines the location of Coordinates relative to an areal geometry, using indexing for efficiency.
Definition: IndexedPointInAreaLocator.h:52
IndexedPointInAreaLocator(const geom::Geometry &g)
Creates a new locator for a given Geometry.
geom::Location locate(const geom::Coordinate *p) override
Determines the Location of a point in an areal Geometry.
An interface for classes which determine the Location of points in Polygon or MultiPolygon geometries...
Definition: PointOnGeometryLocator.h:37
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
A visitor for items in an index.
Definition: ItemVisitor.h:29
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
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:34
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25