@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.
Files changed (56) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE +28 -0
  3. package/README.md +70 -2
  4. package/dist/errors.d.ts +74 -0
  5. package/dist/errors.d.ts.map +1 -0
  6. package/dist/errors.js +34 -0
  7. package/dist/errors.js.map +1 -0
  8. package/dist/geometry/gpx-to-geometries.d.ts +54 -0
  9. package/dist/geometry/gpx-to-geometries.d.ts.map +1 -0
  10. package/dist/geometry/gpx-to-geometries.js +84 -0
  11. package/dist/geometry/gpx-to-geometries.js.map +1 -0
  12. package/dist/gpx-namespaces.d.ts +9 -0
  13. package/dist/gpx-namespaces.d.ts.map +1 -0
  14. package/dist/gpx-namespaces.js +9 -0
  15. package/dist/gpx-namespaces.js.map +1 -0
  16. package/dist/index.d.ts +10 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +10 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/limits.d.ts +38 -0
  21. package/dist/limits.d.ts.map +1 -0
  22. package/dist/limits.js +7 -0
  23. package/dist/limits.js.map +1 -0
  24. package/dist/model/create-gpx.d.ts +32 -0
  25. package/dist/model/create-gpx.d.ts.map +1 -0
  26. package/dist/model/create-gpx.js +101 -0
  27. package/dist/model/create-gpx.js.map +1 -0
  28. package/dist/model/gpx-document.d.ts +169 -0
  29. package/dist/model/gpx-document.d.ts.map +1 -0
  30. package/dist/model/gpx-document.js +2 -0
  31. package/dist/model/gpx-document.js.map +1 -0
  32. package/dist/parse/_reader.d.ts +77 -0
  33. package/dist/parse/_reader.d.ts.map +1 -0
  34. package/dist/parse/_reader.js +1014 -0
  35. package/dist/parse/_reader.js.map +1 -0
  36. package/dist/parse/_shared.d.ts +24 -0
  37. package/dist/parse/_shared.d.ts.map +1 -0
  38. package/dist/parse/_shared.js +61 -0
  39. package/dist/parse/_shared.js.map +1 -0
  40. package/dist/parse/_sink.d.ts +5 -0
  41. package/dist/parse/_sink.d.ts.map +1 -0
  42. package/dist/parse/_sink.js +10 -0
  43. package/dist/parse/_sink.js.map +1 -0
  44. package/dist/parse/parse-gpx.d.ts +54 -0
  45. package/dist/parse/parse-gpx.d.ts.map +1 -0
  46. package/dist/parse/parse-gpx.js +130 -0
  47. package/dist/parse/parse-gpx.js.map +1 -0
  48. package/dist/parse/read-gpx-points.d.ts +80 -0
  49. package/dist/parse/read-gpx-points.d.ts.map +1 -0
  50. package/dist/parse/read-gpx-points.js +220 -0
  51. package/dist/parse/read-gpx-points.js.map +1 -0
  52. package/dist/print/print-gpx.d.ts +31 -0
  53. package/dist/print/print-gpx.d.ts.map +1 -0
  54. package/dist/print/print-gpx.js +290 -0
  55. package/dist/print/print-gpx.js.map +1 -0
  56. package/package.json +63 -3
