GEOS 3.14.0dev
IMPredicate.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (c) 2024 Martin Davis
7 * Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
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/geom/Location.h>
19#include <geos/geom/Dimension.h>
20#include <geos/geom/IntersectionMatrix.h>
21#include <geos/operation/relateng/BasicPredicate.h>
22#include <geos/export.h>
23
24#include <memory>
25#include <vector>
26
27// Forward declarations
28namespace geos {
29namespace geom {
30 class Envelope;
31}
32}
33
34namespace geos { // geos.
35namespace operation { // geos.operation.
36namespace relateng { // geos.operation.relateng
37
38
39class GEOS_DLL IMPredicate : public BasicPredicate {
40protected:
41 using Envelope = geos::geom::Envelope;
43 using Dimension = geos::geom::Dimension;
44 using IntersectionMatrix = geos::geom::IntersectionMatrix;
45
46private:
47
48
49
50protected:
51
52 static constexpr int DIM_UNKNOWN = Dimension::DONTCARE;
53
54 int dimA;
55 int dimB;
56 IntersectionMatrix intMatrix;
57
64 virtual bool valueIM() = 0;
65
76 virtual bool isDetermined() const = 0;
77
85 bool intersectsExteriorOf(bool isA) const;
86
87 bool isIntersects(Location locA, Location locB) const;
88
89
90public:
91
92 IMPredicate()
93 {
94 // intMatrix = new IntersectionMatrix();
95 //-- E/E is always dim = 2
96 intMatrix.set(Location::EXTERIOR, Location::EXTERIOR, Dimension::A);
97 }
98
99 static bool isDimsCompatibleWithCovers(int dim0, int dim1);
100
101 void init(int dA, int dB) override;
102
103 void updateDimension(Location locA, Location locB, int dimension) override;
104
105 bool isDimChanged(Location locA, Location locB, int dimension) const;
106
107 using TopologyPredicate::isKnown;
108 bool isKnown(Location locA, Location locB) const;
109
110 bool isDimension(Location locA, Location locB, int dimension) const;
111
112 int getDimension(Location locA, Location locB) const;
113
117 void finish() override;
118
119 std::string toString() const;
120
121 friend std::ostream& operator<<(std::ostream& os, const IMPredicate& imp);
122
123
124};
125
126} // namespace geos.operation.relateng
127} // namespace geos.operation
128} // namespace geos
129
Definition Dimension.h:27
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Implementation of Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Definition IntersectionMatrix.h:51
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
Basic namespace for all GEOS functionalities.
Definition geos.h:39