Class HilbertParallelPolygonUnion

java.lang.Object
com.github.micycle1.geoblitz.HilbertParallelPolygonUnion

public class HilbertParallelPolygonUnion extends Object
High-performance polygon union built on Hilbert-ordered batching and parallel reduction.

This utility provides a faster alternative to JTS's CascadedPolygonUnion for large collections by:

  • sorting inputs in-place by a Hilbert space-filling-curve key derived from their envelopes, improving spatial locality of subsequent unions; and
  • performing the union as a parallel reduction using Java streams.
The algorithm is intended for polygonal inputs (Polygon or MultiPolygon). If intermediate union results contain non-polygonal artifacts (e.g., due to precision effects), those are discarded and only polygonal components are returned (as a Polygon if one component remains, otherwise as a MultiPolygon).

Notes:

  • The input list is reordered in-place.
  • The list must be non-empty; the result GeometryFactory is taken from the first element.
Author:
Michael Carleton
See Also:
  • CascadedPolygonUnion
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.locationtech.jts.geom.Geometry
    union(List<org.locationtech.jts.geom.Geometry> geoms)
    Computes the union of the provided geometries using Hilbert-order sorting and a parallel reduction.
    static org.locationtech.jts.geom.Geometry
    union(org.locationtech.jts.geom.Geometry geom)
    Computes the union of the provided geometry using Hilbert-order sorting and a parallel reduction.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • union

      public static org.locationtech.jts.geom.Geometry union(org.locationtech.jts.geom.Geometry geom)
      Computes the union of the provided geometry using Hilbert-order sorting and a parallel reduction.

      The input geometries are first sorted in-place by a Hilbert curve key computed from each geometry's envelope to cluster nearby geometries. The union is then evaluated in parallel.

      Any non-polygonal components produced during union are discarded, and the returned geometry is guaranteed to be polygonal:

      • a Polygon if the result contains a single polygon, or
      • a MultiPolygon if multiple polygons remain.
      The result is built using the GeometryFactory of the first input geometry.
      Parameters:
      geom - a geometry (intended for Polygon collection or MultiPolygon)
      Returns:
      a polygonal geometry representing the union (Polygon or MultiPolygon)
    • union

      public static org.locationtech.jts.geom.Geometry union(List<org.locationtech.jts.geom.Geometry> geoms)
      Computes the union of the provided geometries using Hilbert-order sorting and a parallel reduction.

      The input list is first sorted in-place by a Hilbert curve key computed from each geometry's envelope to cluster nearby geometries. The union is then evaluated in parallel.

      Any non-polygonal components produced during union are discarded, and the returned geometry is guaranteed to be polygonal:

      • a Polygon if the result contains a single polygon, or
      • a MultiPolygon if multiple polygons remain.
      The result is built using the GeometryFactory of the first input geometry.
      Parameters:
      geoms - a non-null, non-empty list of geometries (intended for Polygon or MultiPolygon)
      Returns:
      a polygonal geometry representing the union (Polygon or MultiPolygon)