GEOS  3.13.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 <memory>
23 #include <map>
24 
25 // Forward declarations
26 namespace geos {
27 namespace geom {
28 class Coordinate;
29 class Polygon;
30 class LinearRing;
31 class MultiPolygon;
32 }
33 }
34 
35 
36 namespace geos { // geos.
37 namespace operation { // geos.operation
38 namespace valid { // geos.operation.valid
39 
43 using geos::geom::CoordinateXY;
44 using algorithm::locate::IndexedPointInAreaLocator;
45 using index::strtree::TemplateSTRtree;
46 
47 class GEOS_DLL IndexedNestedPolygonTester {
48 
49 private:
50 
51  const MultiPolygon* multiPoly;
52  TemplateSTRtree<const Polygon*> index;
53  // std::vector<IndexedPointInAreaLocator> locators;
54  std::map<const Polygon*, IndexedPointInAreaLocator> locators;
55  CoordinateXY nestedPt;
56 
57  void loadIndex();
58 
59  IndexedPointInAreaLocator& getLocator(const Polygon* poly);
60 
61  bool findNestedPoint(const LinearRing* shell,
62  const Polygon* possibleOuterPoly,
63  IndexedPointInAreaLocator& locator,
64  CoordinateXY& coordNested);
65 
76  static bool findIncidentSegmentNestedPoint(
77  const LinearRing* shell,
78  const Polygon* poly,
79  CoordinateXY& coordNested);
80 
81  // Declare type as noncopyable
82  IndexedNestedPolygonTester(const IndexedNestedPolygonTester& other) = delete;
83  IndexedNestedPolygonTester& operator=(const IndexedNestedPolygonTester& rhs) = delete;
84 
85 public:
86 
87  IndexedNestedPolygonTester(const MultiPolygon* p_multiPoly);
88 
94  const CoordinateXY& getNestedPoint() const { return nestedPt; }
95 
102  bool isNested();
103 
104 
105 };
106 
107 
108 
109 } // namespace geos.operation.valid
110 } // namespace geos.operation
111 } // 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:58
Represents a linear polygon, which may include holes.
Definition: Polygon.h:60
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25