@osmix/shared 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/content-hasher.d.ts +28 -0
- package/dist/content-hasher.d.ts.map +1 -0
- package/dist/content-hasher.js +62 -0
- package/dist/content-hasher.js.map +1 -0
- package/dist/csv-parse-stream.d.ts +38 -0
- package/dist/csv-parse-stream.d.ts.map +1 -0
- package/dist/csv-parse-stream.js +157 -0
- package/dist/csv-parse-stream.js.map +1 -0
- package/dist/relation-kind.d.ts.map +1 -1
- package/dist/relation-kind.js +5 -3
- package/dist/relation-kind.js.map +1 -1
- package/dist/stream-to-bytes.js +2 -1
- package/dist/stream-to-bytes.js.map +1 -1
- package/dist/utils.d.ts +6 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +21 -0
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/content-hasher.ts +70 -0
- package/src/csv-parse-stream.ts +215 -0
- package/src/relation-kind.ts +5 -3
- package/src/stream-to-bytes.ts +1 -1
- package/src/utils.ts +20 -0
- package/test/csv-parse-stream.test.ts +74 -0
- package/dist/src/assert.d.ts +0 -24
- package/dist/src/assert.d.ts.map +0 -1
- package/dist/src/assert.js +0 -28
- package/dist/src/assert.js.map +0 -1
- package/dist/src/bbox-intersects.d.ts +0 -15
- package/dist/src/bbox-intersects.d.ts.map +0 -1
- package/dist/src/bbox-intersects.js +0 -24
- package/dist/src/bbox-intersects.js.map +0 -1
- package/dist/src/bytes-to-stream.d.ts +0 -18
- package/dist/src/bytes-to-stream.d.ts.map +0 -1
- package/dist/src/bytes-to-stream.js +0 -25
- package/dist/src/bytes-to-stream.js.map +0 -1
- package/dist/src/color.d.ts +0 -4
- package/dist/src/color.d.ts.map +0 -1
- package/dist/src/color.js +0 -33
- package/dist/src/color.js.map +0 -1
- package/dist/src/concat-bytes.d.ts +0 -5
- package/dist/src/concat-bytes.d.ts.map +0 -1
- package/dist/src/concat-bytes.js +0 -14
- package/dist/src/concat-bytes.js.map +0 -1
- package/dist/src/coordinates.d.ts +0 -28
- package/dist/src/coordinates.d.ts.map +0 -1
- package/dist/src/coordinates.js +0 -38
- package/dist/src/coordinates.js.map +0 -1
- package/dist/src/haversine-distance.d.ts +0 -16
- package/dist/src/haversine-distance.d.ts.map +0 -1
- package/dist/src/haversine-distance.js +0 -26
- package/dist/src/haversine-distance.js.map +0 -1
- package/dist/src/lineclip.d.ts +0 -2
- package/dist/src/lineclip.d.ts.map +0 -1
- package/dist/src/lineclip.js +0 -3
- package/dist/src/lineclip.js.map +0 -1
- package/dist/src/progress.d.ts +0 -42
- package/dist/src/progress.d.ts.map +0 -1
- package/dist/src/progress.js +0 -53
- package/dist/src/progress.js.map +0 -1
- package/dist/src/relation-kind.d.ts +0 -69
- package/dist/src/relation-kind.d.ts.map +0 -1
- package/dist/src/relation-kind.js +0 -375
- package/dist/src/relation-kind.js.map +0 -1
- package/dist/src/relation-multipolygon.d.ts +0 -43
- package/dist/src/relation-multipolygon.d.ts.map +0 -1
- package/dist/src/relation-multipolygon.js +0 -195
- package/dist/src/relation-multipolygon.js.map +0 -1
- package/dist/src/stream-to-bytes.d.ts +0 -18
- package/dist/src/stream-to-bytes.d.ts.map +0 -1
- package/dist/src/stream-to-bytes.js +0 -30
- package/dist/src/stream-to-bytes.js.map +0 -1
- package/dist/src/test/fixtures.d.ts +0 -36
- package/dist/src/test/fixtures.d.ts.map +0 -1
- package/dist/src/test/fixtures.js +0 -175
- package/dist/src/test/fixtures.js.map +0 -1
- package/dist/src/throttle.d.ts +0 -25
- package/dist/src/throttle.d.ts.map +0 -1
- package/dist/src/throttle.js +0 -34
- package/dist/src/throttle.js.map +0 -1
- package/dist/src/tile.d.ts +0 -34
- package/dist/src/tile.d.ts.map +0 -1
- package/dist/src/tile.js +0 -72
- package/dist/src/tile.js.map +0 -1
- package/dist/src/transform-bytes.d.ts +0 -24
- package/dist/src/transform-bytes.d.ts.map +0 -1
- package/dist/src/transform-bytes.js +0 -28
- package/dist/src/transform-bytes.js.map +0 -1
- package/dist/src/types.d.ts +0 -99
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -9
- package/dist/src/types.js.map +0 -1
- package/dist/src/utils.d.ts +0 -30
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -70
- package/dist/src/utils.js.map +0 -1
- package/dist/src/way-is-area.d.ts +0 -24
- package/dist/src/way-is-area.d.ts.map +0 -1
- package/dist/src/way-is-area.js +0 -104
- package/dist/src/way-is-area.js.map +0 -1
- package/dist/src/zigzag.d.ts +0 -33
- package/dist/src/zigzag.d.ts.map +0 -1
- package/dist/src/zigzag.js +0 -40
- package/dist/src/zigzag.js.map +0 -1
- package/dist/test/haversine-distance.test.d.ts +0 -2
- package/dist/test/haversine-distance.test.d.ts.map +0 -1
- package/dist/test/haversine-distance.test.js +0 -8
- package/dist/test/haversine-distance.test.js.map +0 -1
- package/dist/test/relation-kind.test.d.ts +0 -2
- package/dist/test/relation-kind.test.d.ts.map +0 -1
- package/dist/test/relation-kind.test.js +0 -367
- package/dist/test/relation-kind.test.js.map +0 -1
- package/dist/test/relation-multipolygon.test.d.ts +0 -2
- package/dist/test/relation-multipolygon.test.d.ts.map +0 -1
- package/dist/test/relation-multipolygon.test.js +0 -237
- package/dist/test/relation-multipolygon.test.js.map +0 -1
- package/dist/test/utils.test.d.ts +0 -2
- package/dist/test/utils.test.d.ts.map +0 -1
- package/dist/test/utils.test.js +0 -76
- package/dist/test/utils.test.js.map +0 -1
- package/dist/test/way-is-area.test.d.ts +0 -2
- package/dist/test/way-is-area.test.d.ts.map +0 -1
- package/dist/test/way-is-area.test.js +0 -31
- package/dist/test/way-is-area.test.js.map +0 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-friendly streaming CSV parser.
|
|
3
|
+
*
|
|
4
|
+
* Adapted from mafintosh/csv-parser's parsing approach,
|
|
5
|
+
* but implemented with Web Streams for modern runtimes.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export interface CsvParseStreamOptions {
|
|
11
|
+
separator?: string
|
|
12
|
+
quote?: string
|
|
13
|
+
escape?: string
|
|
14
|
+
headers?: Array<string | null> | false | null
|
|
15
|
+
skipFirstRow?: boolean
|
|
16
|
+
skipComments?: boolean | string
|
|
17
|
+
skipLines?: number
|
|
18
|
+
strict?: boolean
|
|
19
|
+
mapHeaders?: (args: { header: string; index: number }) => string | null
|
|
20
|
+
mapValues?: (args: {
|
|
21
|
+
header: string | undefined
|
|
22
|
+
index: number
|
|
23
|
+
value: string
|
|
24
|
+
}) => string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const defaults: Required<
|
|
28
|
+
Pick<
|
|
29
|
+
CsvParseStreamOptions,
|
|
30
|
+
| "separator"
|
|
31
|
+
| "quote"
|
|
32
|
+
| "escape"
|
|
33
|
+
| "skipFirstRow"
|
|
34
|
+
| "skipComments"
|
|
35
|
+
| "strict"
|
|
36
|
+
>
|
|
37
|
+
> = {
|
|
38
|
+
separator: ",",
|
|
39
|
+
quote: '"',
|
|
40
|
+
escape: '"',
|
|
41
|
+
skipFirstRow: false,
|
|
42
|
+
skipComments: false,
|
|
43
|
+
strict: false,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* TransformStream-like wrapper for CSV parsing.
|
|
48
|
+
*
|
|
49
|
+
* Exposes `writable` + `readable` so it can be used directly in `pipeThrough`.
|
|
50
|
+
*/
|
|
51
|
+
export class CsvParseStream {
|
|
52
|
+
readonly readable: ReadableStream<Record<string, string>>
|
|
53
|
+
readonly writable: WritableStream<string>
|
|
54
|
+
|
|
55
|
+
constructor(opts: CsvParseStreamOptions = {}) {
|
|
56
|
+
const options: Required<CsvParseStreamOptions> = {
|
|
57
|
+
...defaults,
|
|
58
|
+
...opts,
|
|
59
|
+
headers: opts.headers ?? null,
|
|
60
|
+
skipLines: opts.skipLines ?? 0,
|
|
61
|
+
mapHeaders: opts.mapHeaders ?? (({ header }) => header),
|
|
62
|
+
mapValues: opts.mapValues ?? (({ value }) => value),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let headers = options.headers
|
|
66
|
+
let lineNumber = 0
|
|
67
|
+
let row: string[] = []
|
|
68
|
+
let field = ""
|
|
69
|
+
let inQuotes = false
|
|
70
|
+
|
|
71
|
+
const stream = new TransformStream<string, Record<string, string>>({
|
|
72
|
+
transform(chunk, controller) {
|
|
73
|
+
const emitRow = (cells: string[]) => {
|
|
74
|
+
const skip = options.skipLines > lineNumber
|
|
75
|
+
lineNumber++
|
|
76
|
+
if (skip) return
|
|
77
|
+
|
|
78
|
+
if (options.skipComments) {
|
|
79
|
+
const commentPrefix =
|
|
80
|
+
typeof options.skipComments === "string"
|
|
81
|
+
? options.skipComments
|
|
82
|
+
: "#"
|
|
83
|
+
const firstCell = cells[0] ?? ""
|
|
84
|
+
if (firstCell.startsWith(commentPrefix)) return
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (headers === null || (lineNumber === 1 && options.skipFirstRow)) {
|
|
88
|
+
headers = cells.map((header, index) =>
|
|
89
|
+
options.mapHeaders({ header, index }),
|
|
90
|
+
)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (headers === false) {
|
|
95
|
+
const out = Object.fromEntries(
|
|
96
|
+
cells.map((value, index) => [index, value]),
|
|
97
|
+
)
|
|
98
|
+
controller.enqueue(out as unknown as Record<string, string>)
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (options.strict && cells.length !== headers.length) {
|
|
103
|
+
throw new RangeError(
|
|
104
|
+
`Row length ${cells.length} does not match header length ${headers.length}`,
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const out: Record<string, string> = {}
|
|
109
|
+
for (let index = 0; index < cells.length; index++) {
|
|
110
|
+
const header = headers[index] ?? `_${index}`
|
|
111
|
+
if (header === null) continue
|
|
112
|
+
out[header] = options.mapValues({
|
|
113
|
+
header,
|
|
114
|
+
index,
|
|
115
|
+
value: cells[index] ?? "",
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
controller.enqueue(out)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (let i = 0; i < chunk.length; i++) {
|
|
123
|
+
const ch = chunk[i]
|
|
124
|
+
const next = chunk[i + 1]
|
|
125
|
+
|
|
126
|
+
if (ch === options.escape && inQuotes && next === options.quote) {
|
|
127
|
+
field += options.quote
|
|
128
|
+
i++
|
|
129
|
+
continue
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (ch === options.quote) {
|
|
133
|
+
inQuotes = !inQuotes
|
|
134
|
+
continue
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (!inQuotes && ch === options.separator) {
|
|
138
|
+
row.push(field)
|
|
139
|
+
field = ""
|
|
140
|
+
continue
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (!inQuotes && (ch === "\n" || ch === "\r")) {
|
|
144
|
+
if (ch === "\r" && next === "\n") i++
|
|
145
|
+
row.push(field)
|
|
146
|
+
field = ""
|
|
147
|
+
emitRow(row)
|
|
148
|
+
row = []
|
|
149
|
+
continue
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
field += ch
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
flush(controller) {
|
|
156
|
+
const emitRow = (cells: string[]) => {
|
|
157
|
+
const skip = options.skipLines > lineNumber
|
|
158
|
+
lineNumber++
|
|
159
|
+
if (skip) return
|
|
160
|
+
|
|
161
|
+
if (options.skipComments) {
|
|
162
|
+
const commentPrefix =
|
|
163
|
+
typeof options.skipComments === "string"
|
|
164
|
+
? options.skipComments
|
|
165
|
+
: "#"
|
|
166
|
+
const firstCell = cells[0] ?? ""
|
|
167
|
+
if (firstCell.startsWith(commentPrefix)) return
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (headers === null || (lineNumber === 1 && options.skipFirstRow)) {
|
|
171
|
+
headers = cells.map((header, index) =>
|
|
172
|
+
options.mapHeaders({ header, index }),
|
|
173
|
+
)
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (headers === false) {
|
|
178
|
+
const out = Object.fromEntries(
|
|
179
|
+
cells.map((value, index) => [index, value]),
|
|
180
|
+
)
|
|
181
|
+
controller.enqueue(out as unknown as Record<string, string>)
|
|
182
|
+
return
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (options.strict && cells.length !== headers.length) {
|
|
186
|
+
throw new RangeError(
|
|
187
|
+
`Row length ${cells.length} does not match header length ${headers.length}`,
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const out: Record<string, string> = {}
|
|
192
|
+
for (let index = 0; index < cells.length; index++) {
|
|
193
|
+
const header = headers[index] ?? `_${index}`
|
|
194
|
+
if (header === null) continue
|
|
195
|
+
out[header] = options.mapValues({
|
|
196
|
+
header,
|
|
197
|
+
index,
|
|
198
|
+
value: cells[index] ?? "",
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
controller.enqueue(out)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (field.length > 0 || row.length > 0) {
|
|
206
|
+
row.push(field)
|
|
207
|
+
emitRow(row)
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
this.readable = stream.readable
|
|
213
|
+
this.writable = stream.writable
|
|
214
|
+
}
|
|
215
|
+
}
|
package/src/relation-kind.ts
CHANGED
|
@@ -174,10 +174,12 @@ export function buildRelationLineStrings(
|
|
|
174
174
|
const roleGroups = new Map<string, OsmRelationMember[]>()
|
|
175
175
|
for (const member of wayMembers) {
|
|
176
176
|
const role = member.role?.toLowerCase() ?? ""
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
let roleGroup = roleGroups.get(role)
|
|
178
|
+
if (!roleGroup) {
|
|
179
|
+
roleGroup = []
|
|
180
|
+
roleGroups.set(role, roleGroup)
|
|
179
181
|
}
|
|
180
|
-
|
|
182
|
+
roleGroup.push(member)
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
// If no roles or single role group, process all ways together
|
package/src/stream-to-bytes.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
import { dequal } from "dequal/lite"
|
|
11
11
|
import type {
|
|
12
|
+
GeoBbox2D,
|
|
13
|
+
LonLat,
|
|
12
14
|
OsmEntity,
|
|
13
15
|
OsmEntityType,
|
|
14
16
|
OsmNode,
|
|
@@ -77,3 +79,21 @@ export function getEntityType(entity: OsmEntity): OsmEntityType {
|
|
|
77
79
|
export function isMultipolygonRelation(relation: OsmRelation): boolean {
|
|
78
80
|
return relation.tags?.["type"] === "multipolygon"
|
|
79
81
|
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Compute the bounding box of a set of coordinates.
|
|
85
|
+
* Returns `[minLon, minLat, maxLon, maxLat]`.
|
|
86
|
+
*/
|
|
87
|
+
export function bboxFromLonLats(lonLats: LonLat[]): GeoBbox2D {
|
|
88
|
+
let minLon = Number.POSITIVE_INFINITY
|
|
89
|
+
let minLat = Number.POSITIVE_INFINITY
|
|
90
|
+
let maxLon = Number.NEGATIVE_INFINITY
|
|
91
|
+
let maxLat = Number.NEGATIVE_INFINITY
|
|
92
|
+
for (const [lon, lat] of lonLats) {
|
|
93
|
+
if (lon < minLon) minLon = lon
|
|
94
|
+
if (lat < minLat) minLat = lat
|
|
95
|
+
if (lon > maxLon) maxLon = lon
|
|
96
|
+
if (lat > maxLat) maxLat = lat
|
|
97
|
+
}
|
|
98
|
+
return [minLon, minLat, maxLon, maxLat]
|
|
99
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test"
|
|
2
|
+
import {
|
|
3
|
+
CsvParseStream,
|
|
4
|
+
type CsvParseStreamOptions,
|
|
5
|
+
} from "../src/csv-parse-stream"
|
|
6
|
+
|
|
7
|
+
async function parseCsv(
|
|
8
|
+
chunks: string[],
|
|
9
|
+
opts: CsvParseStreamOptions = {},
|
|
10
|
+
): Promise<Record<string, string>[]> {
|
|
11
|
+
const source = new ReadableStream<string>({
|
|
12
|
+
start(controller) {
|
|
13
|
+
for (const chunk of chunks) controller.enqueue(chunk)
|
|
14
|
+
controller.close()
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const parsed = source.pipeThrough(new CsvParseStream(opts))
|
|
19
|
+
return Array.fromAsync(parsed)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
describe("CsvParseStream", () => {
|
|
23
|
+
it("parses basic header + rows", async () => {
|
|
24
|
+
const rows = await parseCsv(["id,name\n1,Alice\n2,Bob\n"])
|
|
25
|
+
expect(rows).toEqual([
|
|
26
|
+
{ id: "1", name: "Alice" },
|
|
27
|
+
{ id: "2", name: "Bob" },
|
|
28
|
+
])
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it("handles quoted fields with commas and escaped quotes", async () => {
|
|
32
|
+
const rows = await parseCsv([
|
|
33
|
+
'id,name,notes\n1,"Alice, A.","says ""hi"""\n',
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
expect(rows).toEqual([
|
|
37
|
+
{ id: "1", name: "Alice, A.", notes: 'says "hi"' },
|
|
38
|
+
])
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it("handles fields split across chunks", async () => {
|
|
42
|
+
const rows = await parseCsv([
|
|
43
|
+
"id,name,notes\n1,Alice,",
|
|
44
|
+
'"line one',
|
|
45
|
+
' and two"\n2,Bob,ok\n',
|
|
46
|
+
])
|
|
47
|
+
|
|
48
|
+
expect(rows).toEqual([
|
|
49
|
+
{ id: "1", name: "Alice", notes: "line one and two" },
|
|
50
|
+
{ id: "2", name: "Bob", notes: "ok" },
|
|
51
|
+
])
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it("supports comment skipping + header/value mapping", async () => {
|
|
55
|
+
const rows = await parseCsv(
|
|
56
|
+
[
|
|
57
|
+
"# comment\n",
|
|
58
|
+
"id,name\n",
|
|
59
|
+
"1,Alice\n",
|
|
60
|
+
"2,Bob\n",
|
|
61
|
+
],
|
|
62
|
+
{
|
|
63
|
+
skipComments: true,
|
|
64
|
+
mapHeaders: ({ header }) => header.toUpperCase(),
|
|
65
|
+
mapValues: ({ value }) => value.trim(),
|
|
66
|
+
},
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
expect(rows).toEqual([
|
|
70
|
+
{ ID: "1", NAME: "Alice" },
|
|
71
|
+
{ ID: "2", NAME: "Bob" },
|
|
72
|
+
])
|
|
73
|
+
})
|
|
74
|
+
})
|
package/dist/src/assert.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Assertion utilities for defensive programming.
|
|
3
|
-
*
|
|
4
|
-
* Provides typed assertion helpers that throw errors when conditions are not met,
|
|
5
|
-
* commonly used for index bounds checking and null/undefined guards.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Assert that a value is neither null nor undefined.
|
|
11
|
-
*
|
|
12
|
-
* @param value - The value to check.
|
|
13
|
-
* @param message - Optional error message if assertion fails.
|
|
14
|
-
* @throws Error if value is null or undefined.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const item = array[index]
|
|
19
|
-
* assertValue(item, `No item at index ${index}`)
|
|
20
|
-
* // TypeScript now knows item is non-nullable
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function assertValue<T>(value?: T, message?: string): asserts value is NonNullable<T>;
|
|
24
|
-
//# sourceMappingURL=assert.d.ts.map
|
package/dist/src/assert.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../src/assert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC5B,KAAK,CAAC,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAIjC"}
|
package/dist/src/assert.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Assertion utilities for defensive programming.
|
|
3
|
-
*
|
|
4
|
-
* Provides typed assertion helpers that throw errors when conditions are not met,
|
|
5
|
-
* commonly used for index bounds checking and null/undefined guards.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Assert that a value is neither null nor undefined.
|
|
11
|
-
*
|
|
12
|
-
* @param value - The value to check.
|
|
13
|
-
* @param message - Optional error message if assertion fails.
|
|
14
|
-
* @throws Error if value is null or undefined.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const item = array[index]
|
|
19
|
-
* assertValue(item, `No item at index ${index}`)
|
|
20
|
-
* // TypeScript now knows item is non-nullable
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export function assertValue(value, message) {
|
|
24
|
-
if (value === undefined || value === null) {
|
|
25
|
-
throw Error(message ?? "Value is undefined or null");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=assert.js.map
|
package/dist/src/assert.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert.js","sourceRoot":"","sources":["../../src/assert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAS,EACT,OAAgB;IAEhB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC3C,MAAM,KAAK,CAAC,OAAO,IAAI,4BAA4B,CAAC,CAAA;IACrD,CAAC;AACF,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bounding box intersection and containment utilities.
|
|
3
|
-
*
|
|
4
|
-
* Provides functions for checking spatial relationships between
|
|
5
|
-
* geographic bounding boxes (west, south, east, north format).
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import type { GeoBbox2D } from "./types";
|
|
10
|
-
/**
|
|
11
|
-
* Check if two bounding boxes intersect or contain each other.
|
|
12
|
-
* Handles both partial overlaps and complete containment.
|
|
13
|
-
*/
|
|
14
|
-
export declare function bboxContainsOrIntersects(bb1: GeoBbox2D, bb2: GeoBbox2D): boolean;
|
|
15
|
-
//# sourceMappingURL=bbox-intersects.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bbox-intersects.d.ts","sourceRoot":"","sources":["../../src/bbox-intersects.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,WActE"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bounding box intersection and containment utilities.
|
|
3
|
-
*
|
|
4
|
-
* Provides functions for checking spatial relationships between
|
|
5
|
-
* geographic bounding boxes (west, south, east, north format).
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Check if two bounding boxes intersect or contain each other.
|
|
11
|
-
* Handles both partial overlaps and complete containment.
|
|
12
|
-
*/
|
|
13
|
-
export function bboxContainsOrIntersects(bb1, bb2) {
|
|
14
|
-
const westIn = (bb1[0] >= bb2[0] && bb1[0] <= bb2[2]) ||
|
|
15
|
-
(bb2[0] >= bb1[0] && bb2[0] <= bb1[2]);
|
|
16
|
-
const eastIn = (bb1[2] >= bb2[0] && bb1[2] <= bb2[2]) ||
|
|
17
|
-
(bb2[2] >= bb1[0] && bb2[2] <= bb1[2]);
|
|
18
|
-
const northIn = (bb1[1] >= bb2[1] && bb1[1] <= bb2[3]) ||
|
|
19
|
-
(bb2[1] >= bb1[1] && bb2[1] <= bb1[3]);
|
|
20
|
-
const southIn = (bb1[3] >= bb2[1] && bb1[3] <= bb2[3]) ||
|
|
21
|
-
(bb2[3] >= bb1[1] && bb2[3] <= bb1[3]);
|
|
22
|
-
return (westIn || eastIn) && (northIn || southIn);
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=bbox-intersects.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bbox-intersects.js","sourceRoot":"","sources":["../../src/bbox-intersects.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAc,EAAE,GAAc;IACtE,MAAM,MAAM,GACX,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,MAAM,MAAM,GACX,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,MAAM,OAAO,GACZ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,MAAM,OAAO,GACZ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Byte array to stream conversion.
|
|
3
|
-
*
|
|
4
|
-
* Wraps a Uint8Array in a ReadableStream for use with streaming APIs.
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Create a ReadableStream from a Uint8Array.
|
|
10
|
-
*
|
|
11
|
-
* The stream will emit the entire byte array as a single chunk,
|
|
12
|
-
* then close immediately.
|
|
13
|
-
*
|
|
14
|
-
* @param bytes - The byte array to wrap.
|
|
15
|
-
* @returns A ReadableStream that emits the bytes.
|
|
16
|
-
*/
|
|
17
|
-
export declare function bytesToStream(bytes: Uint8Array<ArrayBuffer>): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
18
|
-
//# sourceMappingURL=bytes-to-stream.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bytes-to-stream.d.ts","sourceRoot":"","sources":["../../src/bytes-to-stream.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,2CAO3D"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Byte array to stream conversion.
|
|
3
|
-
*
|
|
4
|
-
* Wraps a Uint8Array in a ReadableStream for use with streaming APIs.
|
|
5
|
-
*
|
|
6
|
-
* @module
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Create a ReadableStream from a Uint8Array.
|
|
10
|
-
*
|
|
11
|
-
* The stream will emit the entire byte array as a single chunk,
|
|
12
|
-
* then close immediately.
|
|
13
|
-
*
|
|
14
|
-
* @param bytes - The byte array to wrap.
|
|
15
|
-
* @returns A ReadableStream that emits the bytes.
|
|
16
|
-
*/
|
|
17
|
-
export function bytesToStream(bytes) {
|
|
18
|
-
return new ReadableStream({
|
|
19
|
-
start(controller) {
|
|
20
|
-
controller.enqueue(bytes);
|
|
21
|
-
controller.close();
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=bytes-to-stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bytes-to-stream.js","sourceRoot":"","sources":["../../src/bytes-to-stream.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAAC,KAA8B;IAC3D,OAAO,IAAI,cAAc,CAA0B;QAClD,KAAK,CAAC,UAAU;YACf,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YACzB,UAAU,CAAC,KAAK,EAAE,CAAA;QACnB,CAAC;KACD,CAAC,CAAA;AACH,CAAC"}
|
package/dist/src/color.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Rgba } from "./types";
|
|
2
|
-
export declare function normalizeHexColor(value: string | number | null | undefined): string | undefined;
|
|
3
|
-
export declare function hexColorToRgba(value: string | number | null | undefined): Rgba | undefined;
|
|
4
|
-
//# sourceMappingURL=color.d.ts.map
|
package/dist/src/color.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInC,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,MAAM,GAAG,SAAS,CAiBpB;AAED,wBAAgB,cAAc,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GACvC,IAAI,GAAG,SAAS,CASlB"}
|
package/dist/src/color.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const hexPattern = /^[0-9a-fA-F]+$/;
|
|
2
|
-
export function normalizeHexColor(value) {
|
|
3
|
-
if (value === null || value === undefined)
|
|
4
|
-
return;
|
|
5
|
-
const raw = String(value).trim();
|
|
6
|
-
if (!raw)
|
|
7
|
-
return;
|
|
8
|
-
let hex = raw.startsWith("#") ? raw.slice(1) : raw;
|
|
9
|
-
if (!hexPattern.test(hex))
|
|
10
|
-
return;
|
|
11
|
-
if (hex.length === 3 || hex.length === 4) {
|
|
12
|
-
hex = hex
|
|
13
|
-
.split("")
|
|
14
|
-
.map((char) => `${char}${char}`)
|
|
15
|
-
.join("");
|
|
16
|
-
}
|
|
17
|
-
else if (hex.length !== 6 && hex.length !== 8) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
return `#${hex.toUpperCase()}`;
|
|
21
|
-
}
|
|
22
|
-
export function hexColorToRgba(value) {
|
|
23
|
-
const normalized = normalizeHexColor(value);
|
|
24
|
-
if (!normalized)
|
|
25
|
-
return;
|
|
26
|
-
const hex = normalized.slice(1);
|
|
27
|
-
const r = Number.parseInt(hex.slice(0, 2), 16);
|
|
28
|
-
const g = Number.parseInt(hex.slice(2, 4), 16);
|
|
29
|
-
const b = Number.parseInt(hex.slice(4, 6), 16);
|
|
30
|
-
const a = hex.length === 8 ? Number.parseInt(hex.slice(6, 8), 16) : 255;
|
|
31
|
-
return [r, g, b, a];
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=color.js.map
|
package/dist/src/color.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../src/color.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,gBAAgB,CAAA;AAEnC,MAAM,UAAU,iBAAiB,CAChC,KAAyC;IAEzC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAM;IACjD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAA;IAChC,IAAI,CAAC,GAAG;QAAE,OAAM;IAChB,IAAI,GAAG,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAClD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAM;IAEjC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1C,GAAG,GAAG,GAAG;aACP,KAAK,CAAC,EAAE,CAAC;aACT,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;aAC/B,IAAI,CAAC,EAAE,CAAC,CAAA;IACX,CAAC;SAAM,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjD,OAAM;IACP,CAAC;IAED,OAAO,IAAI,GAAG,CAAC,WAAW,EAAE,EAAE,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,cAAc,CAC7B,KAAyC;IAEzC,MAAM,UAAU,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA;IAC3C,IAAI,CAAC,UAAU;QAAE,OAAM;IACvB,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC/B,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACvE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AACpB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"concat-bytes.d.ts","sourceRoot":"","sources":["../../src/concat-bytes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,GAC9B,UAAU,CAAC,WAAW,CAAC,CASzB"}
|
package/dist/src/concat-bytes.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Concatenates multiple `Uint8Array` segments into a contiguous array.
|
|
3
|
-
*/
|
|
4
|
-
export function concatBytes(parts) {
|
|
5
|
-
const total = parts.reduce((n, p) => n + p.length, 0);
|
|
6
|
-
const out = new Uint8Array(new ArrayBuffer(total));
|
|
7
|
-
let offset = 0;
|
|
8
|
-
for (const p of parts) {
|
|
9
|
-
out.set(p, offset);
|
|
10
|
-
offset += p.length;
|
|
11
|
-
}
|
|
12
|
-
return out;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=concat-bytes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"concat-bytes.js","sourceRoot":"","sources":["../../src/concat-bytes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAgC;IAEhC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IACrD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAc,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/D,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACvB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;QAClB,MAAM,IAAI,CAAC,CAAC,MAAM,CAAA;IACnB,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Coordinate precision utilities for OSM data.
|
|
3
|
-
*
|
|
4
|
-
* OSM stores coordinates as integer microdegrees (7 decimal places) for
|
|
5
|
-
* compact storage and consistent precision. This module provides conversions
|
|
6
|
-
* between floating-point degrees and integer microdegrees.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import type { GeoBbox2D } from "./types";
|
|
11
|
-
/**
|
|
12
|
-
* OSM coordinate scale: coordinates are stored as integer microdegrees.
|
|
13
|
-
* 1 microdegree = 1e-7 degrees = 0.0000001 degrees
|
|
14
|
-
*/
|
|
15
|
-
export declare const OSM_COORD_SCALE = 10000000;
|
|
16
|
-
/**
|
|
17
|
-
* Convert degrees to microdegrees (integer).
|
|
18
|
-
*/
|
|
19
|
-
export declare function toMicroDegrees(degrees: number): number;
|
|
20
|
-
/**
|
|
21
|
-
* Convert microdegrees (integer) to degrees (float).
|
|
22
|
-
*/
|
|
23
|
-
export declare function microToDegrees(microdegrees: number): number;
|
|
24
|
-
/**
|
|
25
|
-
* Convert a bounding box from degrees to microdegrees.
|
|
26
|
-
*/
|
|
27
|
-
export declare function bboxToMicroDegrees(bbox: GeoBbox2D): [minLon: number, minLat: number, maxLon: number, maxLat: number];
|
|
28
|
-
//# sourceMappingURL=coordinates.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coordinates.d.ts","sourceRoot":"","sources":["../../src/coordinates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC;;;GAGG;AACH,eAAO,MAAM,eAAe,WAAM,CAAA;AAElC;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,SAAS,GACb,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAOlE"}
|
package/dist/src/coordinates.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Coordinate precision utilities for OSM data.
|
|
3
|
-
*
|
|
4
|
-
* OSM stores coordinates as integer microdegrees (7 decimal places) for
|
|
5
|
-
* compact storage and consistent precision. This module provides conversions
|
|
6
|
-
* between floating-point degrees and integer microdegrees.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* OSM coordinate scale: coordinates are stored as integer microdegrees.
|
|
12
|
-
* 1 microdegree = 1e-7 degrees = 0.0000001 degrees
|
|
13
|
-
*/
|
|
14
|
-
export const OSM_COORD_SCALE = 1e7;
|
|
15
|
-
/**
|
|
16
|
-
* Convert degrees to microdegrees (integer).
|
|
17
|
-
*/
|
|
18
|
-
export function toMicroDegrees(degrees) {
|
|
19
|
-
return Math.round(degrees * OSM_COORD_SCALE);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Convert microdegrees (integer) to degrees (float).
|
|
23
|
-
*/
|
|
24
|
-
export function microToDegrees(microdegrees) {
|
|
25
|
-
return microdegrees / OSM_COORD_SCALE;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Convert a bounding box from degrees to microdegrees.
|
|
29
|
-
*/
|
|
30
|
-
export function bboxToMicroDegrees(bbox) {
|
|
31
|
-
return [
|
|
32
|
-
toMicroDegrees(bbox[0]),
|
|
33
|
-
toMicroDegrees(bbox[1]),
|
|
34
|
-
toMicroDegrees(bbox[2]),
|
|
35
|
-
toMicroDegrees(bbox[3]),
|
|
36
|
-
];
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=coordinates.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coordinates.js","sourceRoot":"","sources":["../../src/coordinates.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAElC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,eAAe,CAAC,CAAA;AAC7C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB;IAClD,OAAO,YAAY,GAAG,eAAe,CAAA;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAe;IAEf,OAAO;QACN,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvB,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACvB,CAAA;AACF,CAAC"}
|