Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 14x 14x 14x 2058x 14x 2058x 14x 2058x 14x 5014x 14x | import { Option } from 'effect'
import { makeParser } from '../parser'
import { pairReading } from '../reading'
import type { Formatter, Grid, Parser } from '../types'
import {
formatDDMValue,
formatDMSValue,
parseLatLon,
toFixedUnsignedZero,
} from './angles'
import { buildDdmGrid, ddmCellOutline } from './ddmGrid'
const GRATICULE = Option.some('Graticule')
const DDM_GRID_ID = 'Ddm'
export const ddFormatter: Formatter = {
id: 'DD',
label: 'DD',
maybeGridId: GRATICULE,
format: point =>
pairReading(
toFixedUnsignedZero(point.lat, 6),
toFixedUnsignedZero(point.lon, 6),
),
}
export const dmsFormatter: Formatter = {
id: 'DMS',
label: 'DMS',
maybeGridId: GRATICULE,
format: point =>
pairReading(
formatDMSValue(point.lat, 'lat', 2),
formatDMSValue(point.lon, 'lon', 2),
),
}
export const ddmFormatter: Formatter = {
id: 'DDM',
label: 'DDM',
maybeGridId: Option.some(DDM_GRID_ID),
format: point =>
pairReading(
formatDDMValue(point.lat, 'lat', 4),
formatDDMValue(point.lon, 'lon', 4),
),
}
export const parser: Parser = makeParser('DD, DMS, DDM', text =>
Option.map(Option.fromNullishOr(parseLatLon(text)), ({ kind, point }) => ({
kind,
point,
maybeBounds: Option.none(),
})),
)
/** Chart-style degrees and minutes. Off by default: with the decimal graticule on as well, the map is busy. */
export const ddmGrid: Grid = {
id: DDM_GRID_ID,
label: 'DDM',
description:
'Degrees and minutes, as on a nautical chart; ticks on the map edges mark the minutes between lines',
colors: { onDark: [240, 90, 200, 140], onLight: [180, 20, 140, 160] },
isEnabledByDefault: false,
build: buildDdmGrid,
maybeCueOutline: Option.some(point => Option.some(ddmCellOutline(point))),
}
|