@tmcw/togeojson 4.7.1-0 → 5.0.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/CHANGELOG.md +13 -0
- package/README.md +4 -60
- package/dist/index.d.ts +95 -0
- package/dist/togeojson.cjs +830 -793
- package/dist/togeojson.cjs.map +1 -1
- package/dist/togeojson.es.js +830 -793
- package/dist/togeojson.es.js.map +1 -1
- package/dist/togeojson.umd.js +1 -1
- package/dist/togeojson.umd.js.map +1 -1
- package/package.json +25 -16
- package/dist/togeojson.js +0 -786
- package/dist/togeojson.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.0.0-2](https://github.com/placemarkio/togeojson/compare/v5.0.0-1...v5.0.0-2) (2022-03-14)
|
|
6
|
+
|
|
7
|
+
## [5.0.0-1](https://github.com/placemarkio/togeojson/compare/v5.0.0-0...v5.0.0-1) (2022-03-14)
|
|
8
|
+
|
|
9
|
+
## [5.0.0-0](https://github.com/tmcw/togeojson/compare/v4.8.0-0...v5.0.0-0) (2022-03-14)
|
|
10
|
+
|
|
11
|
+
## [4.8.0-0](https://github.com/tmcw/togeojson/compare/v4.7.0...v4.8.0-0) (2022-03-14)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* Folders and TypeScript ([6f36fd3](https://github.com/tmcw/togeojson/commit/6f36fd381798377909632eae11efef9e8b9be596))
|
|
17
|
+
|
|
5
18
|
### [4.7.1-0](https://github.com/tmcw/togeojson/compare/v4.7.0...v4.7.1-0) (2022-03-09)
|
|
6
19
|
|
|
7
20
|
## [4.7.0](https://github.com/tmcw/togeojson/compare/v4.6.1...v4.7.0) (2022-03-08)
|
package/README.md
CHANGED
|
@@ -10,56 +10,13 @@ to [GeoJSON](http://www.geojson.org/), in a browser or with [Node.js](http://nod
|
|
|
10
10
|
- [x] Tested
|
|
11
11
|
- [x] Node.js + Browsers
|
|
12
12
|
|
|
13
|
+
## [📕 API Documentation](https://placemark.github.io/togeojson/)
|
|
14
|
+
|
|
13
15
|
_This is a JavaScript library that lets projects convert KML and GPX to GeoJSON. If you're
|
|
14
16
|
looking for a command line too, use [@tmcw/togeojson-cli](https://github.com/tmcw/togeojson-cli). If you
|
|
15
17
|
want to convert one KML or GPX file, use [my online tool](https://observablehq.com/@tmcw/convert-kml-to-geojson).
|
|
16
18
|
If you want to convert another format, consider [GDAL](https://www.gdal.org/)._
|
|
17
19
|
|
|
18
|
-
## API
|
|
19
|
-
|
|
20
|
-
### `toGeoJSON.kml(doc)`
|
|
21
|
-
|
|
22
|
-
Convert a KML document to GeoJSON. The first argument, `doc`, must be a KML
|
|
23
|
-
document as an XML DOM - not as a string. You can get this using jQuery's default
|
|
24
|
-
`.ajax` function or using a bare XMLHttpRequest with the `.response` property
|
|
25
|
-
holding an XML DOM.
|
|
26
|
-
|
|
27
|
-
The output is a JavaScript object of GeoJSON data. You can convert it to a string
|
|
28
|
-
with [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
|
|
29
|
-
or use it directly in libraries.
|
|
30
|
-
|
|
31
|
-
### `toGeoJSON.kmlGen(doc)`
|
|
32
|
-
|
|
33
|
-
Convert KML to GeoJSON incrementally, returning a [Generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
|
|
34
|
-
that yields output feature by feature.
|
|
35
|
-
|
|
36
|
-
### `toGeoJSON.gpx(doc)`
|
|
37
|
-
|
|
38
|
-
Convert a GPX document to GeoJSON. The first argument, `doc`, must be a GPX
|
|
39
|
-
document as an XML DOM - not as a string. You can get this using jQuery's default
|
|
40
|
-
`.ajax` function or using a bare XMLHttpRequest with the `.response` property
|
|
41
|
-
holding an XML DOM.
|
|
42
|
-
|
|
43
|
-
The output is a JavaScript object of GeoJSON data, same as `.kml` outputs, with the
|
|
44
|
-
addition of a `_gpxType` property on each `LineString` feature that indicates whether
|
|
45
|
-
the feature was encoded as a route (`rte`) or track (`trk`) in the GPX document.
|
|
46
|
-
|
|
47
|
-
### `toGeoJSON.gpxGen(doc)`
|
|
48
|
-
|
|
49
|
-
Convert GPX to GeoJSON incrementally, returning a [Generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
|
|
50
|
-
that yields output feature by feature.
|
|
51
|
-
|
|
52
|
-
### `toGeoJSON.tcx(doc)`
|
|
53
|
-
|
|
54
|
-
Convert a TCX document to GeoJSON. The first argument, `doc`, must be a TCX
|
|
55
|
-
document as an XML DOM - not as a string.
|
|
56
|
-
|
|
57
|
-
### `toGeoJSON.tcxGen(doc)`
|
|
58
|
-
|
|
59
|
-
Convert a TCX document to GeoJSON incrementally, returning a [Generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
|
|
60
|
-
that yields output feature by feature. The first argument, `doc`, must be a TCX
|
|
61
|
-
document as an XML DOM - not as a string.
|
|
62
|
-
|
|
63
20
|
## Property conversions
|
|
64
21
|
|
|
65
22
|
In addition to converting KML’s `<ExtendedData>` verbatim, @tmcw/togeojson
|
|
@@ -138,10 +95,11 @@ import { kml } from "@tmcw/togeojson";
|
|
|
138
95
|
- [x] ExtendedData
|
|
139
96
|
- [x] SimpleData
|
|
140
97
|
- [x] MultiGeometry -> GeometryCollection
|
|
141
|
-
- [x] Styles
|
|
98
|
+
- [x] Styles
|
|
142
99
|
- [x] Tracks & MultiTracks with `gx:coords`, including altitude
|
|
143
100
|
- [x] [TimeSpan](https://developers.google.com/kml/documentation/kmlreference#timespan)
|
|
144
101
|
- [x] [TimeStamp](https://developers.google.com/kml/documentation/kmlreference#timestamp)
|
|
102
|
+
- [x] Folders (with kmlWithFolders)
|
|
145
103
|
- [ ] NetworkLinks
|
|
146
104
|
- [ ] GroundOverlays
|
|
147
105
|
|
|
@@ -167,20 +125,6 @@ import { kml } from "@tmcw/togeojson";
|
|
|
167
125
|
- The command line utility was moved to [tmcw/togeojson-cli](https://github.com/tmcw/togeojson-cli),
|
|
168
126
|
which lets this module enjoy reduced dependencies: installing @tmcw/togeojson doesn’t
|
|
169
127
|
require any other dependencies.
|
|
170
|
-
- The hashing method is improved, which means that parsing is the same between browsers and
|
|
171
|
-
Node.js, and there are no runtime dependencies.
|
|
172
|
-
|
|
173
|
-
### What is hashing?
|
|
174
|
-
|
|
175
|
-
KML's style system isn't semantic: a typical document made through official tools
|
|
176
|
-
(read Google) has hundreds of identical styles. So, togeojson does its best to
|
|
177
|
-
make this into something usable, by taking a quick hash of each style and exposing
|
|
178
|
-
`styleUrl` and `styleHash` to users. This lets you work backwards from the awful
|
|
179
|
-
representation and build your own styles or derive data based on the classes
|
|
180
|
-
chosen.
|
|
181
|
-
|
|
182
|
-
Implied here is that this does not try to represent all data contained in KML
|
|
183
|
-
styles.
|
|
184
128
|
|
|
185
129
|
### Why doesn't toGeoJSON support NetworkLinks?
|
|
186
130
|
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Feature, FeatureCollection, Geometry } from 'geojson';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert GPX to GeoJSON incrementally, returning
|
|
5
|
+
* a [Generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
|
|
6
|
+
* that yields output feature by feature.
|
|
7
|
+
*/
|
|
8
|
+
declare function gpxGen(node: Document): Generator<Feature>;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* Convert a GPX document to GeoJSON. The first argument, `doc`, must be a GPX
|
|
12
|
+
* document as an XML DOM - not as a string. You can get this using jQuery's default
|
|
13
|
+
* `.ajax` function or using a bare XMLHttpRequest with the `.response` property
|
|
14
|
+
* holding an XML DOM.
|
|
15
|
+
*
|
|
16
|
+
* The output is a JavaScript object of GeoJSON data, same as `.kml` outputs, with the
|
|
17
|
+
* addition of a `_gpxType` property on each `LineString` feature that indicates whether
|
|
18
|
+
* the feature was encoded as a route (`rte`) or track (`trk`) in the GPX document.
|
|
19
|
+
*/
|
|
20
|
+
declare function gpx(node: Document): FeatureCollection;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Incrementally convert a TCX document to GeoJSON. The
|
|
24
|
+
* first argument, `doc`, must be a TCX
|
|
25
|
+
* document as an XML DOM - not as a string.
|
|
26
|
+
*/
|
|
27
|
+
declare function tcxGen(node: Document): Generator<Feature>;
|
|
28
|
+
/**
|
|
29
|
+
* Convert a TCX document to GeoJSON. The first argument, `doc`, must be a TCX
|
|
30
|
+
* document as an XML DOM - not as a string.
|
|
31
|
+
*/
|
|
32
|
+
declare function tcx(node: Document): FeatureCollection;
|
|
33
|
+
|
|
34
|
+
declare type F = Feature<Geometry | null>;
|
|
35
|
+
|
|
36
|
+
interface Folder {
|
|
37
|
+
type: "folder";
|
|
38
|
+
meta: {
|
|
39
|
+
name?: string;
|
|
40
|
+
visibility?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
};
|
|
43
|
+
children: Array<Folder | F>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A nested folder structure, represented
|
|
47
|
+
* as a tree with folders and features.
|
|
48
|
+
*/
|
|
49
|
+
interface Root {
|
|
50
|
+
type: "root";
|
|
51
|
+
children: Array<Folder | F>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Yield a nested tree with KML folder structure
|
|
55
|
+
*
|
|
56
|
+
* This generates a tree with the given structure:
|
|
57
|
+
*
|
|
58
|
+
* ```js
|
|
59
|
+
* {
|
|
60
|
+
* "type": "root",
|
|
61
|
+
* "children": [
|
|
62
|
+
* {
|
|
63
|
+
* "type": "folder",
|
|
64
|
+
* "meta": {
|
|
65
|
+
* "name": "Test"
|
|
66
|
+
* },
|
|
67
|
+
* "children": [
|
|
68
|
+
* // ...features and folders
|
|
69
|
+
* ]
|
|
70
|
+
* }
|
|
71
|
+
* // ...features
|
|
72
|
+
* ]
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare function kmlWithFolders(node: Document): Root;
|
|
77
|
+
/**
|
|
78
|
+
* Convert KML to GeoJSON incrementally, returning
|
|
79
|
+
* a [Generator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)
|
|
80
|
+
* that yields output feature by feature.
|
|
81
|
+
*/
|
|
82
|
+
declare function kmlGen(node: Document): Generator<F>;
|
|
83
|
+
/**
|
|
84
|
+
* Convert a KML document to GeoJSON. The first argument, `doc`, must be a KML
|
|
85
|
+
* document as an XML DOM - not as a string. You can get this using jQuery's default
|
|
86
|
+
* `.ajax` function or using a bare XMLHttpRequest with the `.response` property
|
|
87
|
+
* holding an XML DOM.
|
|
88
|
+
*
|
|
89
|
+
* The output is a JavaScript object of GeoJSON data. You can convert it to a string
|
|
90
|
+
* with [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)
|
|
91
|
+
* or use it directly in libraries.
|
|
92
|
+
*/
|
|
93
|
+
declare function kml(node: Document): FeatureCollection<Geometry | null>;
|
|
94
|
+
|
|
95
|
+
export { gpx, gpxGen, kml, kmlGen, kmlWithFolders, tcx, tcxGen };
|