ol 7.0.0-dev.1658257118421 → 7.0.0-dev.1658343947608

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 (163) hide show
  1. package/control/ScaleLine.d.ts +9 -17
  2. package/control/ScaleLine.d.ts.map +1 -1
  3. package/control/ScaleLine.js +12 -20
  4. package/control/ScaleLine.js.map +1 -1
  5. package/format/EsriJSON.d.ts.map +1 -1
  6. package/format/EsriJSON.js +16 -16
  7. package/format/EsriJSON.js.map +1 -1
  8. package/format/GML3.d.ts.map +1 -1
  9. package/format/GML3.js +2 -3
  10. package/format/GML3.js.map +1 -1
  11. package/format/GMLBase.d.ts.map +1 -1
  12. package/format/GMLBase.js +4 -5
  13. package/format/GMLBase.js.map +1 -1
  14. package/format/GPX.d.ts.map +1 -1
  15. package/format/GPX.js +9 -9
  16. package/format/GPX.js.map +1 -1
  17. package/format/IGC.d.ts +6 -2
  18. package/format/IGC.d.ts.map +1 -1
  19. package/format/IGC.js +7 -15
  20. package/format/IGC.js.map +1 -1
  21. package/format/KML.d.ts +3 -3
  22. package/format/KML.d.ts.map +1 -1
  23. package/format/KML.js +29 -30
  24. package/format/KML.js.map +1 -1
  25. package/format/MVT.d.ts.map +1 -1
  26. package/format/MVT.js +6 -7
  27. package/format/MVT.js.map +1 -1
  28. package/format/OSMXML.d.ts.map +1 -1
  29. package/format/OSMXML.js +2 -3
  30. package/format/OSMXML.js.map +1 -1
  31. package/format/Polyline.d.ts +3 -8
  32. package/format/Polyline.d.ts.map +1 -1
  33. package/format/Polyline.js +3 -4
  34. package/format/Polyline.js.map +1 -1
  35. package/format/WKB.d.ts +3 -3
  36. package/format/WKB.d.ts.map +1 -1
  37. package/format/WKB.js +48 -21
  38. package/format/WKB.js.map +1 -1
  39. package/format/WKT.d.ts.map +1 -1
  40. package/format/WKT.js +12 -12
  41. package/format/WKT.js.map +1 -1
  42. package/geom/Circle.d.ts +4 -4
  43. package/geom/Circle.d.ts.map +1 -1
  44. package/geom/Circle.js +2 -2
  45. package/geom/Geometry.d.ts +5 -0
  46. package/geom/Geometry.d.ts.map +1 -1
  47. package/geom/Geometry.js +5 -0
  48. package/geom/Geometry.js.map +1 -1
  49. package/geom/LineString.d.ts +4 -4
  50. package/geom/LineString.d.ts.map +1 -1
  51. package/geom/LineString.js +4 -6
  52. package/geom/LineString.js.map +1 -1
  53. package/geom/LinearRing.d.ts +4 -4
  54. package/geom/LinearRing.d.ts.map +1 -1
  55. package/geom/LinearRing.js +3 -4
  56. package/geom/LinearRing.js.map +1 -1
  57. package/geom/MultiLineString.d.ts +4 -9
  58. package/geom/MultiLineString.d.ts.map +1 -1
  59. package/geom/MultiLineString.js +4 -6
  60. package/geom/MultiLineString.js.map +1 -1
  61. package/geom/MultiPoint.d.ts +4 -4
  62. package/geom/MultiPoint.d.ts.map +1 -1
  63. package/geom/MultiPoint.js +2 -2
  64. package/geom/MultiPolygon.d.ts +4 -4
  65. package/geom/MultiPolygon.d.ts.map +1 -1
  66. package/geom/MultiPolygon.js +4 -5
  67. package/geom/MultiPolygon.js.map +1 -1
  68. package/geom/Point.d.ts +2 -2
  69. package/geom/Point.d.ts.map +1 -1
  70. package/geom/Point.js +2 -2
  71. package/geom/Polygon.d.ts +4 -4
  72. package/geom/Polygon.d.ts.map +1 -1
  73. package/geom/Polygon.js +6 -11
  74. package/geom/Polygon.js.map +1 -1
  75. package/geom/SimpleGeometry.d.ts +13 -13
  76. package/geom/SimpleGeometry.d.ts.map +1 -1
  77. package/geom/SimpleGeometry.js +17 -18
  78. package/geom/SimpleGeometry.js.map +1 -1
  79. package/interaction/Draw.d.ts +7 -7
  80. package/interaction/Draw.d.ts.map +1 -1
  81. package/interaction/Draw.js +34 -42
  82. package/interaction/Draw.js.map +1 -1
  83. package/layer/Graticule.d.ts.map +1 -1
  84. package/layer/Graticule.js +4 -5
  85. package/layer/Graticule.js.map +1 -1
  86. package/package.json +1 -1
  87. package/render/Feature.d.ts.map +1 -1
  88. package/render/Feature.js +5 -6
  89. package/render/Feature.js.map +1 -1
  90. package/render/canvas/TextBuilder.d.ts.map +1 -1
  91. package/render/canvas/TextBuilder.js +1 -2
  92. package/render/canvas/TextBuilder.js.map +1 -1
  93. package/render/canvas/hitdetect.d.ts.map +1 -1
  94. package/render/canvas/hitdetect.js +2 -3
  95. package/render/canvas/hitdetect.js.map +1 -1
  96. package/render/canvas.d.ts +2 -11
  97. package/render/canvas.d.ts.map +1 -1
  98. package/render/canvas.js +1 -14
  99. package/render/canvas.js.map +1 -1
  100. package/source/Zoomify.d.ts +6 -2
  101. package/source/Zoomify.d.ts.map +1 -1
  102. package/source/Zoomify.js +5 -9
  103. package/source/Zoomify.js.map +1 -1
  104. package/src/control/ScaleLine.js +12 -20
  105. package/src/format/EsriJSON.js +16 -19
  106. package/src/format/GML3.js +2 -3
  107. package/src/format/GMLBase.js +4 -5
  108. package/src/format/GPX.js +9 -9
  109. package/src/format/IGC.js +7 -16
  110. package/src/format/KML.js +29 -30
  111. package/src/format/MVT.js +6 -7
  112. package/src/format/OSMXML.js +2 -3
  113. package/src/format/Polyline.js +3 -4
  114. package/src/format/WKB.js +55 -21
  115. package/src/format/WKT.js +12 -12
  116. package/src/geom/Circle.js +2 -2
  117. package/src/geom/Geometry.js +6 -0
  118. package/src/geom/LineString.js +4 -8
  119. package/src/geom/LinearRing.js +3 -4
  120. package/src/geom/MultiLineString.js +4 -10
  121. package/src/geom/MultiPoint.js +2 -2
  122. package/src/geom/MultiPolygon.js +4 -12
  123. package/src/geom/Point.js +2 -2
  124. package/src/geom/Polygon.js +6 -15
  125. package/src/geom/SimpleGeometry.js +17 -18
  126. package/src/interaction/Draw.js +34 -42
  127. package/src/layer/Graticule.js +4 -5
  128. package/src/render/Feature.js +5 -12
  129. package/src/render/canvas/TextBuilder.js +1 -2
  130. package/src/render/canvas/hitdetect.js +2 -3
  131. package/src/render/canvas.js +1 -15
  132. package/src/source/Zoomify.js +5 -9
  133. package/src/style/Icon.js +36 -36
  134. package/src/style/Text.js +13 -6
  135. package/style/Icon.d.ts +28 -12
  136. package/style/Icon.d.ts.map +1 -1
  137. package/style/Icon.js +34 -36
  138. package/style/Icon.js.map +1 -1
  139. package/style/Text.d.ts +14 -7
  140. package/style/Text.d.ts.map +1 -1
  141. package/style/Text.js +12 -6
  142. package/style/Text.js.map +1 -1
  143. package/util.js +1 -1
  144. package/geom/GeometryLayout.d.ts +0 -8
  145. package/geom/GeometryLayout.d.ts.map +0 -1
  146. package/geom/GeometryLayout.js +0 -16
  147. package/geom/GeometryLayout.js.map +0 -1
  148. package/src/geom/GeometryLayout.js +0 -16
  149. package/src/style/IconAnchorUnits.js +0 -20
  150. package/src/style/IconOrigin.js +0 -30
  151. package/src/style/TextPlacement.js +0 -15
  152. package/style/IconAnchorUnits.d.ts +0 -6
  153. package/style/IconAnchorUnits.d.ts.map +0 -1
  154. package/style/IconAnchorUnits.js +0 -20
  155. package/style/IconAnchorUnits.js.map +0 -1
  156. package/style/IconOrigin.d.ts +0 -8
  157. package/style/IconOrigin.d.ts.map +0 -1
  158. package/style/IconOrigin.js +0 -30
  159. package/style/IconOrigin.js.map +0 -1
  160. package/style/TextPlacement.d.ts +0 -6
  161. package/style/TextPlacement.d.ts.map +0 -1
  162. package/style/TextPlacement.js +0 -15
  163. package/style/TextPlacement.js.map +0 -1
