ol 9.0.0-dev.1706534431133 → 9.0.0-dev.1706775218936

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/format/GPX.d.ts CHANGED
@@ -1,4 +1,76 @@
1
1
  export default GPX;
2
+ export type GPXLink = {
3
+ /**
4
+ * text
5
+ */
6
+ text?: string | undefined;
7
+ /**
8
+ * type
9
+ */
10
+ type?: string | undefined;
11
+ };
12
+ export type GPXAuthor = {
13
+ /**
14
+ * name
15
+ */
16
+ name?: string | undefined;
17
+ /**
18
+ * email
19
+ */
20
+ email?: string | undefined;
21
+ /**
22
+ * link
23
+ */
24
+ link?: GPXLink | undefined;
25
+ };
26
+ export type GPXMetadata = {
27
+ /**
28
+ * name
29
+ */
30
+ name?: string | undefined;
31
+ /**
32
+ * desc
33
+ */
34
+ desc?: string | undefined;
35
+ /**
36
+ * author
37
+ */
38
+ author?: GPXAuthor | undefined;
39
+ /**
40
+ * link
41
+ */
42
+ link?: GPXLink | undefined;
43
+ /**
44
+ * time
45
+ */
46
+ time?: number | undefined;
47
+ /**
48
+ * keywords
49
+ */
50
+ keywords?: string | undefined;
51
+ /**
52
+ * bounds
53
+ */
54
+ bounds?: number[] | undefined;
55
+ /**
56
+ * extensions
57
+ */
58
+ extensions?: any;
59
+ };
60
+ export type GPXCopyright = {
61
+ /**
62
+ * author
63
+ */
64
+ author?: string | undefined;
65
+ /**
66
+ * year
67
+ */
68
+ year?: number | undefined;
69
+ /**
70
+ * license
71
+ */
72
+ license?: string | undefined;
73
+ };
2
74
  export type Options = {
3
75
  /**
4
76
  * Callback function
@@ -65,6 +137,29 @@ declare class GPX extends XMLFeature {
65
137
  * @private
66
138
  */
67
139
  private handleReadExtensions_;
140
+ /**
141
+ * Reads a GPX file's metadata tag, reading among other things:
142
+ * - the name and description of this GPX
143
+ * - its author
144
+ * - the copyright associated with this GPX file
145
+ *
146
+ * Will return null if no metadata tag is present (or no valid source is given).
147
+ *
148
+ * @param {Document|Element|Object|string} source Source.
149
+ * @return {GPXMetadata | null} Metadata
150
+ * @api
151
+ */
152
+ readMetadata(source: Document | Element | any | string): GPXMetadata | null;
153
+ /**
154
+ * @param {Document} doc Document.
155
+ * @return {GPXMetadata | null} Metadata
156
+ */
157
+ readMetadataFromDocument(doc: Document): GPXMetadata | null;
158
+ /**
159
+ * @param {Element} node Node.
160
+ * @return {Object} Metadata
161
+ */
162
+ readMetadataFromNode(node: Element): any;
68
163
  }
69
164
  import Feature from '../Feature.js';
70
165
  import XMLFeature from './XMLFeature.js';
