fast-osmpbf-js 0.1.4 → 0.2.1

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/README.md CHANGED
@@ -5,17 +5,25 @@ It is using NodeJS bindings for the high-performance Rust library [fast-osmpbf](
5
5
 
6
6
  [![npm](https://img.shields.io/npm/v/fast-osmpbf-js.svg)](https://www.npmjs.com/package/fast-osmpbf-js)
7
7
 
8
- ## Installation
8
+ ## Benchmarks
9
9
 
10
- ```bash
11
- npm install fast-osmpbf-js
10
+ - CPU: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
11
+ - Memory: 16GB
12
+ - OS: Linux (Ubuntu)
13
+ - Dataset: `germany-latest.osm.pbf` (~4.6GB)
14
+
15
+ ```
16
+ Hyperfine was used to benchmark with 10 runs each.
17
+ What you see here is the mean time of these 10 runs.
18
+ All problems were run using parallelization if the library offered a way to do it.
12
19
  ```
13
20
 
14
- or add this to your `package.json`:
15
21
 
16
- ```json
17
- "fast-osmpbf-js": "0.1"
18
- ```
22
+ | Problem | fast-osmpbf-js | osm-pbf-parser | osm-read |
23
+ |-----------------|----------------|----------------|----------|
24
+ | Count ways | 18.10 s | 330.57 s | 523.80 s |
25
+ | Count addresses | 30.04 s | 359.06 s | 603.33 s |
26
+
19
27
 
20
28
  ## Examples
21
29
 
@@ -100,26 +108,6 @@ export interface JsElementBlock {
100
108
  ```
101
109
 
102
110
 
103
- ## Benchmarks
104
-
105
- - CPU: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
106
- - Memory: 16GB
107
- - OS: Linux (Ubuntu)
108
- - Dataset: `germany-latest.osm.pbf` (~4.6GB)
109
-
110
- ```
111
- Hyperfine was used to benchmark with 10 runs each.
112
- What you see here is the mean time of these 10 runs.
113
- All problems were run using parallelization if the library offered a way to do it.
114
- ```
115
-
116
-
117
- | Problem | fast-osmpbf-js | osm-pbf-parser | osm-read |
118
- |-----------------|----------------|----------------|----------|
119
- | Count ways | 18.10 s | 330.57 s | 523.80 s |
120
- | Count addresses | 30.04 s | 359.06 s | 603.33 s |
121
-
122
-
123
111
  ## License
124
112
 
125
113
  This project is licensed under
package/index.js CHANGED
@@ -1,104 +1,104 @@
1
- import { createRequire } from "module"
2
- import { platform, arch } from "process"
3
- import { join, dirname } from "path"
4
- import { fileURLToPath } from "url"
1
+ import { createRequire } from "module";
2
+ import { platform, arch } from "process";
3
+ import { join, dirname } from "path";
4
+ import { fileURLToPath } from "url";
5
5
 
6
- const require = createRequire(import.meta.url)
7
- const __dirname = dirname(fileURLToPath(import.meta.url))
6
+ const require = createRequire(import.meta.url);
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
8
 
9
9
  // Map Node.js platform/arch to your binding folder names
10
10
  function getBindingPath() {
11
- const platformMap = {
12
- darwin: "apple-darwin",
13
- win32: "pc-windows-msvc",
14
- linux: "unknown-linux-gnu",
15
- }
11
+ const platformMap = {
12
+ darwin: "apple-darwin",
13
+ win32: "pc-windows-msvc",
14
+ linux: "unknown-linux-gnu",
15
+ };
16
16
 
17
- const archMap = {
18
- x64: "x86_64",
19
- arm64: "aarch64",
20
- }
17
+ const archMap = {
18
+ x64: "x86_64",
19
+ arm64: "aarch64",
20
+ };
21
21
 
22
- const nodeFileMap = {
23
- "linux-x64": "index.linux-x64-gnu.node",
24
- "linux-arm64": "index.linux-arm64-gnu.node",
25
- "darwin-x64": "index.darwin-x64.node",
26
- "darwin-arm64": "index.darwin-arm64.node",
27
- "win32-x64": "index.win32-x64-msvc.node",
28
- }
22
+ const nodeFileMap = {
23
+ "linux-x64": "index.linux-x64-gnu.node",
24
+ "linux-arm64": "index.linux-arm64-gnu.node",
25
+ "darwin-x64": "index.darwin-x64.node",
26
+ "darwin-arm64": "index.darwin-arm64.node",
27
+ "win32-x64": "index.win32-x64-msvc.node",
28
+ };
29
29
 
30
- const mappedPlatform = platformMap[platform]
31
- const mappedArch = archMap[arch]
30
+ const mappedPlatform = platformMap[platform];
31
+ const mappedArch = archMap[arch];
32
32
 
33
- if (!mappedPlatform || !mappedArch) {
34
- throw new Error(`Unsupported platform: ${platform}-${arch}`)
35
- }
33
+ if (!mappedPlatform || !mappedArch) {
34
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
35
+ }
36
36
 
37
- const bindingFolder = `bindings-${mappedArch}-${mappedPlatform}`
38
- const nodeFile = nodeFileMap[`${platform}-${arch}`]
37
+ const bindingFolder = `bindings-${mappedArch}-${mappedPlatform}`;
38
+ const nodeFile = nodeFileMap[`${platform}-${arch}`];
39
39
 
40
- if (!nodeFile) {
41
- throw new Error(`No binding available for ${platform}-${arch}`)
42
- }
40
+ if (!nodeFile) {
41
+ throw new Error(`No binding available for ${platform}-${arch}`);
42
+ }
43
43
 
44
- return join(__dirname, bindingFolder, nodeFile)
44
+ return join(__dirname, bindingFolder, nodeFile);
45
45
  }
46
46
 
47
- const native = require(getBindingPath())
47
+ const native = require(getBindingPath());
48
48
 
49
49
  export function getTags(block, index) {
50
- let tags = block.denseTags || block.tags
51
- const start = tags[2][index]
52
- const end = tags[2][index + 1]
53
- const result = []
54
- for (let i = start; i < end; i++) {
55
- result.push([block.stringTable[tags[0][i]], block.stringTable[tags[1][i]]])
56
- }
57
- return result
50
+ let tags = block.denseTags || block.tags;
51
+ const start = tags[2][index];
52
+ const end = tags[2][index + 1];
53
+ const result = [];
54
+ for (let i = start; i < end; i++) {
55
+ result.push([block.stringTable[tags[0][i]], block.stringTable[tags[1][i]]]);
56
+ }
57
+ return result;
58
58
  }
59
59
 
60
60
  export function getNodeIds(block, index) {
61
- if (!block.nodeIds) {
62
- return []
63
- }
64
- const result = []
65
- const start = block.nodeIds[1][index]
66
- const end = block.nodeIds[1][index + 1]
67
- for (let i = start; i < end; i++) {
68
- result.push(block.nodeIds[0][i])
69
- }
70
- return result
61
+ if (!block.nodeIds) {
62
+ return [];
63
+ }
64
+ const result = [];
65
+ const start = block.nodeIds[1][index];
66
+ const end = block.nodeIds[1][index + 1];
67
+ for (let i = start; i < end; i++) {
68
+ result.push(block.nodeIds[0][i]);
69
+ }
70
+ return result;
71
71
  }
72
72
 
73
73
  export function getRelationMembers(block, index) {
74
- if (!block.relationMembers) {
75
- return []
76
- }
77
- const result = []
78
- const start = block.relationMembers[3][index]
79
- const end = block.relationMembers[3][index + 1]
80
- for (let i = start; i < end; i++) {
81
- result.push({
82
- id: block.relationMembers[0][i],
83
- type: mapMemberType(block.relationMembers[1][i]),
84
- role: block.stringTable[block.relationMembers[2][i]],
85
- })
86
- }
87
- return result
74
+ if (!block.relationMembers) {
75
+ return [];
76
+ }
77
+ const result = [];
78
+ const start = block.relationMembers[3][index];
79
+ const end = block.relationMembers[3][index + 1];
80
+ for (let i = start; i < end; i++) {
81
+ result.push({
82
+ id: block.relationMembers[0][i],
83
+ type: mapMemberType(block.relationMembers[1][i]),
84
+ role: block.stringTable[block.relationMembers[2][i]],
85
+ });
86
+ }
87
+ return result;
88
88
  }
89
89
 
90
90
  function mapMemberType(memberType) {
91
- switch (memberType) {
92
- case 0:
93
- return "Node"
94
- case 1:
95
- return "Way"
96
- case 2:
97
- return "Relation"
98
- }
91
+ switch (memberType) {
92
+ case 0:
93
+ return "Node";
94
+ case 1:
95
+ return "Way";
96
+ case 2:
97
+ return "Relation";
98
+ }
99
99
  }
100
100
 
101
101
  // Re-export the NAPI exports
102
- export const OsmReader = native.OsmReader
103
- export const AsyncBlockIterator = native.AsyncBlockIterator
104
- export const JsElementBlock = native.JsElementBlock
102
+ export const OsmReader = native.OsmReader;
103
+ export const AsyncBlockIterator = native.AsyncBlockIterator;
104
+ export const JsElementBlock = native.JsElementBlock;
package/package.json CHANGED
@@ -1,30 +1,44 @@
1
1
  {
2
- "name": "fast-osmpbf-js",
3
- "type": "module",
4
- "version": "0.1.4",
5
- "description": "Node.js bindings for the fast-osmpbf Rust library",
6
- "author": {
7
- "name": "Daniel Steblin",
8
- "email": "d.steblin.dev@gmail.com"
9
- },
10
- "main": "index.js",
11
- "types": "wrapper.d.ts",
12
- "files": [
13
- "index.js",
14
- "wrapper.d.ts",
15
- "index.d.ts",
16
- "bindings-*/*.node"
17
- ],
18
- "scripts": {
19
- "artifacts": "napi artifacts",
20
- "build": "napi build --platform --release"
21
- },
22
- "license": "MIT OR Apache-2.0",
23
- "devDependencies": {
24
- "@napi-rs/cli": "^3.4.1",
25
- "@types/node": "^24.3.0"
26
- },
27
- "engines": {
28
- "node": ">=16"
29
- }
2
+ "name": "fast-osmpbf-js",
3
+ "type": "module",
4
+ "version": "0.2.1",
5
+ "description": "Node.js bindings for the fast-osmpbf Rust library",
6
+ "author": {
7
+ "name": "Daniel Steblin",
8
+ "email": "d.steblin.dev@gmail.com"
9
+ },
10
+ "keywords": [
11
+ "openstreetmap",
12
+ "osmpbf",
13
+ "osm",
14
+ "pbf",
15
+ "parser",
16
+ "geospatial",
17
+ "map",
18
+ "geodata"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/QuodEstDubitandum/fast-osmpbf"
23
+ },
24
+ "main": "index.js",
25
+ "types": "wrapper.d.ts",
26
+ "files": [
27
+ "index.js",
28
+ "wrapper.d.ts",
29
+ "index.d.ts",
30
+ "bindings-*/*.node"
31
+ ],
32
+ "scripts": {
33
+ "artifacts": "napi artifacts",
34
+ "build": "napi build --platform --release"
35
+ },
36
+ "license": "MIT OR Apache-2.0",
37
+ "devDependencies": {
38
+ "@napi-rs/cli": "^3.4.1",
39
+ "@types/node": "^24.3.0"
40
+ },
41
+ "engines": {
42
+ "node": ">=16"
43
+ }
30
44
  }