Table of Contents

Class IntersectionMatrix

Namespace
NetTopologySuite.Geometries
Assembly
NetTopologySuite.dll

Models a Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix.

public class IntersectionMatrix
Inheritance
IntersectionMatrix
Inherited Members

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:

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

IntersectionMatrix()

Creates an IntersectionMatrix with null location values.

public IntersectionMatrix()

IntersectionMatrix(IntersectionMatrix)

Creates an IntersectionMatrix with the same elements as other.

public IntersectionMatrix(IntersectionMatrix other)

Parameters

other IntersectionMatrix

An IntersectionMatrix to copy.

IntersectionMatrix(string)

Creates an IntersectionMatrix with the given dimension symbols.

public IntersectionMatrix(string elements)

Parameters

elements string

A string of nine dimension symbols in row major order.

Properties

this[Location, Location]

See methods Get(int, int) and Set(int, int, int value)

public Dimension this[Location row, Location column] { get; set; }

Parameters

row Location
column Location

Property Value

Dimension

Methods

Add(IntersectionMatrix)

Adds one matrix to another. Addition is defined by taking the maximum dimension value of each position in the summand matrices.

public void Add(IntersectionMatrix im)

Parameters

im IntersectionMatrix

The matrix to add.

Get(Location, Location)

Returns the value of one of this IntersectionMatrixs elements.

public Dimension Get(Location row, Location column)

Parameters

row Location

The row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry.

column Location

The column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry.

Returns

Dimension

The dimension value at the given matrix position.

IsContains()

Tests whether this matrix matches [T*****FF*]

public bool IsContains()

Returns

bool

true if the first Geometry contains the second.

IsCoveredBy()

Tests if this matrix matches [TFF] or [TFF] or [FTF] or [FTF].

public bool IsCoveredBy()

Returns

bool

true if the first Geometry is covered by the second

IsCovers()

Tests if this matrix matches [T**FF*] or [TFF*] or [TFF] or [**TFF].

public bool IsCovers()

Returns

bool

true if the first Geometry covers the second

IsCrosses(Dimension, Dimension)

Tests whether this geometry crosses the specified geometry.

public bool IsCrosses(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)

Parameters

dimensionOfGeometryA Dimension

The dimension of the first Geometry.

dimensionOfGeometryB Dimension

The dimension of the second Geometry.

Returns

bool

true if the two Geometry s related by this matrix cross.

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
For any other combination of dimensions this predicate returns 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***].

public bool IsDisjoint()

Returns

bool

true if the two Geometry's related by this matrix are disjoint.

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.
public bool IsEquals(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)

Parameters

dimensionOfGeometryA Dimension

The dimension of the first Geometry.

dimensionOfGeometryB Dimension

The dimension of the second Geometry.

Returns

bool

true if the two Geometrys related by this matrix are equal; the Geometrys must have the same dimension to be equal.

IsIntersects()

Tests if isDisjoint returns false.

public bool IsIntersects()

Returns

bool

true if the two Geometry's related by this matrix intersect.

IsOverlaps(Dimension, Dimension)

Tests if this matrix matches

  • [T*T***T**] (for two points or two surfaces)
  • [1*T***T**] (for two curves)
public bool IsOverlaps(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)

Parameters

dimensionOfGeometryA Dimension

The dimension of the first Geometry.

dimensionOfGeometryB Dimension

The dimension of the second Geometry.

Returns

bool

true if the two Geometry s related by this matrix overlap. For this function to return true, the Geometrys must be two points, two curves or two surfaces.

IsTouches(Dimension, Dimension)

Tests if this matrix matches [FT*******], [FT***] or [FT*].

public bool IsTouches(Dimension dimensionOfGeometryA, Dimension dimensionOfGeometryB)

Parameters

dimensionOfGeometryA Dimension

The dimension of the first Geometry.

dimensionOfGeometryB Dimension

The dimension of the second Geometry.

Returns

bool

true if the two Geometry s related by this matrix touch; Returns false if both Geometrys are points.

IsTrue(Dimension)