@@ -1 +1 @@
1
- {"version":3,"file":"GPX.d.ts","sourceRoot":"","sources":["GPX.js"],"names":[],"mappings":";;;;;;;;;;6BAkGuB,OAAO,QAAE,IAAI,KAAE,IAAI;;;;;;;;;;;;AAF1C;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IACE;;OAEG;IACH,2CAeC;IALC;;;OAGG;IACH,wBAA6C;IAG/C;;;OAGG;IACH,8BAYC;CAgFF;oBAlPmB,eAAe;uBAIZ,iBAAiB"}
1
+ {"version":3,"file":"GPX.d.ts","sourceRoot":"","sources":["GPX.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BA2KuB,OAAO,QAAE,IAAI,KAAE,IAAI;;;;;;;;;;;;AAF1C;;;;;;;;GAQG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;GAeG;AACH;IACE;;OAEG;IACH,2CAeC;IALC;;;OAGG;IACH,wBAA6C;IAG/C;;;OAGG;IACH,8BAYC;IAED;;;;;;;;;;;OAWG;IACH,qBAJW,QAAQ,GAAC,OAAO,SAAQ,MAAM,GAC7B,WAAW,GAAG,IAAI,CAc7B;IAED;;;OAGG;IACH,8BAHW,QAAQ,GACP,WAAW,GAAG,IAAI,CAY7B;IAED;;;OAGG;IACH,2BAHW,OAAO,OAgBjB;CAgFF;oBAvXmB,eAAe;uBAIZ,iBAAiB"}
package/format/GPX.js CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  OBJECT_PROPERTY_NODE_FACTORY,
11
11
  XML_SCHEMA_INSTANCE_URI,
12
12
  createElementNS,
13
+ isDocument,
13
14
  makeArrayPusher,
14
15
  makeArraySerializer,
15
16
  makeChildAppender,
@@ -17,6 +18,7 @@ import {
17
18
  makeSequence,
18
19
  makeSimpleNodeFactory,
19
20
  makeStructureNS,
21
+ parse,
20
22
  parseNode,
21
23
  pushParseAndPop,
22
24
  pushSerializeAndPop,
@@ -73,6 +75,12 @@ const GPX_PARSERS = makeStructureNS(NAMESPACE_URIS, {
73
75
  'wpt': makeArrayPusher(readWpt),
74
76
  });
75
77
 
78
+ /**
79
+ * @typedef {Object} GPXLink
80
+ * @property {string} [text] text
81
+ * @property {string} [type] type
82
+ */
83
+
76
84
  /**
77
85
  * @const
78
86
  * @type {Object<string, Object<string, import("../xml.js").Parser>>}
@@ -83,6 +91,71 @@ const LINK_PARSERS = makeStructureNS(NAMESPACE_URIS, {
83
91
  'type': makeObjectPropertySetter(readString, 'linkType'),
84
92
  });
85
93
 
94
+ /**
95
+ * @typedef {Object} GPXAuthor
96
+ * @property {string} [name] name
97
+ * @property {string} [email] email
98
+ * @property {GPXLink} [link] link
99
+ */
100
+
101
+ /**
102
+ * @const
103
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
104
+ */
105
+ // @ts-ignore
106
+ const AUTHOR_PARSERS = makeStructureNS(NAMESPACE_URIS, {
107
+ 'name': makeObjectPropertySetter(readString),
108
+ 'email': parseEmail,
109
+ 'link': parseLink,
110
+ });
111
+
112
+ /**
113
+ * @typedef {Object} GPXMetadata
114
+ * @property {string} [name] name
115
+ * @property {string} [desc] desc
116
+ * @property {GPXAuthor} [author] author
117
+ * @property {GPXLink} [link] link
118
+ * @property {number} [time] time
119
+ * @property {string} [keywords] keywords
120
+ * @property {Array<number>} [bounds] bounds
121
+ * @property {Object} [extensions] extensions
122
+ *
123
+ */
124
+
125
+ /**
126
+ * @const
127
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
128
+ */
129
+ // @ts-ignore
130
+ const METADATA_PARSERS = makeStructureNS(NAMESPACE_URIS, {
131
+ 'name': makeObjectPropertySetter(readString),
132
+ 'desc': makeObjectPropertySetter(readString),
133
+ 'author': makeObjectPropertySetter(readAuthor),
134
+ 'copyright': makeObjectPropertySetter(readCopyright),
135
+ 'link': parseLink,
136
+ 'time': makeObjectPropertySetter(readDateTime),
137
+ 'keywords': makeObjectPropertySetter(readString),
138
+ 'bounds': parseBounds,
139
+ 'extensions': parseExtensions,
140
+ });
141
+
142
+ /**
143
+ * @typedef {Object} GPXCopyright
144
+ * @property {string} [author] author
145
+ * @property {number} [year] year
146
+ * @property {string} [license] license
147
+ */
148
+
149
+ /**
150
+ * @const
151
+ * @type {Object<string, Object<string, import("../xml.js").Parser>>}
152
+ */
153
+ // @ts-ignore
154
+ const COPYRIGHT_PARSERS = makeStructureNS(NAMESPACE_URIS, {
155
+ 'year': makeObjectPropertySetter(readPositiveInteger),
156
+ 'license': makeObjectPropertySetter(readString),
157
+ });
158
+
86
159
  /**
87
160
  * @const
88
161
  * @type {Object<string, Object<string, import("../xml.js").Serializer>>}
@@ -165,6 +238,66 @@ class GPX extends XMLFeature {
165
238
  }
166
239
  }
167
240
 
241
+ /**
242
+ * Reads a GPX file's metadata tag, reading among other things:
243
+ * - the name and description of this GPX
244
+ * - its author
245
+ * - the copyright associated with this GPX file
246
+ *
247
+ * Will return null if no metadata tag is present (or no valid source is given).
248
+ *
249
+ * @param {Document|Element|Object|string} source Source.
250
+ * @return {GPXMetadata | null} Metadata
251
+ * @api
252
+ */
253
+ readMetadata(source) {
254
+ if (!source) {
255
+ return null;
256
+ }
257
+ if (typeof source === 'string') {
258
+ return this.readMetadataFromDocument(parse(source));
259
+ }
260
+ if (isDocument(source)) {
261
+ return this.readMetadataFromDocument(/** @type {Document} */ (source));
262
+ }
263
+ return this.readMetadataFromNode(source);
264
+ }
265
+
266
+ /**
267
+ * @param {Document} doc Document.
268
+ * @return {GPXMetadata | null} Metadata
269
+ */
270
+ readMetadataFromDocument(doc) {
271
+ for (let n = /** @type {Node} */ (doc.firstChild); n; n = n.nextSibling) {
272
+ if (n.nodeType === Node.ELEMENT_NODE) {
273
+ const metadata = this.readMetadataFromNode(/** @type {Element} */ (n));
274
+ if (metadata) {
275
+ return metadata;
276
+ }
277
+ }
278
+ }
279
+ return null;
280
+ }
281
+
282
+ /**
283
+ * @param {Element} node Node.
284
+ * @return {Object} Metadata
285
+ */
286
+ readMetadataFromNode(node) {
287
+ if (!NAMESPACE_URIS.includes(node.namespaceURI)) {
288
+ return null;
289
+ }
290
+ for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
291
+ if (
292
+ NAMESPACE_URIS.includes(n.namespaceURI) &&
293
+ n.localName === 'metadata'
294
+ ) {
295
+ return pushParseAndPop({}, METADATA_PARSERS, n, []);
296
+ }
297
+ }
298
+ return null;
299
+ }
300
+
168
301
  /**
169
302
  * @param {Element} node Node.
170
303
  * @param {import("./Feature.js").ReadOptions} [options] Options.
@@ -589,6 +722,72 @@ function applyLayoutOptions(layoutOptions, flatCoordinates, ends) {
589
722
  return layout;
590
723
  }
591
724
 
725
+ /**
726
+ * @param {Element} node Node.
727
+ * @param {Array<any>} objectStack Object stack.
728
+ * @return {GPXAuthor | undefined} Person object.
729
+ */
730
+ function readAuthor(node, objectStack) {
731
+ const values = pushParseAndPop({}, AUTHOR_PARSERS, node, objectStack);
732
+ if (values) {
733
+ return values;
734
+ }
735
+ return undefined;
736
+ }
737
+
738
+ /**
739
+ * @param {Element} node Node.
740
+ * @param {Array<any>} objectStack Object stack.
741
+ * @return {GPXCopyright | undefined} Person object.
742
+ */
743
+ function readCopyright(node, objectStack) {
744
+ const values = pushParseAndPop({}, COPYRIGHT_PARSERS, node, objectStack);
745
+ if (values) {
746
+ const author = node.getAttribute('author');
747
+ if (author !== null) {
748
+ values['author'] = author;
749
+ }
750
+ return values;
751
+ }
752
+ return undefined;
753
+ }
754
+
755
+ /**
756
+ * @param {Element} node Node.
757
+ * @param {Array<*>} objectStack Object stack.
758
+ */
759
+ function parseBounds(node, objectStack) {
760
+ const values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
761
+ const minlat = node.getAttribute('minlat');
762
+ const minlon = node.getAttribute('minlon');
763
+ const maxlat = node.getAttribute('maxlat');
764
+ const maxlon = node.getAttribute('maxlon');
765
+ if (
766
+ minlon !== null &&
767
+ minlat !== null &&
768
+ maxlon !== null &&
769
+ maxlat !== null
770
+ ) {
771
+ values['bounds'] = [
772
+ [parseFloat(minlon), parseFloat(minlat)],
773
+ [parseFloat(maxlon), parseFloat(maxlat)],
774
+ ];
775
+ }
776
+ }
777
+
778
+ /**
779
+ * @param {Element} node Node.
780
+ * @param {Array<*>} objectStack Object stack.
781
+ */
782
+ function parseEmail(node, objectStack) {
783
+ const values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
784
+ const id = node.getAttribute('id');
785
+ const domain = node.getAttribute('domain');
786
+ if (id !== null && domain !== null) {
787
+ values['email'] = `${id}@${domain}`;
788
+ }
789
+ }
790
+
592
791
  /**
593
792
  * @param {Element} node Node.
594
793
  * @param {Array<*>} objectStack Object stack.
@@ -195,11 +195,11 @@ declare class Geometry extends BaseObject {
195
195
  * string identifier or a {@link module:ol/proj/Projection~Projection} object.
196
196
  * @param {import("../proj.js").ProjectionLike} destination The desired projection. Can be a
197
197
  * string identifier or a {@link module:ol/proj/Projection~Projection} object.
198
- * @return {Geometry} This geometry. Note that original geometry is
198
+ * @return {this} This geometry. Note that original geometry is
199
199
  * modified in place.
200
200
  * @api
201
201
  */
202
- transform(source: import("../proj.js").ProjectionLike, destination: import("../proj.js").ProjectionLike): Geometry;
202
+ transform(source: import("../proj.js").ProjectionLike, destination: import("../proj.js").ProjectionLike): this;
203
203
  }
204
204
  import BaseObject from '../Object.js';
205
205
  //# sourceMappingURL=Geometry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Geometry.d.ts","sourceRoot":"","sources":["Geometry.js"],"names":[],"mappings":";;;;;6BAoBa,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM;;;;;;mBAM7B,OAAO,GAAG,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,iBAAiB,GAAG,cAAc,GAAG,oBAAoB,GAAG,QAAQ;AAWpJ;;;;;;;;;;;GAWG;AACH;IACE,cA6CC;IA1CC;;;OAGG;IACH,gBAA4B;IAE5B;;;OAGG;IACH,wBAAyB;IAEzB;;;OAGG;IACH,oDAFU,MAAM,CAEiC;IAEjD;;;OAGG;IACH,sCAFU,MAAM,CAEmB;IAEnC;;;;;;;OAOG;IACH,0DASC;IAGH;;;;;;OAMG;IACH,sCAJW,MAAM,mEAEL,QAAQ,CAQnB;IAED;;;;OAIG;IACH,SAFa,QAAQ,CAIpB;IAED;;;;;;;OAOG;IACH,kBANW,MAAM,KACN,MAAM,gBACN,OAAO,kBAAkB,EAAE,UAAU,sBACrC,MAAM,GACL,MAAM,CAIjB;IAED;;;;OAIG;IACH,cAJW,MAAM,KACN,MAAM,GACL,OAAO,CAKlB;IAED;;;;;;;OAOG;IACH,uBALW,OAAO,kBAAkB,EAAE,UAAU,qEAEpC,OAAO,kBAAkB,EAAE,UAAU,CAOhD;IAED;;;;;;OAMG;IACH,iCAJW,OAAO,kBAAkB,EAAE,UAAU,GACpC,OAAO,CAKlB;IAED;;;;;OAKG;IACH,gCAJW,OAAO,cAAc,EAAE,MAAM,GAE5B,OAAO,cAAc,EAAE,MAAM,CAIxC;IAED;;;;;OAKG;IACH,+DAHY,OAAO,cAAc,EAAE,MAAM,CAYxC;IAED;;;;;;;OAOG;IACH,cAJW,MAAM,UACN,OAAO,kBAAkB,EAAE,UAAU,QAK/C;IAED;;;;;;;;;OASG;IACH,UANW,MAAM,6FAQhB;IAED;;;;;;;;OAQG;I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UAAU,qEAEpC,OAAO,kBAAkB,EAAE,UAAU,CAOhD;IAED;;;;;;OAMG;IACH,iCAJW,OAAO,kBAAkB,EAAE,UAAU,GACpC,OAAO,CAKlB;IAED;;;;;OAKG;IACH,gCAJW,OAAO,cAAc,EAAE,MAAM,GAE5B,OAAO,cAAc,EAAE,MAAM,CAIxC;IAED;;;;;OAKG;IACH,+DAHY,OAAO,cAAc,EAAE,MAAM,CAYxC;IAED;;;;;;;OAOG;IACH,cAJW,MAAM,UACN,OAAO,kBAAkB,EAAE,UAAU,QAK/C;IAED;;;;;;;;;OASG;IACH,UANW,MAAM,6FAQhB;IAED;;;;;;;;OAQG;IACH,oBAJW,MAAM,GACL,QAAQ,CAKnB;IAED;;;;;;;OAOG;IACH,wCAHW,MAAM,GACL,QAAQ,CAInB;IAED;;;;OAIG;IACH,WAFY,IAAI,CAIf;IAED;;;;;;;;OAQG;IACH,4BAHW,OAAO,YAAY,EAAE,iBAAiB,QAKhD;IAED;;;;;OAKG;IACH,yBAHW,OAAO,cAAc,EAAE,MAAM,GAC5B,OAAO,CAIlB;IAED;;;;;;;OAOG;IACH,kBAJW,MAAM,UACN,MAAM,QAKhB;IAED;;;;;;;;;;;;;;OAcG;IACH,kBARW,OAAO,YAAY,EAAE,cAAc,eAEnC,OAAO,YAAY,EAAE,cAAc,GAElC,IAAI,CAwCf;CACF;uBAnVsB,cAAc"}
package/geom/Geometry.js CHANGED
@@ -299,7 +299,7 @@ class Geometry extends BaseObject {
299
299
  * string identifier or a {@link module:ol/proj/Projection~Projection} object.
300
300
  * @param {import("../proj.js").ProjectionLike} destination The desired projection. Can be a
301
301
  * string identifier or a {@link module:ol/proj/Projection~Projection} object.
302
- * @return {Geometry} This geometry. Note that original geometry is
302
+ * @return {this} This geometry. Note that original geometry is
303
303
  * modified in place.
304
304
  * @api
305
305
  */
@@ -1586,9 +1586,9 @@ function projectedDistanceToSegmentDataSquared(
1586
1586
  if (segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
1587
1587
  const userProjection = getUserProjection();
1588
1588
  if (userProjection) {
1589
- circleGeometry = /** @type {import("../geom/Circle.js").default} */ (
1590
- circleGeometry.clone().transform(userProjection, projection)
1591
- );
1589
+ circleGeometry = circleGeometry
1590
+ .clone()
1591
+ .transform(userProjection, projection);
1592
1592
  }
1593
1593
  const distanceToCenterSquared = squaredCoordinateDistance(
1594
1594
  circleGeometry.getCenter(),
@@ -1628,9 +1628,9 @@ function closestOnSegmentData(pointCoordinates, segmentData, projection) {
1628
1628
  );
1629
1629
  const userProjection = getUserProjection();
1630
1630
  if (userProjection) {
1631
- circleGeometry = /** @type {import("../geom/Circle.js").default} */ (
1632
- circleGeometry.clone().transform(userProjection, projection)
1633
- );
1631
+ circleGeometry = circleGeometry
1632
+ .clone()
1633
+ .transform(userProjection, projection);
1634
1634
  }
1635
1635
  return toUserCoordinate(
1636
1636
  circleGeometry.getClosestPoint(
@@ -586,9 +586,9 @@ class Snap extends PointerInteraction {
586
586
  let circleGeometry = geometry;
587
587
  const userProjection = getUserProjection();
588
588
  if (userProjection) {
589
- circleGeometry = /** @type {import("../geom/Circle.js").default} */ (
590
- circleGeometry.clone().transform(userProjection, projection)
591
- );
589
+ circleGeometry = circleGeometry
590
+ .clone()
591
+ .transform(userProjection, projection);
592
592
  }
593
593
  const polygon = fromCircle(circleGeometry);
594
594
  if (userProjection) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ol",
3
- "version": "9.0.0-dev.1706534431133",
3
+ "version": "9.0.0-dev.1706775218936",
4
4
  "description": "OpenLayers mapping library",
5
5
  "keywords": [
6
6
  "map",
package/util.js CHANGED
@@ -33,4 +33,4 @@ export function getUid(obj) {
33
33
  * OpenLayers version.
34
34
  * @type {string}
35
35
  */
36
- export const VERSION = '9.0.0-dev.1706534431133';
36
+ export const VERSION = '9.0.0-dev.1706775218936';