@osmix/core 0.1.10 → 0.3.0

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/LICENSE +21 -0
  3. package/README.md +136 -72
  4. package/dist/contracts.d.ts +27 -0
  5. package/dist/contracts.d.ts.map +1 -0
  6. package/dist/contracts.js +1 -0
  7. package/dist/contracts.js.map +1 -0
  8. package/dist/entities.d.ts +22 -2
  9. package/dist/entities.d.ts.map +1 -1
  10. package/dist/entities.js +54 -10
  11. package/dist/entities.js.map +1 -1
  12. package/dist/ids.d.ts +20 -5
  13. package/dist/ids.d.ts.map +1 -1
  14. package/dist/ids.js +87 -29
  15. package/dist/ids.js.map +1 -1
  16. package/dist/index.d.ts +7 -4
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +6 -4
  19. package/dist/index.js.map +1 -1
  20. package/dist/indirect-kd-index.d.ts +28 -0
  21. package/dist/indirect-kd-index.d.ts.map +1 -0
  22. package/dist/indirect-kd-index.js +163 -0
  23. package/dist/indirect-kd-index.js.map +1 -0
  24. package/dist/limits.d.ts +30 -0
  25. package/dist/limits.d.ts.map +1 -0
  26. package/dist/limits.js +51 -0
  27. package/dist/limits.js.map +1 -0
  28. package/dist/mocks.d.ts.map +1 -1
  29. package/dist/mocks.js.map +1 -1
  30. package/dist/nodes.d.ts +36 -15
  31. package/dist/nodes.d.ts.map +1 -1
  32. package/dist/nodes.js +185 -62
  33. package/dist/nodes.js.map +1 -1
  34. package/dist/osm.d.ts +60 -4
  35. package/dist/osm.d.ts.map +1 -1
  36. package/dist/osm.js +32 -6
  37. package/dist/osm.js.map +1 -1
  38. package/dist/relations.d.ts +11 -4
  39. package/dist/relations.d.ts.map +1 -1
  40. package/dist/relations.js +73 -29
  41. package/dist/relations.js.map +1 -1
  42. package/dist/renumber.d.ts +23 -0
  43. package/dist/renumber.d.ts.map +1 -0
  44. package/dist/renumber.js +64 -0
  45. package/dist/renumber.js.map +1 -0
  46. package/dist/stringtable.d.ts +2 -1
  47. package/dist/stringtable.d.ts.map +1 -1
  48. package/dist/stringtable.js +9 -14
  49. package/dist/stringtable.js.map +1 -1
  50. package/dist/tags.d.ts +45 -12
  51. package/dist/tags.d.ts.map +1 -1
  52. package/dist/tags.js +153 -27
  53. package/dist/tags.js.map +1 -1
  54. package/dist/typed-arrays.d.ts +63 -48
  55. package/dist/typed-arrays.d.ts.map +1 -1
  56. package/dist/typed-arrays.js +184 -107
  57. package/dist/typed-arrays.js.map +1 -1
  58. package/dist/ways.d.ts +52 -3
  59. package/dist/ways.d.ts.map +1 -1
  60. package/dist/ways.js +223 -46
  61. package/dist/ways.js.map +1 -1
  62. package/package.json +45 -31
  63. package/src/contracts.ts +29 -0
  64. package/src/entities.ts +242 -194
  65. package/src/ids.ts +278 -235
  66. package/src/index.ts +22 -13
  67. package/src/indirect-kd-index.ts +212 -0
  68. package/src/limits.ts +73 -0
  69. package/src/mocks.ts +114 -113
  70. package/src/nodes.ts +538 -397
  71. package/src/osm.ts +282 -207
  72. package/src/relations.ts +580 -558
  73. package/src/renumber.ts +80 -0
  74. package/src/stringtable.ts +189 -184
  75. package/src/tags.ts +406 -272
  76. package/src/typed-arrays.ts +307 -205
  77. package/src/types/geoflatbush.d.ts +28 -33
  78. package/src/ways.ts +577 -406
  79. package/test/entity-index-errors.test.ts +41 -0
  80. package/test/ids.bench.ts +33 -0
  81. package/test/ids.test.ts +122 -0
  82. package/test/limits.test.ts +83 -0
  83. package/test/memory.test.ts +29 -30
  84. package/test/no-shared-array-buffer.test.ts +41 -0
  85. package/test/nodes-spatial-index.test.ts +261 -0
  86. package/test/osm-bbox.test.ts +30 -0
  87. package/test/relations.bench.ts +32 -0
  88. package/test/relations.test.ts +124 -0
  89. package/test/renumber.test.ts +54 -0
  90. package/test/spatial-index-rebuild.test.ts +33 -0
  91. package/test/storage-compaction.test.ts +269 -0
  92. package/test/tags-search.test.ts +89 -56
  93. package/test/typed-arrays.test.ts +252 -132
  94. package/tsconfig.build.json +6 -6
  95. package/tsconfig.json +7 -7
  96. package/src/types/geokdbush.d.ts +0 -37
  97. package/src/types/kdbush.d.ts +0 -47
