@ac-kit/format-gpx 0.0.0-stage → 0.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/CHANGELOG.md +45 -0
- package/LICENSE +28 -0
- package/README.md +70 -2
- package/dist/errors.d.ts +74 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +34 -0
- package/dist/errors.js.map +1 -0
- package/dist/geometry/gpx-to-geometries.d.ts +54 -0
- package/dist/geometry/gpx-to-geometries.d.ts.map +1 -0
- package/dist/geometry/gpx-to-geometries.js +84 -0
- package/dist/geometry/gpx-to-geometries.js.map +1 -0
- package/dist/gpx-namespaces.d.ts +9 -0
- package/dist/gpx-namespaces.d.ts.map +1 -0
- package/dist/gpx-namespaces.js +9 -0
- package/dist/gpx-namespaces.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/limits.d.ts +38 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +7 -0
- package/dist/limits.js.map +1 -0
- package/dist/model/create-gpx.d.ts +32 -0
- package/dist/model/create-gpx.d.ts.map +1 -0
- package/dist/model/create-gpx.js +101 -0
- package/dist/model/create-gpx.js.map +1 -0
- package/dist/model/gpx-document.d.ts +169 -0
- package/dist/model/gpx-document.d.ts.map +1 -0
- package/dist/model/gpx-document.js +2 -0
- package/dist/model/gpx-document.js.map +1 -0
- package/dist/parse/_reader.d.ts +77 -0
- package/dist/parse/_reader.d.ts.map +1 -0
- package/dist/parse/_reader.js +1014 -0
- package/dist/parse/_reader.js.map +1 -0
- package/dist/parse/_shared.d.ts +24 -0
- package/dist/parse/_shared.d.ts.map +1 -0
- package/dist/parse/_shared.js +61 -0
- package/dist/parse/_shared.js.map +1 -0
- package/dist/parse/_sink.d.ts +5 -0
- package/dist/parse/_sink.d.ts.map +1 -0
- package/dist/parse/_sink.js +10 -0
- package/dist/parse/_sink.js.map +1 -0
- package/dist/parse/parse-gpx.d.ts +54 -0
- package/dist/parse/parse-gpx.d.ts.map +1 -0
- package/dist/parse/parse-gpx.js +130 -0
- package/dist/parse/parse-gpx.js.map +1 -0
- package/dist/parse/read-gpx-points.d.ts +80 -0
- package/dist/parse/read-gpx-points.d.ts.map +1 -0
- package/dist/parse/read-gpx-points.js +220 -0
- package/dist/parse/read-gpx-points.js.map +1 -0
- package/dist/print/print-gpx.d.ts +31 -0
- package/dist/print/print-gpx.d.ts.map +1 -0
- package/dist/print/print-gpx.js +290 -0
- package/dist/print/print-gpx.js.map +1 -0
- package/package.json +63 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @ac-kit/format-gpx
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5c203e7: New package: GPX 1.1 and 1.0.
|
|
8
|
+
|
|
9
|
+
- `parseGpx(source, { mode, maxLength, maxPoints, maxWarnings, budget, … })`
|
|
10
|
+
reads text, bytes or a parsed `XmlDocument` into a `GpxDocument`:
|
|
11
|
+
metadata, waypoints, routes, tracks and segments, every schema field typed
|
|
12
|
+
and range-checked, times as `Temporal.Instant` (a time with no zone is read
|
|
13
|
+
as UTC with a `missing-time-zone` advisory). GPX 1.0 maps onto the same
|
|
14
|
+
model and keeps its points' `course` and `speed`. Extensions are kept as
|
|
15
|
+
self-contained XML elements; `schemaLocations` keeps the extension schemas.
|
|
16
|
+
Strict mode (the default) throws `GpxSyntaxError` with a `code` and the
|
|
17
|
+
`span` at fault; lenient mode recovers and records `warnings`. Limits throw
|
|
18
|
+
`GpxLimitError`. `tryParseGpx` answers `null` for a malformed document.
|
|
19
|
+
- `readGpxPoints(source, options)` streams the points of a text or byte
|
|
20
|
+
source (an async iterable or a `ReadableStream`) with their route, track
|
|
21
|
+
and segment indices, then the document without them; memory does not grow
|
|
22
|
+
with the points, and each point is read exactly as `parseGpx` reads it.
|
|
23
|
+
- `printGpx(document, { version, indent })` writes GPX 1.1 or 1.0 in schema
|
|
24
|
+
order; what the target version cannot carry throws `TypeError` instead of
|
|
25
|
+
being dropped.
|
|
26
|
+
- `gpxToGeometries(document, { tracks })` gives `@ac-kit/model-dataset`
|
|
27
|
+
geometries with the times of their positions.
|
|
28
|
+
- `createGpxDocument`, `createGpxPoint`, `createGpxRoute`, `createGpxTrack`,
|
|
29
|
+
`createGpxTrackSegment`, `createGpxMetadata` build the model from partial
|
|
30
|
+
fields.
|
|
31
|
+
|
|
32
|
+
Nothing is fetched: external entities are refused and links are data.
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [5c203e7]
|
|
37
|
+
- Updated dependencies [5c203e7]
|
|
38
|
+
- Updated dependencies [5c203e7]
|
|
39
|
+
- Updated dependencies [5c203e7]
|
|
40
|
+
- Updated dependencies [5c203e7]
|
|
41
|
+
- Updated dependencies [5c203e7]
|
|
42
|
+
- @ac-kit/core@0.14.0
|
|
43
|
+
- @ac-kit/format-xml@0.3.0
|
|
44
|
+
- @ac-kit/math-numbers@0.3.0
|
|
45
|
+
- @ac-kit/model-dataset@0.3.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Anthony Champagne and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ac-kit/format-gpx
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
GPX 1.1 and 1.0, the GPS exchange format: read waypoints, routes and tracks
|
|
4
|
+
into one typed model, write it back, stream the points of a file too large to
|
|
5
|
+
hold, and hand the result to anything that speaks GeoJSON.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import {
|
|
9
|
+
gpxToGeometries,
|
|
10
|
+
parseGpx,
|
|
11
|
+
printGpx,
|
|
12
|
+
readGpxPoints,
|
|
13
|
+
} from "@ac-kit/format-gpx";
|
|
14
|
+
|
|
15
|
+
const { document, warnings } = parseGpx(bytes, { mode: "lenient" });
|
|
16
|
+
document.waypoints[0]?.name; // "Beach"
|
|
17
|
+
document.tracks[0]?.segments[0]?.points[0]?.time; // Temporal.Instant
|
|
18
|
+
gpxToGeometries(document); // Point, LineString, MultiLineString…
|
|
19
|
+
printGpx(document); // GPX 1.1
|
|
20
|
+
|
|
21
|
+
// A day-long recording, in the memory of one batch of points:
|
|
22
|
+
for await (const item of readGpxPoints((await fetch(url)).body!)) {
|
|
23
|
+
if (item.kind === "track-point") {
|
|
24
|
+
plot(item.track, item.segment, item.point);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## What it exposes
|
|
30
|
+
|
|
31
|
+
- `parseGpx`, `tryParseGpx` — a document (text, bytes or a parsed
|
|
32
|
+
`XmlDocument`) to a `GpxDocument`: metadata, waypoints, routes, tracks and
|
|
33
|
+
their segments, every field of the schema typed and range-checked, times as
|
|
34
|
+
`Temporal.Instant`s. GPX 1.0 is mapped onto the same model (`url` and
|
|
35
|
+
`urlname` to a link, `author` and `email` to the metadata's author) and
|
|
36
|
+
keeps its points' `course` and `speed`. Extensions are kept as XML
|
|
37
|
+
elements, each self-contained so it resolves and prints on its own.
|
|
38
|
+
- Strict and lenient modes: strict (the default) throws a `GpxSyntaxError`
|
|
39
|
+
with a code and the source span of the first violation; lenient recovers —
|
|
40
|
+
the field is `null`, the element kept in `otherElements` — and records each
|
|
41
|
+
violation in `warnings`.
|
|
42
|
+
- `readGpxPoints` — the points of a stream of text or bytes as they are
|
|
43
|
+
parsed, with the index of their route, track and segment, then the
|
|
44
|
+
document without them. Each point is read exactly as `parseGpx` reads it.
|
|
45
|
+
- `printGpx` — GPX 1.1 (or 1.0) in the schema's order, numbers as plain
|
|
46
|
+
decimals that read back to the same `number`. What the target version
|
|
47
|
+
cannot carry is refused, never dropped.
|
|
48
|
+
- `gpxToGeometries` — RFC 7946 geometries (`@ac-kit/model-dataset`), each
|
|
49
|
+
with its times.
|
|
50
|
+
- `createGpxDocument`, `createGpxPoint`, … — the model's nodes from the
|
|
51
|
+
fields you have.
|
|
52
|
+
|
|
53
|
+
## Untrusted input
|
|
54
|
+
|
|
55
|
+
Every limit is on by default: 64 Mi characters of source, 1 048 576 points
|
|
56
|
+
for a whole parse (none for a stream, which holds no points), 1 000 warnings,
|
|
57
|
+
the XML limits of `@ac-kit/format-xml` (entity expansion, 1024 levels of
|
|
58
|
+
nesting) and an optional work budget. **Nothing is fetched**: an external
|
|
59
|
+
entity is refused, links are data. Time is linear in the source.
|
|
60
|
+
|
|
61
|
+
Portable: no Node.js built-ins.
|
|
62
|
+
|
|
63
|
+
See the
|
|
64
|
+
[generated API docs](https://anthochamp.pages.grenadine.io/node-essentials/api/format-gpx/)
|
|
65
|
+
for the full reference.
|
|
66
|
+
|
|
67
|
+
## Further reading
|
|
68
|
+
|
|
69
|
+
- [GPX 1.1 schema documentation](https://www.topografix.com/GPX/1/1/) — the
|
|
70
|
+
specification.
|
|
71
|
+
- [GPX 1.0](https://www.topografix.com/gpx_manual.asp) — the earlier version.
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Span } from "@ac-kit/core";
|
|
2
|
+
import type { XmlVocabularyDiagnostic } from "@ac-kit/format-xml";
|
|
3
|
+
/**
|
|
4
|
+
* Stable identifiers of everything {@link parseGpx} and {@link readGpxPoints}
|
|
5
|
+
* report. Every code but the advisories `nonstandard-namespace` and
|
|
6
|
+
* `missing-time-zone` is a violation of the GPX schema: a strict parse throws
|
|
7
|
+
* at the first, a lenient one recovers as the code says and records it.
|
|
8
|
+
*
|
|
9
|
+
* - `not-gpx`: the root is not a `gpx` element in a GPX namespace (or in none);
|
|
10
|
+
* fails in both modes.
|
|
11
|
+
* - `nonstandard-namespace`: advisory, the root is in no namespace; read as the
|
|
12
|
+
* namespace of its `version` (1.1 when absent or unknown).
|
|
13
|
+
* - `unsupported-version`: `version` is missing, is not `1.0` or `1.1`, or
|
|
14
|
+
* contradicts the namespace. Lenient: the namespace decides.
|
|
15
|
+
* - `namespace`: a Namespaces in XML violation the lenient resolution recovered
|
|
16
|
+
* from (strict mode throws its `XmlNamespaceError`).
|
|
17
|
+
* - `missing-attribute`: a required attribute is absent — `gpx@creator`,
|
|
18
|
+
* `@lat`/`@lon` of a point, `link@href`, `copyright@author`, an `email`'s
|
|
19
|
+
* `@id`/`@domain`, a corner of `bounds`. Lenient: a point without its
|
|
20
|
+
* position, a link without `href`, an incomplete `bounds` or `email` is left
|
|
21
|
+
* out and its element kept in `otherElements`; a missing creator is `""`, a
|
|
22
|
+
* missing copyright author `""`.
|
|
23
|
+
* - `invalid-value`: a value does not read as its type or is out of its range — a
|
|
24
|
+
* decimal, a latitude past ±90, a longitude outside [−180, 180), an angle
|
|
25
|
+
* outside [0, 360), a non-negative integer, a DGPS station past 1023, a
|
|
26
|
+
* `fix`, an `xs:dateTime`, an `xs:gYear`, or a GPX 1.0 e-mail with no `@`.
|
|
27
|
+
* Lenient: a number written with an exponent or out of range is kept as read;
|
|
28
|
+
* anything else is `null`, its element kept in `otherElements`.
|
|
29
|
+
* - `unexpected-element`: an element the schema does not allow where it is —
|
|
30
|
+
* unknown, in the wrong order, repeated, or (GPX 1.1) of another namespace
|
|
31
|
+
* outside `<extensions>`. Lenient: an out-of-order element is read anyway,
|
|
32
|
+
* the others are kept in `otherElements`.
|
|
33
|
+
* - `unexpected-attribute`: an attribute in no namespace the element does not
|
|
34
|
+
* have. Lenient: kept in `otherAttributes`. Attributes of another namespace
|
|
35
|
+
* are kept there in both modes.
|
|
36
|
+
* - `missing-time-zone`: advisory, a time written with no timezone, read as UTC
|
|
37
|
+
* as GPX requires.
|
|
38
|
+
*/
|
|
39
|
+
export type GpxDiagnosticCode = "not-gpx" | "nonstandard-namespace" | "unsupported-version" | "namespace" | "missing-attribute" | "invalid-value" | "unexpected-element" | "unexpected-attribute" | "missing-time-zone";
|
|
40
|
+
/** One problem found while reading, where it was. */
|
|
41
|
+
export type GpxDiagnostic = XmlVocabularyDiagnostic<GpxDiagnosticCode>;
|
|
42
|
+
/**
|
|
43
|
+
* A document XML accepts and GPX does not, in the way the active mode does not
|
|
44
|
+
* tolerate: any violation in strict mode, and in both modes a root that is not
|
|
45
|
+
* GPX.
|
|
46
|
+
*/
|
|
47
|
+
export declare class GpxSyntaxError extends SyntaxError {
|
|
48
|
+
readonly code: GpxDiagnosticCode;
|
|
49
|
+
/**
|
|
50
|
+
* The source span of the element or attribute at fault, or of its nearest
|
|
51
|
+
* ancestor with one; `null` for a tree built in code.
|
|
52
|
+
*/
|
|
53
|
+
readonly span: Span | null;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
constructor(code: GpxDiagnosticCode, message: string,
|
|
56
|
+
/**
|
|
57
|
+
* The source span of the element or attribute at fault, or of its nearest
|
|
58
|
+
* ancestor with one; `null` for a tree built in code.
|
|
59
|
+
*/
|
|
60
|
+
span: Span | null);
|
|
61
|
+
}
|
|
62
|
+
/** Which of the {@link GpxLimits} a {@link GpxLimitError} reports. */
|
|
63
|
+
export type GpxLimitName = "maxLength" | "maxPoints" | "budget";
|
|
64
|
+
/** Input past one of the {@link GpxLimits}; thrown in every mode. */
|
|
65
|
+
export declare class GpxLimitError extends RangeError {
|
|
66
|
+
readonly limit: GpxLimitName;
|
|
67
|
+
/** The bound that was exceeded. */
|
|
68
|
+
readonly value: number;
|
|
69
|
+
readonly name: string;
|
|
70
|
+
constructor(limit: GpxLimitName,
|
|
71
|
+
/** The bound that was exceeded. */
|
|
72
|
+
value: number, options?: ErrorOptions);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,MAAM,iBAAiB,GAC1B,SAAS,GACT,uBAAuB,GACvB,qBAAqB,GACrB,WAAW,GACX,mBAAmB,GACnB,eAAe,GACf,oBAAoB,GACpB,sBAAsB,GACtB,mBAAmB,CAAC;AAEvB,qDAAqD;AACrD,MAAM,MAAM,aAAa,GAAG,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;AAEvE;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAI7C,QAAQ,CAAC,IAAI,EAAE,iBAAiB;IAEhC;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAT3B,SAAkB,IAAI,EAAE,MAAM,CAAoB;IAElD,YACU,IAAI,EAAE,iBAAiB,EAChC,OAAO,EAAE,MAAM;IACf;;;OAGG;IACM,IAAI,EAAE,IAAI,GAAG,IAAI,EAG1B;CACD;AAED,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEhE,qEAAqE;AACrE,qBAAa,aAAc,SAAQ,UAAU;IAI3C,QAAQ,CAAC,KAAK,EAAE,YAAY;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM;IALvB,SAAkB,IAAI,EAAE,MAAM,CAAmB;IAEjD,YACU,KAAK,EAAE,YAAY;IAC5B,mCAAmC;IAC1B,KAAK,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,YAAY,EAGtB;CACD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A document XML accepts and GPX does not, in the way the active mode does not
|
|
3
|
+
* tolerate: any violation in strict mode, and in both modes a root that is not
|
|
4
|
+
* GPX.
|
|
5
|
+
*/
|
|
6
|
+
export class GpxSyntaxError extends SyntaxError {
|
|
7
|
+
code;
|
|
8
|
+
span;
|
|
9
|
+
name = "GpxSyntaxError";
|
|
10
|
+
constructor(code, message,
|
|
11
|
+
/**
|
|
12
|
+
* The source span of the element or attribute at fault, or of its nearest
|
|
13
|
+
* ancestor with one; `null` for a tree built in code.
|
|
14
|
+
*/
|
|
15
|
+
span) {
|
|
16
|
+
super(span === null ? message : `${message} at ${span.start}`);
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.span = span;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Input past one of the {@link GpxLimits}; thrown in every mode. */
|
|
22
|
+
export class GpxLimitError extends RangeError {
|
|
23
|
+
limit;
|
|
24
|
+
value;
|
|
25
|
+
name = "GpxLimitError";
|
|
26
|
+
constructor(limit,
|
|
27
|
+
/** The bound that was exceeded. */
|
|
28
|
+
value, options) {
|
|
29
|
+
super(`GPX document exceeds ${limit} (${value})`, options);
|
|
30
|
+
this.limit = limit;
|
|
31
|
+
this.value = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAqDA;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAIpC,IAAI;IAMJ,IAAI;IATI,IAAI,GAAW,gBAAgB,CAAC;IAElD,YACU,IAAuB,EAChC,OAAe;IACf;;;OAGG;IACM,IAAiB;QAE1B,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;oBARtD,IAAI;oBAMJ,IAAI;IAGd,CAAC;CACD;AAKD,qEAAqE;AACrE,MAAM,OAAO,aAAc,SAAQ,UAAU;IAIlC,KAAK;IAEL,KAAK;IALG,IAAI,GAAW,eAAe,CAAC;IAEjD,YACU,KAAmB;IAC5B,mCAAmC;IAC1B,KAAa,EACtB,OAAsB;QAEtB,KAAK,CAAC,wBAAwB,KAAK,KAAK,KAAK,GAAG,EAAE,OAAO,CAAC,CAAC;qBALlD,KAAK;qBAEL,KAAK;IAIf,CAAC;CACD"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { GeoLineString, GeoMultiLineString, GeoPoint } from "@ac-kit/model-dataset";
|
|
2
|
+
import type { GpxDocument, GpxPoint, GpxRoute, GpxTrack } from "../model/gpx-document.js";
|
|
3
|
+
/** Options of {@link gpxToGeometries}. */
|
|
4
|
+
export type GpxGeometryOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* `"multi-line-string"` (the default) gives one `MultiLineString` per track,
|
|
7
|
+
* a line per segment; `"line-strings"` one `LineString` per segment.
|
|
8
|
+
*/
|
|
9
|
+
readonly tracks?: "multi-line-string" | "line-strings";
|
|
10
|
+
};
|
|
11
|
+
/** A time per position, in the shape of the geometry's coordinates. */
|
|
12
|
+
export type GpxLineTimes = readonly (Temporal.Instant | null)[];
|
|
13
|
+
/** One geometry of a document, with what it came from. */
|
|
14
|
+
export type GpxGeometry = {
|
|
15
|
+
readonly kind: "waypoint";
|
|
16
|
+
readonly index: number;
|
|
17
|
+
readonly source: GpxPoint;
|
|
18
|
+
readonly geometry: GeoPoint;
|
|
19
|
+
readonly times: Temporal.Instant | null;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "route";
|
|
22
|
+
readonly index: number;
|
|
23
|
+
readonly source: GpxRoute;
|
|
24
|
+
readonly geometry: GeoLineString;
|
|
25
|
+
readonly times: GpxLineTimes;
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: "track";
|
|
28
|
+
readonly index: number;
|
|
29
|
+
readonly source: GpxTrack;
|
|
30
|
+
readonly geometry: GeoMultiLineString;
|
|
31
|
+
readonly times: readonly GpxLineTimes[];
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: "track-segment";
|
|
34
|
+
readonly index: number;
|
|
35
|
+
/** The segment's index in its track. */
|
|
36
|
+
readonly segment: number;
|
|
37
|
+
readonly source: GpxTrack;
|
|
38
|
+
readonly geometry: GeoLineString;
|
|
39
|
+
readonly times: GpxLineTimes;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The document as GeoJSON geometries (RFC 7946, `@ac-kit/model-dataset`'s
|
|
43
|
+
* `Geometry`), longitude first: each waypoint a `Point`, each route a
|
|
44
|
+
* `LineString`, each track a `MultiLineString` of its segments (or a
|
|
45
|
+
* `LineString` per segment), in document order, each with the times of its
|
|
46
|
+
* positions beside it.
|
|
47
|
+
*
|
|
48
|
+
* A position carries the elevation only when every point of its geometry has
|
|
49
|
+
* one, so a geometry is all 2D or all 3D. A route or segment of fewer than two
|
|
50
|
+
* points is no line and is left out, and a track left with no line too. Time
|
|
51
|
+
* and memory O(n) in the points.
|
|
52
|
+
*/
|
|
53
|
+
export declare function gpxToGeometries(document: GpxDocument, options?: GpxGeometryOptions): GpxGeometry[];
|
|
54
|
+
//# sourceMappingURL=gpx-to-geometries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpx-to-geometries.d.ts","sourceRoot":"","sources":["../../src/geometry/gpx-to-geometries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,kBAAkB,EAClB,QAAQ,EAER,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,0BAA0B,CAAC;AAElC,0CAA0C;AAC1C,MAAM,MAAM,kBAAkB,GAAG;IAChC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAAC;CACvD,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;AAEhE,0DAA0D;AAC1D,MAAM,MAAM,WAAW,GACpB;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7946, `@ac-kit/model-dataset`'s
|
|
3
|
+
* `Geometry`), longitude first: each waypoint a `Point`, each route a
|
|
4
|
+
* `LineString`, each track a `MultiLineString` of its segments (or a
|
|
5
|
+
* `LineString` per segment), in document order, each with the times of its
|
|
6
|
+
* positions beside it.
|
|
7
|
+
*
|
|
8
|
+
* A position carries the elevation only when every point of its geometry has
|
|
9
|
+
* one, so a geometry is all 2D or all 3D. A route or segment of fewer than two
|
|
10
|
+
* points is no line and is left out, and a track left with no line too. Time
|
|
11
|
+
* and memory O(n) in the points.
|
|
12
|
+
*/
|
|
13
|
+
export function gpxToGeometries(document, options) {
|
|
14
|
+
const result = [];
|
|
15
|
+
for (const [index, point] of document.waypoints.entries()) {
|
|
16
|
+
result.push({
|
|
17
|
+
kind: "waypoint",
|
|
18
|
+
index,
|
|
19
|
+
source: point,
|
|
20
|
+
geometry: {
|
|
21
|
+
type: "Point",
|
|
22
|
+
coordinates: position_(point, point.elevation !== null),
|
|
23
|
+
},
|
|
24
|
+
times: point.time,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
for (const [index, route] of document.routes.entries()) {
|
|
28
|
+
if (route.points.length >= 2) {
|
|
29
|
+
result.push({
|
|
30
|
+
kind: "route",
|
|
31
|
+
index,
|
|
32
|
+
source: route,
|
|
33
|
+
geometry: { type: "LineString", coordinates: line_(route.points) },
|
|
34
|
+
times: route.points.map((point) => point.time),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const perSegment = options?.tracks === "line-strings";
|
|
39
|
+
for (const [index, track] of document.tracks.entries()) {
|
|
40
|
+
const lines = [];
|
|
41
|
+
const times = [];
|
|
42
|
+
for (const [segment, { points }] of track.segments.entries()) {
|
|
43
|
+
if (points.length < 2) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const line = line_(points);
|
|
47
|
+
const lineTimes = points.map((point) => point.time);
|
|
48
|
+
if (perSegment) {
|
|
49
|
+
result.push({
|
|
50
|
+
kind: "track-segment",
|
|
51
|
+
index,
|
|
52
|
+
segment,
|
|
53
|
+
source: track,
|
|
54
|
+
geometry: { type: "LineString", coordinates: line },
|
|
55
|
+
times: lineTimes,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
lines.push(line);
|
|
60
|
+
times.push(lineTimes);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!perSegment && lines.length > 0) {
|
|
64
|
+
result.push({
|
|
65
|
+
kind: "track",
|
|
66
|
+
index,
|
|
67
|
+
source: track,
|
|
68
|
+
geometry: { type: "MultiLineString", coordinates: lines },
|
|
69
|
+
times,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
function line_(points) {
|
|
76
|
+
const withElevation = points.every((point) => point.elevation !== null);
|
|
77
|
+
return points.map((point) => position_(point, withElevation));
|
|
78
|
+
}
|
|
79
|
+
function position_(point, withElevation) {
|
|
80
|
+
return withElevation
|
|
81
|
+
? [point.longitude, point.latitude, point.elevation]
|
|
82
|
+
: [point.longitude, point.latitude];
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=gpx-to-geometries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpx-to-geometries.js","sourceRoot":"","sources":["../../src/geometry/gpx-to-geometries.ts"],"names":[],"mappings":"AA2DA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAC9B,QAAqB,EACrB,OAA4B;IAE5B,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3D,MAAM,CAAC,IAAI,CAAC;YACX,IAAI,EAAE,UAAU;YAChB,KAAK;YACL,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE;gBACT,IAAI,EAAE,OAAO;gB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AK,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The namespace of GPX 1.1 (`http://www.topografix.com/GPX/1/1`). */
|
|
2
|
+
export declare const GPX_1_1_NAMESPACE = "http://www.topografix.com/GPX/1/1";
|
|
3
|
+
/** The namespace of GPX 1.0 (`http://www.topografix.com/GPX/1/0`). */
|
|
4
|
+
export declare const GPX_1_0_NAMESPACE = "http://www.topografix.com/GPX/1/0";
|
|
5
|
+
/** The schema location `printGpx` writes for GPX 1.1. */
|
|
6
|
+
export declare const GPX_1_1_SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/1/gpx.xsd";
|
|
7
|
+
/** The schema location `printGpx` writes for GPX 1.0. */
|
|
8
|
+
export declare const GPX_1_0_SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/0/gpx.xsd";
|
|
9
|
+
//# sourceMappingURL=gpx-namespaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpx-namespaces.d.ts","sourceRoot":"","sources":["../src/gpx-namespaces.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,sCAAsC,CAAC;AAErE,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,sCAAsC,CAAC;AAErE,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,8CACQ,CAAC;AAE7C,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,8CACQ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The namespace of GPX 1.1 (`http://www.topografix.com/GPX/1/1`). */
|
|
2
|
+
export const GPX_1_1_NAMESPACE = "http://www.topografix.com/GPX/1/1";
|
|
3
|
+
/** The namespace of GPX 1.0 (`http://www.topografix.com/GPX/1/0`). */
|
|
4
|
+
export const GPX_1_0_NAMESPACE = "http://www.topografix.com/GPX/1/0";
|
|
5
|
+
/** The schema location `printGpx` writes for GPX 1.1. */
|
|
6
|
+
export const GPX_1_1_SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/1/gpx.xsd";
|
|
7
|
+
/** The schema location `printGpx` writes for GPX 1.0. */
|
|
8
|
+
export const GPX_1_0_SCHEMA_LOCATION = "http://www.topografix.com/GPX/1/0/gpx.xsd";
|
|
9
|
+
//# sourceMappingURL=gpx-namespaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpx-namespaces.js","sourceRoot":"","sources":["../src/gpx-namespaces.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AAErE,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AAErE,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GACnC,2CAA2C,CAAC;AAE7C,yDAAyD;AACzD,MAAM,CAAC,MAAM,uBAAuB,GACnC,2CAA2C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./errors.js";
|
|
2
|
+
export * from "./geometry/gpx-to-geometries.js";
|
|
3
|
+
export * from "./gpx-namespaces.js";
|
|
4
|
+
export * from "./limits.js";
|
|
5
|
+
export * from "./model/create-gpx.js";
|
|
6
|
+
export * from "./model/gpx-document.js";
|
|
7
|
+
export * from "./parse/parse-gpx.js";
|
|
8
|
+
export * from "./parse/read-gpx-points.js";
|
|
9
|
+
export * from "./print/print-gpx.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./errors.js";
|
|
2
|
+
export * from "./geometry/gpx-to-geometries.js";
|
|
3
|
+
export * from "./gpx-namespaces.js";
|
|
4
|
+
export * from "./limits.js";
|
|
5
|
+
export * from "./model/create-gpx.js";
|
|
6
|
+
export * from "./model/gpx-document.js";
|
|
7
|
+
export * from "./parse/parse-gpx.js";
|
|
8
|
+
export * from "./parse/read-gpx-points.js";
|
|
9
|
+
export * from "./print/print-gpx.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
package/dist/limits.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { WorkBudget } from "@ac-kit/core";
|
|
2
|
+
/**
|
|
3
|
+
* Bounds on what one GPX document may cost to read. A GPX file comes from a
|
|
4
|
+
* device, an app or a stranger: each bound guards a different multiplier. The
|
|
5
|
+
* XML limits of `@ac-kit/format-xml` (entity expansion, element nesting) apply
|
|
6
|
+
* on top.
|
|
7
|
+
*/
|
|
8
|
+
export type GpxLimits = {
|
|
9
|
+
/**
|
|
10
|
+
* Most characters of source {@link parseGpx} reads, 67 108 864 (64 Mi) by
|
|
11
|
+
* default; bytes are bounded at three times this before decoding.
|
|
12
|
+
* {@link readGpxPoints} reads any length: its memory does not grow with the
|
|
13
|
+
* points.
|
|
14
|
+
*/
|
|
15
|
+
readonly maxLength?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Most waypoints, route points and track points together: 1 048 576 by
|
|
18
|
+
* default for {@link parseGpx}, which holds them all, and no bound for
|
|
19
|
+
* {@link readGpxPoints}, which holds none.
|
|
20
|
+
*/
|
|
21
|
+
readonly maxPoints?: number;
|
|
22
|
+
/** Most warnings kept, 1 000 by default; later ones are counted, not stored. */
|
|
23
|
+
readonly maxWarnings?: number;
|
|
24
|
+
/**
|
|
25
|
+
* A work allowance shared by XML parsing, namespace resolution and the GPX
|
|
26
|
+
* pass: a caller's `WorkBudget`, whose error propagates unchanged, or a limit
|
|
27
|
+
* for a private one, whose exhaustion is a {@link GpxLimitError}. None by
|
|
28
|
+
* default: every pass is linear in the source, which `maxLength` bounds.
|
|
29
|
+
*/
|
|
30
|
+
readonly budget?: WorkBudget | number;
|
|
31
|
+
};
|
|
32
|
+
/** The defaults behind the unset bounds of {@link GpxLimits}. */
|
|
33
|
+
export declare const DEFAULT_GPX_LIMITS: {
|
|
34
|
+
readonly maxLength: 67108864;
|
|
35
|
+
readonly maxPoints: 1048576;
|
|
36
|
+
readonly maxWarnings: 1000;
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gFAAgF;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CACtC,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,kBAAkB;aAC9B,SAAS,EAAE,QAAU;aACrB,SAAS,EAAE,OAAS;aACpB,WAAW,EAAE,IAAI;CACR,CAAC"}
|
package/dist/limits.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAiCA,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,SAAS,EAAE,QAAU;IACrB,SAAS,EAAE,OAAS;IACpB,WAAW,EAAE,IAAI;CACR,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { GpxDocument, GpxMetadata, GpxPoint, GpxRoute, GpxTrack, GpxTrackSegment } from "./gpx-document.js";
|
|
2
|
+
type Init_<T, Required extends keyof T> = Pick<T, Required> & Partial<Omit<T, Required>>;
|
|
3
|
+
/** A point from its position and any other fields, the rest `null` or empty. */
|
|
4
|
+
export declare function createGpxPoint(init: Init_<GpxPoint, "latitude" | "longitude">): GpxPoint;
|
|
5
|
+
/** A route from any of its fields, the rest `null` or empty. */
|
|
6
|
+
export declare function createGpxRoute(init?: Partial<GpxRoute>): GpxRoute;
|
|
7
|
+
/** A track from any of its fields, the rest `null` or empty. */
|
|
8
|
+
export declare function createGpxTrack(init?: Partial<GpxTrack>): GpxTrack;
|
|
9
|
+
/** A track segment from any of its fields, the rest empty. */
|
|
10
|
+
export declare function createGpxTrackSegment(init?: Partial<GpxTrackSegment>): GpxTrackSegment;
|
|
11
|
+
/** Metadata from any of its fields, the rest `null` or empty. */
|
|
12
|
+
export declare function createGpxMetadata(init?: Partial<GpxMetadata>): GpxMetadata;
|
|
13
|
+
/**
|
|
14
|
+
* A GPX 1.1 document from its creator and any other fields, the rest empty.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* printGpx(
|
|
18
|
+
* createGpxDocument({
|
|
19
|
+
* creator: "my app",
|
|
20
|
+
* waypoints: [
|
|
21
|
+
* createGpxPoint({
|
|
22
|
+
* latitude: 45.83,
|
|
23
|
+
* longitude: 6.86,
|
|
24
|
+
* name: "Mont Blanc",
|
|
25
|
+
* }),
|
|
26
|
+
* ],
|
|
27
|
+
* }),
|
|
28
|
+
* );
|
|
29
|
+
*/
|
|
30
|
+
export declare function createGpxDocument(init: Init_<GpxDocument, "creator">): GpxDocument;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=create-gpx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-gpx.d.ts","sourceRoot":"","sources":["../../src/model/create-gpx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,MAAM,mBAAmB,CAAC;AAI3B,KAAK,KAAK,CAAC,CAAC,EAAE,QAAQ,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,GAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AAoB5B,gFAAgF;AAChF,wBAAgB,cAAc,CAC7B,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,UAAU,GAAG,WAAW,CAAC,GAC7C,QAAQ,CAyBV;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,IAAI,GAAE,OAAO,CAAC,QAAQ,CAAM,GAAG,QAAQ,CAErE;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,IAAI,GAAE,OAAO,CAAC,QAAQ,CAAM,GAAG,QAAQ,CAErE;AAED,8DAA8D;AAC9D,wBAAgB,qBAAqB,CACpC,IAAI,GAAE,OAAO,CAAC,eAAe,CAAM,GACjC,eAAe,CAEjB;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAChC,IAAI,GAAE,OAAO,CAAC,WAAW,CAAM,GAC7B,WAAW,CAab;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,GACjC,WAAW,CAWb"}
|