Class IntersectionMatrix
Models a Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.
Inherited Members
Namespace: NetTopologySuite.Geometries
Assembly: NetTopologySuite.dll
Syntax
public class IntersectionMatrix
Remarks
DE-9IM matrix values (such as "212FF1FF2") specify the topological relationship between two Geometrys. This class can also represent matrix patterns (such as "TT*****") which are used for matching instances of DE-9IM matrices.
DE-9IM matrices are 3x3 matrices with integer entries. The matrix indices {0,1,2} represent the topological locations that occur in a geometry(Interior, Boundary, Exterior). These are provided by the constants Interior, Boundary, and Exterior.
When used to specify the topological relationship between two geometries,
the matrix entries represent the possible dimensions of each intersection:
A = 2, L = 1, P = 0 and False = -1.
When used to represent a matrix pattern entries can have the additional values
True ("T") and Dontcare ("*").
For a description of the DE-9IM and the spatial predicates derived from it, see the following references:
- OGC 99-049 OpenGIS Simple Features Specification for SQL.
- OGC 06-103r4 OpenGIS Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture, Section 6.1.15 (which provides some further details on certain predicate specifications).
- Wikipedia article on DE-9IM
Methods are provided to:
- set and query the elements of the matrix in a convenient fashion
- convert to and from the standard string representation(specified in SFS Section 2.1.13.2).
- test if a matrix matches a given pattern string.
- test if a matrix(possibly with geometry dimensions) matches a standard named spatial predicate
Constructors
| Improve this Doc View SourceIntersectionMatrix()
Creates an IntersectionMatrix with null
location values.
Declaration
public IntersectionMatrix()
IntersectionMatrix(IntersectionMatrix)
Creates an IntersectionMatrix with the same elements as
other
.
Declaration
public IntersectionMatrix(IntersectionMatrix other)
Parameters
Type | Name | Description |
---|---|---|
IntersectionMatrix | other | An IntersectionMatrix to copy. |
IntersectionMatrix(String)
Creates an IntersectionMatrix with the given dimension symbols.
Declaration
public IntersectionMatrix(string elements)
Parameters
Type | Name | Description |
---|---|---|
String | elements | A string of nine dimension symbols in row major order. |
Properties
| Improve this Doc View SourceItem[Location, Location]
See methods Get(int, int) and Set(int, int, int value)
Declaration
public Dimension this[Location row, Location column] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Location | row | |
Location | column |
Property Value
Type | Description |
---|---|
Dimension |
Methods
| Improve this Doc View SourceAdd(IntersectionMatrix)
Adds one matrix to another. Addition is defined by taking the maximum dimension value of each position in the summand matrices.
Declaration
public void Add(IntersectionMatrix im)
Parameters
Type | Name | Description |
---|---|---|
IntersectionMatrix | im | The matrix to add. |
Get(Location, Location)
Returns the value of one of this IntersectionMatrixs elements.
Declaration
public Dimension Get(Location row, Location column)
Parameters
Type | Name | Description |
---|---|---|
Location | row | The row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry. |
Location | column | The column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry. |
Returns
Type | Description |
---|---|
Dimension | The dimension value at the given matrix position. |
IsContains()
Tests whether this matrix matches [T*****FF*]
Declaration
public bool IsContains()
Returns
Type | Description |
---|---|
Boolean |
|
IsCoveredBy()
Tests if this matrix matches
[TFF]
or [TFF]
or [FTF]
or [FTF]
.
Declaration
public bool IsCoveredBy()
Returns
Type | Description |
---|---|
Boolean |
|
IsCovers()
Tests if this matrix matches
[T**FF*]
or [TFF*]
or [TFF]
or [**TFF]
.
Declaration
public bool IsCovers()
Returns
Type | Description |
---|---|
Boolean |
|
IsCrosses(Dimension, Dimension)
Tests whether this geometry crosses the specified geometry.
Declaration
public bool IsCrosses(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)
Parameters
Type | Name | Description |
---|---|---|
Dimension | dimensionOfGeometryA | The dimension of the first Geometry. |
Dimension | dimensionOfGeometryB | The dimension of the second Geometry. |
Returns
Type | Description |
---|---|
Boolean |
|
Remarks
The crosses
predicate has the following equivalent definitions:
- The geometries have some but not all interior points in common.
- The DE-9IM Intersection Matrix for the two geometries matches
false
.
The SFS defined this predicate only for P/L, P/A, L/L, and L/A situations. JTS extends the definition to apply to L/P, A/P and A/L situations as well. This makes the relation symmetric.
IsDisjoint()
Tests if this matrix matches [FFFF***]
.
Declaration
public bool IsDisjoint()
Returns
Type | Description |
---|---|
Boolean |
|
IsEquals(Dimension, Dimension)
Tests whether the argument dimensions are equal and
this matrix matches the pattern [TF**FFF]
.
Note: This pattern differs from the one stated in
Simple feature access - Part 1: Common architecture.
That document states the pattern as [TFFFTFFFT]
. This would
specify that
two identical POINTs are not equal, which is not desirable behaviour.
The pattern used here has been corrected to compute equality in this situation.
Declaration
public bool IsEquals(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)
Parameters
Type | Name | Description |
---|---|---|
Dimension | dimensionOfGeometryA | The dimension of the first Geometry. |
Dimension | dimensionOfGeometryB | The dimension of the second Geometry. |
Returns
Type | Description |
---|---|
Boolean |
|
IsIntersects()
Tests if isDisjoint
returns false.
Declaration
public bool IsIntersects()
Returns
Type | Description |
---|---|
Boolean |
|
IsOverlaps(Dimension, Dimension)
Tests if this matrix matches
[T*T***T**]
(for two points or two surfaces)[1*T***T**]
(for two curves)
Declaration
public bool IsOverlaps(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)
Parameters
Type | Name | Description |
---|---|---|
Dimension | dimensionOfGeometryA | The dimension of the first Geometry. |
Dimension | dimensionOfGeometryB | The dimension of the second Geometry. |
Returns
Type | Description |
---|---|
Boolean |
|
IsTouches(Dimension, Dimension)
Tests if this matrix matches
[FT*******]
, [FT***]
or [FT*]
.
Declaration
public bool IsTouches(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)
Parameters
Type | Name | Description |
---|---|---|
Dimension | dimensionOfGeometryA | The dimension of the first Geometry. |
Dimension | dimensionOfGeometryB | The dimension of the second Geometry. |
Returns
Type | Description |
---|---|
Boolean |
|
IsTrue(Dimension)
Tests if the dimension value matches TRUE (i.e. has value 0, 1, 2 or TRUE).
Declaration
public static bool IsTrue(Dimension actualDimensionValue)
Parameters
Type | Name | Description |
---|---|---|
Dimension | actualDimensionValue | A number that can be stored in the |
Returns
Type | Description |
---|---|
Boolean |
|
IsWithin()
Tests whether this matrix matches [TFF]
.
Declaration
public bool IsWithin()
Returns
Type | Description |
---|---|
Boolean |
|
Matches(Dimension, Char)
Tests if the dimension value satisfies the dimension symbol.
Declaration
public static bool Matches(Dimension actualDimensionValue, char requiredDimensionSymbol)
Parameters
Type | Name | Description |
---|---|---|
Dimension | actualDimensionValue | a number that can be stored in the |
Char | requiredDimensionSymbol | A character used in the string
representation of an IntersectionMatrix.
Possible values are |
Returns
Type | Description |
---|---|
Boolean |
|
Matches(String)
Tests whether this matrix matches the given matrix pattern
Declaration
public bool Matches(string pattern)
Parameters
Type | Name | Description |
---|---|---|
String | pattern | A pattern containing nine dimension symbols with which to
compare the entries of this matrix.Possible
symbol values are |
Returns
Type | Description |
---|---|
Boolean |
|
Matches(String, String)
Tests if each of the actual dimension symbols in a matrix string satisfies the corresponding required dimension symbol in a pattern string.
Declaration
public static bool Matches(string actualDimensionSymbols, string requiredDimensionSymbols)
Parameters
Type | Name | Description |
---|---|---|
String | actualDimensionSymbols | Nine dimension symbols to validate.
Possible values are |
String | requiredDimensionSymbols | Nine dimension symbols to validate
against. Possible values are |
Returns
Type | Description |
---|---|
Boolean |
|
Set(Location, Location, Dimension)
Changes the value of one of this IntersectionMatrix elements.
Declaration
public void Set(Location row, Location column, Dimension dimensionValue)
Parameters
Type | Name | Description |
---|---|---|
Location | row | The row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry |
Location | column | The column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry |
Dimension | dimensionValue | The new value of the element |
Set(String)
Changes the elements of this IntersectionMatrix to the
dimension symbols in dimensionSymbols
.
Declaration
public void Set(string dimensionSymbols)
Parameters
Type | Name | Description |
---|---|---|
String | dimensionSymbols | Nine dimension symbols to which to set this IntersectionMatrix
s elements. Possible values are |
SetAll(Dimension)
Changes the elements of this IntersectionMatrix to dimensionValue
.
Declaration
public void SetAll(Dimension dimensionValue)
Parameters
Type | Name | Description |
---|---|---|
Dimension | dimensionValue | The dimension value to which to set this IntersectionMatrix
s elements. Possible values |
SetAtLeast(Location, Location, Dimension)
Changes the specified element to minimumDimensionValue
if the element is less.
Declaration
public void SetAtLeast(Location row, Location column, Dimension minimumDimensionValue)
Parameters
Type | Name | Description |
---|---|---|
Location | row | The row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry. |
Location | column | The column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry. |
Dimension | minimumDimensionValue | The dimension value with which to compare the
element. The order of dimension values from least to greatest is
|
SetAtLeast(String)
For each element in this IntersectionMatrix, changes the element to the corresponding minimum dimension symbol if the element is less.
Declaration
public void SetAtLeast(string minimumDimensionSymbols)
Parameters
Type | Name | Description |
---|---|---|
String | minimumDimensionSymbols | Nine dimension symbols with which to
compare the elements of this IntersectionMatrix. The
order of dimension values from least to greatest is |
SetAtLeastIfValid(Location, Location, Dimension)
If row >= 0 and column >= 0, changes the specified element to minimumDimensionValue
if the element is less. Does nothing if row is smaller to 0 or column is smaller to 0.
Declaration
public void SetAtLeastIfValid(Location row, Location column, Dimension minimumDimensionValue)
Parameters
Type | Name | Description |
---|---|---|
Location | row | |
Location | column | |
Dimension | minimumDimensionValue |
ToString()
Returns a nine-character String
representation of this IntersectionMatrix.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The nine dimension symbols of this IntersectionMatrix in row-major order. |
Overrides
| Improve this Doc View SourceTranspose()
Transposes this IntersectionMatrix.
Declaration
public IntersectionMatrix Transpose()
Returns
Type | Description |
---|---|
IntersectionMatrix | This IntersectionMatrix as a convenience, |