package/CHANGELOG.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # @osmix/core
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e4785fe: Enable memory-aware loading of Australia-scale PBF data. Core storage and transfers now use the compact
8
+ version 2 representation, node spatial queries use independent indirect all-node and tagged-node indexes, and
9
+ loaders expose Auto, Full, View, and explicit spatial-index selection with structured capacity diagnostics.
10
+ Vector-tile encoders use the tagged-node capability without requiring an all-node index.
11
+ - e4785fe: Expose structured typed-buffer and entity-finalization failures across workers, identify safe View-profile
12
+ retries for spatial capacity errors, and show persistent actionable dataset-load diagnostics in Merge.
13
+ - 66eb7cd: **Breaking:** `Osm.bbox()` and `OsmInfo.bbox` are `null` for a dataset with no nodes.
14
+
15
+ Add `renumberNegativeIds` and `negativeIdMap`, which renumber new (negative) IDs after each entity type's highest ID for tools that reject negative IDs, with every way ref and relation member following. Ways, relations and strings beyond what the stored format holds (65,535 refs, members or bytes) now throw `OsmCapacityError`, which names the entity and the limit; the limits and `assertCapacity` are exported. `ResizeableTypedArray` is exported.
16
+
17
+ ### Patch Changes
18
+
19
+ - df04f92: Add a cross-runtime managed worker pool with browser, Bun, and Node worker support,
20
+ cooperative cancellation utilities, a transferable Shortbread feature index, and worker-backed
21
+ consumer integrations.
22
+ - 66eb7cd: Reuse built way and relation spatial indexes. `Ways.buildSpatialIndex()` and `Relations.buildSpatialIndex()` rebuilt their Flatbush trees on every call, so calling `Osm.buildSpatialIndexes()` on a loaded dataset repeated work. They now return the existing index, as node indexes already did.
23
+ - 8be5c80: Allow Osmix to use its ArrayBuffer fallback when SharedArrayBuffer is unavailable, so browser
24
+ applications no longer need to install a global SharedArrayBuffer shim.
25
+ - Updated dependencies [e4785fe]
26
+ - Updated dependencies [df04f92]
27
+ - Updated dependencies [466adc0]
28
+ - Updated dependencies [66eb7cd]
29
+ - Updated dependencies [8be5c80]
30
+ - @osmix/shared@0.2.0
31
+ - @osmix/types@0.2.0
32
+ - @osmix/geo@0.1.1
33
+
34
+ ## 0.2.0
35
+
36
+ ### Minor Changes
37
+
38
+ - 368d103: Split shared concerns into `@osmix/types`, `@osmix/geo`, and `@osmix/test-utils`. Add `OsmReader`/`OsmWriter` contracts, curated `osmix` facade exports, and dependency guardrails.
39
+ - c7a5a35: Harden parsing, loading, changeset generation, worker orchestration, and package verification across Osmix.
40
+
41
+ - `@osmix/pbf`, `@osmix/json`, and `@osmix/load` now validate PBF framing and decompression limits, normalize every supported input form, apply timestamp granularity consistently, translate tags before filtering, remove dangling filtered references, and build every requested spatial index.
42
+ - `@osmix/core` now returns `null` for unknown node-coordinate lookups, safely handles incomplete geometry, caches relation-to-way membership, and avoids repeated ID lookups and per-entity object allocation during sorted iteration.
43
+ - `@osmix/change` now preserves relation references during deduplication, escapes OSC XML attributes, applies changesets non-destructively, allocates collision-free IDs for empty or unsorted data, and resolves pending intersection geometry safely. Its intersection runtime is now vendored and strictly typed, removing the upstream test/build dependency graph.
44
+ - `osmix` now preserves sliced typed-array views during transfer, disposes and terminates owned workers reliably, uses collision-safe worker registries, and supports all documented PBF input forms across local and remote APIs.
45
+ - `@osmix/geojson`, `@osmix/vt`, and `@osmix/shortbread` now consume nullable or read-only geometry data without aliasing or mutation hazards.
46
+ - `@osmix/gtfs` and `@osmix/router` documentation now uses the current archive, routing, transfer, and distance APIs.
47
+ - `@osmix/shared` and `@osmix/test-utils` add executable package smoke coverage for byte streams and checked-in fixtures.
48
+ - Public package examples are classified as compilable or schematic and are checked against current exports and argument types.
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [368d103]
53
+ - Updated dependencies [368d103]
54
+ - Updated dependencies [c7a5a35]
55
+ - @osmix/shared@0.1.0
56
+ - @osmix/geo@0.1.0
57
+ - @osmix/types@0.1.0
58
+
3
59
  ## 0.1.10
