Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Context
mvt-postgis#29 tracks SQL-side conversions for geometry types that GISTools cannot decode. Native WKB/WKT/TWKB support belongs in this package.
Current state:
- WKB:
WKBCoderunderstands type codes 1–7 and 17 (Triangle, decoded asPolygon). Curves (8–12),PolyhedralSurface(15) andTIN(16) throwWKBCoderError.unexpectedType. - WKT:
WKTCoderparsesPoint,MultiPoint,LineString,LinearRing,Polygon,MultiPolygon,GeometryCollectionandTriangle. Curves,TINandPolyhedralSurfaceare not recognized. - TWKB:
TWKBCoderdecodes type codes 1–7 only. - Empty
Point: WKB storesPOINT EMPTYasNaNcoordinates, whichWKBCoderrejects asinvalidGeometry.Pointhas no empty representation, while the other empty geometries decode with zero parts.
Proposed work
Curves
Add decoding/encoding for WKB types 8–12 and the matching WKT names:
| Type | WKB | WKT |
|---|---|---|
CircularString |
8 | CIRCULARSTRING |
CompoundCurve |
9 | COMPOUNDCURVE |
CurvePolygon |
10 | CURVEPOLYGON |
MultiCurve |
11 | MULTICURVE |
MultiSurface |
12 | MULTISURFACE |
Decide between:
- native curve types in the geometry model, or
- linearizing into
LineString/Polygon/Multi*with a documented tolerance.
TIN and PolyhedralSurface
TINis WKB type 16;PolyhedralSurfaceis 15.- Proposed mapping: decode
TINpatches asPolygontriangles andPolyhedralSurfacepatches as polygons, then return aMultiPolygonorGeometryCollection. - Add WKT parsing/serialization for both.
- Confirm whether TWKB can represent them; if not, document the limitation.
Empty Point
Choose a representation:
- an
EmptyGeometrytype, or - an optional/empty coordinate on
Point, or - an explicit decode error with a documented rule.
If a representation is added, make empty handling consistent across Point, LineString, Polygon, the multi-types and GeometryCollection in WKB, WKT and TWKB.
Coders and dimensions
- Keep
Z,MandZMhandling consistent with the existing WKB flag decoding. - Preserve SRID handling for WKB and TWKB.
- Ensure encoding is the inverse of decoding where the mapping is lossless.
Acceptance criteria
- Deterministic WKB, WKT and TWKB fixtures for every type above.
- Decode and encode tests, including
Z/M/ZMand SRID variants. - Lossy mappings are documented and asserted.
- Empty
Pointbehavior is explicit in all three coders. - DocC support matrix updated.
-
mvt-postgis#29can either drop its SQL fallback or keep it as compatibility.
Out of scope
- Abstract
CurveandSurfacetypes: they cannot appear as concrete geometry values. - PostGIS-specific SQL conversion functions (
ST_CurveToLine,ST_UnaryUnion,ST_Dump) — those stay inmvt-postgis#29.
References
mvt-postgis#29,mvt-postgis#15Sources/GISTools/GeoJson/WKBCoder.swiftSources/GISTools/GeoJson/WKTCoder.swiftSources/GISTools/GeoJson/TWKBCoder.swift
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
trasch commentedon Oct 28, 2026
Follow-up from Outdooractive/mvt-postgis#29: the SQL-side conversions (
ST_CurveToLine,ST_UnaryUnion,ST_Dump/ST_Collect) stay in mvt-postgis; this issue covers native WKB/WKT/TWKB support.trasch commentedon Oct 28, 2026
Implemented in #405.
LineString/Polygon/Multi*.TINandPolyhedralSurfacedecode toMultiPolygon.POINT EMPTYdecodes to an emptyMultiPoint; WKT supportsEMPTYfor all types and encodes it asTYPE EMPTY.GeometryCollectionbecause that is how PostGIS encodes it. Curves andPolyhedralSurfaceare explicitly unsupported in TWKB.Verification: 3057 tests, 90.34% coverage, DocC clean, no new formatting violations.