@osmix/core 0.2.0 → 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.
- package/CHANGELOG.md +31 -0
- package/README.md +54 -7
- package/dist/contracts.d.ts +2 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/entities.d.ts +21 -1
- package/dist/entities.d.ts.map +1 -1
- package/dist/entities.js +52 -3
- package/dist/entities.js.map +1 -1
- package/dist/ids.d.ts +18 -5
- package/dist/ids.d.ts.map +1 -1
- package/dist/ids.js +68 -18
- package/dist/ids.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/indirect-kd-index.d.ts +28 -0
- package/dist/indirect-kd-index.d.ts.map +1 -0
- package/dist/indirect-kd-index.js +163 -0
- package/dist/indirect-kd-index.js.map +1 -0
- package/dist/limits.d.ts +30 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +51 -0
- package/dist/limits.js.map +1 -0
- package/dist/nodes.d.ts +28 -13
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +181 -51
- package/dist/nodes.js.map +1 -1
- package/dist/osm.d.ts +59 -3
- package/dist/osm.d.ts.map +1 -1
- package/dist/osm.js +31 -2
- package/dist/osm.js.map +1 -1
- package/dist/relations.d.ts +10 -4
- package/dist/relations.d.ts.map +1 -1
- package/dist/relations.js +66 -28
- package/dist/relations.js.map +1 -1
- package/dist/renumber.d.ts +23 -0
- package/dist/renumber.d.ts.map +1 -0
- package/dist/renumber.js +64 -0
- package/dist/renumber.js.map +1 -0
- package/dist/stringtable.d.ts +2 -1
- package/dist/stringtable.d.ts.map +1 -1
- package/dist/stringtable.js +5 -1
- package/dist/stringtable.js.map +1 -1
- package/dist/tags.d.ts +44 -11
- package/dist/tags.d.ts.map +1 -1
- package/dist/tags.js +153 -27
- package/dist/tags.js.map +1 -1
- package/dist/typed-arrays.d.ts +63 -48
- package/dist/typed-arrays.d.ts.map +1 -1
- package/dist/typed-arrays.js +184 -107
- package/dist/typed-arrays.js.map +1 -1
- package/dist/ways.d.ts +50 -2
- package/dist/ways.d.ts.map +1 -1
- package/dist/ways.js +212 -35
- package/dist/ways.js.map +1 -1
- package/package.json +11 -12
- package/src/contracts.ts +2 -1
- package/src/entities.ts +67 -4
- package/src/ids.ts +72 -22
- package/src/index.ts +13 -7
- package/src/indirect-kd-index.ts +212 -0
- package/src/limits.ts +73 -0
- package/src/nodes.ts +228 -54
- package/src/osm.ts +90 -4
- package/src/relations.ts +80 -30
- package/src/renumber.ts +80 -0
- package/src/stringtable.ts +15 -1
- package/src/tags.ts +173 -31
- package/src/typed-arrays.ts +225 -113
- package/src/ways.ts +233 -38
- package/test/entity-index-errors.test.ts +41 -0
- package/test/ids.bench.ts +11 -7
- package/test/ids.test.ts +38 -0
- package/test/limits.test.ts +83 -0
- package/test/no-shared-array-buffer.test.ts +41 -0
- package/test/nodes-spatial-index.test.ts +261 -0
- package/test/osm-bbox.test.ts +30 -0
- package/test/relations.bench.ts +9 -4
- package/test/relations.test.ts +52 -29
- package/test/renumber.test.ts +54 -0
- package/test/spatial-index-rebuild.test.ts +33 -0
- package/test/storage-compaction.test.ts +269 -0
- package/test/tags-search.test.ts +13 -0
- package/test/typed-arrays.test.ts +178 -59
- package/src/types/geokdbush.d.ts +0 -32
- package/src/types/kdbush.d.ts +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
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
|
+
|
|
3
34
|
## 0.2.0
|
|
4
35
|
|
|
5
36
|
### Minor Changes
|
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**:
|
|
8
|
-
- **Spatial indexing**:
|
|
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.
|
|
@@ -88,6 +88,13 @@ const { ids: wayIds, positions: wayCoords, startIndices } = osm.ways.withinBbox(
|
|
|
88
88
|
// Radius query (uses great-circle distance)
|
|
89
89
|
const nearbyIndexes = osm.nodes.findIndexesWithinRadius(-122.4, 47.6, 10); // 10km
|
|
90
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"));
|
|
97
|
+
|
|
91
98
|
// Get entities from indexes
|
|
92
99
|
const nearbyNodes = nearbyIndexes.map((i) => osm.nodes.getByIndex(i));
|
|
93
100
|
|
|
@@ -112,6 +119,24 @@ const osm = new Osm(transferables);
|
|
|
112
119
|
// Index is already built, ready for queries
|
|
113
120
|
```
|
|
114
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
|
+
|
|
115
140
|
## API
|
|
116
141
|
|
|
117
142
|
### Classes
|
|
@@ -119,7 +144,7 @@ const osm = new Osm(transferables);
|
|
|
119
144
|
| Class | Description |
|
|
120
145
|
| ------------- | ------------------------------------------------------------------- |
|
|
121
146
|
| `Osm` | Main container with nodes, ways, relations, and shared string table |
|
|
122
|
-
| `Nodes` | Node storage with
|
|
147
|
+
| `Nodes` | Node storage with independent all-node and tagged-node KD indexes |
|
|
123
148
|
| `Ways` | Way storage with Flatbush spatial index |
|
|
124
149
|
| `Relations` | Relation storage with Flatbush spatial index |
|
|
125
150
|
| `StringTable` | Deduplicated UTF-8 string storage for tags |
|
|
@@ -150,11 +175,34 @@ const osm = new Osm(transferables);
|
|
|
150
175
|
| `neighbors(lon, lat, max, maxKm)` | Find nearest entities (ways/relations) |
|
|
151
176
|
| `sorted()` | Iterator over entities sorted by ID |
|
|
152
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.
|
|
193
|
+
|
|
153
194
|
## Environment and Limitations
|
|
154
195
|
|
|
155
|
-
- Requires Web Streams, `TextEncoder`/`TextDecoder`, `CompressionStream`/`DecompressionStream` (Bun, Node
|
|
196
|
+
- Requires Web Streams, `TextEncoder`/`TextDecoder`, `CompressionStream`/`DecompressionStream` (Bun, Node 24+, modern browsers).
|
|
156
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.
|
|
157
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.
|
|
158
206
|
|
|
159
207
|
## Related Packages
|
|
160
208
|
|
|
@@ -169,11 +217,10 @@ const osm = new Osm(transferables);
|
|
|
169
217
|
|
|
170
218
|
```sh
|
|
171
219
|
pnpm run test packages/core
|
|
172
|
-
pnpm
|
|
173
|
-
pnpm run lint packages/core
|
|
220
|
+
pnpm exec oxlint packages/core
|
|
174
221
|
```
|
|
175
222
|
|
|
176
|
-
Run `pnpm run
|
|
223
|
+
Run `pnpm run verify` at the repo root before publishing.
|
|
177
224
|
|
|
178
225
|
## Test helpers
|
|
179
226
|
|
package/dist/contracts.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ export interface OsmReader {
|
|
|
13
13
|
readonly nodes: Nodes;
|
|
14
14
|
readonly ways: Ways;
|
|
15
15
|
readonly relations: Relations;
|
|
16
|
-
|
|
16
|
+
/** Bounding box of all nodes, or `null` when the dataset has no nodes. */
|
|
17
|
+
bbox(): GeoBbox2D | null;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Write contract for format importers that populate an in-memory index.
|
package/dist/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sour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"}
|
package/dist/entities.d.ts
CHANGED
|
@@ -10,7 +10,24 @@ import type { ContentHasher } from "@osmix/shared/content-hasher";
|
|
|
10
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
|
|
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
|
*/
|
package/dist/entities.d.ts.map
CHANGED
|
@@ -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,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjF,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EA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MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,CAItB;IAED,8DAA8D;IAC7D,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC,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)) {
|
|
@@ -133,6 +176,12 @@ export class Entities {
|
|
|
133
176
|
yield this.getFullEntity(index, id, this.tags.getTags(index));
|
|
134
177
|
}
|
|
135
178
|
}
|
|
179
|
+
/** @internal Iterate entities in canonical OSM file order. */
|
|
180
|
+
*osmSorted() {
|
|
181
|
+
for (const [id, index] of this.ids.osmSortedEntries()) {
|
|
182
|
+
yield this.getFullEntity(index, id, this.tags.getTags(index));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
136
185
|
/**
|
|
137
186
|
* Search for entities with a specific tag key and optional value.
|
|
138
187
|
*/
|
package/dist/entities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../src/entities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EACL,0BAA0B,GAI3B,MAAM,mBAAmB,CAAC;AAI3B,qEAAqE;AACrE,MAAM,UAAU,kBAAkB,CAChC,IAAY,EACZ,IAAY,EACZ,IAAY,EACZ,IAAY;IAEZ,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC;AACtC,CAAC;AAED,uFAAuF;AACvF,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,IAAI,GAAG,+BAA+B,CAAC;IACvC,KAAK,GAAG,2BAA2B,CAAC;IACpC,UAAU,CAAgB;IAC1B,SAAS,CAA0B;IACnC,SAAS,CAAkC;IAC3C,UAAU,CAAU;IACpB,UAAU,CAAmB;IAC7B,YAAY,CAAU;IACtB,eAAe,CAAU;IACzB,aAAa,CAAU;IAEhC,YAAY,UAAyB,EAAE,SAAkC,EAAE,KAAc;QACvF,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,KAAK,CAAC,sBAAsB,UAAU,IAAI,SAAS,KAAK,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,KAAK,YAAY,0BAA0B,EAAE,CAAC;YAChD,IAAI,CAAC,SAA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AG,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QACvC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAqB;QAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
package/dist/ids.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export type IdOrIndex = {
|
|
|
22
22
|
export interface IdsTransferables<T extends BufferType = BufferType> {
|
|
23
23
|
/** Entity IDs in insertion order. */
|
|
24
24
|
ids: T;
|
|
25
|
-
/** Sorted IDs for binary search
|
|
26
|
-
sortedIds
|
|
27
|
-
/** Maps sorted position → original insertion index. */
|
|
28
|
-
sortedIdPositionToIndex
|
|
25
|
+
/** Sorted IDs for binary search. Omitted when `idsAreSorted` is true. */
|
|
26
|
+
sortedIds?: T;
|
|
27
|
+
/** Maps sorted position → original insertion index. Omitted for sorted IDs. */
|
|
28
|
+
sortedIdPositionToIndex?: T;
|
|
29
29
|
/** Anchor array: every BLOCK_SIZE-th sorted ID. */
|
|
30
30
|
anchors: T;
|
|
31
31
|
/** True if IDs were inserted in ascending order. */
|
|
@@ -103,6 +103,14 @@ export declare class Ids {
|
|
|
103
103
|
get sorted(): Float64Array<ArrayBufferLike>;
|
|
104
104
|
/** @internal Iterate sorted IDs with their original storage positions. */
|
|
105
105
|
sortedEntries(): Generator<readonly [id: number, index: number]>;
|
|
106
|
+
/**
|
|
107
|
+
* Iterate in canonical OSM file order: negative IDs first by increasing
|
|
108
|
+
* absolute value, followed by non-negative IDs in ascending order.
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
osmSortedEntries(): Generator<readonly [id: number, index: number]>;
|
|
113
|
+
private sortedEntry;
|
|
106
114
|
/**
|
|
107
115
|
* Get transferable buffers for passing to another thread.
|
|
108
116
|
* @returns Serializable representation of this index.
|
|
@@ -110,8 +118,13 @@ export declare class Ids {
|
|
|
110
118
|
transferables(): IdsTransferables;
|
|
111
119
|
/**
|
|
112
120
|
* Get the approximate memory requirements for a given number of IDs in bytes.
|
|
121
|
+
*
|
|
122
|
+
* `idsAreSorted` defaults to true because PBF entity collections arrive in
|
|
123
|
+
* ascending ID order and retain no separate sort buffers. Pass false when
|
|
124
|
+
* estimating a programmatically built (unsorted) collection, which also
|
|
125
|
+
* retains sorted IDs plus a position map.
|
|
113
126
|
*/
|
|
114
|
-
static getBytesRequired(count: number): number;
|
|
127
|
+
static getBytesRequired(count: number, idsAreSorted?: boolean): number;
|
|
115
128
|
/**
|
|
116
129
|
* Update a ContentHasher with the IDs data.
|
|
117
130
|
* Uses the sorted IDs for consistent hashing regardless of insertion order.
|
package/dist/ids.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,EAAqB,KAAK,UAAU,EAA+B,MAAM,mBAAmB,CAAC;AAEpG;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAS3D;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IACjE,qCAAqC;IACrC,GAAG,EAAE,CAAC,CAAC;IACP,
|
|
1
|
+
{"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,aAAa,EAA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,UAAU,SAyCT;IAED;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAmCjC;IAED;;OAEG;IACH,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,CAGnD;IAED,qDAAqD;IACrD,IAAI,MAAM,kCAET;IAED,0EAA0E;IACzE,aAAa,IAAI,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAIhE;IAED;;;;;OAKG;IACF,gBAAgB,IAAI,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAuBnE;IAED,OAAO,CAAC,WAAW;IASnB;;;OAGG;IACH,aAAa,IAAI,gBAAgB,CAYhC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,UAAO,UASzD;IAED;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAE/C;CACF"}
|
package/dist/ids.js
CHANGED
|
@@ -40,8 +40,17 @@ export class Ids {
|
|
|
40
40
|
constructor(transferables) {
|
|
41
41
|
if (transferables) {
|
|
42
42
|
this.ids = RTA.from(Float64Array, transferables.ids);
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (transferables.idsAreSorted) {
|
|
44
|
+
this.idsSorted = this.ids.array;
|
|
45
|
+
this.sortedIdPositionToIndex = new Uint32Array(new BufferConstructor(0));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
if (!transferables.sortedIds || !transferables.sortedIdPositionToIndex) {
|
|
49
|
+
throw Error("Unsorted IDs require sorted lookup buffers.");
|
|
50
|
+
}
|
|
51
|
+
this.idsSorted = new Float64Array(transferables.sortedIds);
|
|
52
|
+
this.sortedIdPositionToIndex = new Uint32Array(transferables.sortedIdPositionToIndex);
|
|
53
|
+
}
|
|
45
54
|
this.anchors = new Float64Array(transferables.anchors);
|
|
46
55
|
this.idsAreSorted = transferables.idsAreSorted;
|
|
47
56
|
this.indexBuilt = true;
|
|
@@ -128,12 +137,8 @@ export class Ids {
|
|
|
128
137
|
else {
|
|
129
138
|
// Point to the same array
|
|
130
139
|
this.idsSorted = this.ids.array;
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
this.sortedIdPositionToIndex = new Uint32Array(posBuffer);
|
|
134
|
-
for (let i = 0; i < this.size; i++) {
|
|
135
|
-
this.sortedIdPositionToIndex[i] = i;
|
|
136
|
-
}
|
|
140
|
+
// Sorted position is already the insertion index; no identity map is needed.
|
|
141
|
+
this.sortedIdPositionToIndex = new Uint32Array(new BufferConstructor(0));
|
|
137
142
|
}
|
|
138
143
|
// Build anchors (every blockSize-th key)
|
|
139
144
|
const aLen = Math.ceil(this.size / BLOCK_SIZE);
|
|
@@ -207,35 +212,80 @@ export class Ids {
|
|
|
207
212
|
/** @internal Iterate sorted IDs with their original storage positions. */
|
|
208
213
|
*sortedEntries() {
|
|
209
214
|
for (let i = 0; i < this.idsSorted.length; i++) {
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
yield this.sortedEntry(i);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Iterate in canonical OSM file order: negative IDs first by increasing
|
|
220
|
+
* absolute value, followed by non-negative IDs in ascending order.
|
|
221
|
+
*
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
*osmSortedEntries() {
|
|
225
|
+
let firstNonNegative = 0;
|
|
226
|
+
while (firstNonNegative < this.idsSorted.length && this.idsSorted[firstNonNegative] < 0) {
|
|
227
|
+
firstNonNegative++;
|
|
228
|
+
}
|
|
229
|
+
// Numeric sorting places negative IDs in the opposite of canonical OSM
|
|
230
|
+
// order. Reverse ID groups while preserving duplicate insertion order.
|
|
231
|
+
let groupEnd = firstNonNegative;
|
|
232
|
+
while (groupEnd > 0) {
|
|
233
|
+
const id = this.idsSorted[groupEnd - 1];
|
|
212
234
|
assertValue(id, "Sorted ID is undefined");
|
|
213
|
-
|
|
214
|
-
|
|
235
|
+
let groupStart = groupEnd - 1;
|
|
236
|
+
while (groupStart > 0 && this.idsSorted[groupStart - 1] === id)
|
|
237
|
+
groupStart--;
|
|
238
|
+
for (let position = groupStart; position < groupEnd; position++) {
|
|
239
|
+
yield this.sortedEntry(position);
|
|
240
|
+
}
|
|
241
|
+
groupEnd = groupStart;
|
|
242
|
+
}
|
|
243
|
+
for (let position = firstNonNegative; position < this.idsSorted.length; position++) {
|
|
244
|
+
yield this.sortedEntry(position);
|
|
215
245
|
}
|
|
216
246
|
}
|
|
247
|
+
sortedEntry(position) {
|
|
248
|
+
const id = this.idsSorted[position];
|
|
249
|
+
assertValue(id, "Sorted ID is undefined");
|
|
250
|
+
if (this.idsAreSorted)
|
|
251
|
+
return [id, position];
|
|
252
|
+
const index = this.sortedIdPositionToIndex[position];
|
|
253
|
+
assertValue(index, "Sorted position is undefined");
|
|
254
|
+
return [id, index];
|
|
255
|
+
}
|
|
217
256
|
/**
|
|
218
257
|
* Get transferable buffers for passing to another thread.
|
|
219
258
|
* @returns Serializable representation of this index.
|
|
220
259
|
*/
|
|
221
260
|
transferables() {
|
|
222
|
-
|
|
261
|
+
const base = {
|
|
223
262
|
ids: this.ids.array.buffer,
|
|
224
|
-
sortedIds: this.idsSorted.buffer,
|
|
225
|
-
sortedIdPositionToIndex: this.sortedIdPositionToIndex.buffer,
|
|
226
263
|
anchors: this.anchors.buffer,
|
|
227
264
|
idsAreSorted: this.idsAreSorted,
|
|
228
265
|
};
|
|
266
|
+
if (this.idsAreSorted)
|
|
267
|
+
return base;
|
|
268
|
+
return {
|
|
269
|
+
...base,
|
|
270
|
+
sortedIds: this.idsSorted.buffer,
|
|
271
|
+
sortedIdPositionToIndex: this.sortedIdPositionToIndex.buffer,
|
|
272
|
+
};
|
|
229
273
|
}
|
|
230
274
|
/**
|
|
231
275
|
* Get the approximate memory requirements for a given number of IDs in bytes.
|
|
276
|
+
*
|
|
277
|
+
* `idsAreSorted` defaults to true because PBF entity collections arrive in
|
|
278
|
+
* ascending ID order and retain no separate sort buffers. Pass false when
|
|
279
|
+
* estimating a programmatically built (unsorted) collection, which also
|
|
280
|
+
* retains sorted IDs plus a position map.
|
|
232
281
|
*/
|
|
233
|
-
static getBytesRequired(count) {
|
|
282
|
+
static getBytesRequired(count, idsAreSorted = true) {
|
|
234
283
|
if (count === 0)
|
|
235
284
|
return 0;
|
|
236
285
|
return (count * Float64Array.BYTES_PER_ELEMENT + // ids
|
|
237
|
-
|
|
238
|
-
|
|
286
|
+
(idsAreSorted
|
|
287
|
+
? 0
|
|
288
|
+
: count * (Float64Array.BYTES_PER_ELEMENT + Uint32Array.BYTES_PER_ELEMENT)) + // sort index
|
|
239
289
|
Math.ceil(count / BLOCK_SIZE) * Float64Array.BYTES_PER_ELEMENT // anchors
|
|
240
290
|
);
|
|
241
291
|
}
|
package/dist/ids.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ids.js","sourceRoot":"","sources":["../src/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,iBAAiB,EAAmB,oBAAoB,IAAI,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAOpG;;;;GAIG;AACH,MAAM,UAAU,GAAG,GAAG,CAAC;AAkBvB;;;;;GAKG;AACH,MAAM,OAAO,GAAG;IACd,iCAAiC;IACzB,GAAG,CAAoB;IAC/B,2CAA2C;IACnC,UAAU,GAAG,KAAK,CAAC;IAC3B,4EAA4E;IACpE,YAAY,GAAG,IAAI,CAAC;IAC5B,2CAA2C;IACnC,SAAS,CAAe;IAChC,+DAA+D;IACvD,uBAAuB,CAAc;IAC7C,8EAA8E;IACtE,OAAO,CAAe;IAE9B;;;OAGG;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
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Efficiently stores and queries OpenStreetMap entities (nodes, ways, relations).
|
|
5
5
|
*
|
|
6
6
|
* Features:
|
|
7
|
-
* - **Memory-efficient**: Uses typed arrays
|
|
8
|
-
* - **Spatial indexing**:
|
|
7
|
+
* - **Memory-efficient**: Uses typed arrays; coordinates are Int32 at 1e-7 degrees.
|
|
8
|
+
* - **Spatial indexing**: Compact indirect KD trees (points) and Flatbush (bboxes).
|
|
9
9
|
* - **Worker-ready**: Zero-copy transfer via `transferables()`.
|
|
10
10
|
* - **Tag indexing**: Fast reverse lookup by tag key.
|
|
11
11
|
*
|
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
*/
|
|
24
24
|
export type { IdOrIndex } from "./ids.ts";
|
|
25
25
|
export type { OsmReader, OsmWriter } from "./contracts.ts";
|
|
26
|
+
export { OsmEntityIndexBuildError, type OsmEntityIndexComponent } from "./entities.ts";
|
|
27
|
+
export * from "./limits.ts";
|
|
26
28
|
export * from "./nodes.ts";
|
|
27
29
|
export * from "./osm.ts";
|
|
28
30
|
export * from "./relations.ts";
|
|
31
|
+
export { negativeIdMap, renumberNegativeIds, type OsmIdMap } from "./renumber.ts";
|
|
29
32
|
export * from "./stringtable.ts";
|
|
30
33
|
export * from "./tags.ts";
|
|
31
|
-
export { BufferConstructor, type BufferType } from "./typed-arrays.ts";
|
|
34
|
+
export { BufferConstructor, ResizeableTypedArray, TypedBufferAllocationError, type BufferType, type TypedBufferAllocationOperation, type TypedBufferType, } from "./typed-arrays.ts";
|
|
32
35
|
export * from "./ways.ts";
|
|
33
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,KAAK,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACvF,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAClF,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,UAAU,EACf,KAAK,8BAA8B,EACnC,KAAK,eAAe,GACrB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Efficiently stores and queries OpenStreetMap entities (nodes, ways, relations).
|
|
5
5
|
*
|
|
6
6
|
* Features:
|
|
7
|
-
* - **Memory-efficient**: Uses typed arrays
|
|
8
|
-
* - **Spatial indexing**:
|
|
7
|
+
* - **Memory-efficient**: Uses typed arrays; coordinates are Int32 at 1e-7 degrees.
|
|
8
|
+
* - **Spatial indexing**: Compact indirect KD trees (points) and Flatbush (bboxes).
|
|
9
9
|
* - **Worker-ready**: Zero-copy transfer via `transferables()`.
|
|
10
10
|
* - **Tag indexing**: Fast reverse lookup by tag key.
|
|
11
11
|
*
|
|
@@ -21,11 +21,14 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @module @osmix/core
|
|
23
23
|
*/
|
|
24
|
+
export { OsmEntityIndexBuildError } from "./entities.js";
|
|
25
|
+
export * from "./limits.js";
|
|
24
26
|
export * from "./nodes.js";
|
|
25
27
|
export * from "./osm.js";
|
|
26
28
|
export * from "./relations.js";
|
|
29
|
+
export { negativeIdMap, renumberNegativeIds } from "./renumber.js";
|
|
27
30
|
export * from "./stringtable.js";
|
|
28
31
|
export * from "./tags.js";
|
|
29
|
-
export { BufferConstructor } from "./typed-arrays.js";
|
|
32
|
+
export { BufferConstructor, ResizeableTypedArray, TypedBufferAllocationError, } from "./typed-arrays.js";
|
|
30
33
|
export * from "./ways.js";
|
|
31
34
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAOH,OAAO,EAAE,wBAAwB,EAAgC,MAAM,eAAe,CAAC;AACvF,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAiB,MAAM,eAAe,CAAC;AAClF,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,0BAA0B,GAI3B,MAAM,mBAAmB,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|