4
60
 
5
61
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Conveyal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -4,8 +4,8 @@ In-memory OSM entity storage with spatial indexing. Provides core data structure
4
4
 
5
5
  ## Highlights
6
6
 
7
- - **Memory-efficient**: Typed arrays and microdegree coordinates (`Int32Array`) minimize memory while maintaining precision.
8
- - **Spatial indexing**: KDBush (points) and Flatbush (bboxes) for fast geographic queries. Supports bbox and radius searches via geokdbush/geoflatbush.
7
+ - **Memory-efficient**: Sorted IDs reuse their primary column, tags use sparse rank metadata, and ways store compact node indexes instead of duplicate OSM IDs.
8
+ - **Spatial indexing**: Compact indirect KD indexes for nodes and Flatbush indexes for entity bounding boxes. Supports bbox and great-circle radius searches without copying node coordinates.
9
9
  - **Worker-ready**: Serialize to `ArrayBuffer`/`SharedArrayBuffer` for zero-copy transfer via `transferables()`.
10
10
  - **Tag search**: Reverse-index lookup for fast entity searches by tag key.
11
11
  - **Streaming**: Iterate entities or sorted-by-ID without materializing full arrays.
@@ -13,7 +13,7 @@ In-memory OSM entity storage with spatial indexing. Provides core data structure
13
13
  ## Installation
14
14
 
15
15
  ```sh
16
- bun add @osmix/core
16
+ pnpm add @osmix/core
17
17
  ```
18
18
 
19
19
  ## Usage
@@ -22,139 +22,192 @@ bun add @osmix/core
22
22
 
23
23
  `@osmix/core` provides the in-memory data structures. To parse `.osm.pbf` files, use the high-level `osmix` package:
24
24
 
25
- ```ts
26
- import { fromPbf } from "osmix"
25
+ ```ts check-docs monaco-pbf
26
+ import { fromPbf } from "osmix";
27
27
 
28
- const osm = await fromPbf(Bun.file("./monaco.pbf").stream())
29
- console.log(osm.nodes.size, osm.ways.size, osm.relations.size)
28
+ const osm = await fromPbf(monacoPbf);
29
+ console.log(osm.nodes.size, osm.ways.size, osm.relations.size);
30
30
  ```
31
31
 
32
32
  ### Building data directly
33
33
 
34
34
  For synthetic data or tests, instantiate `Osm` directly and call `buildIndexes()` / `buildSpatialIndexes()` before querying:
35
35
 
36
- ```ts
37
- import { Osm } from "@osmix/core"
36
+ ```ts check-docs
37
+ import { Osm } from "@osmix/core";
38
38
 
39
- const osm = new Osm({ id: "fixture" })
39
+ const osm = new Osm({ id: "fixture" });
40
40
 
41
41
  osm.nodes.addNode({
42
- id: 1,
43
- lon: -122.4,
44
- lat: 47.6,
45
- tags: { amenity: "cafe" },
46
- })
42
+ id: 1,
43
+ lon: -122.4,
44
+ lat: 47.6,
45
+ tags: { amenity: "cafe" },
46
+ });
47
47
 
48
48
  osm.ways.addWay({
49
- id: 10,
50
- refs: [1],
51
- tags: { highway: "service" },
52
- })
49
+ id: 10,
50
+ refs: [1],
51
+ tags: { highway: "service" },
52
+ });
53
53
 
54
- osm.buildIndexes()
55
- osm.buildSpatialIndexes()
54
+ osm.buildIndexes();
55
+ osm.buildSpatialIndexes();
56
56
  ```
57
57
 
58
58
  ### Querying entities
59
59
 
60
- ```ts
60
+ ```ts check-docs osm
61
61
  // Get by ID
62
- const node = osm.nodes.getById(123)
63
- const way = osm.ways.get({ id: 456 })
62
+ const node = osm.nodes.getById(123);
63
+ const way = osm.ways.get({ id: 456 });
64
64
 
65
65
  // Iterate all entities
