osm2geojson-lite 1.2.0 → 2.1.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/README.md +37 -15
- package/dist/cli.mjs +1504 -0
- package/dist/index.cjs +1469 -0
- package/dist/index.d.ts +226 -0
- package/dist/index.mjs +1469 -0
- package/dist/polytags.json +63 -0
- package/package.json +53 -56
- package/dist/node/index.d.ts +0 -25
- package/dist/node/index.js +0 -196
- package/dist/node/late-binder.d.ts +0 -8
- package/dist/node/late-binder.js +0 -24
- package/dist/node/node.d.ts +0 -14
- package/dist/node/node.js +0 -31
- package/dist/node/osm-object.d.ts +0 -25
- package/dist/node/osm-object.js +0 -38
- package/dist/node/polytags.json +0 -84
- package/dist/node/ref-elements.d.ts +0 -9
- package/dist/node/ref-elements.js +0 -19
- package/dist/node/relation.d.ts +0 -21
- package/dist/node/relation.js +0 -220
- package/dist/node/utils.d.ts +0 -22
- package/dist/node/utils.js +0 -97
- package/dist/node/way-collection.d.ts +0 -14
- package/dist/node/way-collection.js +0 -109
- package/dist/node/way.d.ts +0 -21
- package/dist/node/way.js +0 -87
- package/dist/node/xmlparser.d.ts +0 -32
- package/dist/node/xmlparser.js +0 -161
- package/dist/web/osm2geojson-lite.js +0 -1
package/README.md
CHANGED
|
@@ -27,11 +27,20 @@ Usage:
|
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### In the Browser
|
|
30
|
+
|
|
31
|
+
Modern browsers load the ESM build directly via `<script type="module">`. Import it from a CDN (e.g. [esm.sh](https://esm.sh) or [jsDelivr](https://www.jsdelivr.com)):
|
|
32
|
+
|
|
30
33
|
```html
|
|
31
|
-
<script
|
|
34
|
+
<script type="module">
|
|
35
|
+
import osm2geojson from 'https://esm.sh/osm2geojson-lite';
|
|
36
|
+
|
|
37
|
+
const geojson = osm2geojson(osm, opts);
|
|
38
|
+
</script>
|
|
32
39
|
```
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
|
|
41
|
+
### In the command line
|
|
42
|
+
```sh
|
|
43
|
+
npx osm2geojson-lite --help
|
|
35
44
|
```
|
|
36
45
|
|
|
37
46
|
API
|
|
@@ -46,29 +55,42 @@ Converts OSM data (XML/JSON) to GeoJSON.
|
|
|
46
55
|
- `completeFeature`: the default value is `false`. When it's set to `true`, the returned geojson will include all elements that meet the specified conditions in `FeatureCollection` format; otherwise, only the bare geometry of the first `relation` element will be returned.
|
|
47
56
|
- `renderTagged`: the default value is `false`. When it's set to `true`, the returned geojson will include all elements with tags (i.e., tagged) until `excludeWay` changes its behavior a bit; otherwise only the unreferenced ones get returned.
|
|
48
57
|
- `excludeWay`: the default value is `true`. When it's set to `true`, the returned `FeatureCollection` will exclude all referenced `way`s even though they are tagged; otherwise the features of those `way`s will be included in the resulted result as well.
|
|
58
|
+
- `elementId`: optional, an OSM element id in the form `type/id` (e.g. `way/123`). When set, only that single `Feature` is returned; `undefined` is returned when the element does not exist.
|
|
59
|
+
- `tainted`: the default value is `false`. When set to `true`, features whose referenced nodes/ways/relations are missing (e.g. partial Overpass responses) receive an `@tainted: true` property.
|
|
60
|
+
- `polygonTags`: optional, alternative polygon tag rules for ways. The shape matches the bundled `polytags.json`, e.g. `{ "building": { "ignore": ["no"] } }`; the legacy `whitelist`/`blacklist` spellings are still accepted.
|
|
61
|
+
|
|
62
|
+
Beyond plain OSM data the converter understands the shapes produced by Overpass
|
|
63
|
+
`out geom`, `out center`, `out bb`, `convert`, `make` and `local` (both JSON and
|
|
64
|
+
XML), including derived `Point`/`LineString`/`Polygon`/`GeometryCollection`
|
|
65
|
+
output, member geometries, `center` fallbacks and `bounds`-only rectangles.
|
|
49
66
|
|
|
50
67
|
|
|
51
68
|
Performance
|
|
52
69
|
---
|
|
53
70
|
1. Workloads include the boundary XML and JSON of 4 administrive areas (zhucheng, hebei, tokyodo, usa)
|
|
54
|
-
2.
|
|
55
|
-
3. For each script, run as many as times seperately and then calculate the average cost time (ACT for short)
|
|
56
|
-
4. The # listed in the table below are coarse lowest values of dividing the ACT of `osmtogeojson` by the one of this library
|
|
71
|
+
2. The benchmark is written with [Vitest's `bench`](https://vitest.dev/guide/features.html#benchmarking), which warms up and then samples each conversion many times, comparing this library against [`osm2geojson-ultra`](https://www.npmjs.com/package/osm2geojson-ultra) (which uses the `txml` parser) and `osmtogeojson` (+ `xmldom` for XML).
|
|
57
72
|
```
|
|
58
|
-
$ cd test
|
|
59
73
|
$ npm run bench
|
|
60
74
|
```
|
|
75
|
+
3. The # listed in the tables below are coarse lowest speed-up factors (this library vs. the competitor) observed on the sample data.
|
|
76
|
+
|
|
61
77
|
1. XML
|
|
62
|
-
|
|
63
|
-
| zhucheng
|
|
64
|
-
|
|
65
|
-
| >
|
|
78
|
+
|
|
79
|
+
| | zhucheng | hebei | tokyodo | usa |
|
|
80
|
+
|-----------------|----------|-------|---------|-------|
|
|
81
|
+
| vs osmtogeojson | >10.9x | >20.8x| >14.9x | >14.8x|
|
|
82
|
+
| vs ultra | >2.5x | >3.0x | >3.7x | >4.2x |
|
|
66
83
|
|
|
67
84
|
2. Overpass JSON
|
|
68
|
-
|
|
69
|
-
| zhucheng
|
|
70
|
-
|
|
71
|
-
| >
|
|
85
|
+
|
|
86
|
+
| | zhucheng | hebei | tokyodo | usa |
|
|
87
|
+
|-----------------|----------|--------|---------|-------|
|
|
88
|
+
| vs osmtogeojson | >13.7x | >56.3x | >21.8x | >27.5x|
|
|
89
|
+
| vs ultra | >4.4x | >7.4x | >14.2x | >20.3x|
|
|
90
|
+
|
|
91
|
+
> **Note on column values:** the numbers are `hz` ratios reported by Vitest on
|
|
92
|
+
> the reference machine (Node 26, Apple silicon). Run `npm run bench` on your
|
|
93
|
+
> own hardware to compare.
|
|
72
94
|
|
|
73
95
|
|
|
74
96
|
Correctness
|