@osmix/geojson 0.0.16 → 0.0.17
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 +19 -0
- package/README.md +3 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -1
- package/dist/utils.js.map +1 -1
- package/package.json +11 -11
- package/src/utils.ts +3 -1
- package/test/no-shared-array-buffer.test.ts +31 -0
- package/osmix-geojson-0.0.16.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @osmix/geojson
|
|
2
2
|
|
|
3
|
+
## 0.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8be5c80: Allow Osmix to use its ArrayBuffer fallback when SharedArrayBuffer is unavailable, so browser
|
|
8
|
+
applications no longer need to install a global SharedArrayBuffer shim.
|
|
9
|
+
- Updated dependencies [e4785fe]
|
|
10
|
+
- Updated dependencies [df04f92]
|
|
11
|
+
- Updated dependencies [e4785fe]
|
|
12
|
+
- Updated dependencies [66eb7cd]
|
|
13
|
+
- Updated dependencies [466adc0]
|
|
14
|
+
- Updated dependencies [66eb7cd]
|
|
15
|
+
- Updated dependencies [66eb7cd]
|
|
16
|
+
- Updated dependencies [8be5c80]
|
|
17
|
+
- @osmix/shared@0.2.0
|
|
18
|
+
- @osmix/core@0.3.0
|
|
19
|
+
- @osmix/types@0.2.0
|
|
20
|
+
- @osmix/geo@0.1.1
|
|
21
|
+
|
|
3
22
|
## 0.0.16
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ console.log(`Imported ${osm.ways.size} ways`);
|
|
|
113
113
|
|
|
114
114
|
## Environment and Limitations
|
|
115
115
|
|
|
116
|
-
- Requires `Map`/`Set`, typed arrays, and `ReadableStream`/`TextDecoder` (Bun, Node
|
|
116
|
+
- Requires `Map`/`Set`, typed arrays, and `ReadableStream`/`TextDecoder` (Bun, Node 24+, modern browsers).
|
|
117
117
|
- Import supports Point, LineString, Polygon, MultiPolygon only.
|
|
118
118
|
- Relation export focuses on multipolygon/route relations; other types return GeometryCollection.
|
|
119
119
|
|
|
@@ -121,8 +121,7 @@ console.log(`Imported ${osm.ways.size} ways`);
|
|
|
121
121
|
|
|
122
122
|
```sh
|
|
123
123
|
pnpm run test packages/geojson
|
|
124
|
-
pnpm
|
|
125
|
-
pnpm run typecheck packages/geojson
|
|
124
|
+
pnpm exec oxlint packages/geojson
|
|
126
125
|
```
|
|
127
126
|
|
|
128
|
-
Run `pnpm run
|
|
127
|
+
Run `pnpm run verify` at the repo root before publishing.
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAyB1F"}
|
package/dist/utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Utility functions for GeoJSON data handling.
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
+
import { isSharedArrayBuffer } from "@osmix/shared/backing-buffers";
|
|
5
6
|
/**
|
|
6
7
|
* Parse GeoJSON from various input formats.
|
|
7
8
|
*
|
|
@@ -42,7 +43,7 @@ export async function readDataAsGeoJSON(data) {
|
|
|
42
43
|
}
|
|
43
44
|
return JSON.parse(result);
|
|
44
45
|
}
|
|
45
|
-
if (data instanceof ArrayBuffer || data
|
|
46
|
+
if (data instanceof ArrayBuffer || isSharedArrayBuffer(data)) {
|
|
46
47
|
const decoder = new TextDecoder();
|
|
47
48
|
const text = decoder.decode(new Uint8Array(data));
|
|
48
49
|
return JSON.parse(text);
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAsB;IAC5D,IAAI,IAAI,IAAI,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;IAClD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAsB,CAAC;IAE3E,IAAI,IAAI,YAAY,cAAc,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;QACrE,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI;gBAAE,MAAM;YAChB,IAAI,KAAK,KAAK,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAsB,CAAC;IACjD,CAAC;IACD,IAAI,IAAI,YAAY,WAAW,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAsB,CAAC;IAC/C,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,IAAI,IAAI,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QACrE,OAAO,IAAyB,CAAC;IACnC,CAAC;IACD,MAAM,IAAI,KAAK,CACb,mGAAmG,CACpG,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@osmix/geojson",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.17",
|
|
5
5
|
"description": "Convert OSM files to and from GeoJSON.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -11,22 +11,22 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "./dist/index.js",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"
|
|
16
|
-
"@osmix/
|
|
17
|
-
"@osmix/
|
|
18
|
-
"@
|
|
19
|
-
"@osmix/geo": "0.1.0"
|
|
14
|
+
"@osmix/core": "0.3.0",
|
|
15
|
+
"@osmix/geo": "0.1.1",
|
|
16
|
+
"@osmix/shared": "0.2.0",
|
|
17
|
+
"@osmix/types": "0.2.0",
|
|
18
|
+
"@placemarkio/geojson-rewind": "^1.0.3"
|
|
20
19
|
},
|
|
21
20
|
"devDependencies": {
|
|
22
21
|
"@types/geojson": "^7946.0.16",
|
|
23
|
-
"typescript": "7.0.
|
|
22
|
+
"typescript": "^7.0.2"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=24"
|
|
24
26
|
},
|
|
25
27
|
"types": "./dist/index.d.ts",
|
|
26
28
|
"scripts": {
|
|
27
29
|
"build": "tsc -p tsconfig.build.json",
|
|
28
|
-
"bench": "vitest bench"
|
|
29
|
-
"test": "pnpm -w exec vitest run --project \"$npm_package_name\"",
|
|
30
|
-
"typecheck": "tsc --noEmit"
|
|
30
|
+
"bench": "vitest bench"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/utils.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { isSharedArrayBuffer } from "@osmix/shared/backing-buffers";
|
|
7
|
+
|
|
6
8
|
import type { ImportableGeoJSON, ReadOsmDataTypes } from "./types.ts";
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -42,7 +44,7 @@ export async function readDataAsGeoJSON(data: ReadOsmDataTypes): Promise<Importa
|
|
|
42
44
|
}
|
|
43
45
|
return JSON.parse(result) as ImportableGeoJSON;
|
|
44
46
|
}
|
|
45
|
-
if (data instanceof ArrayBuffer || data
|
|
47
|
+
if (data instanceof ArrayBuffer || isSharedArrayBuffer(data)) {
|
|
46
48
|
const decoder = new TextDecoder();
|
|
47
49
|
const text = decoder.decode(new Uint8Array(data));
|
|
48
50
|
return JSON.parse(text) as ImportableGeoJSON;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
describe("GeoJSON without SharedArrayBuffer", () => {
|
|
4
|
+
afterEach(() => {
|
|
5
|
+
vi.unstubAllGlobals();
|
|
6
|
+
vi.resetModules();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("reads binary GeoJSON into ArrayBuffer-backed indexes", async () => {
|
|
10
|
+
vi.stubGlobal("SharedArrayBuffer", undefined);
|
|
11
|
+
vi.resetModules();
|
|
12
|
+
|
|
13
|
+
const { fromGeoJSON } = await import("../src/osm-from-geojson.ts");
|
|
14
|
+
const input = new TextEncoder().encode(
|
|
15
|
+
JSON.stringify({
|
|
16
|
+
type: "FeatureCollection",
|
|
17
|
+
features: [
|
|
18
|
+
{
|
|
19
|
+
type: "Feature",
|
|
20
|
+
geometry: { type: "Point", coordinates: [115.2167, -8.65] },
|
|
21
|
+
properties: { name: "Denpasar" },
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
}),
|
|
25
|
+
).buffer;
|
|
26
|
+
|
|
27
|
+
const osm = await fromGeoJSON(input);
|
|
28
|
+
|
|
29
|
+
expect(osm.nodes.getById(-1)?.tags?.["name"]).toBe("Denpasar");
|
|
30
|
+
});
|
|
31
|
+
});
|
package/osmix-geojson-0.0.16.tgz
DELETED
|
Binary file
|