The Java Topology Suite (JTS)
The
Java Topology Suite (JTS) provides
a wealth of geometric functions for 2D geometry,
that's useful for computational geometry
and application domains
such as geographical information systems. A
summary of its features can be found
here.
One of JTS's tools is TestBuilder
for visualizing geometries, but I found
it more useful to implement a simple
GeomsViewer.java,
which is called from my examples. All of the
"Screenshot" links included with the examples go to images
generated by GeomsViewer.
Note: GeoViewer uses a JPanel
as a canvas, so the y-axis runs down the window. This means that
a shape with its points ordered clockwise appears to be
drawn in a counter-clockwise direction. See
Triangles.java for an example
of this drawback.
My Examples
- BuildGeoms.java
creates a variety of geometries, including
Point, MultiPoint,
LineString, MultiLineString,
Polygon, polygons with holes
(LinearRing), MultiPolygon,
and GeometryCollection.
Screenshot.
- BuildShapes.java
builds shapes from collections of points; moves
and rotates a shape using JTS's AffineTransformation class, and
tests for similarity using the HausdorffSimilarityMeasure
and AreaSimilarityMeasure classes.
Screenshot.
- WTKExamples.java
converts WTK
(Well-Known Text) strings into geometries,
loads WTK shapes from a file, and writes them out.
Screenshot.
The input data file is data1.txt.
- GeomOps.java
illustrates an assortment of geometry methods, including
getArea(), getLength(),
distance(), nearestPoints(),
isWithinDistance(),
contains(), within(), coveredBy(),
intersects(), intersection(),
disjoint(),
crosses(), touches(), overlaps(),
equals(), and equalsExact().
Screenshot.
- ClosestPoints.java
computes the distance and closest points between geometries using
JTS's DistanceOp.
Screenshot.
- Triangles.java
employs computational geometry methods
commonly used with triangles, mostly via JTS's
Triangle class. It calculates
interior angles, performs
acuteness tests, measures
lengths, perimeters, areas, and finds
the centroid, circumcenter, orthocenter, and incenter.
Screenshot.
- Overlays.java
utilizes the boolean shape operations:
union, intersection, difference, and symmetric difference,
and also performs shape buffering.
Screenshots:
here,
here.
- Polygonize.java
uses the Polygonizer class to convert lines into polygons.
Screenshot.
- LineAdjust.java
utilizes the DouglasPeuckerSimplifier class to simplify lines, and
Densifier to add points.
Screenshot.
- Dissolver.java
shows how to use the LineDissolver class.
Screenshot.
- LinesMerge.java
sews lines together using LineMerger.
Screenshot.
- Fixer.java
employs GeometryFixer to fix invalid
geometries by spliting them into parts
or by reorganizing coordinates.
Screenshot.
- TreeSearch.java
can use Quadtree or Kdtree to determine which
points lie inside a rectangle.
Screenshot.
- Covers.java:
applies three different point coverings:
Delaunay triangulation, Voronoi diagramming, and
the convex hull.
Screenshots:
here,
here, and
here.
- Triangulate.java
triangulates a polygon in two ways – using
constrained Delaunay processing and
polygon triangulation.
Screenshot.
- Conforming.java
triangulates using the
ConformingDelaunayTriangulationBuilder
class.
Screenshot.
- Concavity.java
calculates concave hulls.
Screenshot.
- Utils.java: a
repository for various utilities.
- GeomsViewer.java
creates a window that displays JTS geometries as shapes
in a JPanel.
Other Downloads and Links
Dr. Andrew Davison
E-mail: ad@coe.psu.ac.th
Back to the third-party libraries page