package/src/format/KML.js CHANGED
@@ -4,10 +4,7 @@
4
4
  import Feature from '../Feature.js';
5
5
  import Fill from '../style/Fill.js';
6
6
  import GeometryCollection from '../geom/GeometryCollection.js';
7
- import GeometryLayout from '../geom/GeometryLayout.js';
8
7
  import Icon from '../style/Icon.js';
9
- import IconAnchorUnits from '../style/IconAnchorUnits.js';
10
- import IconOrigin from '../style/IconOrigin.js';
11
8
  import ImageState from '../ImageState.js';
12
9
  import LineString from '../geom/LineString.js';
13
10
  import MultiLineString from '../geom/MultiLineString.js';
@@ -57,10 +54,10 @@ import {transformGeometryWithOptions} from './Feature.js';
57
54
  /**
58
55
  * @typedef {Object} Vec2
59
56
  * @property {number} x X coordinate.
60
- * @property {import("../style/IconAnchorUnits").default} xunits Units of x.
57
+ * @property {import("../style/Icon.js").IconAnchorUnits} xunits Units of x.
61
58
  * @property {number} y Y coordinate.
62
- * @property {import("../style/IconAnchorUnits").default} yunits Units of Y.
63
- * @property {import("../style/IconOrigin.js").default} [origin] Origin.
59
+ * @property {import("../style/Icon.js").IconAnchorUnits} yunits Units of Y.
60
+ * @property {import("../style/Icon.js").IconOrigin} [origin] Origin.
64
61
  */
