GEOS 3.16.0dev
IndexedNestedPolygonTester.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2021 Paul Ramsey <pramsey@cleverelephant.ca>
7 * Copyright (C) 2021 Martin Davis
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#pragma once
17
18#include <geos/export.h>
19#include <geos/index/strtree/TemplateSTRtree.h>
20#include <geos/algorithm/locate/IndexedPointInAreaLocator.h>
21
22#include <map>
23
24// Forward declarations
25namespace geos {
26namespace geom {
27class Coordinate;
28class Polygon;
29class LinearRing;
30class MultiPolygon;
31}
32}
33
34
35namespace geos { // geos.
36namespace operation { // geos.operation
37namespace valid { // geos.operation.valid
38
39class GEOS_DLL IndexedNestedPolygonTester {
40 using Polygon = geos::geom::Polygon;
41 using MultiPolygon = geos::geom::MultiPolygon;
42 using LinearRing = geos::geom::LinearRing;
43 using CoordinateXY = geos::geom::CoordinateXY;
44 using IndexedPointInAreaLocator = algorithm::locate::IndexedPointInAreaLocator;
45 template<typename ItemType>
46 using TemplateSTRtree = index::strtree::TemplateSTRtree<ItemType>;
47
48private:
49
50 const MultiPolygon* multiPoly;
51 TemplateSTRtree<const Polygon*> index;
52 // std::vector<IndexedPointInAreaLocator> locators;
53 std::map<const Polygon*, IndexedPointInAreaLocator> locators;
54 CoordinateXY nestedPt;
55
56 void loadIndex();
57
58 IndexedPointInAreaLocator& getLocator(const Polygon* poly);
59
60 bool findNestedPoint(const LinearRing* shell,
61 const Polygon* possibleOuterPoly,
62 IndexedPointInAreaLocator& locator,
63 CoordinateXY& coordNested);
64
75 static bool findIncidentSegmentNestedPoint(
76 const LinearRing* shell,
77 const Polygon* poly,
78 CoordinateXY& coordNested);
79
80 // Declare type as noncopyable
81 IndexedNestedPolygonTester(const IndexedNestedPolygonTester& other) = delete;
82 IndexedNestedPolygonTester& operator=(const IndexedNestedPolygonTester& rhs) = delete;
83
84public:
85
86 IndexedNestedPolygonTester(const MultiPolygon* p_multiPoly);
87
93 const CoordinateXY& getNestedPoint() const { return nestedPt; }
94
101 bool isNested();
102
103
104};
105
106
107
108} // namespace geos.operation.valid
109} // namespace geos.operation
110} // namespace geos
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
Definition MultiPolygon.h:57
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
Basic namespace for all GEOS functionalities.
Definition geos.h:38