com.vividsolutions.jts.geom

Class IntersectionMatrix

Implemented Interfaces:
Cloneable

public class IntersectionMatrix
extends java.lang.Object
implements Cloneable

A Dimensionally Extended Nine-Intersection Model (DE-9IM) matrix. This class can used to represent both computed DE-9IM's (like 212FF1FF2) as well as patterns for matching them (like T*T******).

Methods are provided to:

For a description of the DE-9IM, see the OpenGIS Simple Features Specification for SQL .

Version:
1.7

Constructor Summary

IntersectionMatrix()
Creates an IntersectionMatrix with FALSE dimension values.
IntersectionMatrix(String elements)
Creates an IntersectionMatrix with the given dimension symbols.
IntersectionMatrix(IntersectionMatrix other)
Creates an IntersectionMatrix with the same elements as other.

Method Summary

void
add(IntersectionMatrix im)
Adds one matrix to another.
int
get(int row, int column)
Returns the value of one of this IntersectionMatrixs elements.
boolean
isContains()
Returns true if this IntersectionMatrix is T*****FF*.
boolean
isCoveredBy()
Returns true if this IntersectionMatrix is T*F**F*** or *TF**F*** or **FT*F*** or **F*TF***
boolean
isCovers()
Returns true if this IntersectionMatrix is T*****FF* or *T****FF* or ***T**FF* or ****T*FF*
boolean
isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB)
Returns true if this geometry crosses the specified geometry.
boolean
isDisjoint()
Returns true if this IntersectionMatrix is FF*FF****.
boolean
isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB)
Returns true if this IntersectionMatrix is T*F**FFF*.
boolean
isIntersects()
Returns true if isDisjoint returns false.
boolean
isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB)
Returns true if this IntersectionMatrix is
  • T*T***T** (for two points or two surfaces)
  • 1*T***T** (for two curves)
.
boolean
isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB)
Returns true if this IntersectionMatrix is FT*******, F**T***** or F***T****.
boolean
isWithin()
Returns true if this IntersectionMatrix is T*F**F***.
boolean
matches(String requiredDimensionSymbols)
Returns whether the elements of this IntersectionMatrix satisfies the required dimension symbols.
static boolean
matches(String actualDimensionSymbols, String requiredDimensionSymbols)
Returns true if each of the actual dimension symbols satisfies the corresponding required dimension symbol.
static boolean
matches(int actualDimensionValue, char requiredDimensionSymbol)
Returns true if the dimension value satisfies the dimension symbol.
void
set(String dimensionSymbols)
Changes the elements of this IntersectionMatrix to the dimension symbols in dimensionSymbols.
void
set(int row, int column, int dimensionValue)
Changes the value of one of this IntersectionMatrixs elements.
void
setAll(int dimensionValue)
Changes the elements of this IntersectionMatrix to dimensionValue .
void
setAtLeast(String minimumDimensionSymbols)
For each element in this IntersectionMatrix, changes the element to the corresponding minimum dimension symbol if the element is less.
void
setAtLeast(int row, int column, int minimumDimensionValue)
Changes the specified element to minimumDimensionValue if the element is less.
void
setAtLeastIfValid(int row, int column, int minimumDimensionValue)
If row >= 0 and column >= 0, changes the specified element to minimumDimensionValue if the element is less.
String
toString()
Returns a nine-character String representation of this IntersectionMatrix .
IntersectionMatrix
transpose()
Transposes this IntersectionMatrix.

Constructor Details

IntersectionMatrix

public IntersectionMatrix()
Creates an IntersectionMatrix with FALSE dimension values.

IntersectionMatrix

public IntersectionMatrix(String elements)
Creates an IntersectionMatrix with the given dimension symbols.
Parameters:
elements - a String of nine dimension symbols in row major order

IntersectionMatrix

public IntersectionMatrix(IntersectionMatrix other)
Creates an IntersectionMatrix with the same elements as other.
Parameters:
other - an IntersectionMatrix to copy

