Class DiskUnion
This algorithm maintains the exact circular arcs that form the union
boundary, deferring linearization until the final geometry construction. This
approach is significantly faster than polygonizing each circle and using JTS
CascadedPolygonUnion, particularly when high-fidelity circle
approximations would require many vertices.
- Author:
- Michael Carleton
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA boundary arc of the union, oriented so the union interior is on the left.static final classResult: boundary as arc cycles (outer shells + holes).static final classOne closed boundary component: a cyclic list of arcs.static final classImmutable disk definition used by this algorithm. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.locationtech.jts.geom.GeometryComputes the union of the given circles and linearizes the result to aGeometry.static org.locationtech.jts.geom.GeometryComputes the union of the given circles with specified geometric tolerance.
-
Constructor Details
-
DiskUnion
public DiskUnion()
-
-
Method Details
-
union
public static org.locationtech.jts.geom.Geometry union(List<org.locationtech.jts.geom.Coordinate> circles, double maxSegmentLength) Computes the union of the given circles and linearizes the result to aGeometry.Circles are specified as
Coordinateobjects wherexandydefine the center point andzdefines the radius. The algorithm computes the exact arc boundary of the union, then approximates it with linear segments.The
maxSegmentLengthparameter controls the linearization fidelity. Smaller values produce smoother approximations at the cost of more vertices. For a circle of radiusr, approximately2πr / maxSegmentLengthsegments will be used per full circle.This overload uses a default geometric tolerance of
1e-9. For coordinate systems with unusual magnitude, useunion(List, double, double)to specify an appropriate tolerance.- Parameters:
circles- list of circles as Coordinates (x,y= center,z= radius)maxSegmentLength- maximum chord length for linearized arc segments- Returns:
Geometry(Polygon or MultiPolygon) representing the union- Throws:
IllegalArgumentException- if any circle has NaN radius
-
union
public static org.locationtech.jts.geom.Geometry union(List<org.locationtech.jts.geom.Coordinate> circles, double maxSegmentLength, double eps) Computes the union of the given circles with specified geometric tolerance.This variant allows explicit control over the geometric tolerance
eps, which governs coordinate snapping, duplicate circle detection, and intersection point deduplication. The tolerance should be chosen relative to the coordinate system magnitude and desired precision.The
epsparameter affects:- Vertex snapping: points within
epsare merged to a single node - Circle deduplication: circles with centers and radii within
epsare treated as identical - Intersection detection: used as a numerical threshold in circle-circle relation tests
- Parameters:
circles- list of circles as Coordinates (x,y= center,z= radius)maxSegmentLength- maximum chord length for linearized arc segmentseps- geometric tolerance for snapping and intersection detection (typically 1e-9 to 1e-6)- Returns:
Geometry(Polygon or MultiPolygon) representing the union- Throws:
IllegalArgumentException- if any circle has NaN radius
- Vertex snapping: points within
-