Class GeometryUtils

Object
io.delta.kernel.internal.util.GeometryUtils

public class GeometryUtils extends Object
Utility for parsing and formatting WKT POINT strings for geometry/geography stats.
  • Method Details

    • formatPointWKT

      public static String formatPointWKT(double x, double y, OptionalDouble z, OptionalDouble m)
      Formats x/y (and optional z/m) coordinates as a WKT POINT string. Uses standard OGC WKT format: "POINT(1.0 2.0)", "POINT Z (1.0 2.0 3.0)", "POINT ZM (1.0 2.0 3.0 4.0)".
    • validatePointWKT

      public static void validatePointWKT(String wkt)
      Validates that the given string is a well-formed WKT POINT. Throws KernelException if the string is null or not a valid POINT WKT.
    • parsePointXY

      public static double[] parsePointXY(String wkt)
      Parses only the x and y coordinates from a WKT POINT string. Returns double[]{x, y}. Z and M coordinates are validated but not returned because stats bounding boxes only use 2D coordinates.

      Supported formats: POINT(x y), POINT Z (x y z), POINT M (x y m), POINT ZM (x y z m), POINT EMPTY, POINT Z EMPTY, POINT M EMPTY, POINT ZM EMPTY.

      All EMPTY variants return {NaN, NaN}.

      Throws:
      IllegalArgumentException - if not a valid POINT WKT
    • validateGeographyPointWKT

      public static void validateGeographyPointWKT(String wkt)
      Validates that the given WKT POINT is a valid geography point with coordinates in range: longitude in [-180, 180] and latitude in [-90, 90]. Throws KernelException if invalid.
    • validateGeographyCoordinates

      public static void validateGeographyCoordinates(double lon, double lat, String wkt)
      Validates that longitude is in [-180, 180] and latitude is in [-90, 90]. Throws KernelException if out of range.