66
66
  for (const node of osm.nodes) {
67
- console.log(node.id, node.lon, node.lat)
67
+ console.log(node.id, node.lon, node.lat);
68
68
  }
69
69
 
70
70
  // Iterate sorted by ID (useful for PBF export)
71
71
  for (const way of osm.ways.sorted()) {
72
- console.log(way.id, way.refs)
72
+ console.log(way.id, way.refs);
73
73
  }
74
74
 
75
75
  // Search by tag key
76
- const highways = osm.ways.search("highway")
77
- const cafes = osm.nodes.search("amenity", "cafe")
76
+ const highways = osm.ways.search("highway");
77
+ const cafes = osm.nodes.search("amenity", "cafe");
78
78
  ```
79
79
 
80
80
  ### Spatial queries
81
81
 
82
- ```ts
82
+ ```ts check-docs osm
83
83
  // Bounding box query
84
- const bbox: [number, number, number, number] = [-122.34, 47.57, -122.30, 47.61]
85
- const { ids, positions } = osm.nodes.withinBbox(bbox)
86
- const { ids: wayIds, positions: wayCoords, startIndices } = osm.ways.withinBbox(bbox)
84
+ const bbox: [number, number, number, number] = [-122.34, 47.57, -122.3, 47.61];
85
+ const { ids, positions } = osm.nodes.withinBbox(bbox);
86
+ const { ids: wayIds, positions: wayCoords, startIndices } = osm.ways.withinBbox(bbox);
87
87
 
88
88
  // Radius query (uses great-circle distance)
89
- const nearbyIndexes = osm.nodes.findIndexesWithinRadius(-122.4, 47.6, 10) // 10km
89
+ const nearbyIndexes = osm.nodes.findIndexesWithinRadius(-122.4, 47.6, 10); // 10km
90
+
91
+ // Renderers can build/query only tagged nodes when an all-node index is unnecessary
92
+ osm.nodes.buildSpatialIndex("tagged");
93
+ const taggedIndexes = osm.nodes.findTaggedIndexesWithinBbox(bbox);
94
+
95
+ console.log(osm.nodes.hasSpatialIndex("all"));
96
+ console.log(osm.nodes.hasSpatialIndex("tagged"));
90
97
 
91
98
  // Get entities from indexes
92
- const nearbyNodes = nearbyIndexes.map((i) => osm.nodes.getByIndex(i))
99
+ const nearbyNodes = nearbyIndexes.map((i) => osm.nodes.getByIndex(i));
93
100
 
94
101
  // Ways/relations use Flatbush for bounding-box intersection
95
- const intersectingWays = osm.ways.intersects(bbox)
96
- const nearestWays = osm.ways.neighbors(-122.4, 47.6, 5, 10) // 5 results, 10km max
102
+ const intersectingWays = osm.ways.intersects(bbox);
103
+ const nearestWays = osm.ways.neighbors(-122.4, 47.6, 5, 10); // 5 results, 10km max
97
104
  ```
98
105
 
99
106
  ### Transferring between workers
100
107
 
101
- ```ts
108
+ The following is schematic worker wiring; use the facade's worker helpers for production orchestration:
109
+
110
+ ```ts schematic
111
+ import { collectTransferables, Osm } from "osmix";
112
+
102
113
  // In the main thread
103
- const transferables = osm.transferables()
104
- worker.postMessage(transferables, Object.values(transferables).filter(ArrayBuffer.isView))
114
+ const transferables = osm.transferables();
115
+ worker.postMessage(transferables, collectTransferables(transferables));
105
116
 
106
117
  // In the worker
107
- const osm = new Osm(transferables)
118
+ const osm = new Osm(transferables);
108
119
  // Index is already built, ready for queries
