GEOS 3.14.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
26namespace geos {
27namespace geom {
28class Coordinate;
29class Polygon;
30class LinearRing;
31class MultiPolygon;
32}
33}
34
35
36namespace geos { // geos.
37namespace operation { // geos.operation
38namespace valid { // geos.operation.valid
39
40class GEOS_DLL IndexedNestedPolygonTester {
41 using Polygon = geos::geom::Polygon;
42 using MultiPolygon = geos::geom::MultiPolygon;
43 using LinearRing = geos::geom::LinearRing;
44 using CoordinateXY = geos::geom::CoordinateXY;
45 using IndexedPointInAreaLocator = algorithm::locate::IndexedPointInAreaLocator;
46 template<typename ItemType>
47 using TemplateSTRtree = index::strtree::TemplateSTRtree<ItemType>;
48
49private:
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
85public:
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:61
Basic namespace for all GEOS functionalities.
Definition geos.h:39