osm2geojson-lite 1.0.1 → 1.0.2
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 +25 -14
- package/package.json +5 -7
- package/osm2geojson-lite +0 -8
- package/ts/release/index.d.ts +0 -12
- package/ts/release/osmobjs.d.ts +0 -73
- package/ts/release/utils.d.ts +0 -60
- package/ts/release/xmlparser.d.ts +0 -32
- /package/{ts/release → dist/node}/index.js +0 -0
- /package/{ts/release → dist/node}/osmobjs.js +0 -0
- /package/{ts/release → dist/node}/polytags.json +0 -0
- /package/{ts/release → dist/node}/utils.js +0 -0
- /package/{ts/release → dist/node}/xmlparser.js +0 -0
- /package/dist/{osm2geojson-lite.js → web/osm2geojson-lite.js} +0 -0
package/README.md
CHANGED
|
@@ -7,6 +7,12 @@ History
|
|
|
7
7
|
-----
|
|
8
8
|
An internal function inside [query-geo-boundary](https://www.npmjs.com/package/query-geo-boundary) → stripped out to handle OSM XML only [xml2geojson-lite](https://www.npmjs.com/package/xml2geojson-lite) → this library that supports both OSM XML and OSM/Overpass JSON
|
|
9
9
|
|
|
10
|
+
Changelog:
|
|
11
|
+
-----
|
|
12
|
+
* Late 2018: this repository was created and the initial version was pushed to github - almost around specific usages for myself.
|
|
13
|
+
* 2019-2025: quite a few contributors had fixed quite a few bugs and also contributed some good ideas - thanks for their efforts!
|
|
14
|
+
* 2025-03-03: fixed a few bugs around non-*Polygon features processing and convert it to a pure TypeScript project (codes published to [NPM](https://npmjs.org/) have become TSC compiled from now on).
|
|
15
|
+
|
|
10
16
|
Usage
|
|
11
17
|
-----
|
|
12
18
|
|
|
@@ -55,26 +61,25 @@ Performance
|
|
|
55
61
|
$ cd bench
|
|
56
62
|
$ node o2gl-bench.js
|
|
57
63
|
$ node otg-bench.js
|
|
58
|
-
|
|
64
|
+
```
|
|
59
65
|
1. XML
|
|
60
|
-
|
|
61
|
-
|
|
|
62
|
-
|
|
63
|
-
|
|
|
64
|
-
|
|
66
|
+
|
|
67
|
+
| zhucheng | hebei | tokyodo | usa |
|
|
68
|
+
|-----------|----------|---------|------|
|
|
69
|
+
| >2.5x | >4.0x | >3.0x | >3.0x|
|
|
70
|
+
|
|
65
71
|
2. Overpass JSON
|
|
66
|
-
|
|
67
|
-
|
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
+
|
|
73
|
+
| zhucheng | hebei | tokyodo | usa |
|
|
74
|
+
|-----------|----------|---------|------|
|
|
75
|
+
| >2.5x | >11.0x | >7.0x | >5.0x|
|
|
76
|
+
|
|
72
77
|
|
|
73
78
|
Correctness
|
|
74
79
|
---
|
|
75
80
|
You can copy the converted results to [geojsonlint](http://geojsonlint.com) for the correctness validation. Up until now, `osm2geojson-lite` behaves pretty well with all the samples (also quite representative) in the `data` subfolers under `test` and `bench` directories, which also outperforms `osmtogeojson`.
|
|
76
81
|
|
|
77
|
-
The client side example shipped along with this package, `index.html` will automatically call `geojsonlint` validation service directly after each conversion, you can wait for a while to see the validation result after click the conversion button.
|
|
82
|
+
The client side example shipped along with this package, `test/index.html` ~~will automatically call `geojsonlint` validation service directly after each conversion, you can wait for a while to see the validation result after click the conversion button.~~ - because the CORS limitation, the direct post to geojsonlint was blocked, so I added a "copy to clipboard" button for you to ease the validation.
|
|
78
83
|
|
|
79
84
|
Node.JS version
|
|
80
85
|
---
|
|
@@ -86,4 +91,10 @@ Dependencies
|
|
|
86
91
|
|
|
87
92
|
License
|
|
88
93
|
---
|
|
89
|
-
|
|
94
|
+
Copyleft
|
|
95
|
+
|
|
96
|
+
Collaborators
|
|
97
|
+
---
|
|
98
|
+
* tibetty
|
|
99
|
+
* HarelM
|
|
100
|
+
|
package/package.json
CHANGED
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"multipolygon"
|
|
46
46
|
],
|
|
47
47
|
"license": "ISC",
|
|
48
|
-
"main": "
|
|
49
|
-
"types": "
|
|
48
|
+
"main": "dist/node/index.js",
|
|
49
|
+
"types": "dist/node/index.d.ts",
|
|
50
50
|
"name": "osm2geojson-lite",
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"optionalDependencies": {
|
|
60
60
|
"@types/geojson": "^7946.0.16"
|
|
61
61
|
},
|
|
62
|
-
"version": "1.0.
|
|
62
|
+
"version": "1.0.2",
|
|
63
63
|
"directories": {
|
|
64
64
|
"lib": "lib",
|
|
65
65
|
"test": "test"
|
|
@@ -69,9 +69,7 @@
|
|
|
69
69
|
"uglify-js": "^3.19.3"
|
|
70
70
|
},
|
|
71
71
|
"files": [
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"ts/release/**/*.json",
|
|
75
|
-
"dist/osm2geojson-lite.js"
|
|
72
|
+
"dist/**/*.js",
|
|
73
|
+
"dist/**/*.json"
|
|
76
74
|
]
|
|
77
75
|
}
|
package/osm2geojson-lite
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const osm2geojson = require('./lib/index.js');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
|
|
6
|
-
const data = fs.readFileSync("/dev/stdin", "utf-8");
|
|
7
|
-
const geojson = osm2geojson(data, {completeFeature: true, renderTagged: true});
|
|
8
|
-
console.log(JSON.stringify(geojson));
|
package/ts/release/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FeatureCollection, GeometryObject } from 'geojson';
|
|
2
|
-
interface IOptions {
|
|
3
|
-
completeFeature?: boolean;
|
|
4
|
-
allFeatures?: boolean;
|
|
5
|
-
renderTagged?: boolean;
|
|
6
|
-
excludeWay?: boolean;
|
|
7
|
-
suppressWay?: boolean;
|
|
8
|
-
}
|
|
9
|
-
declare function osm2geojson(osm: string | {
|
|
10
|
-
[k: string]: any;
|
|
11
|
-
}, opts?: IOptions): FeatureCollection<GeometryObject>;
|
|
12
|
-
export = osm2geojson;
|
package/ts/release/osmobjs.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Feature } from 'geojson';
|
|
2
|
-
import { RefElements } from './utils';
|
|
3
|
-
declare class OsmObject {
|
|
4
|
-
refCount: number;
|
|
5
|
-
protected refElems: RefElements;
|
|
6
|
-
private type;
|
|
7
|
-
private id;
|
|
8
|
-
private tags;
|
|
9
|
-
private props;
|
|
10
|
-
private hasTag;
|
|
11
|
-
constructor(type: string, id: string, refElems: RefElements);
|
|
12
|
-
addTags(tags: {
|
|
13
|
-
[k: string]: string;
|
|
14
|
-
}): void;
|
|
15
|
-
addTag(k: string, v: string): void;
|
|
16
|
-
addProp(k: string, v: any): void;
|
|
17
|
-
addProps(props: {
|
|
18
|
-
[k: string]: string;
|
|
19
|
-
}): void;
|
|
20
|
-
getCompositeId(): string;
|
|
21
|
-
getProps(): {
|
|
22
|
-
[k: string]: string;
|
|
23
|
-
};
|
|
24
|
-
toFeatureArray(): Array<Feature<any, any>>;
|
|
25
|
-
}
|
|
26
|
-
export declare class Node extends OsmObject {
|
|
27
|
-
private latLng;
|
|
28
|
-
constructor(id: string, refElems: RefElements);
|
|
29
|
-
setLatLng(latLng: {
|
|
30
|
-
lat: string;
|
|
31
|
-
lon: string;
|
|
32
|
-
}): void;
|
|
33
|
-
toFeatureArray(): Array<Feature<any, any>>;
|
|
34
|
-
getLatLng(): {
|
|
35
|
-
lat: string;
|
|
36
|
-
lon: string;
|
|
37
|
-
} | null;
|
|
38
|
-
}
|
|
39
|
-
export declare class Way extends OsmObject {
|
|
40
|
-
private latLngArray;
|
|
41
|
-
private isPolygon;
|
|
42
|
-
constructor(id: string, refElems: RefElements);
|
|
43
|
-
addLatLng(latLng: {
|
|
44
|
-
lat: string;
|
|
45
|
-
lon: string;
|
|
46
|
-
}): void;
|
|
47
|
-
setLatLngArray(latLngArray: Array<{
|
|
48
|
-
lat: string;
|
|
49
|
-
lon: string;
|
|
50
|
-
[k: string]: any;
|
|
51
|
-
}>): void;
|
|
52
|
-
addNodeRef(ref: string): void;
|
|
53
|
-
addTags(tags: {
|
|
54
|
-
[k: string]: string;
|
|
55
|
-
}): void;
|
|
56
|
-
addTag(k: string, v: string): void;
|
|
57
|
-
toCoordsArray(): string[][];
|
|
58
|
-
toFeatureArray(): Array<Feature<any, any>>;
|
|
59
|
-
private analyzeTag;
|
|
60
|
-
}
|
|
61
|
-
export declare class Relation extends OsmObject {
|
|
62
|
-
private relations;
|
|
63
|
-
private nodes;
|
|
64
|
-
private bounds;
|
|
65
|
-
[k: string]: any;
|
|
66
|
-
constructor(id: string, refElems: RefElements);
|
|
67
|
-
setBounds(bounds: any[]): void;
|
|
68
|
-
addMember(member: {
|
|
69
|
-
[k: string]: any;
|
|
70
|
-
}): void;
|
|
71
|
-
toFeatureArray(): Array<Feature<any, any>>;
|
|
72
|
-
}
|
|
73
|
-
export {};
|
package/ts/release/utils.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Way } from './osmobjs';
|
|
2
|
-
export declare function purgeProps(obj: {
|
|
3
|
-
[k: string]: any;
|
|
4
|
-
}, blacklist: string[]): {
|
|
5
|
-
[k: string]: any;
|
|
6
|
-
};
|
|
7
|
-
export declare function mergeProps(obj1: {
|
|
8
|
-
[k: string]: any;
|
|
9
|
-
}, obj2: {
|
|
10
|
-
[k: string]: any;
|
|
11
|
-
}): {
|
|
12
|
-
[k: string]: any;
|
|
13
|
-
};
|
|
14
|
-
export declare function addPropToFeature(f: {
|
|
15
|
-
[k: string]: any;
|
|
16
|
-
}, k: string, v: any): void;
|
|
17
|
-
export declare function addPropToFeatures(fs: Array<{
|
|
18
|
-
[k: string]: any;
|
|
19
|
-
}>, k: string, v: any): void;
|
|
20
|
-
export declare const first: <T>(a: T[]) => T;
|
|
21
|
-
export declare const last: <T>(a: T[]) => T;
|
|
22
|
-
export declare const coordsToKey: <T>(a: T[]) => string;
|
|
23
|
-
export declare function addToMap<T>(m: {
|
|
24
|
-
[k: string]: T[];
|
|
25
|
-
}, k: string, v: T): void;
|
|
26
|
-
export declare function removeFromMap<T>(m: {
|
|
27
|
-
[k: string]: T[];
|
|
28
|
-
}, k: string, v: T): void;
|
|
29
|
-
export declare function getFirstFromMap<T>(m: {
|
|
30
|
-
[k: string]: T[];
|
|
31
|
-
}, k: string): T | null;
|
|
32
|
-
export declare const isRing: (a: number[][]) => boolean;
|
|
33
|
-
export declare const ringDirection: (a: number[][], xIdx?: number, yIdx?: number) => string;
|
|
34
|
-
export declare const ptInsidePolygon: (pt: number[], polygon: number[][], xIdx?: number, yIdx?: number) => boolean;
|
|
35
|
-
export declare const strToFloat: (el: any[] | string) => any;
|
|
36
|
-
export declare class LateBinder {
|
|
37
|
-
private container;
|
|
38
|
-
private valueFunc;
|
|
39
|
-
private ctx;
|
|
40
|
-
private args;
|
|
41
|
-
constructor(container: any[] | {
|
|
42
|
-
[k: string]: any;
|
|
43
|
-
}, valueFunc: (...args: any[]) => any, ctx: any, args: any[]);
|
|
44
|
-
bind(): void;
|
|
45
|
-
}
|
|
46
|
-
export declare class RefElements extends Map {
|
|
47
|
-
private binders;
|
|
48
|
-
constructor();
|
|
49
|
-
add(k: string, v: any): void;
|
|
50
|
-
addBinder(binder: LateBinder): void;
|
|
51
|
-
bindAll(): void;
|
|
52
|
-
}
|
|
53
|
-
export declare class WayCollection extends Array {
|
|
54
|
-
private firstMap;
|
|
55
|
-
private lastMap;
|
|
56
|
-
constructor();
|
|
57
|
-
addWay(way: Way): void;
|
|
58
|
-
toStrings(): number[][][];
|
|
59
|
-
toRings(direction: string): number[][][];
|
|
60
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default class {
|
|
2
|
-
private queryParent;
|
|
3
|
-
private progressive;
|
|
4
|
-
private parentMap;
|
|
5
|
-
private evtListeners;
|
|
6
|
-
constructor(opts: any);
|
|
7
|
-
parse(xml: string, parent?: any, dir?: string): any[];
|
|
8
|
-
getParent(node: any): any;
|
|
9
|
-
addListener(evt: string, func: (node: {
|
|
10
|
-
[k: string]: any;
|
|
11
|
-
}, parent?: {
|
|
12
|
-
[k: string]: any;
|
|
13
|
-
}) => void): void;
|
|
14
|
-
removeListener(evt: string, func: (node: {
|
|
15
|
-
[k: string]: any;
|
|
16
|
-
}, parent?: {
|
|
17
|
-
[k: string]: any;
|
|
18
|
-
}) => void): void;
|
|
19
|
-
on(evt: string, func: (node: {
|
|
20
|
-
[k: string]: any;
|
|
21
|
-
}, parent?: {
|
|
22
|
-
[k: string]: any;
|
|
23
|
-
}) => void): void;
|
|
24
|
-
off(evt: string, func: (node: {
|
|
25
|
-
[k: string]: any;
|
|
26
|
-
}, parent?: {
|
|
27
|
-
[k: string]: any;
|
|
28
|
-
}) => void): void;
|
|
29
|
-
private $addListener;
|
|
30
|
-
private $removeListener;
|
|
31
|
-
private emit;
|
|
32
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|