109
120
  ```
110
121
 
122
+ `OsmTransferables` uses `transferVersion: 2` and `contentHashVersion: 2`. Version 2 is an
123
+ intentional format break: version 1 transfers are rejected rather than upgraded in memory, and version 1/2
124
+ hash values are not interchangeable. Within version 2, hashes remain representation-independent because they
125
+ use reconstructed OSM IDs, tags, references, and members rather than derived rank or spatial-index data.
126
+
127
+ ### Compact storage layout
128
+
129
+ - Sorted entity collections keep the primary ID column and sparse search anchors. Unsorted collections also
130
+ keep the derived sorted-ID and sorted-position columns needed for lookup.
131
+ - Tag presence uses one bit per entity, rank checkpoints every 256 entities, and offsets only for tagged
132
+ entities. An entity may have more than 255 tags.
133
+ - Way references are stored as `Uint32Array` node indexes. Unresolved references retain their original OSM
134
+ IDs in sparse parallel arrays, so reading `OsmWay.refs` is lossless. Geometry construction still throws when
135
+ a referenced node is unavailable.
136
+ - Node spatial indexes are indirect permutations over the existing microdegree coordinate columns. The
137
+ all-node capability uses exactly four bytes per node; the tagged-node capability uses exactly four bytes per
138
+ tagged node.
139
+
111
140
  ## API
112
141
 
113
142
  ### Classes
114
143
 
115
- | Class | Description |
116
- |-------|-------------|
117
- | `Osm` | Main container with nodes, ways, relations, and shared string table |
118
- | `Nodes` | Node storage with KDBush spatial index |
119
- | `Ways` | Way storage with Flatbush spatial index |
120
- | `Relations` | Relation storage with Flatbush spatial index |
121
- | `StringTable` | Deduplicated UTF-8 string storage for tags |
122
- | `Tags` | Bidirectional tag storage (entity→tags, key→entities) |
144
+ | Class | Description |
145
+ | ------------- | ------------------------------------------------------------------- |
146
+ | `Osm` | Main container with nodes, ways, relations, and shared string table |
147
+ | `Nodes` | Node storage with independent all-node and tagged-node KD indexes |
148
+ | `Ways` | Way storage with Flatbush spatial index |
149
+ | `Relations` | Relation storage with Flatbush spatial index |
150
+ | `StringTable` | Deduplicated UTF-8 string storage for tags |
151
+ | `Tags` | Bidirectional tag storage (entity→tags, key→entities) |
123
152
 
124
153
  ### Osm Methods
125
154
 
126
- | Method | Description |
127
- |--------|-------------|
128
- | `buildIndexes()` | Finalize ID, tag, and entity indexes after adding data |
129
- | `buildSpatialIndexes()` | Build spatial indexes for all entity types |
130
- | `bbox()` | Get bounding box of all entities |
131
- | `info()` | Get summary info (id, bbox, header, stats) |
132
- | `transferables()` | Get serializable buffers for worker transfer |
133
- | `isReady()` | Check if all indexes are built |
155
+ | Method | Description |
156
+ | ----------------------- | ------------------------------------------------------ |
157
+ | `buildIndexes()` | Finalize ID, tag, and entity indexes after adding data |
158
+ | `buildSpatialIndexes()` | Build spatial indexes for all entity types |
159
+ | `bbox()` | Get bounding box of all entities |
160
+ | `info()` | Get summary info (id, bbox, header, stats) |
161
+ | `transferables()` | Get serializable buffers for worker transfer |
162
+ | `isReady()` | Check if all indexes are built |
134
163
 
135
164
  ### Entity Collection Methods
136
165
 
137
- | Method | Description |
138
- |--------|-------------|
139
- | `getById(id)` | Get entity by OSM ID |
140
- | `get({ id } \| { index })` | Get by ID or internal index |
141
- | `getByIndex(index)` | Get by internal array index |
142
- | `search(key, value?)` | Find entities with tag key (and optional value) |
143
- | `withinBbox(bbox)` | Get entities within bounding box |
144
- | `findIndexesWithinRadius(lon, lat, km)` | Find nearby entities (nodes) |
145
- | `intersects(bbox)` | Find intersecting entities (ways/relations) |
146
- | `neighbors(lon, lat, max, maxKm)` | Find nearest entities (ways/relations) |
147
- | `sorted()` | Iterator over entities sorted by ID |
166
+ | Method | Description |
167
+ | --------------------------------------- | ----------------------------------------------- |
168
+ | `getById(id)` | Get entity by OSM ID |
169
+ | `get({ id } \| { index })` | Get by ID or internal index |
170
+ | `getByIndex(index)` | Get by internal array index |
171
+ | `search(key, value?)` | Find entities with tag key (and optional value) |
172
+ | `withinBbox(bbox)` | Get entities within bounding box |
173
+ | `findIndexesWithinRadius(lon, lat, km)` | Find nearby entities (nodes) |
174
+ | `intersects(bbox)` | Find intersecting entities (ways/relations) |
175
+ | `neighbors(lon, lat, max, maxKm)` | Find nearest entities (ways/relations) |
176
+ | `sorted()` | Iterator over entities sorted by ID |
177
+
178
+ `Osm.info()` reports each spatial capability independently at
179
+ `spatialIndexes.nodes.all`, `spatialIndexes.nodes.tagged`, `spatialIndexes.ways`, and
180
+ `spatialIndexes.relations`. Loader-provided memory decisions and phase timings may also be present in
181
+ `loadDiagnostics`.
182
+
183
+ Node queries require the corresponding capability. All-node bbox and radius methods require `"all"`, while
184
+ `findTaggedIndexesWithinBbox` requires `"tagged"`. A missing capability throws
185
+ `SpatialIndexNotBuiltError`; queries never return an artificial empty result or build a large index
186
+ synchronously.
187
+
188
+ Typed-buffer allocation failures expose structured diagnostics. `TypedBufferAllocationError` reports the
189
+ operation, typed-array and buffer types, element count, element width, and required bytes.
190
+ `OsmEntityIndexBuildError` adds the entity type and the failing `ids`, `tags`, or entity-data component while
191
+ preserving the allocation error as its cause. Worker clients can use these fields to distinguish a mandatory
192
+ core-storage limit from an optional spatial-index failure.
148
193
 
149
194
  ## Environment and Limitations
150
195
 
151
- - Requires Web Streams, `TextEncoder`/`TextDecoder`, `CompressionStream`/`DecompressionStream` (Bun, Node 20+, modern browsers).
196
+ - Requires Web Streams, `TextEncoder`/`TextDecoder`, `CompressionStream`/`DecompressionStream` (Bun, Node 24+, modern browsers).
152
197
  - Uses ES2024 resizable `ArrayBuffer` and growable `SharedArrayBuffer` when available.
198
+ - Every individual typed-array column must still fit in one fixed buffer when entity indexes are finalized. A column reserves 4 GiB of address space and grows in place: it doubles up to 256 MiB, then grows by 1.5×. Where a reservation is refused, it grows by copying. `ResizeableTypedArray.capacityBytesFor` gives the size a column reaches.
199
+ - One way holds at most 65,535 node refs (`MAX_WAY_REFS`), one relation at most 65,535 members (`MAX_RELATION_MEMBERS`) and one string at most 65,535 UTF-8 bytes (`MAX_STRING_BYTES`). Totals of way refs, relation members and string bytes must each fit in `Uint32` offsets. Past a limit, the add method throws `OsmCapacityError` instead of storing a wrapped value.
200
+ - IDs are `Float64` (exact to ±2^53) and entity indexes are `Uint32`. The string table keeps a JavaScript `Map` of unique strings, which V8 limits to about 16.7 million entries.
201
+ - Memory after a load is about 16 bytes for each node (plus 4 for each spatial index that holds it), about 82 bytes plus 4 for each ref for each way, about 82 bytes plus 13 for each member for each relation, and 12 bytes for each tag. `Nodes`, `Ways` and `Relations.getBytesRequired` give these estimates.
153
202
  - Coordinates stored as `Int32Array` microdegrees (1e-7 degree precision, ~1cm at equator); converted to degrees at API boundaries.
203
+ - Algorithms that need arbitrary untagged-node lookup require the all-node spatial capability. Build it
204
+ explicitly or load with the Full profile from `@osmix/load`.
205
+ - See [docs/limits.md](../../docs/limits.md) for all limits and for measured memory use.
154
206
 
155
207
  ## Related Packages
156
208
 
157
209
  - [`osmix`](../osmix/README.md) — High-level API for loading PBF files and worker orchestration.
210
+ - [`@osmix/load`](../load/README.md) — PBF loading, geographic extracts, and export into `Osm` indexes.
158
211
  - [`@osmix/pbf`](../pbf/README.md) — Low-level PBF parsing and serialization.
159
212
  - [`@osmix/json`](../json/README.md) — JSON entity conversion.
160
213
  - [`@osmix/geojson`](../geojson/README.md) — Convert entities to GeoJSON features.
@@ -163,9 +216,20 @@ const osm = new Osm(transferables)
163
216
  ## Development
164
217
 
165
218
  ```sh
