Skip to content

[BUG]: Empty Geography LineStrings produce malformed WKB #3200

Description

@jiayuasu

Problem

An empty Geography LineString does not produce valid WKB. Structural functions that convert the value to JTS therefore fail:

SELECT ST_NPoints(ST_GeogFromWKT('LINESTRING EMPTY', 4326));

The call throws RuntimeException: Failed to parse WKB to JTS Geometry instead of returning 0.

Root cause

WKBWriter.writePolyline writes the LineString header but does not write the required zero coordinate count when SinglePolylineGeography has no S2 polyline.

Expected behavior

  • Serialize an empty Geography LineString as valid WKB with a coordinate count of zero.
  • Preserve the SRID.
  • Allow WKB-to-JTS and WKB-to-S2 round trips.
  • Return 0 from structural accessors such as ST_NPoints.

This was discovered while reviewing the Geography overload for ST_MakeLine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions