forked from OurHike/OurHike
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdownloadDetail.ts
More file actions
36 lines (31 loc) · 1.51 KB
/
Copy pathdownloadDetail.ts
File metadata and controls
36 lines (31 loc) · 1.51 KB
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
// Whole-corridor download detail levels. See WIREFRAMES.md's Known
// Deviations #1: the wireframe's per-section download list is superseded by
// ROADMAP.md Phase 2's decision - one package for the whole corridor, with
// this Light/Standard/Fine choice as the *only* download's detail, not a
// per-section override. Sizes are the real measured whole-corridor figures
// from pipeline/README.md, not derived per-section ratios.
export type DetailLevel = 'light' | 'standard' | 'fine'
export interface DownloadDetail {
level: DetailLevel
zoom: 11 | 12 | 13
sizeBytes: number
recommended: boolean
}
export const DOWNLOAD_DETAIL_LEVELS: DownloadDetail[] = [
{ level: 'light', zoom: 11, sizeBytes: 64_000_000, recommended: false },
{ level: 'standard', zoom: 12, sizeBytes: 314_000_000, recommended: true },
{ level: 'fine', zoom: 13, sizeBytes: 1_180_000_000, recommended: false },
]
export function getDownloadDetail(level: DetailLevel): DownloadDetail {
const found = DOWNLOAD_DETAIL_LEVELS.find((d) => d.level === level)
if (!found) throw new Error(`Unknown download detail level: ${level}`)
return found
}
/** The reverse lookup, for reading the choice back out of
* UserPreferences.max_background_zoom - which is where it is stored, since
* the zoom ceiling IS what the choice means. */
export function detailLevelForZoom(zoom: number): DetailLevel {
const found = DOWNLOAD_DETAIL_LEVELS.find((d) => d.zoom === zoom)
if (!found) throw new Error(`No download detail level for zoom ${zoom}`)
return found.level
}