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.
Problem
An empty Geography LineString does not produce valid WKB. Structural functions that convert the value to JTS therefore fail:
The call throws
RuntimeException: Failed to parse WKB to JTS Geometryinstead of returning0.Root cause
WKBWriter.writePolylinewrites the LineString header but does not write the required zero coordinate count whenSinglePolylineGeographyhas no S2 polyline.Expected behavior
0from structural accessors such asST_NPoints.This was discovered while reviewing the Geography overload for
ST_MakeLine.