GEOS  3.11.1
IntersectionMatrix.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  **********************************************************************
14  *
15  * Last port: geom/IntersectionMatrix.java rev. 1.18
16  *
17  **********************************************************************/
18 
19 #pragma once
20 
21 #include <geos/geom/Location.h>
22 
23 #include <geos/export.h>
24 #include <array>
25 #include <string>
26 
27 namespace geos {
28 namespace geom { // geos::geom
29 
51 class GEOS_DLL IntersectionMatrix {
52 
53 public:
54 
62 
71  IntersectionMatrix(const std::string& elements);
72 
81 
92  bool matches(const std::string& requiredDimensionSymbols) const;
93 
106  static bool matches(int actualDimensionValue,
107  char requiredDimensionSymbol);
108 
121  static bool matches(const std::string& actualDimensionSymbols,
122  const std::string& requiredDimensionSymbols);
123 
134  void add(IntersectionMatrix* other);
135 
146  void set(Location row, Location column, int dimensionValue);
147 
156  void set(const std::string& dimensionSymbols);
157 
170  void setAtLeast(Location row, Location column, int minimumDimensionValue);
171 
192  void setAtLeastIfValid(Location row, Location column, int minimumDimensionValue);
193 
204  void setAtLeast(std::string minimumDimensionSymbols);
205 
214  void setAll(int dimensionValue);
215 
229  int get(geom::Location row, geom::Location column) const {
230  return matrix[static_cast<size_t>(row)][static_cast<size_t>(column)];
231  }
232 
239  bool isDisjoint() const;
240 
247  bool isIntersects() const;
248 
261  bool isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB)
262  const;
263 
281  bool isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB)
282  const;
283 
289  bool isWithin() const;
290 
296  bool isContains() const;
297 
307  bool isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB)
308  const;
309 
323  bool isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB)
324  const;
325 
334  bool isCovers() const;
335 
336 
345  bool isCoveredBy() const;
346 
355  IntersectionMatrix* transpose();
356 
364  std::string toString() const;
365 
366 private:
367 
368  static const int firstDim; // = 3;
369 
370  static const int secondDim; // = 3;
371 
372  // Internal buffer for 3x3 matrix.
373  std::array<std::array<int, 3>, 3> matrix;
374 
375 }; // class IntersectionMatrix
376 
377 GEOS_DLL std::ostream& operator<< (std::ostream& os, const IntersectionMatrix& im);
378 
379 
380 } // namespace geos::geom
381 } // namespace geos
382 
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: Angle.h:25