java.lang.Cloneable
public class IntersectionMatrix
extends java.lang.Object
implements java.lang.Cloneable
Geometry
s.
This class can also represent matrix patterns (such as "T*T******")
which are used for matching instances of DE-9IM matrices.
Methods are provided to:
For a description of the DE-9IM and the spatial predicates derived from it, see the OGC 99-049 OpenGIS Simple Features Specification for SQL, as well as OGC 06-103r4 OpenGIS Implementation Standard for Geographic information - Simple feature access - Part 1: Common architecture (which provides some further details on certain predicate specifications).
The entries of the matrix are defined by the constants in the Dimension
class.
The indices of the matrix represent the topological locations
that occur in a geometry (Interior, Boundary, Exterior).
These are provided as constants in the Location
class.
Constructor | Description |
---|---|
IntersectionMatrix() |
Creates an
IntersectionMatrix with FALSE
dimension values. |
IntersectionMatrix(java.lang.String elements) |
Creates an
IntersectionMatrix with the given dimension
symbols. |
IntersectionMatrix(IntersectionMatrix other) |
Creates an
IntersectionMatrix with the same elements as
other . |
Modifier and Type | Method | Description |
---|---|---|
void |
add(IntersectionMatrix im) |
Adds one matrix to another.
|
int |
get(int row,
int column) |
Returns the value of one of this matrix
entries.
|
boolean |
isContains() |
Tests whether 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) |
Tests whether this geometry crosses the
specified geometry.
|
boolean |
isDisjoint() |
Returns
true if this IntersectionMatrix is
FF*FF****. |
boolean |
isEquals(int dimensionOfGeometryA,
int dimensionOfGeometryB) |
Tests whether the argument dimensions are equal and
this
IntersectionMatrix matches
the pattern 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****. |
static boolean |
isTrue(int actualDimensionValue) |
Tests if the dimension value matches TRUE
(i.e.
|
boolean |
isWithin() |
Tests whether this
IntersectionMatrix is
T*F**F***. |
static boolean |
matches(int actualDimensionValue,
char requiredDimensionSymbol) |
Tests if the dimension value satisfies the dimension symbol.
|
boolean |
matches(java.lang.String requiredDimensionSymbols) |
Returns whether the elements of this
IntersectionMatrix
satisfies the required dimension symbols. |
static boolean |
matches(java.lang.String actualDimensionSymbols,
java.lang.String requiredDimensionSymbols) |
Tests if each of the actual dimension symbols in a matrix string satisfies the
corresponding required dimension symbol in a pattern string.
|
void |
set(int row,
int column,
int dimensionValue) |
Changes the value of one of this
IntersectionMatrix s
elements. |
void |
set(java.lang.String dimensionSymbols) |
Changes the elements of this
IntersectionMatrix to the
dimension symbols in dimensionSymbols . |
void |
setAll(int dimensionValue) |
Changes the elements of this
IntersectionMatrix to dimensionValue
. |
void |
setAtLeast(int row,
int column,
int minimumDimensionValue) |
Changes the specified element to
minimumDimensionValue if the
element is less. |
void |
setAtLeast(java.lang.String minimumDimensionSymbols) |
For each element in this
IntersectionMatrix , changes the
element to the corresponding minimum dimension symbol 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. |
java.lang.String |
toString() |
Returns a nine-character
String representation of this IntersectionMatrix
. |
IntersectionMatrix |
transpose() |
Transposes this IntersectionMatrix.
|
public IntersectionMatrix()
IntersectionMatrix
with FALSE
dimension values.public IntersectionMatrix(java.lang.String elements)
IntersectionMatrix
with the given dimension
symbols.elements
- a String of nine dimension symbols in row major orderpublic IntersectionMatrix(IntersectionMatrix other)
IntersectionMatrix
with the same elements as
other
.other
- an IntersectionMatrix
to copypublic void add(IntersectionMatrix im)
im
- the matrix to addpublic static boolean isTrue(int actualDimensionValue)
actualDimensionValue
- a number that can be stored in the IntersectionMatrix
. Possible values are {TRUE, FALSE, DONTCARE, 0, 1, 2}
.public static boolean matches(int actualDimensionValue, char requiredDimensionSymbol)
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}
.public static boolean matches(java.lang.String actualDimensionSymbols, java.lang.String requiredDimensionSymbols)
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}
.public void set(int row, int column, int dimensionValue)
IntersectionMatrix
s
elements.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 elementpublic void set(java.lang.String dimensionSymbols)
IntersectionMatrix
to the
dimension symbols in dimensionSymbols
.dimensionSymbols
- nine dimension symbols to which to set this IntersectionMatrix
s elements. Possible values are {T, F, * , 0, 1, 2}
public void setAtLeast(int row, int column, int minimumDimensionValue)
minimumDimensionValue
if the
element is less.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}
.public void setAtLeastIfValid(int row, int column, int minimumDimensionValue)
minimumDimensionValue
if the element is less. Does nothing if row <0 or column < 0.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}
.public void setAtLeast(java.lang.String minimumDimensionSymbols)
IntersectionMatrix
, changes the
element to the corresponding minimum dimension symbol if the element is
less.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}
.public void setAll(int dimensionValue)
IntersectionMatrix
to dimensionValue
.dimensionValue
- the dimension value to which to set this IntersectionMatrix
s elements. Possible values {TRUE, FALSE, DONTCARE, 0, 1, 2}
.public int get(int row, int column)
Location
class.
The value returned is a constant
from the Dimension
class.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
public boolean isDisjoint()
true
if this IntersectionMatrix
is
FF*FF****.true
if the two Geometry
s related by
this IntersectionMatrix
are disjointpublic boolean isIntersects()
true
if isDisjoint
returns false.true
if the two Geometry
s related by
this IntersectionMatrix
intersectpublic boolean isTouches(int dimensionOfGeometryA, int dimensionOfGeometryB)
true
if this IntersectionMatrix
is
FT*******, F**T***** or F***T****.dimensionOfGeometryA
- the dimension of the first Geometry
dimensionOfGeometryB
- the dimension of the second Geometry
true
if the two Geometry
s related by this IntersectionMatrix
touch; Returns false
if both Geometry
s are points.public boolean isCrosses(int dimensionOfGeometryA, int dimensionOfGeometryB)
The crosses
predicate has the following equivalent definitions:
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.
dimensionOfGeometryA
- the dimension of the first Geometry
dimensionOfGeometryB
- the dimension of the second Geometry
true
if the two Geometry
s
related by this IntersectionMatrix
cross.public boolean isWithin()
IntersectionMatrix
is
T*F**F***.true
if the first Geometry
is within
the secondpublic boolean isContains()
IntersectionMatrix
is
T*****FF*.true
if the first Geometry
contains the
secondpublic boolean isCovers()
true
if this IntersectionMatrix
is
T*****FF*
or *T****FF*
or ***T**FF*
or ****T*FF*
true
if the first Geometry
covers the
secondpublic boolean isCoveredBy()
true
if this IntersectionMatrix
is
T*F**F***
or *TF**F***
or **FT*F***
or **F*TF***
true
if the first Geometry
is covered by the secondpublic boolean isEquals(int dimensionOfGeometryA, int dimensionOfGeometryB)
IntersectionMatrix
matches
the pattern T*F**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.
dimensionOfGeometryA
- the dimension of the first Geometry
dimensionOfGeometryB
- the dimension of the second Geometry
true
if the two Geometry
s
related by this IntersectionMatrix
are equal; the
Geometry
s must have the same dimension to be equalpublic boolean isOverlaps(int dimensionOfGeometryA, int dimensionOfGeometryB)
true
if this IntersectionMatrix
is
dimensionOfGeometryA
- the dimension of the first Geometry
dimensionOfGeometryB
- the dimension of the second Geometry
true
if the two Geometry
s
related by this IntersectionMatrix
overlap. For this
function to return true
, the Geometry
s must
be two points, two curves or two surfaces.public boolean matches(java.lang.String requiredDimensionSymbols)
IntersectionMatrix
satisfies the required dimension symbols.requiredDimensionSymbols
- nine dimension symbols with which to
compare the elements of this IntersectionMatrix
. Possible
values are {T, F, * , 0, 1, 2}
.true
if this IntersectionMatrix
matches the required dimension symbolspublic IntersectionMatrix transpose()
IntersectionMatrix
as a conveniencepublic java.lang.String toString()
String
representation of this IntersectionMatrix
.toString
in class java.lang.Object
IntersectionMatrix
in row-major order.Copyright © 2018. All rights reserved.