65
62
 
66
63
  /**
@@ -96,12 +93,12 @@ const SCHEMA_LOCATION =
96
93
  'https://developers.google.com/kml/schema/kml22gx.xsd';
97
94
 
98
95
  /**
99
- * @type {Object<string, import("../style/IconAnchorUnits").default>}
96
+ * @type {Object<string, import("../style/Icon.js").IconAnchorUnits>}
100
97
  */
101
98
  const ICON_ANCHOR_UNITS_MAP = {
102
- 'fraction': IconAnchorUnits.FRACTION,
103
- 'pixels': IconAnchorUnits.PIXELS,
104
- 'insetPixels': IconAnchorUnits.PIXELS,
99
+ 'fraction': 'fraction',
100
+ 'pixels': 'pixels',
101
+ 'insetPixels': 'pixels',
105
102
  };
106
103
 
107
104
  /**
@@ -212,12 +209,12 @@ export function getDefaultFillStyle() {
212
209
  let DEFAULT_IMAGE_STYLE_ANCHOR;
213
210
 
214
211
  /**
215
- * @type {import("../style/IconAnchorUnits").default}
212
+ * @type {import("../style/Icon.js").IconAnchorUnits}
216
213
  */
217
214
  let DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS;
218
215
 
219
216
  /**
220
- * @type {import("../style/IconAnchorUnits").default}
217
+ * @type {import("../style/Icon.js").IconAnchorUnits}
221
218
  */
222
219
  let DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS;
223
220
 