166
- bun run test packages/core
167
- bun run typecheck packages/core
168
- bun run lint packages/core
219
+ pnpm run test packages/core
220
+ pnpm exec oxlint packages/core
169
221
  ```
170
222
 
171
- Run `bun run check` at the repo root before publishing.
223
+ Run `pnpm run verify` at the repo root before publishing.
224
+
225
+ ## Test helpers
226
+
227
+ Mock OSM datasets for tests are available via a separate entrypoint (not re-exported from the main package):
228
+
229
+ ```ts check-docs
230
+ import { createMockBaseOsm, createMockPatchOsm } from "@osmix/core/mocks";
231
+
232
+ const base = createMockBaseOsm();
233
+ const patch = createMockPatchOsm();
234
+ console.log(base.id, patch.id);
235
+ ```
@@ -0,0 +1,27 @@
1
+ import type { GeoBbox2D } from "@osmix/types";
2
+ import type { Nodes } from "./nodes.ts";
3
+ import type { Relations } from "./relations.ts";
4
+ import type { Ways } from "./ways.ts";
5
+ /**
6
+ * Read-only contract for tile encoders, exporters, and spatial queries.
7
+ *
8
+ * Encoders only need entity accessors and spatial indexes; they do not mutate
9
+ * the underlying dataset. The concrete {@link Osm} class satisfies this interface.
10
+ */
11
+ export interface OsmReader {
12
+ readonly id: string;
13
+ readonly nodes: Nodes;
14
+ readonly ways: Ways;
15
+ readonly relations: Relations;
16
+ /** Bounding box of all nodes, or `null` when the dataset has no nodes. */
17
+ bbox(): GeoBbox2D | null;
18
+ }
19
+ /**
20
+ * Write contract for format importers that populate an in-memory index.
21
+ */
22
+ export interface OsmWriter extends OsmReader {
23
+ buildIndexes(): void;
24
+ buildSpatialIndexes(): void;
25
+ isReady(): boolean;
26
+ }
27
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,0EAA0E;IAC1E,IAAI,IAAI,SAAS,GAAG,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,SAAS;IAC1C,YAAY,IAAI,IAAI,CAAC;IACrB,mBAAmB,IAAI,IAAI,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAC;CACpB"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":""}
@@ -7,10 +7,27 @@
7
7
  * @module
8
8
  */
9
9
  import type { ContentHasher } from "@osmix/shared/content-hasher";
10
- import type { GeoBbox2D, OsmEntity, OsmEntityType, OsmTags } from "@osmix/shared/types";
10
+ import type { GeoBbox2D, OsmEntity, OsmEntityType, OsmTags } from "@osmix/types";
11
11
  import type { IdOrIndex, Ids, IdsTransferables } from "./ids.ts";
12
12
  import type { Tags, TagsTransferables } from "./tags.ts";
13
- import type { BufferType } from "./typed-arrays.ts";
13
+ import { type BufferType, type TypedBufferAllocationOperation, type TypedBufferType } from "./typed-arrays.ts";
14
+ export type OsmEntityIndexComponent = "ids" | "tags" | "entity-data";
15
+ /** Whether bbox coordinates describe a non-inverted spatial item. */
16
+ export declare function isValidSpatialBbox(minX: number, minY: number, maxX: number, maxY: number): boolean;
17
+ /** Structured entity-finalization failure suitable for actionable load diagnostics. */
18
+ export declare class OsmEntityIndexBuildError extends Error {
19
+ readonly code = "OSM_ENTITY_INDEX_BUILD_FAILED";
20
+ readonly stage = "entity-index-finalization";
21
+ readonly entityType: OsmEntityType;
22
+ readonly component: OsmEntityIndexComponent;
23
+ readonly operation?: TypedBufferAllocationOperation;
24
+ readonly typedArray?: string;
25
+ readonly bufferType?: TypedBufferType;
26
+ readonly elementCount?: number;
27
+ readonly bytesPerElement?: number;
28
+ readonly requiredBytes?: number;
29
+ constructor(entityType: OsmEntityType, component: OsmEntityIndexComponent, cause: unknown);
30
+ }
14
31
  /**
15
32
  * Serializable representation of an Entities collection for worker transfer.
16
33
  * Combines ID and tag transferables; subclasses add entity-specific data.
@@ -62,6 +79,7 @@ export declare abstract class Entities<T extends OsmEntity> {
62
79
  * Must be called after adding entities and before querying.
63
80
  */
64
81
  buildIndex(): void;
82
+ private buildIndexComponent;
65
83
  /**
66
84
  * Get the bounding box of an entity.
67
85
  * @param idOrIndex - Entity identifier (by ID or internal index).
@@ -107,6 +125,8 @@ export declare abstract class Entities<T extends OsmEntity> {
107
125
  * Iterate over entities sorted by ID.
108
126
  */
109
127
  sorted(): Generator<T>;
128
+ /** @internal Iterate entities in canonical OSM file order. */
129
+ osmSorted(): Generator<T>;
110
130
  /**
111
131
  * Search for entities with a specific tag key and optional value.
112
132
  */
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AACjE,OAAO,KAAK,EACX,SAAS,EACT,SAAS,EACT,aAAa,EACb,OAAO,EACP,MAAM,qBAAqB,CAAA;AAC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C,CAIzB;IAED;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,CAKrC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAE/C;CACF"}
package/dist/entities.js CHANGED
@@ -6,6 +6,39 @@
6
6
  *
7
7
  * @module
8
8
  */
9
+ import { TypedBufferAllocationError, } from "./typed-arrays.js";
10
+ /** Whether bbox coordinates describe a non-inverted spatial item. */
11
+ export function isValidSpatialBbox(minX, minY, maxX, maxY) {
12
+ return minX <= maxX && minY <= maxY;
13
+ }
14
+ /** Structured entity-finalization failure suitable for actionable load diagnostics. */
15
+ export class OsmEntityIndexBuildError extends Error {
16
+ code = "OSM_ENTITY_INDEX_BUILD_FAILED";
17
+ stage = "entity-index-finalization";
18
+ entityType;
19
+ component;
20
+ operation;
21
+ typedArray;
22
+ bufferType;
23
+ elementCount;
24
+ bytesPerElement;
25
+ requiredBytes;
26
+ constructor(entityType, component, cause) {
27
+ const detail = cause instanceof Error ? cause.message : String(cause);
28
+ super(`Failed to finalize ${entityType} ${component}: ${detail}`, { cause });
29
+ this.name = "OsmEntityIndexBuildError";
30
+ this.entityType = entityType;
31
+ this.component = component;
32
+ if (cause instanceof TypedBufferAllocationError) {
33
+ this.operation = cause.operation;
34
+ this.typedArray = cause.typedArray;
35
+ this.bufferType = cause.bufferType;
36
+ this.elementCount = cause.elementCount;
37
+ this.bytesPerElement = cause.bytesPerElement;
38
+ this.requiredBytes = cause.requiredBytes;
39
+ }
40
+ }
41
+ }
9
42
  /**
10
43
  * Abstract base for typed entity collections.
11
44
  *
@@ -61,12 +94,22 @@ export class Entities {
61
94
  if (this.indexBuilt)
62
95
  return;
63
96
  console.time(`${this.indexType}Index.buildIndex`);
64
- this.ids.buildIndex();
65
- this.tags.buildIndex();
66
- this.buildEntityIndex();
97
+ this.buildIndexComponent("ids", () => this.ids.buildIndex());
98
+ this.buildIndexComponent("tags", () => this.tags.buildIndex());
99
+ this.buildIndexComponent("entity-data", () => this.buildEntityIndex());
67
100
  this.indexBuilt = true;
68
101
  console.timeEnd(`${this.indexType}Index.buildIndex`);
69
102
  }
103
+ buildIndexComponent(component, build) {
104
+ try {
105
+ build();
106
+ }
107
+ catch (cause) {
108
+ if (cause instanceof OsmEntityIndexBuildError)
109
+ throw cause;
110
+ throw new OsmEntityIndexBuildError(this.indexType, component, cause);
111
+ }
112
+ }
70
113
  addEntity(id, tags, values) {
71
114
  const entityIndex = this.ids.add(id);
72
115
  if (Array.isArray(tags)) {
@@ -129,10 +172,13 @@ export class Entities {
129
172
  * Iterate over entities sorted by ID.
130
173
  */
131
174
  *sorted() {
132
- for (const id of this.ids.sorted) {
133
- const index = this.ids.getIndexFromId(id);
134
- if (index === -1)
135
- throw Error(`Entity not found at id ${id}`);
175
+ for (const [id, index] of this.ids.sortedEntries()) {
176
+ yield this.getFullEntity(index, id, this.tags.getTags(index));
177
+ }
178
+ }
179
+ /** @internal Iterate entities in canonical OSM file order. */
180
+ *osmSorted() {
181
+ for (const [id, index] of this.ids.osmSortedEntries()) {
136
182
  yield this.getFullEntity(index, id, this.tags.getTags(index));
137
183
  }
138
184
  }
@@ -141,9 +187,7 @@ export class Entities {
141
187
  */
142
188
  search(key, val) {
143
189
  const keyIndex = this.tags.find(key);
144
- const entities = this.tags
145
- .hasKey(keyIndex)
146
- .map((index) => this.getByIndex(index));
190
+ const entities = this.tags.hasKey(keyIndex).map((index) => this.getByIndex(index));
147
191
  if (val === undefined)
148
192
  return entities;
149
193
  return entities.filter((entity) => entity.tags?.[key] === val);
@@ -1 +1 @@
1
- {"version":3,"file":"entities.js","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH;;;;;;;GAOG;AACH,MAAM,OAAgB,QAAQ;IAC7B,mFAAmF;IACnF,SAAS,CAAe;IACxB,4BAA4B;IAC5B,GAAG,CAAK;IACR,6BAA6B;I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