Architecture decision record · ADR-0013
betterknown for the WKT codec
The wkt codec uses betterknown.
Context
wkx reads Buffer.prototype when it loads. A browser has no Buffer, so @millwork-ts/geo/wkt
failed to load in an app with no Buffer polyfill. We looked at two WKT libraries that need no
Buffer:
betterknown1.2.0 has its own types. It reads WKT keywords in each case, and it gives plain GeoJSON.@terraformer/wkt2.2.2 reads only upper-case keywords. It addsproperties: { z: true }to a 3D geometry, which is not part of a GeoJSON geometry.
Decision drivers
Not recorded in the original ADR.
Options considered
Not recorded in the original ADR.
Decision
- The
wktcodec usesbetterknown. The peer range is^1.0.5. Version 1.0.4 and lower read only upper-case keywords, so 1.0.5 is the lowest version that passes the package tests. - A test deletes
globalThis.Buffer, loads thewktentry again, and reads and writes WKT.
Consequences
serializewrites a space after the keyword:POINT (1 2), notPOINT(1 2). The codec still reads both forms, andequalscompares the written form, so a dirty check does not change.EMPTYgeometries (POINT EMPTY) are bad input. betterknown givesnullfor them, andnullis not a geometry.- EWKT (
SRID=4326;…) stays bad input. GeoJSON has no SRID, so a write would drop it.
Confirmation
Not recorded in the original ADR.
Interview record
Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.
| Question | Answer | Source |
|---|---|---|
| Where does the text of this page come from? | From the Markdown file docs/adr/0013-wkt-library.md at commit c8154b0. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so. | Document: docs/adr/0013-wkt-library.md |
Changelog
| Date | Author | Change |
|---|---|---|
| 2026-12-01 | Joe Gaudet | Status in the Markdown file: Accepted. This replaces wkx in @millwork-ts/geo/wkt. |
| 2026-12-01 | Joe Gaudet | Commit 0a16254: Build Millwork 1.0 (#1) |
| 2026-12-04 | Joe Gaudet (agent) | Converted from docs/adr/0013-wkt-library.md to this page. The text is the text of the Markdown file. |
The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.