@@ -324,9 +321,9 @@ function createStyleDefaults() {
324
321
 
325
322
  DEFAULT_IMAGE_STYLE_ANCHOR = [20, 2];
326
323
 
327
- DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS = IconAnchorUnits.PIXELS;
324
+ DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS = 'pixels';
328
325
 
329
- DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS = IconAnchorUnits.PIXELS;
326
+ DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS = 'pixels';
330
327
 
331
328
  DEFAULT_IMAGE_STYLE_SIZE = [64, 64];
332
329
 
@@ -335,7 +332,7 @@ function createStyleDefaults() {
335
332
 
336
333
  DEFAULT_IMAGE_STYLE = new Icon({
337
334
  anchor: DEFAULT_IMAGE_STYLE_ANCHOR,
338
- anchorOrigin: IconOrigin.BOTTOM_LEFT,
335
+ anchorOrigin: 'bottom-left',
339
336
  anchorXUnits: DEFAULT_IMAGE_STYLE_ANCHOR_X_UNITS,
340
337
  anchorYUnits: DEFAULT_IMAGE_STYLE_ANCHOR_Y_UNITS,
341
338
  crossOrigin: 'anonymous',
@@ -1175,18 +1172,19 @@ function readStyleURL(node) {
1175
1172
  function readVec2(node) {
1176
1173
  const xunits = node.getAttribute('xunits');
1177
1174
  const yunits = node.getAttribute('yunits');
1175
+ /** @type {import('../style/Icon.js').IconOrigin} */
1178
1176
  let origin;
1179
1177
  if (xunits !== 'insetPixels') {
1180
1178
  if (yunits !== 'insetPixels') {
1181
- origin = IconOrigin.BOTTOM_LEFT;
1179
+ origin = 'bottom-left';
1182
1180
  } else {
1183
- origin = IconOrigin.TOP_LEFT;
1181
+ origin = 'top-left';
1184
1182
  }
1185
1183
  } else {
1186
1184
  if (yunits !== 'insetPixels') {
1187
- origin = IconOrigin.BOTTOM_RIGHT;
1185
+ origin = 'bottom-right';
1188
1186
  } else {
1189
- origin = IconOrigin.TOP_RIGHT;
1187
+ origin = 'top-right';
1190
1188
  }
1191
1189
  }
1192
1190
  return {
@@ -1267,7 +1265,8 @@ function iconStyleParser(node, objectStack) {
1267
1265
  src = DEFAULT_IMAGE_STYLE_SRC;
1268
1266
  }
1269
1267
  let anchor, anchorXUnits, anchorYUnits;
1270
- let anchorOrigin = IconOrigin.BOTTOM_LEFT;
1268
+ /** @type {import('../style/Icon.js').IconOrigin|undefined} */
1269
+ let anchorOrigin = 'bottom-left';
1271
1270
  const hotSpot = /** @type {Vec2|undefined} */ (object['hotSpot']);
1272
1271
  if (hotSpot) {
1273
1272
  anchor = [hotSpot.x, hotSpot.y];
@@ -1327,7 +1326,7 @@ function iconStyleParser(node, objectStack) {
1327
1326
  anchorYUnits: anchorYUnits,
1328
1327
  crossOrigin: this.crossOrigin_,
1329
1328
  offset: offset,
1330
- offsetOrigin: IconOrigin.BOTTOM_LEFT,
1329
+ offsetOrigin: 'bottom-left',
1331
1330
  rotation: rotation,
1332
1331
  scale: scale,
1333
1332
  size: size,
@@ -1594,7 +1593,7 @@ function readGxTrack(node, objectStack) {
1594
1593
  );
1595
1594
  }
1596
1595
  }
1597
- return new LineString(flatCoordinates, GeometryLayout.XYZM);
1596
+ return new LineString(flatCoordinates, 'XYZM');
1598
1597
  }
1599
1598
 
1600
1599
  /**
@@ -1677,7 +1676,7 @@ function readLineString(node, objectStack) {
1677
1676
  );
1678
1677
  const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack);
1679
1678
  if (flatCoordinates) {
1680
- const lineString = new LineString(flatCoordinates, GeometryLayout.XYZ);
1679
+ const lineString = new LineString(flatCoordinates, 'XYZ');
1681
1680
  lineString.setProperties(properties, true);
1682
1681
  return lineString;
1683
1682
  } else {
@@ -1699,7 +1698,7 @@ function readLinearRing(node, objectStack) {
1699
1698
  );
1700
1699
  const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack);
1701
1700
  if (flatCoordinates) {
1702
- const polygon = new Polygon(flatCoordinates, GeometryLayout.XYZ, [
1701
+ const polygon = new Polygon(flatCoordinates, 'XYZ', [
1703
1702
  flatCoordinates.length,
1704
1703
  ]);
1705
1704
  polygon.setProperties(properties, true);
@@ -1795,7 +1794,7 @@ function readPoint(node, objectStack) {
1795
1794
  );
1796
1795
  const flatCoordinates = readFlatCoordinatesFromNode(node, objectStack);
1797
1796
  if (flatCoordinates) {
1798
- const point = new Point(flatCoordinates, GeometryLayout.XYZ);
1797
+ const point = new Point(flatCoordinates, 'XYZ');
1799
1798
  point.setProperties(properties, true);
1800
1799
  return point;
1801
1800
  } else {
@@ -1838,7 +1837,7 @@ function readPolygon(node, objectStack) {
1838
1837
  extend(flatCoordinates, flatLinearRings[i]);
1839
1838
  ends.push(flatCoordinates.length);
1840
1839
  }
1841
- const polygon = new Polygon(flatCoordinates, GeometryLayout.XYZ, ends);
1840
+ const polygon = new Polygon(flatCoordinates, 'XYZ', ends);
1842
1841
  polygon.setProperties(properties, true);
1843
1842
  return polygon;
1844
1843
  } else {
@@ -2338,9 +2337,9 @@ function writeCoordinatesTextNode(node, coordinates, objectStack) {
2338
2337
  const stride = context['stride'];
2339
2338
 
2340
2339
  let dimension;
2341
- if (layout == GeometryLayout.XY || layout == GeometryLayout.XYM) {
2340
+ if (layout == 'XY' || layout == 'XYM') {
2342
2341
  dimension = 2;
2343
- } else if (layout == GeometryLayout.XYZ || layout == GeometryLayout.XYZM) {
2342
+ } else if (layout == 'XYZ' || layout == 'XYZM') {
2344
2343
  dimension = 3;
2345
2344
  } else {
2346
2345
  assert(false, 34); // Invalid geometry layout
@@ -2628,9 +2627,9 @@ function writeIconStyle(node, style, objectStack) {
2628
2627
  if (anchor && (anchor[0] !== size[0] / 2 || anchor[1] !== size[1] / 2)) {
2629
2628
  const /** @type {Vec2} */ hotSpot = {
2630
2629
  x: anchor[0],
2631
- xunits: IconAnchorUnits.PIXELS,
2630
+ xunits: 'pixels',
2632
2631
  y: size[1] - anchor[1],
2633
- yunits: IconAnchorUnits.PIXELS,
2632
+ yunits: 'pixels',
2634
2633
  };
2635
2634
  properties['hotSpot'] = hotSpot;
2636
2635
  }
package/src/format/MVT.js CHANGED
@@ -4,7 +4,6 @@
4
4
  //FIXME Implement projection handling
5
5
 
6
6
  import FeatureFormat, {transformGeometryWithOptions} from './Feature.js';
7
- import GeometryLayout from '../geom/GeometryLayout.js';
8
7
  import LineString from '../geom/LineString.js';
9
8
  import MultiLineString from '../geom/MultiLineString.js';
10
9
  import MultiPoint from '../geom/MultiPoint.js';
@@ -204,18 +203,18 @@ class MVT extends FeatureFormat {
204
203
  const endss = inflateEnds(flatCoordinates, ends);
205
204
  geom =
206
205
  endss.length > 1
207
- ? new MultiPolygon(flatCoordinates, GeometryLayout.XY, endss)
208
- : new Polygon(flatCoordinates, GeometryLayout.XY, ends);
206
+ ? new MultiPolygon(flatCoordinates, 'XY', endss)
207
+ : new Polygon(flatCoordinates, 'XY', ends);
209
208
  } else {
210
209
  geom =
211
210
  geometryType === 'Point'
212
- ? new Point(flatCoordinates, GeometryLayout.XY)
211
+ ? new Point(flatCoordinates, 'XY')
213
212
  : geometryType === 'LineString'
214
- ? new LineString(flatCoordinates, GeometryLayout.XY)
213
+ ? new LineString(flatCoordinates, 'XY')
215
214
  : geometryType === 'MultiPoint'
216
- ? new MultiPoint(flatCoordinates, GeometryLayout.XY)
215
+ ? new MultiPoint(flatCoordinates, 'XY')
217
216
  : geometryType === 'MultiLineString'
218
- ? new MultiLineString(flatCoordinates, GeometryLayout.XY, ends)
217
+ ? new MultiLineString(flatCoordinates, 'XY', ends)
219
218
  : null;
220
219
  }
221
220
  const ctor = /** @type {typeof import("../Feature.js").default} */ (
@@ -3,7 +3,6 @@
3
3
  */
4
4
  // FIXME add typedef for stack state objects
5
5
  import Feature from '../Feature.js';
6
- import GeometryLayout from '../geom/GeometryLayout.js';
7
6
  import LineString from '../geom/LineString.js';
8
7
  import Point from '../geom/Point.js';
9
8
  import Polygon from '../geom/Polygon.js';
@@ -88,11 +87,11 @@ class OSMXML extends XMLFeature {
88
87
  let geometry;
89
88
  if (values.ndrefs[0] == values.ndrefs[values.ndrefs.length - 1]) {
90
89
  // closed way
91
- geometry = new Polygon(flatCoordinates, GeometryLayout.XY, [
90
+ geometry = new Polygon(flatCoordinates, 'XY', [
92
91
  flatCoordinates.length,
93
92
  ]);
94
93
  } else {
95
- geometry = new LineString(flatCoordinates, GeometryLayout.XY);
94
+ geometry = new LineString(flatCoordinates, 'XY');
96
95
  }
97
96
  transformGeometryWithOptions(geometry, false, options);
98
97
  const feature = new Feature(geometry);
@@ -2,7 +2,6 @@
2
2
  * @module ol/format/Polyline
3
3
  */
4
4
  import Feature from '../Feature.js';
5
- import GeometryLayout from '../geom/GeometryLayout.js';
6
5
  import LineString from '../geom/LineString.js';
7
6
  import TextFeature from './TextFeature.js';
8
7
  import {assert} from '../asserts.js';
@@ -15,7 +14,7 @@ import {transformGeometryWithOptions} from './Feature.js';
15
14
  /**
16
15
  * @typedef {Object} Options
17
16
  * @property {number} [factor=1e5] The factor by which the coordinates values will be scaled.
18
- * @property {GeometryLayout} [geometryLayout='XY'] Layout of the
17
+ * @property {import("../geom/Geometry.js").GeometryLayout} [geometryLayout='XY'] Layout of the
19
18
  * feature geometries created by the format reader.
20
19
  */
21
20
 
@@ -55,11 +54,11 @@ class Polyline extends TextFeature {
55
54
 
56
55
  /**
57
56
  * @private
58
- * @type {import("../geom/GeometryLayout").default}
57
+ * @type {import("../geom/Geometry.js").GeometryLayout}
59
58
  */
60
59
  this.geometryLayout_ = options.geometryLayout
61
60
  ? options.geometryLayout
62
- : GeometryLayout.XY;
61
+ : 'XY';
63
62
  }
64
63
 
65
64
  /**
package/src/format/WKB.js CHANGED
@@ -4,7 +4,6 @@
4
4
  import Feature from '../Feature.js';
5
5
  import FeatureFormat, {transformGeometryWithOptions} from './Feature.js';
6
6
  import GeometryCollection from '../geom/GeometryCollection.js';
7
- import GeometryLayout from '../geom/GeometryLayout.js';
8
7
  import LineString from '../geom/LineString.js';
9
8
  import MultiLineString from '../geom/MultiLineString.js';
10
9
  import MultiPoint from '../geom/MultiPoint.js';
@@ -53,17 +52,50 @@ class WkbReader {
53
52
  * @param {DataView} view source to read
54
53
  */
55
54
  constructor(view) {
55
+ /** @private */
56
56
  this.view_ = view;
57
+
58
+ /**
59
+ * @type {number}
60
+ * @private
61
+ */
57
62
  this.pos_ = 0;
58
63
 
64
+ /**
65
+ * @type {boolean}
66
+ * @private
67
+ */
59
68
  this.initialized_ = false;
69
+
70
+ /**
71
+ * @type {boolean}
72
+ * @private
73
+ */
60
74
  this.isLittleEndian_ = false;
75
+
76
+ /**
77
+ * @type {boolean}
78
+ * @private
79
+ */
61
80
  this.hasZ_ = false;
81
+
82
+ /**
83
+ * @type {boolean}
84
+ * @private
85
+ */
62
86
  this.hasM_ = false;
63
- /** @type {number|null} */
87
+
88
+ /**
89
+ * @type {number|null}
90
+ * @private
91
+ */
64
92
  this.srid_ = null;
65
93
 
66
- this.layout_ = GeometryLayout.XY;
94
+ /**
95
+ * @type {import("../geom/Geometry.js").GeometryLayout}
96
+ * @private
97
+ */
98
+ this.layout_ = 'XY';
67
99
  }
68
100
 
69
101
  /**
@@ -164,7 +196,9 @@ class WkbReader {
164
196
  wkbTypeThousandth === 3;
165
197
  const hasSRID = Boolean(wkbType & 0x20000000);
166
198
  const typeId = (wkbType & 0x0fffffff) % 1000; // Assume 1000 is an upper limit for type ID
167
- const layout = ['XY', hasZ ? 'Z' : '', hasM ? 'M' : ''].join('');
199
+ const layout = /** @type {import("../geom/Geometry.js").GeometryLayout} */ (
200
+ ['XY', hasZ ? 'Z' : '', hasM ? 'M' : ''].join('')
201
+ );
168
202
 
169
203
  const srid = hasSRID ? this.readUint32(isLittleEndian) : null;
170
204
 
@@ -415,7 +449,7 @@ class WkbWriter {
415
449
 
416
450
  /**
417
451
  * @param {import('../coordinate.js').Coordinate} coords coords
418
- * @param {import("../geom/GeometryLayout").default} layout layout
452
+ * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
419
453
  */
420
454
  writePoint(coords, layout) {
421
455
  /**
@@ -439,7 +473,7 @@ class WkbWriter {
439
473
 
440
474
  /**
441
475
  * @param {Array<import('../coordinate.js').Coordinate>} coords coords
442
- * @param {import("../geom/GeometryLayout").default} layout layout
476
+ * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
443
477
  */
444
478
  writeLineString(coords, layout) {
445
479
  this.writeUint32(coords.length); // numPoints
@@ -450,7 +484,7 @@ class WkbWriter {
450
484
 
451
485
  /**
452
486
  * @param {Array<Array<import('../coordinate.js').Coordinate>>} rings rings
453
- * @param {import("../geom/GeometryLayout").default} layout layout
487
+ * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
454
488
  */
455
489
  writePolygon(rings, layout) {
456
490
  this.writeUint32(rings.length); // numRings
@@ -484,7 +518,7 @@ class WkbWriter {
484
518
 
485
519
  /**
486
520
  * @param {Array<import('../coordinate.js').Coordinate>} coords coords
487
- * @param {string} layout layout
521
+ * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
488
522
  */
489
523
  writeMultiPoint(coords, layout) {
490
524
  this.writeUint32(coords.length); // numItems
@@ -496,7 +530,7 @@ class WkbWriter {
496
530
 
497
531
  /**
498
532
  * @param {Array<Array<import('../coordinate.js').Coordinate>>} coords coords
499
- * @param {string} layout layout
533
+ * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
500
534
  */
501
535
  writeMultiLineString(coords, layout) {
502
536
  this.writeUint32(coords.length); // numItems
@@ -508,7 +542,7 @@ class WkbWriter {
508
542
 
509
543
  /**
510
544
  * @param {Array<Array<Array<import('../coordinate.js').Coordinate>>>} coords coords
511
- * @param {string} layout layout
545
+ * @param {import("../geom/Geometry.js").GeometryLayout} layout layout
512
546
  */
513
547
  writeMultiPolygon(coords, layout) {
514
548
  this.writeUint32(coords.length); // numItems
@@ -531,31 +565,31 @@ class WkbWriter {
531
565
 
532
566
  /**
533
567
  * @param {import("../geom/Geometry.js").default} geom geometry
534
- * @param {import("../geom/GeometryLayout.js").default} [layout] layout
535
- * @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes
568
+ * @param {import("../geom/Geometry.js").GeometryLayout} [layout] layout
569
+ * @return {import("../geom/Geometry.js").GeometryLayout} minumum layout made by common axes
536
570
  */
537
- findMinimumLayout(geom, layout = GeometryLayout.XYZM) {
571
+ findMinimumLayout(geom, layout = 'XYZM') {
538
572
  /**
539
- * @param {import("../geom/GeometryLayout.js").default} a A
540
- * @param {import("../geom/GeometryLayout.js").default} b B
541
- * @return {import("../geom/GeometryLayout.js").default} minumum layout made by common axes
573
+ * @param {import("../geom/Geometry.js").GeometryLayout} a A
574
+ * @param {import("../geom/Geometry.js").GeometryLayout} b B
575
+ * @return {import("../geom/Geometry.js").GeometryLayout} minumum layout made by common axes
542
576
  */
543
577
  const GeometryLayout_min = (a, b) => {
544
578
  if (a === b) {
545
579
  return a;
546
580
  }
547
581
 
548
- if (a === GeometryLayout.XYZM) {
582
+ if (a === 'XYZM') {
549
583
  // anything `b` is minimum
550
584
  return b;
551
585
  }
552
- if (b === GeometryLayout.XYZM) {
586
+ if (b === 'XYZM') {
553
587
  // anything `a` is minimum
554
588
  return a;
555
589
  }
556
590
 
557
591
  // otherwise, incompatible
558
- return GeometryLayout.XY;
592
+ return 'XY';
559
593
  };
560
594
 
561
595
  if (geom instanceof SimpleGeometry) {
@@ -564,7 +598,7 @@ class WkbWriter {
564
598
 
565
599
  if (geom instanceof GeometryCollection) {
566
600
  const geoms = geom.getGeometriesArray();
567
- for (let i = 0; i < geoms.length && layout !== GeometryLayout.XY; i++) {
601
+ for (let i = 0; i < geoms.length && layout !== 'XY'; i++) {
568
602
  layout = this.findMinimumLayout(geoms[i], layout);
569
603
  }
570
604
  }
@@ -652,7 +686,7 @@ class WkbWriter {
652
686
  * @property {boolean} [hex=true] Returns hex string instead of ArrayBuffer for output. This also is used as a hint internally whether it should load contents as text or ArrayBuffer on reading.
653
687
  * @property {boolean} [littleEndian=true] Use littleEndian for output.
654
688
  * @property {boolean} [ewkb=true] Use EWKB format for output.
655
- * @property {import("../geom/GeometryLayout").default} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect)
689
+ * @property {import("../geom/Geometry.js").GeometryLayout} [geometryLayout=null] Use specific coordinate layout for output features (null: auto detect)
656
690
  * @property {number} [nodataZ=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of Z.
657
691
  * @property {number} [nodataM=0] If the `geometryLayout` doesn't match with geometry to be output, this value is used to fill missing coordinate value of M.
658
692
  * @property {number|boolean} [srid=true] SRID for output. Specify integer value to enforce the value as a SRID. Specify `true` to extract from `dataProjection`. `false` to suppress the output. This option only takes effect when `ewkb` is `true`.
package/src/format/WKT.js CHANGED
@@ -3,7 +3,6 @@
3
3
  */
4
4
  import Feature from '../Feature.js';
5
5
  import GeometryCollection from '../geom/GeometryCollection.js';
6
- import GeometryLayout from '../geom/GeometryLayout.js';
7
6
  import LineString from '../geom/LineString.js';
8
7
  import MultiLineString from '../geom/MultiLineString.js';
9
8
  import MultiPoint from '../geom/MultiPoint.js';
@@ -15,7 +14,7 @@ import {transformGeometryWithOptions} from './Feature.js';
15
14
 
16
15
  /**
17
16
  * Geometry constructors
18
- * @enum {function (new:import("../geom/Geometry.js").default, Array, import("../geom/GeometryLayout.js").default)}
17
+ * @enum {function (new:import("../geom/Geometry.js").default, Array, import("../geom/Geometry.js").GeometryLayout)}
19
18
  */
20
19
  const GeometryConstructor = {
21
20
  'POINT': Point,
@@ -249,10 +248,10 @@ class Parser {
249
248
  };
250
249
 
251
250
  /**
252
- * @type {import("../geom/GeometryLayout.js").default}
251
+ * @type {import("../geom/Geometry.js").GeometryLayout}
253
252
  * @private
254
253
  */
255
- this.layout_ = GeometryLayout.XY;
254
+ this.layout_ = 'XY';
256
255
  }
257
256
 
258
257
  /**
@@ -296,22 +295,23 @@ class Parser {
296
295
 
297
296
  /**
298
297
  * Try to parse the dimensional info.
299
- * @return {import("../geom/GeometryLayout.js").default} The layout.
298
+ * @return {import("../geom/Geometry.js").GeometryLayout} The layout.
300
299
  * @private
301
300
  */
302
301
  parseGeometryLayout_() {
303
- let layout = GeometryLayout.XY;
302
+ /** @type {import("../geom/Geometry.js").GeometryLayout} */
303
+ let layout = 'XY';
304
304
  const dimToken = this.token_;
305
305
  if (this.isTokenType(TokenType.TEXT)) {
306
306
  const dimInfo = dimToken.value;
307
307
  if (dimInfo === Z) {
308
- layout = GeometryLayout.XYZ;
308
+ layout = 'XYZ';
309
309
  } else if (dimInfo === M) {
310
- layout = GeometryLayout.XYM;
310
+ layout = 'XYM';
311
311
  } else if (dimInfo === ZM) {
312
- layout = GeometryLayout.XYZM;
312
+ layout = 'XYZM';
313
313
  }
314
- if (layout !== GeometryLayout.XY) {
314
+ if (layout !== 'XY') {
315
315
  this.consume_();
316
316
  }
317
317
  }
@@ -819,10 +819,10 @@ function encodeMultiPolygonGeometry(geom) {
819
819
  function encodeGeometryLayout(geom) {
820
820
  const layout = geom.getLayout();
821
821
  let dimInfo = '';
822
- if (layout === GeometryLayout.XYZ || layout === GeometryLayout.XYZM) {
822
+ if (layout === 'XYZ' || layout === 'XYZM') {
823
823
  dimInfo += Z;
824
824
  }
825
- if (layout === GeometryLayout.XYM || layout === GeometryLayout.XYZM) {
825
+ if (layout === 'XYM' || layout === 'XYZM') {
826
826
  dimInfo += M;
827
827
  }
828
828
  return dimInfo;
@@ -18,7 +18,7 @@ class Circle extends SimpleGeometry {
18
18
  * For internal use, flat coordinates in combination with `opt_layout` and no
19
19
  * `opt_radius` are also accepted.
20
20
  * @param {number} [opt_radius] Radius.
21
- * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
21
+ * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
22
22
  */
23
23
  constructor(center, opt_radius, opt_layout) {
24
24
  super();
@@ -188,7 +188,7 @@ class Circle extends SimpleGeometry {
188
188
  * number) of the circle.
189
189
  * @param {!import("../coordinate.js").Coordinate} center Center.
190
190
  * @param {number} radius Radius.
191
- * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
191
+ * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
192
192
  * @api
193
193
  */
194
194
  setCenterAndRadius(center, radius, opt_layout) {
@@ -18,6 +18,12 @@ import {get as getProjection, getTransform} from '../proj.js';
18
18
  import {memoizeOne} from '../functions.js';
19
19
  import {transform2D} from './flat/transform.js';
20
20
 
21
+ /**
22
+ * @typedef {'XY' | 'XYZ' | 'XYM' | 'XYZM'} GeometryLayout
23
+ * The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')
24
+ * or measure ('M') coordinate is available.
25
+ */
26
+
21
27
  /**
22
28
  * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type
23
29
  * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * @module ol/geom/LineString
3
3
  */
4
- import GeometryLayout from './GeometryLayout.js';
5
4
  import SimpleGeometry from './SimpleGeometry.js';
6
5
  import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
7
6
  import {closestSquaredDistanceXY} from '../extent.js';
@@ -24,7 +23,7 @@ class LineString extends SimpleGeometry {
24
23
  /**
25
24
  * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
26
25
  * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
27
- * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
26
+ * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
28
27
  */
29
28
  constructor(coordinates, opt_layout) {
30
29
  super();
@@ -169,10 +168,7 @@ class LineString extends SimpleGeometry {
169
168
  * @api
170
169
  */
171
170
  getCoordinateAtM(m, opt_extrapolate) {
172
- if (
173
- this.layout != GeometryLayout.XYM &&
174
- this.layout != GeometryLayout.XYZM
175
- ) {
171
+ if (this.layout != 'XYM' && this.layout != 'XYZM') {
176
172
  return null;
177
173
  }
178
174
  const extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
@@ -263,7 +259,7 @@ class LineString extends SimpleGeometry {
263
259
  simplifiedFlatCoordinates,
264
260
  0
265
261
  );
266
- return new LineString(simplifiedFlatCoordinates, GeometryLayout.XY);
262
+ return new LineString(simplifiedFlatCoordinates, 'XY');
267
263
  }
268
264
 
269
265
  /**
@@ -294,7 +290,7 @@ class LineString extends SimpleGeometry {
294
290
  /**
295
291
  * Set the coordinates of the linestring.
296
292
  * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
297
- * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
293
+ * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
298
294
  * @api
299
295
  */
300
296
  setCoordinates(coordinates, opt_layout) {
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * @module ol/geom/LinearRing
3
3
  */
4
- import GeometryLayout from './GeometryLayout.js';
5
4
  import SimpleGeometry from './SimpleGeometry.js';
6
5
  import {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';
7
6
  import {closestSquaredDistanceXY} from '../extent.js';
@@ -21,7 +20,7 @@ class LinearRing extends SimpleGeometry {
21
20
  /**
22
21
  * @param {Array<import("../coordinate.js").Coordinate>|Array<number>} coordinates Coordinates.
23
22
  * For internal use, flat coordinates in combination with `opt_layout` are also accepted.
24
- * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
23
+ * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
25
24
  */
26
25
  constructor(coordinates, opt_layout) {
27
26
  super();
@@ -143,7 +142,7 @@ class LinearRing extends SimpleGeometry {
143
142
  simplifiedFlatCoordinates,
144
143
  0
145
144
  );
146
- return new LinearRing(simplifiedFlatCoordinates, GeometryLayout.XY);
145
+ return new LinearRing(simplifiedFlatCoordinates, 'XY');
147
146
  }
148
147
 
149
148
  /**
@@ -168,7 +167,7 @@ class LinearRing extends SimpleGeometry {
168
167
  /**
169
168
  * Set the coordinates of the linear ring.
170
169
  * @param {!Array<import("../coordinate.js").Coordinate>} coordinates Coordinates.
171
- * @param {import("./GeometryLayout.js").default} [opt_layout] Layout.
170
+ * @param {import("./Geometry.js").GeometryLayout} [opt_layout] Layout.
172
171
  * @api
173
172
  */
174
173
  setCoordinates(coordinates, opt_layout) {