Millwork codecs for WKT with betterknown and for geohash with ngeohash.
Install the peer of each codec that you use.
pnpm add @millwork-ts/geo @millwork-ts/core betterknown ngeohash
| Entry | Codecs | Peers |
|---|---|---|
@millwork-ts/geo |
wkt, geohash, codecs |
betterknown, ngeohash |
@millwork-ts/geo/wkt |
wkt |
betterknown |
@millwork-ts/geo/geohash |
geohash |
ngeohash |
The root entry loads both peers. If you use only one codec, import its entry.
| Codec | Value | Raw |
|---|---|---|
wkt |
a frozen GeoJSON geometry | "POINT(-79.38 43.65)" |
geohash |
a frozen { lat, lng, error, precision } |
"dpz83d" |
"POINT (1 2)". It reads both "POINT(1 2)" and "POINT (1 2)"."point(1 2)", and writes upper case."SRID=4326;POINT(1 2)". GeoJSON has no SRID, so a
write would remove it.EMPTY geometries, such as "POINT EMPTY". They are bad input,
because betterknown gives no geometry for them.Buffer, so the entry loads in a browser.lat and lng are the center of the cell. error is the half-size of the cell in
degrees. precision is the length of the hash.| Codec | Option | Type | Use |
|---|---|---|---|
geohash |
precision |
number |
The length of the hash that the codec writes. The default is the precision of the value. |
wkt: equals compares the WKT form.geohash: equals compares the point and the precision. "dpz83d" equals "DPZ83D".
"dpz83" is a different cell.Register the codecs before the store calls transformations(), because transformations()
reads the registry when it runs. See the
@millwork-ts/warp-drive README.
import { codecs } from '@millwork-ts/geo'
import { registerCodecs, valueField } from '@millwork-ts/warp-drive'
import { withDefaults } from '@warp-drive/core/reactive'
registerCodecs(codecs)
export const StoreSchema = withDefaults({
type: 'store',
fields: [valueField('area', 'wkt'), valueField('cell', 'geohash', { precision: 7 })],
})