Architecture decision record · ADR-0013

betterknown for the WKT codec

The wkt codec uses betterknown.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

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:

  • betterknown 1.2.0 has its own types. It reads WKT keywords in each case, and it gives plain GeoJSON.
  • @terraformer/wkt 2.2.2 reads only upper-case keywords. It adds properties: { 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 wkt codec uses betterknown. 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 the wkt entry again, and reads and writes WKT.

Consequences

  • serialize writes a space after the keyword: POINT (1 2), not POINT(1 2). The codec still reads both forms, and equals compares the written form, so a dirty check does not change.
  • EMPTY geometries (POINT EMPTY) are bad input. betterknown gives null for them, and null is 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.

QuestionAnswerSource
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

DateAuthorChange
2026-12-01Joe GaudetStatus in the Markdown file: Accepted. This replaces wkx in @millwork-ts/geo/wkt.
2026-12-01Joe GaudetCommit 0a16254: Build Millwork 1.0 (#1)
2026-12-04Joe 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.