@@ -0,0 +1,101 @@
1
+ const NONE_ = Object.freeze([]);
2
+ const EXTENSIBLE_ = {
3
+ extensions: NONE_,
4
+ otherElements: NONE_,
5
+ otherAttributes: NONE_,
6
+ span: null,
7
+ };
8
+ const DESCRIPTION_ = {
9
+ ...EXTENSIBLE_,
10
+ name: null,
11
+ comment: null,
12
+ description: null,
13
+ source: null,
14
+ links: NONE_,
15
+ number: null,
16
+ type: null,
17
+ };
18
+ /** A point from its position and any other fields, the rest `null` or empty. */
19
+ export function createGpxPoint(init) {
20
+ return {
21
+ ...EXTENSIBLE_,
22
+ elevation: null,
23
+ time: null,
24
+ magneticVariation: null,
25
+ geoidHeight: null,
26
+ name: null,
27
+ comment: null,
28
+ description: null,
29
+ source: null,
30
+ links: NONE_,
31
+ symbol: null,
32
+ type: null,
33
+ fix: null,
34
+ satellites: null,
35
+ hdop: null,
36
+ vdop: null,
37
+ pdop: null,
38
+ ageOfDgpsData: null,
39
+ dgpsId: null,
40
+ course: null,
41
+ speed: null,
42
+ ...init,
43
+ };
44
+ }
45
+ /** A route from any of its fields, the rest `null` or empty. */
46
+ export function createGpxRoute(init = {}) {
47
+ return { ...DESCRIPTION_, points: NONE_, ...init };
48
+ }
49
+ /** A track from any of its fields, the rest `null` or empty. */
50
+ export function createGpxTrack(init = {}) {
51
+ return { ...DESCRIPTION_, segments: NONE_, ...init };
52
+ }
53
+ /** A track segment from any of its fields, the rest empty. */
54
+ export function createGpxTrackSegment(init = {}) {
55
+ return { ...EXTENSIBLE_, points: NONE_, ...init };
56
+ }
57
+ /** Metadata from any of its fields, the rest `null` or empty. */
58
+ export function createGpxMetadata(init = {}) {
59
+ return {
60
+ ...EXTENSIBLE_,
61
+ name: null,
62
+ description: null,
63
+ author: null,
64
+ copyright: null,
65
+ links: NONE_,
66
+ time: null,
67
+ keywords: null,
68
+ bounds: null,
69
+ ...init,
70
+ };
71
+ }
72
+ /**
73
+ * A GPX 1.1 document from its creator and any other fields, the rest empty.
74
+ *
75
+ * @example
76
+ * printGpx(
77
+ * createGpxDocument({
78
+ * creator: "my app",
79
+ * waypoints: [
80
+ * createGpxPoint({
81
+ * latitude: 45.83,
82
+ * longitude: 6.86,
83
+ * name: "Mont Blanc",
84
+ * }),
85
+ * ],
86
+ * }),
87
+ * );
88
+ */
89
+ export function createGpxDocument(init) {
90
+ return {
91
+ ...EXTENSIBLE_,
92
+ version: "1.1",
93
+ schemaLocations: NONE_,
94
+ metadata: createGpxMetadata(),
95
+ waypoints: NONE_,
96
+ routes: NONE_,
97
+ tracks: NONE_,
98
+ ...init,
99
+ };
100
+ }
101
+ //# sourceMappingURL=create-gpx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-gpx.js","sourceRoot":"","sources":["../../src/model/create-gpx.ts"],"names":[],"mappings":"AASA,MAAM,KAAK,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAKlD,MAAM,WAAW,GAAG;IACnB,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,KAAK;IACpB,eAAe,EAAE,KAAK;IACtB,IAAI,EAAE,IAAI;CACD,CAAC;AAEX,MA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,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,CAAC;AACnD,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,iBAAiB,CAChC,IAAI,GAAyB,EAAE;IAE/B,OAAO;QACN,GAAG,WAAW;QACd,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,IAAI;QACjB,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;QACZ,GAAG,IAAI;KACP,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAChC,IAAmC;IAEnC,OAAO;QACN,GAAG,WAAW;QACd,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,KAAK;QACtB,QAAQ,EAAE,iBAAiB,EAAE;QAC7B,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;QACb,GAAG,IAAI;KACP,CAAC;AACH,CAAC"}
@@ -0,0 +1,169 @@
1
+ import type { Span } from "@ac-kit/core";
2
+ import type { XmlAttribute, XmlElement } from "@ac-kit/format-xml";
3
+ /** Which GPX schema a document was read as, or is printed as. */
4
+ export type GpxVersion = "1.0" | "1.1";
5
+ /**
6
+ * What every element-backed node keeps beyond its typed fields.
7
+ *
8
+ * - `extensions`: GPX 1.1's `<extensions>` children, or GPX 1.0's elements of
9
+ * another namespace, in source order. Each is self-contained: the namespace
10
+ * declarations it relies on are copied onto it (`detachXmlElement`), so it
11
+ * resolves and prints on its own.
12
+ * - `otherElements`: elements a lenient parse could not place — unknown, out of
13
+ * order, repeated or unreadable — kept self-contained as well. They are not
14
+ * printed.
15
+ * - `otherAttributes`: attributes the model does not type (namespace declarations
16
+ * excepted), in source order. They are not printed.
17
+ * - `span`: the element's source span, `null` for a node built in code or one an
18
+ * entity expanded into.
19
+ */
20
+ export type GpxExtensible = {
21
+ readonly extensions: readonly XmlElement[];
22
+ readonly otherElements: readonly XmlElement[];
23
+ readonly otherAttributes: readonly XmlAttribute[];
24
+ readonly span: Span | null;
25
+ };
26
+ /** A link to a web page or file (`linkType`; GPX 1.0's `url` and `urlname`). */
27
+ export type GpxLink = {
28
+ readonly href: string;
29
+ /** The text of the hyperlink. */
30
+ readonly text: string | null;
31
+ /** Its MIME type, as written (`image/jpeg`). GPX 1.1 only. */
32
+ readonly type: string | null;
33
+ };
34
+ /** An e-mail address split at its last `@` (`emailType`). */
35
+ export type GpxEmail = {
36
+ readonly id: string;
37
+ readonly domain: string;
38
+ };
39
+ /** A person or organisation (`personType`). */
40
+ export type GpxPerson = {
41
+ readonly name: string | null;
42
+ readonly email: GpxEmail | null;
43
+ /** GPX 1.1 only. */
44
+ readonly link: GpxLink | null;
45
+ };
46
+ /** The holder and licence of a file (`copyrightType`), GPX 1.1 only. */
47
+ export type GpxCopyright = {
48
+ readonly author: string;
49
+ /** `xs:gYear`, a year of the proleptic Gregorian calendar (0 is 1 BCE). */
50
+ readonly year: number | null;
51
+ /** A URI of the licence. */
52
+ readonly license: string | null;
53
+ };
54
+ /** Two latitude–longitude corners, in degrees (`boundsType`). */
55
+ export type GpxBounds = {
56
+ readonly minLatitude: number;
57
+ readonly minLongitude: number;
58
+ readonly maxLatitude: number;
59
+ readonly maxLongitude: number;
60
+ };
61
+ /** The type of GPS fix (`fixType`). */
62
+ export type GpxFix = "none" | "2d" | "3d" | "dgps" | "pps";
63
+ /** What a document says about itself (`metadataType`; GPX 1.0's root fields). */
64
+ export type GpxMetadata = GpxExtensible & {
65
+ readonly name: string | null;
66
+ readonly description: string | null;
67
+ readonly author: GpxPerson | null;
68
+ readonly copyright: GpxCopyright | null;
69
+ readonly links: readonly GpxLink[];
70
+ readonly time: Temporal.Instant | null;
71
+ readonly keywords: string | null;
72
+ readonly bounds: GpxBounds | null;
73
+ };
74
+ /**
75
+ * A waypoint, route point or track point (`wptType`), angles in degrees and
76
+ * lengths in metres, WGS 84.
77
+ */
78
+ export type GpxPoint = GpxExtensible & {
79
+ /** −90 to 90. */
80
+ readonly latitude: number;
81
+ /** −180 (included) to 180 (excluded). */
82
+ readonly longitude: number;
83
+ readonly elevation: number | null;
84
+ /** Read as UTC when written with no timezone, as GPX requires. */
85
+ readonly time: Temporal.Instant | null;
86
+ /** Magnetic variation, 0 (included) to 360 (excluded). */
87
+ readonly magneticVariation: number | null;
88
+ /** Height of the geoid above the WGS 84 ellipsoid. */
89
+ readonly geoidHeight: number | null;
90
+ readonly name: string | null;
91
+ readonly comment: string | null;
92
+ readonly description: string | null;
93
+ /** Where the data came from (`src`). */
94
+ readonly source: string | null;
95
+ readonly links: readonly GpxLink[];
96
+ /** The symbol's name, as written (`sym`). */
97
+ readonly symbol: string | null;
98
+ /** A classification, as written. */
99
+ readonly type: string | null;
100
+ readonly fix: GpxFix | null;
101
+ /** Satellites used (`sat`). */
102
+ readonly satellites: number | null;
103
+ /** Horizontal dilution of precision. */
104
+ readonly hdop: number | null;
105
+ /** Vertical dilution of precision. */
106
+ readonly vdop: number | null;
107
+ /** Position dilution of precision. */
108
+ readonly pdop: number | null;
109
+ /** Seconds since the last DGPS update. */
110
+ readonly ageOfDgpsData: number | null;
111
+ /** DGPS station, 0 to 1023. */
112
+ readonly dgpsId: number | null;
113
+ /**
114
+ * Course over ground in degrees, 0 (included) to 360 (excluded); GPX 1.0's
115
+ * track points only.
116
+ */
117
+ readonly course: number | null;
118
+ /** Speed in metres per second; GPX 1.0's track points only. */
119
+ readonly speed: number | null;
120
+ };
121
+ /** What routes and tracks describe themselves with. */
122
+ export type GpxPathDescription = GpxExtensible & {
123
+ readonly name: string | null;
124
+ readonly comment: string | null;
125
+ readonly description: string | null;
126
+ readonly source: string | null;
127
+ readonly links: readonly GpxLink[];
128
+ /** A number for the route or track, a non-negative integer. */
129
+ readonly number: number | null;
130
+ readonly type: string | null;
131
+ };
132
+ /** An ordered list of points leading to a destination (`rteType`). */
133
+ export type GpxRoute = GpxPathDescription & {
134
+ readonly points: readonly GpxPoint[];
135
+ };
136
+ /** Points that are logically connected in order (`trksegType`). */
137
+ export type GpxTrackSegment = GpxExtensible & {
138
+ readonly points: readonly GpxPoint[];
139
+ };
140
+ /** An ordered list of track segments (`trkType`). */
141
+ export type GpxTrack = GpxPathDescription & {
142
+ readonly segments: readonly GpxTrackSegment[];
143
+ };
144
+ /** Where the schema of a namespace is, as `xsi:schemaLocation` pairs them. */
145
+ export type GpxSchemaLocation = {
146
+ readonly namespace: string;
147
+ readonly location: string;
148
+ };
149
+ /**
150
+ * A GPX document: one shape for both versions, GPX 1.0's fields mapped onto GPX
151
+ * 1.1's (`url`/`urlname` to a link, `author`/`email` to the metadata's author)
152
+ * and its `course` and `speed` kept on the points.
153
+ */
154
+ export type GpxDocument = GpxExtensible & {
155
+ /** The schema the document was read as. */
156
+ readonly version: GpxVersion;
157
+ /** The program that wrote it. */
158
+ readonly creator: string;
159
+ /**
160
+ * The schemas of its extensions, from `xsi:schemaLocation`, in order; GPX's
161
+ * own is implied by `version` and left out.
162
+ */
163
+ readonly schemaLocations: readonly GpxSchemaLocation[];
164
+ readonly metadata: GpxMetadata;
165
+ readonly waypoints: readonly GpxPoint[];
166
+ readonly routes: readonly GpxRoute[];
167
+ readonly tracks: readonly GpxTrack[];
168
+ };
169
+ //# sourceMappingURL=gpx-document.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpx-document.d.ts","sourceRoot":"","sources":["../../src/model/gpx-document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEnE,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,QAAQ,CAAC,UAAU,EAAE,SA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AE,SAAS,QAAQ,EAAE,CAAC;CACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=gpx-document.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpx-document.js","sourceRoot":"","sources":["../../src/model/gpx-document.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ import type { Span, WorkBudget } from "@ac-kit/core";
2
+ import { type XmlElement, type XmlNamespaces, type XmlSequence } from "@ac-kit/format-xml";
3
+ import type { GpxDocument, GpxMetadata, GpxPoint, GpxRoute, GpxTrack, GpxVersion } from "../model/gpx-document.js";
4
+ import type { DiagnosticSink_ } from "./_sink.js";
5
+ /** What every reader of one document shares. */
6
+ export type ReadContext_ = {
7
+ readonly sink: DiagnosticSink_;
8
+ readonly namespaces: XmlNamespaces;
9
+ /** The namespace GPX elements are matched in: the root's. */
10
+ readonly gpxNamespace: string | null;
11
+ readonly version: GpxVersion;
12
+ readonly budget: WorkBudget | undefined;
13
+ readonly maxPoints: number;
14
+ points: number;
15
+ /**
16
+ * Set when reading the rest of a streamed document: the children of `gpx`,
17
+ * `rte` and `trkseg` were checked as they streamed by, their points are not
18
+ * there, and the children refused then are at these source offsets.
19
+ */
20
+ readonly rejected: ReadonlySet<number> | null;
21
+ };
22
+ export declare const NONE_: readonly never[];
23
+ type Sequence_ = XmlSequence;
24
+ export declare const GPX_11_SEQUENCE_: XmlSequence;
25
+ export declare const GPX_10_SEQUENCE_: XmlSequence;
26
+ export declare const ROUTE_11_SEQUENCE_: XmlSequence;
27
+ export declare const ROUTE_10_SEQUENCE_: XmlSequence;
28
+ export declare const SEGMENT_11_SEQUENCE_: XmlSequence;
29
+ export declare const SEGMENT_10_SEQUENCE_: XmlSequence;
30
+ /**
31
+ * Checks children against a sequence as they come, one at a time, reporting in
32
+ * GPX's terms.
33
+ */
34
+ export declare class SequenceChecker_ {
35
+ private readonly context;
36
+ private readonly parent;
37
+ private readonly checker;
38
+ constructor(context: ReadContext_ | {
39
+ readonly sink: DiagnosticSink_;
40
+ }, sequence: Sequence_, parent: string);
41
+ /**
42
+ * Whether the child named `local` is to be read: `false` for an unknown or a
43
+ * repeated one, reported (strict mode throws), whose element the caller keeps
44
+ * in `otherElements`. An out-of-order child is reported and read.
45
+ */
46
+ accept(local: string, span: Span | null): boolean;
47
+ }
48
+ export declare function isGpxElement_(context: ReadContext_, element: XmlElement): boolean;
49
+ type NumberRange_ = {
50
+ readonly min?: number;
51
+ readonly max?: number;
52
+ /** Whether `max` itself is out of range. */
53
+ readonly maxExclusive?: boolean;
54
+ readonly integer?: boolean;
55
+ };
56
+ export declare function number_(context: {
57
+ readonly sink: DiagnosticSink_;
58
+ }, text: string, what: string, span: Span | null, range?: NumberRange_): number | undefined;
59
+ export declare function time_(context: {
60
+ readonly sink: DiagnosticSink_;
61
+ }, text: string, span: Span | null): Temporal.Instant | undefined;
62
+ export declare function countPoint_(context: ReadContext_): void;
63
+ /**
64
+ * A point (`wpt`, `rtept` or `trkpt`); `null` for one without a readable
65
+ * position in lenient mode.
66
+ */
67
+ export declare function readPoint_(context: ReadContext_, element: XmlElement, kind: "wpt" | "rtept" | "trkpt", fallback: Span | null): GpxPoint | null;
68
+ type Mutable_<T> = {
69
+ -readonly [K in keyof T]: T[K];
70
+ };
71
+ export declare function emptyMetadata_(): Mutable_<GpxMetadata>;
72
+ export declare function readRoute_(context: ReadContext_, element: XmlElement, fallback: Span | null): GpxRoute;
73
+ export declare function readTrack_(context: ReadContext_, element: XmlElement, fallback: Span | null): GpxTrack;
74
+ /** The whole document from its root, once its version is known. */
75
+ export declare function readGpx_(context: ReadContext_, root: XmlElement): GpxDocument;
76
+ export {};
77
+ //# sourceMappingURL=_reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_reader.d.ts","sourceRoot":"","sources":["../../src/parse/_reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAA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