Tests if the dimension value matches TRUE (i.e. has value 0, 1, 2 or TRUE).

public static bool IsTrue(Dimension actualDimensionValue)

Parameters

actualDimensionValue Dimension

A number that can be stored in the IntersectionMatrix. Possible values are {True, False, Dontcare, Point, Curve, Surface}

Returns

bool

true if the dimension value matches True

IsWithin()

Tests whether this matrix matches [TFF].

public bool IsWithin()

Returns

bool

true if the first Geometry is within the second.

Matches(Dimension, char)

Tests if the dimension value satisfies the dimension symbol.

public static bool Matches(Dimension actualDimensionValue, char requiredDimensionSymbol)

Parameters

actualDimensionValue Dimension

a number that can be stored in the IntersectionMatrix. Possible values are {True, False, Dontcare, 0, 1, 2}.

requiredDimensionSymbol char

A character used in the string representation of an IntersectionMatrix. Possible values are T, F, * , 0, 1, 2.

Returns

bool

true if the dimension symbol encompasses the dimension value.

Matches(string)

Tests whether this matrix matches the given matrix pattern

public bool Matches(string pattern)

Parameters

pattern string

A pattern containing nine dimension symbols with which to compare the entries of this matrix.Possible symbol values are { T, F, * , 0, 1, 2}.

Returns

bool

true if this IntersectionMatrix matches the required dimension symbols.

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.

public static bool Matches(string actualDimensionSymbols, string requiredDimensionSymbols)

Parameters

actualDimensionSymbols string

Nine dimension symbols to validate. Possible values are T, F, * , 0, 1, 2.

requiredDimensionSymbols string

Nine dimension symbols to validate against. Possible values are T, F, * , 0, 1, 2.

Returns

bool

true if each of the required dimension symbols encompass the corresponding actual dimension symbol.

Set(Location, Location, Dimension)

Changes the value of one of this IntersectionMatrix elements.

public void Set(Location row, Location column, Dimension dimensionValue)

Parameters

row Location

The row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry

column Location

The column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry

dimensionValue Dimension

The new value of the element

Set(string)

Changes the elements of this IntersectionMatrix to the dimension symbols in dimensionSymbols.

public void Set(string dimensionSymbols)

Parameters

dimensionSymbols string

Nine dimension symbols to which to set this IntersectionMatrix s elements. Possible values are {T, F, * , 0, 1, 2}

SetAll(Dimension)

Changes the elements of this IntersectionMatrix to dimensionValue.

public void SetAll(Dimension dimensionValue)

Parameters

dimensionValue Dimension

The dimension value to which to set this IntersectionMatrix s elements. Possible values True, False, Dontcare, 0, 1, 2}.

SetAtLeast(Location, Location, Dimension)

Changes the specified element to minimumDimensionValue if the element is less.

public void SetAtLeast(Location row, Location column, Dimension minimumDimensionValue)

Parameters

row Location

The row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry.

column Location

The column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry.

minimumDimensionValue Dimension

The dimension value with which to compare the element. The order of dimension values from least to greatest is True, False, Dontcare, 0, 1, 2.

SetAtLeast(string)

For each element in this IntersectionMatrix, changes the element to the corresponding minimum dimension symbol if the element is less.

public void SetAtLeast(string minimumDimensionSymbols)

Parameters

minimumDimensionSymbols string

Nine dimension symbols with which to compare the elements of this IntersectionMatrix. The order of dimension values from least to greatest is Dontcare, True, False, 0, 1, 2.

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.

public void SetAtLeastIfValid(Location row, Location column, Dimension minimumDimensionValue)

Parameters

row Location
column Location
minimumDimensionValue Dimension

ToString()

Returns a nine-character String representation of this IntersectionMatrix.

public override string ToString()

Returns

string

The nine dimension symbols of this IntersectionMatrix in row-major order.

Transpose()

Transposes this IntersectionMatrix.

public IntersectionMatrix Transpose()

Returns

IntersectionMatrix

This IntersectionMatrix as a convenience,