Method Details

add

public void add(IntersectionMatrix im)
Adds one matrix to another. Addition is defined by taking the maximum dimension value of each position in the summand matrices.
Parameters:
im - the matrix to add

get

public int get(int row,
               int column)
Returns the value of one of this IntersectionMatrixs elements.
Parameters:
row - the row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry
column - the column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry
Returns:
the dimension value at the given matrix position.

isContains

public boolean isContains()
Returns true if this IntersectionMatrix is T*****FF*.
Returns:
true if the first Geometry contains the second

isCoveredBy

public boolean isCoveredBy()
Returns true if this IntersectionMatrix is T*F**F*** or *TF**F*** or **FT*F*** or **F*TF***
Returns:
true if the first Geometry covers the second

isCovers

public boolean isCovers()
Returns true if this IntersectionMatrix is T*****FF* or *T****FF* or ***T**FF* or ****T*FF*
Returns:
true if the first Geometry covers the second

isCrosses

public boolean isCrosses(int dimensionOfGeometryA,
                         int dimensionOfGeometryB)
Returns true if this geometry crosses the specified geometry.

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 is
    • T*T****** (for P/L, P/A, and L/A situations)
    • T*****T** (for L/P, L/A, and A/L situations)
    • 0******** (for L/L situations)
    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.

    Parameters:
    dimensionOfGeometryA - the dimension of the first Geometry
    dimensionOfGeometryB - the dimension of the second Geometry
    Returns:
    true if the two Geometrys related by this IntersectionMatrix cross.

    isDisjoint

    public boolean isDisjoint()
    Returns true if this IntersectionMatrix is FF*FF****.
    Returns:
    true if the two Geometrys related by this IntersectionMatrix are disjoint

    isEquals

    public boolean isEquals(int dimensionOfGeometryA,
                            int dimensionOfGeometryB)
    Returns true if this IntersectionMatrix is T*F**FFF*.
    Parameters:
    dimensionOfGeometryA - the dimension of the first Geometry
    dimensionOfGeometryB - the dimension of the second Geometry
    Returns:
    true if the two Geometry s related by this IntersectionMatrix are equal; the Geometrys must have the same dimension for this function to return true

    isIntersects

    public boolean isIntersects()
    Returns true if isDisjoint returns false.
    Returns:
    true if the two Geometrys related by this IntersectionMatrix intersect

    isOverlaps

    public boolean isOverlaps(int dimensionOfGeometryA,
                              int dimensionOfGeometryB)
    Returns true if this IntersectionMatrix is
    • T*T***T** (for two points or two surfaces)
    • 1*T***T** (for two curves)
    .
    Parameters:
    dimensionOfGeometryA - the dimension of the first Geometry
    dimensionOfGeometryB - the dimension of the second Geometry
    Returns:
    true if the two Geometry s related by this IntersectionMatrix overlap. For this function to return true, the Geometrys must be two points, two curves or two surfaces.

    isTouches

    public boolean isTouches(int dimensionOfGeometryA,
                             int dimensionOfGeometryB)
    Returns true if this IntersectionMatrix is FT*******, F**T***** or F***T****.
    Parameters:
    dimensionOfGeometryA - the dimension of the first Geometry
    dimensionOfGeometryB - the dimension of the second Geometry
    Returns:
    true if the two Geometry s related by this IntersectionMatrix touch; Returns false if both Geometrys are points.

    isWithin

    public boolean isWithin()
    Returns true if this IntersectionMatrix is T*F**F***.
    Returns:
    true if the first Geometry is within the second

    matches

    public boolean matches(String requiredDimensionSymbols)
    Returns whether the elements of this IntersectionMatrix satisfies the required dimension symbols.
    Parameters:
    requiredDimensionSymbols - nine dimension symbols with which to compare the elements of this IntersectionMatrix. Possible values are {T, F, * , 0, 1, 2}.
    Returns:
    true if this IntersectionMatrix matches the required dimension symbols

    matches

    public static boolean matches(String actualDimensionSymbols,
                                  String requiredDimensionSymbols)
    Returns true if each of the actual dimension symbols satisfies the corresponding required dimension symbol.
    Parameters:
    actualDimensionSymbols - nine dimension symbols to validate. Possible values are {T, F, * , 0, 1, 2}.
    requiredDimensionSymbols - nine dimension symbols to validate against. Possible values are {T, F, * , 0, 1, 2}.
    Returns:
    true if each of the required dimension symbols encompass the corresponding actual dimension symbol

    matches

    public static boolean matches(int actualDimensionValue,
                                  char requiredDimensionSymbol)
    Returns true if the dimension value satisfies the dimension symbol.
    Parameters:
    actualDimensionValue - a number that can be stored in the IntersectionMatrix . Possible values are {TRUE, FALSE, DONTCARE, 0, 1, 2}.
    requiredDimensionSymbol - a character used in the string representation of an IntersectionMatrix. Possible values are {T, F, * , 0, 1, 2}.
    Returns:
    true if the dimension symbol encompasses the dimension value

    set

    public void set(String dimensionSymbols)
    Changes the elements of this IntersectionMatrix to the dimension symbols in dimensionSymbols.
    Parameters:
    dimensionSymbols - nine dimension symbols to which to set this IntersectionMatrix s elements. Possible values are {T, F, * , 0, 1, 2}

    set

    public void set(int row,
                    int column,
                    int dimensionValue)
    Changes the value of one of this IntersectionMatrixs elements.
    Parameters:
    row - the row of this IntersectionMatrix, indicating the interior, boundary or exterior of the first Geometry
    column - the column of this IntersectionMatrix, indicating the interior, boundary or exterior of the second Geometry
    dimensionValue - the new value of the element

    setAll

    public void setAll(int dimensionValue)
    Changes the elements of this IntersectionMatrix to dimensionValue .
    Parameters:
    dimensionValue - the dimension value to which to set this IntersectionMatrix s elements. Possible values {TRUE, FALSE, DONTCARE, 0, 1, 2} .

    setAtLeast

    public void setAtLeast(String minimumDimensionSymbols)
    For each element in this IntersectionMatrix, changes the element to the corresponding minimum dimension symbol if the element is less.
    Parameters:
    minimumDimensionSymbols - 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} .

    setAtLeast

    public void setAtLeast(int row,
                           int column,
                           int minimumDimensionValue)
    Changes the specified element to minimumDimensionValue if the element is less.
    Parameters:
    row - the row of this IntersectionMatrix , indicating the interior, boundary or exterior of the first Geometry
    column - the column of this IntersectionMatrix , indicating the interior, boundary or exterior of the second Geometry
    minimumDimensionValue - the dimension value with which to compare the element. The order of dimension values from least to greatest is {DONTCARE, TRUE, FALSE, 0, 1, 2}.

    setAtLeastIfValid

    public void setAtLeastIfValid(int row,
                                  int column,
                                  int minimumDimensionValue)
    If row >= 0 and column >= 0, changes the specified element to minimumDimensionValue if the element is less. Does nothing if row <0 or column <320.
    Parameters:
    row - the row of this IntersectionMatrix , indicating the interior, boundary or exterior of the first Geometry
    column - the column of this IntersectionMatrix , indicating the interior, boundary or exterior of the second Geometry
    minimumDimensionValue - the dimension value with which to compare the element. The order of dimension values from least to greatest is {DONTCARE, TRUE, FALSE, 0, 1, 2}.

    toString

    public String toString()
    Returns a nine-character String representation of this IntersectionMatrix .
    Returns:
    the nine dimension symbols of this IntersectionMatrix in row-major order.

    transpose

    public IntersectionMatrix transpose()
    Transposes this IntersectionMatrix.
    Returns:
    this IntersectionMatrix as a convenience