JTS is an API which provides:
touch
and overlap) and spatial analysis
methods (such as intersection and buffer)
Point
|
MultiPoint
|
LineString
|
LinearRing
|
MultiLineString
|
Polygon
|
MultiPolygon
|
GeometryCollection
|
As in the SFS, Geometries in JTS have an Interior, a Boundary, and an Exterior.
The algorithm used for computing Binary Predicates in JTS is robust, and is not
subject to dimensional collapse problems.
Example:
Binary Predicates
JTS supports a complete set of binary predicates. Binary predicate methods take
two Geometries as arguments and return a boolean indicating whether the
Geometries have the named spatial relationship. The relationships supported are
equals, disjoint, intersects, touches, crosses, within, contains, overlaps.
Also, the general relate operator is supported. relate
can be used to determine the Dimensionally Extended 9 Intersection Matrix
(DE-9IM) which completely describes the relationship of two Geometries.
Two Geometries to compare
|
The Binary Predicates
|
The DE-9IM returned by relate
|
The spatial analysis methods are:
Intersection
|
Union
|
Difference
|
Symmetric Difference
|
Convex Hull
|
Buffer (with both positive...
|
and negative widths)
|
Intersection of a LineString and a Polygon
|
Union of a MultiPoint and a LineString
|
| Fixed | Coordinates are represented as points on a grid with uniform spacing. (This can be assumed to be the integer grid, with the use of appropriate scale and offset factors). Computed coordinates are rounded to this grid. |
| Floating | Coordinates are represented as floating-point numbers. Computed coordinates may have more digits of precision than the input values (up the maximum allowed by the finite floating-point representation). |
Unfortunately, truncating coordinates moves them slightly. Line segments which would not be coincident in the exact result may become coincident in the truncated representation. For Line-Area combinations, this can lead to dimensional collapses , which are situations where a computed element has a lower dimension than it would in the exact result.
JTS handles dimensional collapses as gracefully as possible, by forming the lower-dimension Geometry resulting from the collapse. For instance, an Area-Area overlay with a dimensional collapse would return a Line or Point Geometry as an element of the result, as seen in the following diagram.
Example of a dimensional collapse in the evaluation of A.difference(B).
(The square is 1 unit tall) |
There are many approaches to dealing with the problem of robustness in geometric computation. Not surprisingly, most robust algorithms are substantially more complex and less performant than the non-robust versions. JTS attempts to deal with the problem of robustness in two ways: