@osmix/core 0.1.3 → 0.1.6

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 (109) hide show
  1. package/dist/entities.d.ts +1 -1
  2. package/dist/entities.d.ts.map +1 -1
  3. package/dist/ids.d.ts +1 -1
  4. package/dist/ids.d.ts.map +1 -1
  5. package/dist/ids.js +1 -2
  6. package/dist/ids.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +0 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/nodes.d.ts +1 -1
  12. package/dist/nodes.d.ts.map +1 -1
  13. package/dist/nodes.js.map +1 -1
  14. package/dist/osm.d.ts.map +1 -1
  15. package/dist/osm.js +1 -1
  16. package/dist/osm.js.map +1 -1
  17. package/dist/relations.d.ts +1 -1
  18. package/dist/relations.d.ts.map +1 -1
  19. package/dist/relations.js +1 -1
  20. package/dist/relations.js.map +1 -1
  21. package/dist/stringtable.d.ts +1 -1
  22. package/dist/stringtable.d.ts.map +1 -1
  23. package/dist/stringtable.js.map +1 -1
  24. package/dist/tags.d.ts +1 -1
  25. package/dist/tags.d.ts.map +1 -1
  26. package/dist/tags.js.map +1 -1
  27. package/dist/typed-arrays.d.ts +2 -2
  28. package/dist/ways.d.ts +1 -1
  29. package/dist/ways.d.ts.map +1 -1
  30. package/dist/ways.js +0 -7
  31. package/dist/ways.js.map +1 -1
  32. package/package.json +22 -20
  33. package/src/entities.ts +1 -1
  34. package/src/ids.ts +2 -3
  35. package/src/index.ts +1 -1
  36. package/src/nodes.ts +1 -1
  37. package/src/osm.ts +1 -1
  38. package/src/relations.ts +2 -1
  39. package/src/stringtable.ts +1 -1
  40. package/src/tags.ts +1 -1
  41. package/src/ways.ts +1 -8
  42. package/CHANGELOG.md +0 -97
  43. package/dist/src/entities.d.ts +0 -120
  44. package/dist/src/entities.d.ts.map +0 -1
  45. package/dist/src/entities.js +0 -159
  46. package/dist/src/entities.js.map +0 -1
  47. package/dist/src/ids.d.ts +0 -119
  48. package/dist/src/ids.d.ts.map +0 -1
  49. package/dist/src/ids.js +0 -243
  50. package/dist/src/ids.js.map +0 -1
  51. package/dist/src/index.d.ts +0 -32
  52. package/dist/src/index.d.ts.map +0 -1
  53. package/dist/src/index.js +0 -35
  54. package/dist/src/index.js.map +0 -1
  55. package/dist/src/nodes.d.ts +0 -106
  56. package/dist/src/nodes.d.ts.map +0 -1
  57. package/dist/src/nodes.js +0 -318
  58. package/dist/src/nodes.js.map +0 -1
  59. package/dist/src/osm.d.ts +0 -99
  60. package/dist/src/osm.d.ts.map +0 -1
  61. package/dist/src/osm.js +0 -165
  62. package/dist/src/osm.js.map +0 -1
  63. package/dist/src/relations.d.ts +0 -123
  64. package/dist/src/relations.d.ts.map +0 -1
  65. package/dist/src/relations.js +0 -424
  66. package/dist/src/relations.js.map +0 -1
  67. package/dist/src/stringtable.d.ts +0 -101
  68. package/dist/src/stringtable.d.ts.map +0 -1
  69. package/dist/src/stringtable.js +0 -180
  70. package/dist/src/stringtable.js.map +0 -1
  71. package/dist/src/tags.d.ts +0 -132
  72. package/dist/src/tags.d.ts.map +0 -1
  73. package/dist/src/tags.js +0 -239
  74. package/dist/src/tags.js.map +0 -1
  75. package/dist/src/typed-arrays.d.ts +0 -124
  76. package/dist/src/typed-arrays.d.ts.map +0 -1
  77. package/dist/src/typed-arrays.js +0 -198
  78. package/dist/src/typed-arrays.js.map +0 -1
  79. package/dist/src/utils.d.ts +0 -38
  80. package/dist/src/utils.d.ts.map +0 -1
  81. package/dist/src/utils.js +0 -87
  82. package/dist/src/utils.js.map +0 -1
  83. package/dist/src/ways.d.ts +0 -106
  84. package/dist/src/ways.d.ts.map +0 -1
  85. package/dist/src/ways.js +0 -346
  86. package/dist/src/ways.js.map +0 -1
  87. package/dist/test/memory.test.d.ts +0 -7
  88. package/dist/test/memory.test.d.ts.map +0 -1
  89. package/dist/test/memory.test.js +0 -29
  90. package/dist/test/memory.test.js.map +0 -1
  91. package/dist/test/mock-osm.d.ts +0 -13
  92. package/dist/test/mock-osm.d.ts.map +0 -1
  93. package/dist/test/mock-osm.js +0 -122
  94. package/dist/test/mock-osm.js.map +0 -1
  95. package/dist/test/tags-search.test.d.ts +0 -2
  96. package/dist/test/tags-search.test.d.ts.map +0 -1
  97. package/dist/test/tags-search.test.js +0 -56
  98. package/dist/test/tags-search.test.js.map +0 -1
  99. package/dist/test/typed-arrays.test.d.ts +0 -2
  100. package/dist/test/typed-arrays.test.d.ts.map +0 -1
  101. package/dist/test/typed-arrays.test.js +0 -102
  102. package/dist/test/typed-arrays.test.js.map +0 -1
  103. package/dist/utils.d.ts +0 -38
  104. package/dist/utils.d.ts.map +0 -1
  105. package/dist/utils.js +0 -87
  106. package/dist/utils.js.map +0 -1
  107. package/src/utils.ts +0 -95
  108. package/tsconfig.build.json +0 -5
  109. package/tsconfig.json +0 -9
@@ -1,159 +0,0 @@
1
- /**
2
- * Base class for OSM entity collections.
3
- *
4
- * Provides common ID and tag storage, streaming iteration, and sorted access.
5
- * Subclasses implement entity-specific storage and spatial indexing.
6
- *
7
- * @module
8
- */
9
- /**
10
- * Abstract base for typed entity collections.
11
- *
12
- * Lifecycle:
13
- * 1. **Ingest**: `addEntity()` (no lookups).
14
- * 2. **Finalize**: `buildIndex()`.
15
- * 3. **Query**: Lookups and iteration enabled.
16
- */
17
- export class Entities {
18
- /** The type of entity stored in this collection ("node", "way", or "relation"). */
19
- indexType;
20
- /** ID storage and lookup */
21
- ids;
22
- /** Tag storage and search */
23
- tags;
24
- /** Whether buildIndex() has been called */
25
- indexBuilt = false;
26
- /**
27
- * Create a new Entities collection.
28
- * @param indexType - The entity type ("node", "way", or "relation").
29
- * @param ids - The ID storage instance.
30
- * @param tags - The tag storage instance.
31
- */
32
- constructor(indexType, ids, tags) {
33
- this.indexType = indexType;
34
- this.ids = ids;
35
- this.tags = tags;
36
- }
37
- /**
38
- * Get transferable objects for passing to another thread.
39
- */
40
- transferables() {
41
- return {
42
- ...this.ids.transferables(),
43
- ...this.tags.transferables(),
44
- };
45
- }
46
- /**
47
- * Check if the index is built and ready for use.
48
- */
49
- isReady() {
50
- return this.ids.isReady() && this.tags.isReady() && this.indexBuilt;
51
- }
52
- /** Number of entities in this collection. */
53
- get size() {
54
- return this.ids.size;
55
- }
56
- /**
57
- * Finalize indexes.
58
- * Must be called after adding entities and before querying.
59
- */
60
- buildIndex() {
61
- if (this.indexBuilt)
62
- return;
63
- console.time(`${this.indexType}Index.buildIndex`);
64
- this.ids.buildIndex();
65
- this.tags.buildIndex();
66
- this.buildEntityIndex();
67
- this.indexBuilt = true;
68
- console.timeEnd(`${this.indexType}Index.buildIndex`);
69
- }
70
- addEntity(id, tags, values) {
71
- const entityIndex = this.ids.add(id);
72
- if (Array.isArray(tags)) {
73
- if (values === undefined)
74
- throw Error("Values are required when tags is an array");
75
- this.tags.addTagKeysAndValues(entityIndex, tags, values);
76
- }
77
- else {
78
- this.tags.addTags(entityIndex, tags);
79
- }
80
- return entityIndex;
81
- }
82
- /**
83
- * Get an entity by ID or index.
84
- */
85
- get(idOrIndex) {
86
- const [index, id] = this.ids.idOrIndex(idOrIndex);
87
- if (index === -1)
88
- return null;
89
- return this.getFullEntity(index, id, this.tags.getTags(index));
90
- }
91
- /**
92
- * Get an entity by index.
93
- */
94
- getByIndex(index) {
95
- return this.getFullEntity(index, this.ids.at(index), this.tags.getTags(index));
96
- }
97
- /**
98
- * Get multiple entities by their indexes.
99
- */
100
- getEntitiesByIndex(indexes) {
101
- const entities = [];
102
- for (const index of indexes) {
103
- const entity = this.getByIndex(index);
104
- if (entity)
105
- entities.push(entity);
106
- else
107
- throw Error(`Entity not found at index ${index}`);
108
- }
109
- return entities;
110
- }
111
- /**
112
- * Iterate over all entities in the index.
113
- */
114
- *[Symbol.iterator]() {
115
- for (let i = 0; i < this.size; i++) {
116
- yield this.getFullEntity(i, this.ids.at(i), this.tags.getTags(i));
117
- }
118
- }
119
- /**
120
- * Get an entity by ID.
121
- */
122
- getById(id) {
123
- const index = this.ids.getIndexFromId(id);
124
- if (index !== -1)
125
- return this.getFullEntity(index, id, this.tags.getTags(index));
126
- return null;
127
- }
128
- /**
129
- * Iterate over entities sorted by ID.
130
- */
131
- *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}`);
136
- yield this.getFullEntity(index, id, this.tags.getTags(index));
137
- }
138
- }
139
- /**
140
- * Search for entities with a specific tag key and optional value.
141
- */
142
- search(key, val) {
143
- const keyIndex = this.tags.find(key);
144
- const entities = this.tags
145
- .hasKey(keyIndex)
146
- .map((index) => this.getByIndex(index));
147
- if (val === undefined)
148
- return entities;
149
- return entities.filter((entity) => entity.tags?.[key] === val);
150
- }
151
- /**
152
- * Update a ContentHasher with this entity collection's base data (IDs and tags).
153
- * Subclasses should override to add entity-specific data.
154
- */
155
- updateHash(hasher) {
156
- return this.ids.updateHash(this.tags.updateHash(hasher));
157
- }
158
- }
159
- //# sourceMappingURL=entities.js.map
@@ -1 +0,0 @@
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;IAC7B,IAAI,CAAM;IAEV,2CAA2C;IACjC,UAAU,GAAG,KAAK,CAAA;IAE5B;;;;;OAKG;IACH,YAAY,SAAwB,EAAE,GAAQ,EAAE,IAAU;QACzD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACjB,CAAC;IAED;;OAEG;IACH,aAAa;QACZ,OAAO;YACN,GAAG,IAAI,CAAC,GAAG,CAA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C/D,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAqB;QAC/B,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;IACzD,CAAC;CACD"}
package/dist/src/ids.d.ts DELETED
@@ -1,119 +0,0 @@
1
- /**
2
- * ID storage and lookup for OSM entities.
3
- *
4
- * Uses a two-level binary search (anchor array + block search) to map 64-bit OSM IDs
5
- * to internal array indices. Balances memory usage with O(log n) lookup speed.
6
- *
7
- * @module
8
- */
9
- import { type BufferType } from "./typed-arrays";
10
- import type { ContentHasher } from "./utils";
11
- /**
12
- * Union type for looking up entities by either OSM ID or internal array index.
13
- */
14
- export type IdOrIndex = {
15
- id: number;
16
- } | {
17
- index: number;
18
- };
19
- /**
20
- * Serializable state for worker transfer.
21
- */
22
- export interface IdsTransferables<T extends BufferType = BufferType> {
23
- /** Entity IDs in insertion order. */
24
- ids: T;
25
- /** Sorted IDs for binary search (aliases `ids` if already sorted). */
26
- sortedIds: T;
27
- /** Maps sorted position → original insertion index. */
28
- sortedIdPositionToIndex: T;
29
- /** Anchor array: every BLOCK_SIZE-th sorted ID. */
30
- anchors: T;
31
- /** True if IDs were inserted in ascending order. */
32
- idsAreSorted: boolean;
33
- }
34
- /**
35
- * Efficiently store and lookup OSM entity IDs.
36
- *
37
- * Stores 64-bit IDs in a Float64Array and maintains a sorted index for O(log n) lookups.
38
- * Max capacity: ~2^32 entities.
39
- */
40
- export declare class Ids {
41
- /** All IDs in insertion order */
42
- private ids;
43
- /** Whether buildIndex() has been called */
44
- private indexBuilt;
45
- /** True if IDs were added in ascending order (allows index optimization) */
46
- private idsAreSorted;
47
- /** Sorted view of IDs for binary search */
48
- private idsSorted;
49
- /** Maps position in sorted array → original insertion index */
50
- private sortedIdPositionToIndex;
51
- /** Anchor array for two-level binary search: every BLOCK_SIZE-th sorted ID */
52
- private anchors;
53
- /**
54
- * Create a new Ids index.
55
- * @param transferables - Optional serialized state to reconstruct from.
56
- */
57
- constructor(transferables?: IdsTransferables);
58
- /** Number of IDs stored in this index. */
59
- get size(): number;
60
- /** Returns true if buildIndex() has been called and lookups are enabled. */
61
- isReady(): boolean;
62
- /** Returns true if IDs were inserted in ascending order. */
63
- isSorted(): boolean;
64
- /**
65
- * Add an ID to the index.
66
- * @param id - The OSM entity ID to add.
67
- * @returns The internal array index where this ID was stored.
68
- * @throws If the index has already been built.
69
- */
70
- add(id: number): number;
71
- /**
72
- * Get the ID at a specific internal index.
73
- * @param index - The internal array index.
74
- * @returns The OSM entity ID at that index.
75
- */
76
- at(index: number): number;
77
- /**
78
- * Check if an ID exists in this index.
79
- * @param id - The OSM entity ID to check.
80
- * @returns True if the ID exists in this index.
81
- */
82
- has(id: number): boolean;
83
- /**
84
- * Build the index of IDs to positions.
85
- *
86
- * If the IDs are not sorted, we need to sort them and build a new index.
87
- * If the IDs are sorted, we can use the existing index.
88
- */
89
- buildIndex(): void;
90
- /**
91
- * Look up the internal array index for an OSM entity ID.
92
- *
93
- * @param id - The OSM entity ID to look up.
94
- * @returns The internal array index, or -1 if not found.
95
- * @throws If the index has not been built.
96
- */
97
- getIndexFromId(id: number): number;
98
- /**
99
- * Pass an ID or an index, get both.
100
- */
101
- idOrIndex(i: IdOrIndex): [index: number, id: number];
102
- /** Returns the sorted array of IDs for iteration. */
103
- get sorted(): Float64Array<ArrayBufferLike>;
104
- /**
105
- * Get transferable buffers for passing to another thread.
106
- * @returns Serializable representation of this index.
107
- */
108
- transferables(): IdsTransferables;
109
- /**
110
- * Get the approximate memory requirements for a given number of IDs in bytes.
111
- */
112
- static getBytesRequired(count: number): number;
113
- /**
114
- * Update a ContentHasher with the IDs data.
115
- * Uses the sorted IDs for consistent hashing regardless of insertion order.
116
- */
117
- updateHash(hasher: ContentHasher): ContentHasher;
118
- }
119
- //# sourceMappingURL=ids.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ids.d.ts","sourceRoot":"","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AM,GAAG,OAAO;IAIxB;;;;;OAKG;IACH,UAAU;IA6DV;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAqClC;;OAEG;IACH,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC;IAKpD,qDAAqD;IACrD,IAAI,MAAM,kCAET;IAED;;;OAGG;IACH,aAAa,IAAI,gBAAgB;IAUjC;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM;IAUrC;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa;CAGhD"}
package/dist/src/ids.js DELETED
@@ -1,243 +0,0 @@
1
- /**
2
- * ID storage and lookup for OSM entities.
3
- *
4
- * Uses a two-level binary search (anchor array + block search) to map 64-bit OSM IDs
5
- * to internal array indices. Balances memory usage with O(log n) lookup speed.
6
- *
7
- * @module
8
- */
9
- import { assertValue } from "@osmix/shared/assert";
10
- import { BufferConstructor, ResizeableTypedArray as RTA, } from "./typed-arrays";
11
- /**
12
- * Number of IDs per anchor block for the two-level binary search.
13
- * Smaller values increase anchor array size but speed up block-level search;
14
- * larger values reduce anchor overhead but slow the final search.
15
- */
16
- const BLOCK_SIZE = 256;
17
- /**
18
- * Efficiently store and lookup OSM entity IDs.
19
- *
20
- * Stores 64-bit IDs in a Float64Array and maintains a sorted index for O(log n) lookups.
21
- * Max capacity: ~2^32 entities.
22
- */
23
- export class Ids {
24
- /** All IDs in insertion order */
25
- ids;
26
- /** Whether buildIndex() has been called */
27
- indexBuilt = false;
28
- /** True if IDs were added in ascending order (allows index optimization) */
29
- idsAreSorted = true;
30
- /** Sorted view of IDs for binary search */
31
- idsSorted;
32
- /** Maps position in sorted array → original insertion index */
33
- sortedIdPositionToIndex;
34
- /** Anchor array for two-level binary search: every BLOCK_SIZE-th sorted ID */
35
- anchors;
36
- /**
37
- * Create a new Ids index.
38
- * @param transferables - Optional serialized state to reconstruct from.
39
- */
40
- constructor(transferables) {
41
- if (transferables) {
42
- this.ids = RTA.from(Float64Array, transferables.ids);
43
- this.idsSorted = new Float64Array(transferables.sortedIds);
44
- this.sortedIdPositionToIndex = new Uint32Array(transferables.sortedIdPositionToIndex);
45
- this.anchors = new Float64Array(transferables.anchors);
46
- this.idsAreSorted = transferables.idsAreSorted;
47
- this.indexBuilt = true;
48
- }
49
- else {
50
- this.ids = new RTA(Float64Array);
51
- this.idsSorted = new Float64Array(new BufferConstructor(0));
52
- this.sortedIdPositionToIndex = new Uint32Array(new BufferConstructor(0));
53
- this.anchors = new Float64Array(new BufferConstructor(0));
54
- }
55
- }
56
- /** Number of IDs stored in this index. */
57
- get size() {
58
- return this.ids.length;
59
- }
60
- /** Returns true if buildIndex() has been called and lookups are enabled. */
61
- isReady() {
62
- return this.indexBuilt;
63
- }
64
- /** Returns true if IDs were inserted in ascending order. */
65
- isSorted() {
66
- return this.idsAreSorted;
67
- }
68
- /**
69
- * Add an ID to the index.
70
- * @param id - The OSM entity ID to add.
71
- * @returns The internal array index where this ID was stored.
72
- * @throws If the index has already been built.
73
- */
74
- add(id) {
75
- if (this.indexBuilt)
76
- throw Error("ID index already built.");
77
- if (this.ids.length > 0 && id < this.ids.at(-1))
78
- this.idsAreSorted = false;
79
- return this.ids.push(id);
80
- }
81
- /**
82
- * Get the ID at a specific internal index.
83
- * @param index - The internal array index.
84
- * @returns The OSM entity ID at that index.
85
- */
86
- at(index) {
87
- return this.ids.at(index);
88
- }
89
- /**
90
- * Check if an ID exists in this index.
91
- * @param id - The OSM entity ID to check.
92
- * @returns True if the ID exists in this index.
93
- */
94
- has(id) {
95
- return this.getIndexFromId(id) !== -1;
96
- }
97
- /**
98
- * Build the index of IDs to positions.
99
- *
100
- * If the IDs are not sorted, we need to sort them and build a new index.
101
- * If the IDs are sorted, we can use the existing index.
102
- */
103
- buildIndex() {
104
- if (this.indexBuilt)
105
- throw Error("ID index already build.");
106
- this.ids.compact();
107
- if (!this.idsAreSorted) {
108
- console.warn("IDs were not sorted. Sorting now...");
109
- // Build the sorted index
110
- const idsBuffer = new BufferConstructor(this.size * Float64Array.BYTES_PER_ELEMENT);
111
- const posBuffer = new BufferConstructor(this.size * Uint32Array.BYTES_PER_ELEMENT);
112
- this.idsSorted = new Float64Array(idsBuffer);
113
- this.sortedIdPositionToIndex = new Uint32Array(posBuffer);
114
- // Fill and sort with positions.
115
- for (let i = 0; i < this.size; i++) {
116
- this.idsSorted[i] = this.ids.at(i);
117
- this.sortedIdPositionToIndex[i] = i;
118
- }
119
- // Sort by id, carrying position; use native sort on chunks or a custom radix/merge for stability.
120
- // For simplicity:
121
- const tmp = Array.from({ length: this.size }, (_, i) => ({
122
- id: this.idsSorted[i],
123
- pos: this.sortedIdPositionToIndex[i],
124
- }));
125
- tmp.sort((a, b) => a.id - b.id);
126
- tmp.forEach(({ id, pos }, i) => {
127
- this.idsSorted[i] = id;
128
- this.sortedIdPositionToIndex[i] = pos;
129
- });
130
- }
131
- else {
132
- // Point to the same array
133
- this.idsSorted = this.ids.array;
134
- // Create the sortedIdPositionToIndex array
135
- const posBuffer = new BufferConstructor(this.size * Uint32Array.BYTES_PER_ELEMENT);
136
- this.sortedIdPositionToIndex = new Uint32Array(posBuffer);
137
- for (let i = 0; i < this.size; i++) {
138
- this.sortedIdPositionToIndex[i] = i;
139
- }
140
- }
141
- // Build anchors (every blockSize-th key)
142
- const aLen = Math.ceil(this.size / BLOCK_SIZE);
143
- const sab = new BufferConstructor(aLen * Float64Array.BYTES_PER_ELEMENT);
144
- this.anchors = new Float64Array(sab, 0, aLen);
145
- for (let j = 0; j < aLen; j++) {
146
- const id = this.idsSorted[Math.min(j * BLOCK_SIZE, this.size - 1)];
147
- assertValue(id, "ID is undefined");
148
- this.anchors[j] = id;
149
- }
150
- this.indexBuilt = true;
151
- }
152
- /**
153
- * Look up the internal array index for an OSM entity ID.
154
- *
155
- * @param id - The OSM entity ID to look up.
156
- * @returns The internal array index, or -1 if not found.
157
- * @throws If the index has not been built.
158
- */
159
- getIndexFromId(id) {
160
- if (!this.indexBuilt)
161
- throw Error("IdIndex not built.");
162
- // binary search anchors
163
- let lo = 0;
164
- let hi = this.anchors.length - 1;
165
- while (lo < hi) {
166
- const mid = (lo + hi + 1) >>> 1;
167
- const anchor = this.anchors[mid];
168
- assertValue(anchor, "Anchor is undefined");
169
- if (anchor <= id)
170
- lo = mid;
171
- else
172
- hi = mid - 1;
173
- }
174
- const start = lo * BLOCK_SIZE;
175
- const end = Math.min(start + BLOCK_SIZE, this.idsSorted.length);
176
- // binary search within block
177
- let l = start;
178
- let r = end - 1;
179
- while (l <= r) {
180
- const m = (l + r) >>> 1;
181
- const v = this.idsSorted[m];
182
- assertValue(v, "Value is undefined");
183
- if (v === id) {
184
- if (this.idsAreSorted)
185
- return m;
186
- const index = this.sortedIdPositionToIndex[m];
187
- assertValue(index, "Position is undefined");
188
- return index;
189
- }
190
- if (v < id)
191
- l = m + 1;
192
- else
193
- r = m - 1;
194
- }
195
- // ID not found
196
- return -1;
197
- }
198
- /**
199
- * Pass an ID or an index, get both.
200
- */
201
- idOrIndex(i) {
202
- if ("id" in i)
203
- return [this.getIndexFromId(i.id), i.id];
204
- return [i.index, this.at(i.index)];
205
- }
206
- /** Returns the sorted array of IDs for iteration. */
207
- get sorted() {
208
- return this.idsSorted;
209
- }
210
- /**
211
- * Get transferable buffers for passing to another thread.
212
- * @returns Serializable representation of this index.
213
- */
214
- transferables() {
215
- return {
216
- ids: this.ids.array.buffer,
217
- sortedIds: this.idsSorted.buffer,
218
- sortedIdPositionToIndex: this.sortedIdPositionToIndex.buffer,
219
- anchors: this.anchors.buffer,
220
- idsAreSorted: this.idsAreSorted,
221
- };
222
- }
223
- /**
224
- * Get the approximate memory requirements for a given number of IDs in bytes.
225
- */
226
- static getBytesRequired(count) {
227
- if (count === 0)
228
- return 0;
229
- return (count * Float64Array.BYTES_PER_ELEMENT + // ids
230
- count * Float64Array.BYTES_PER_ELEMENT + // sortedIds
231
- count * Uint32Array.BYTES_PER_ELEMENT + // sortedIdPositionToIndex
232
- Math.ceil(count / BLOCK_SIZE) * Float64Array.BYTES_PER_ELEMENT // anchors
233
- );
234
- }
235
- /**
236
- * Update a ContentHasher with the IDs data.
237
- * Uses the sorted IDs for consistent hashing regardless of insertion order.
238
- */
239
- updateHash(hasher) {
240
- return hasher.update(this.idsSorted);
241
- }
242
- }
243
- //# sourceMappingURL=ids.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../src/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EACN,iBAAiB,EAEjB,oBAAoB,IAAI,GAAG,GAC3B,MAAM,gBAAgB,CAAA;AAQvB;;;;GAIG;AACH,MAAM,UAAU,GAAG,GAAG,CAAA;AAkBtB;;;;;GAKG;AACH,MAAM,OAAO,GAAG;IACf,iCAAiC;IACzB,GAAG,CAAmB;IAC9B,2CAA2C;IACnC,UAAU,GAAG,KAAK,CAAA;IAC1B,4EAA4E;IACpE,YAAY,GAAG,IAAI,CAAA;IAC3B,2CAA2C;IACnC,SAAS,CAAc;IAC/B,+DAA+D;IACvD,uBAAuB,CAAa;IAC5C,8EAA8E;IACtE,OAAO,CAAc;IAE7B;;;OAGG;IACH,YAAY,aAAgC;QAC3C,IAAI,aAAa,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,CAAC,CAAA;YACpD,IAAI,CAAC,SAAS,GAAG,IAAI,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;YAC1D,IAAI,CAAC,uBAAuB,GAAG,IAAI,WAAW,CAC7C,aAAa,CAAC,uBAAuB,CACrC,CAAA;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,aAAa,CAAC,O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AAC,uBAAuB,CAAC,MAAM;YAC5D,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;YAC5B,YAAY,EAAE,IAAI,CAAC,YAAY;SAC/B,CAAA;IACF,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAa;QACpC,IAAI,KAAK,KAAK,CAAC;YAAE,OAAO,CAAC,CAAA;QACzB,OAAO,CACN,KAAK,GAAG,YAAY,CAAC,iBAAiB,GAAG,MAAM;YAC/C,KAAK,GAAG,YAAY,CAAC,iBAAiB,GAAG,YAAY;YACrD,KAAK,GAAG,WAAW,CAAC,iBAAiB,GAAG,0BAA0B;YAClE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,YAAY,CAAC,iBAAiB,CAAC,UAAU;SACzE,CAAA;IACF,CAAC;IAED;;;OAGG;IACH,UAAU,CAAC,MAAqB;QAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;CACD"}
@@ -1,32 +0,0 @@
1
- /**
2
- * @osmix/core - In-memory OSM entity storage with spatial indexing.
3
- *
4
- * Efficiently stores and queries OpenStreetMap entities (nodes, ways, relations).
5
- *
6
- * Features:
7
- * - **Memory-efficient**: Uses typed arrays and Int32Array microdegrees.
8
- * - **Spatial indexing**: KDBush (points) and Flatbush (bboxes) for fast geographic queries.
9
- * - **Worker-ready**: Zero-copy transfer via `transferables()`.
10
- * - **Tag indexing**: Fast reverse lookup by tag key.
11
- *
12
- * @example
13
- * ```ts
14
- * import { Osm } from "@osmix/core"
15
- * const osm = new Osm({ id: "example" })
16
- * osm.nodes.addNode({ id: 1, lon: -122.4, lat: 47.6, tags: { name: "Seattle" } })
17
- * osm.buildIndexes()
18
- * osm.buildSpatialIndexes()
19
- * const nearby = osm.nodes.findIndexesWithinRadius(-122.4, 47.6, 10)
20
- * ```
21
- *
22
- * @module @osmix/core
23
- */
24
- export * from "./nodes";
25
- export * from "./osm";
26
- export * from "./relations";
27
- export * from "./stringtable";
28
- export * from "./tags";
29
- export { BufferConstructor, type BufferType } from "./typed-arrays";
30
- export * from "./utils";
31
- export * from "./ways";
32
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACnE,cAAc,SAAS,CAAA;AACvB,cAAc,QAAQ,CAAA"}
package/dist/src/index.js DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * @osmix/core - In-memory OSM entity storage with spatial indexing.
3
- *
4
- * Efficiently stores and queries OpenStreetMap entities (nodes, ways, relations).
5
- *
6
- * Features:
7
- * - **Memory-efficient**: Uses typed arrays and Int32Array microdegrees.
8
- * - **Spatial indexing**: KDBush (points) and Flatbush (bboxes) for fast geographic queries.
9
- * - **Worker-ready**: Zero-copy transfer via `transferables()`.
10
- * - **Tag indexing**: Fast reverse lookup by tag key.
11
- *
12
- * @example
13
- * ```ts
14
- * import { Osm } from "@osmix/core"
15
- * const osm = new Osm({ id: "example" })
16
- * osm.nodes.addNode({ id: 1, lon: -122.4, lat: 47.6, tags: { name: "Seattle" } })
17
- * osm.buildIndexes()
18
- * osm.buildSpatialIndexes()
19
- * const nearby = osm.nodes.findIndexesWithinRadius(-122.4, 47.6, 10)
20
- * ```
21
- *
22
- * @module @osmix/core
23
- */
24
- /// <reference path="./types/kdbush.d.ts" />
25
- /// <reference path="./types/geokdbush.d.ts" />
26
- /// <reference path="./types/geoflatbush.d.ts" />
27
- export * from "./nodes";
28
- export * from "./osm";
29
- export * from "./relations";
30
- export * from "./stringtable";
31
- export * from "./tags";
32
- export { BufferConstructor } from "./typed-arrays";
33
- export * from "./utils"; // TODO Move into shared?
34
- export * from "./ways";
35
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,4CAA4C;AAC5C,+CAA+C;AAC/C,iDAAiD;AAEjD,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAmB,MAAM,gBAAgB,CAAA;AACnE,cAAc,SAAS,CAAA,CAAC,yBAAyB;AACjD,cAAc,QAAQ,CAAA"}