@vcmap/core 5.0.0-rc.0 → 5.0.0-rc.4

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 (46) hide show
  1. package/index.d.ts +7470 -0
  2. package/index.js +2 -2
  3. package/package.json +3 -2
  4. package/src/vcs/vcm/interaction/coordinateAtPixel.js +1 -1
  5. package/src/vcs/vcm/layer/cesiumTileset.js +3 -3
  6. package/src/vcs/vcm/layer/czml.js +2 -2
  7. package/src/vcs/vcm/layer/dataSource.js +2 -2
  8. package/src/vcs/vcm/layer/featureLayer.js +2 -2
  9. package/src/vcs/vcm/layer/featureStore.js +4 -4
  10. package/src/vcs/vcm/layer/geojson.js +4 -4
  11. package/src/vcs/vcm/layer/layer.js +3 -3
  12. package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +2 -2
  13. package/src/vcs/vcm/layer/openStreetMap.js +2 -2
  14. package/src/vcs/vcm/layer/pointCloud.js +2 -2
  15. package/src/vcs/vcm/layer/rasterLayer.js +2 -2
  16. package/src/vcs/vcm/layer/singleImage.js +4 -3
  17. package/src/vcs/vcm/layer/terrain.js +2 -2
  18. package/src/vcs/vcm/layer/terrainHelpers.js +4 -8
  19. package/src/vcs/vcm/layer/tileProvider/tileProvider.js +2 -2
  20. package/src/vcs/vcm/layer/tms.js +2 -2
  21. package/src/vcs/vcm/layer/vector.js +4 -4
  22. package/src/vcs/vcm/layer/vectorTile.js +3 -3
  23. package/src/vcs/vcm/layer/wfs.js +3 -3
  24. package/src/vcs/vcm/layer/wms.js +3 -3
  25. package/src/vcs/vcm/layer/wmts.js +2 -2
  26. package/src/vcs/vcm/maps/cameraLimiter.js +6 -6
  27. package/src/vcs/vcm/maps/cesium.js +3 -3
  28. package/src/vcs/vcm/maps/map.js +28 -13
  29. package/src/vcs/vcm/maps/oblique.js +10 -10
  30. package/src/vcs/vcm/maps/openlayers.js +2 -2
  31. package/src/vcs/vcm/object.js +2 -2
  32. package/src/vcs/vcm/oblique/ObliqueCollection.js +83 -31
  33. package/src/vcs/vcm/oblique/ObliqueDataSet.js +60 -17
  34. package/src/vcs/vcm/oblique/ObliqueImage.js +1 -1
  35. package/src/vcs/vcm/oblique/ObliqueImageMeta.js +2 -2
  36. package/src/vcs/vcm/oblique/ObliqueProvider.js +10 -7
  37. package/src/vcs/vcm/oblique/helpers.js +12 -40
  38. package/src/vcs/vcm/oblique/parseImageJson.js +17 -9
  39. package/src/vcs/vcm/util/extent.js +18 -11
  40. package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +2 -2
  41. package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +4 -4
  42. package/src/vcs/vcm/util/indexedCollection.js +23 -0
  43. package/src/vcs/vcm/util/layerCollection.js +10 -5
  44. package/src/vcs/vcm/util/projection.js +38 -4
  45. package/src/vcs/vcm/util/style/styleItem.js +17 -0
  46. package/src/vcs/vcm/util/viewpoint.js +6 -3
@@ -154,9 +154,9 @@ class AbstractFeatureProvider extends VcsObject {
154
154
  * @returns {AbstractFeatureProviderOptions}
155
155
  * @api
156
156
  */
157
- getConfigObject() {
157
+ toJSON() {
158
158
  const config =
159
- /** @type {AbstractFeatureProviderOptions} */ (super.getConfigObject());
159
+ /** @type {AbstractFeatureProviderOptions} */ (super.toJSON());
160
160
 
161
161
  const defaultOptions = AbstractFeatureProvider.getDefaultOptions();
162
162
  delete config.name; // the name is irrelevant, since its the layers name
@@ -222,8 +222,8 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
222
222
  * @inheritDoc
223
223
  * @returns {WMSFeatureProviderOptions}
224
224
  */
225
- getConfigObject() {
226
- const config = /** @type {WMSFeatureProviderOptions} */ (super.getConfigObject());
225
+ toJSON() {
226
+ const config = /** @type {WMSFeatureProviderOptions} */ (super.toJSON());
227
227
  const defaultOptions = WMSFeatureProvider.getDefaultOptions();
228
228
  if (this.featureInfoResponseType !== defaultOptions.responseType) {
229
229
  config.responseType = this.featureInfoResponseType;
@@ -234,7 +234,7 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
234
234
  }
235
235
 
236
236
  if (this.projection !== defaultOptions.projection) {
237
- config.projection = this.projection.getConfigObject();
237
+ config.projection = this.projection.toJSON();
238
238
  }
239
239
 
240
240
  config.url = this._wmsSourceOptions.url;
@@ -259,7 +259,7 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
259
259
  config.tileSize = this._wmsSourceOptions.tileSize.slice();
260
260
  }
261
261
  if (this.extent) {
262
- config.extent = this.extent.getConfigObject();
262
+ config.extent = this.extent.toJSON();
263
263
  }
264
264
 
265
265
  return config;
@@ -42,8 +42,22 @@ class IndexedCollection extends Collection {
42
42
  * @api
43
43
  */
44
44
  this.moved = new VcsEvent();
45
+
46
+ /**
47
+ * @type {symbol}
48
+ * @private
49
+ */
50
+ this._previousIndexSymbol = Symbol('previousIndex');
45
51
  }
46
52
 
53
+ /**
54
+ * Get the symbol which is attached to an item prior to its removal. If an item is removed, the current index of the item
55
+ * is set on the item with this symbol.
56
+ * @type {symbol}
57
+ * @readonly
58
+ */
59
+ get previousIndexSymbol() { return this._previousIndexSymbol; }
60
+
47
61
  /**
48
62
  * Returns an item at index.
49
63
  * @param {number} index
@@ -76,6 +90,15 @@ class IndexedCollection extends Collection {
76
90
  return null;
77
91
  }
78
92
 
93
+ /**
94
+ * @inheritDoc
95
+ * @param {T} item
96
+ */
97
+ remove(item) {
98
+ item[this._previousIndexSymbol] = this._array.indexOf(item);
99
+ super.remove(item);
100
+ }
101
+
79
102
  /**
80
103
  * @param {T} item
81
104
  * @param {number} itemIndex
@@ -44,9 +44,6 @@ class LayerCollection extends IndexedCollection {
44
44
  this._layerEventListeners = {};
45
45
 
46
46
  /**
47
- * A symbol to describe the local z index of a layer. The local z index must not equal the layers z index, but is
48
- * always consistent in comparison to the neighbouring layers. If a layer is moved other then by z index, the collection
49
- * ensures consistency by setting a new local z index if needed.
50
47
  * @type {symbol}
51
48
  * @private
52
49
  */
@@ -67,6 +64,15 @@ class LayerCollection extends IndexedCollection {
67
64
  this.exclusiveManager = new ExclusiveManager();
68
65
  }
69
66
 
67
+ /**
68
+ * A symbol to describe the local z index of a layer. The local z index must not equal the layers z index, but is
69
+ * always consistent in comparison to the neighbouring layers. If a layer is moved other then by z index, the collection
70
+ * ensures consistency by setting a new local z index if needed.
71
+ * @type {symbol}
72
+ * @readonly
73
+ */
74
+ get zIndexSymbol() { return this._zIndexSymbol; }
75
+
70
76
  /**
71
77
  * @param {import("@vcmap/core").Layer} layer
72
78
  * @private
@@ -116,10 +122,9 @@ class LayerCollection extends IndexedCollection {
116
122
  _zIndexChanged(layer) {
117
123
  const currentIndex = this.indexOf(layer);
118
124
  if (currentIndex > -1) {
119
- const increased = layer[this._zIndexSymbol] < layer.zIndex;
120
125
  layer[this._zIndexSymbol] = layer.zIndex;
121
126
  let zIndexPosition = this._findZIndexPosition(layer.zIndex);
122
- if (increased && zIndexPosition > 0) {
127
+ if (zIndexPosition > 0 && zIndexPosition > currentIndex) {
123
128
  zIndexPosition -= 1; // remove self from count
124
129
  }
125
130
  zIndexPosition = zIndexPosition != null ? zIndexPosition : this._array.length - 1;
@@ -3,12 +3,15 @@ import { register } from 'ol/proj/proj4.js';
3
3
  import proj4 from 'proj4';
4
4
  import { getLogger as getLoggerByName } from '@vcsuite/logger';
5
5
  import { check } from '@vcsuite/check';
6
+ import { VcsClassRegistry } from '../classRegistry.js';
6
7
 
7
8
  /**
8
9
  * @typedef {Object} ProjectionOptions
10
+ * @property {string} [type]
9
11
  * @property {string|number} [epsg] - EPSG of the projection, for example: "EPSG:4326" if not specified, uses the framework projection
10
12
  * @property {string|undefined|null} [proj4] - definition of the projection. See for example: {@link http://spatialreference.org/ref/epsg/4326/proj4/} proj4
11
13
  * @property {Array<string>|undefined|null} [alias] - aliases to define
14
+ * @property {string|undefined} [prefix='EPSG:'] - an alternate prefix to use for custom projection
12
15
  * @api stable
13
16
  */
14
17
 
@@ -36,7 +39,8 @@ let defaultProjectionOption = {
36
39
  * @returns {string}
37
40
  */
38
41
  function parseEPSGCode(value, prefix = 'EPSG:') {
39
- const matches = `${value}`.match(/^(?:epsg:)?(\d+)/i);
42
+ const regex = new RegExp(`^(?:${prefix})?(\\d+)`, 'i');
43
+ const matches = `${value}`.match(regex);
40
44
  if (matches && matches[1]) {
41
45
  return `${prefix}${matches[1]}`;
42
46
  }
@@ -73,9 +77,11 @@ function validateProjectionOptions(options) {
73
77
  * @returns {ProjectionOptions} valid options
74
78
  */
75
79
  function registerProjection(options) {
76
- const saneOptions = {};
80
+ const saneOptions = {
81
+ prefix: options.prefix,
82
+ };
77
83
  if (options.epsg) {
78
- saneOptions.epsg = parseEPSGCode(options.epsg);
84
+ saneOptions.epsg = parseEPSGCode(options.epsg, options.prefix);
79
85
  if (saneOptions.epsg) {
80
86
  if (options.proj4) {
81
87
  saneOptions.proj4 = options.proj4;
@@ -123,6 +129,11 @@ export function setDefaultProjectionOptions(options) {
123
129
  * @api stable
124
130
  */
125
131
  class Projection {
132
+ /**
133
+ * @returns {string}
134
+ */
135
+ static get className() { return 'vcs.vcm.util.Projection'; }
136
+
126
137
  /**
127
138
  * @param {ProjectionOptions} options
128
139
  */
@@ -143,6 +154,20 @@ class Projection {
143
154
  if (!this.proj) {
144
155
  this._epsg = Projection.parseEPSGCode(defaultProjectionOption.epsg);
145
156
  }
157
+
158
+ /**
159
+ * Cached for toJSON
160
+ * @type {Array<string>}
161
+ * @private
162
+ */
163
+ this._alias = saneOptions.alias;
164
+
165
+ /**
166
+ * Cached for toJSON
167
+ * @type {string}
168
+ * @private
169
+ */
170
+ this._prefix = saneOptions.prefix;
146
171
  }
147
172
 
148
173
  /**
@@ -262,13 +287,20 @@ class Projection {
262
287
  * @returns {ProjectionOptions}
263
288
  * @api stable
264
289
  */
265
- getConfigObject() {
290
+ toJSON() {
266
291
  const configObject = {
292
+ type: Projection.className,
267
293
  epsg: this.epsg,
268
294
  };
269
295
  if (this.proj4) {
270
296
  configObject.proj4 = this.proj4;
271
297
  }
298
+ if (Array.isArray(this._alias) && this._alias.length > 0) {
299
+ configObject.alias = this._alias.slice();
300
+ }
301
+ if (this._prefix) {
302
+ configObject.prefix = this._prefix;
303
+ }
272
304
  return configObject;
273
305
  }
274
306
 
@@ -346,3 +378,5 @@ export const wgs84Projection = new Projection({ epsg: 4326 });
346
378
  * @export
347
379
  */
348
380
  export const mercatorProjection = new Projection({ epsg: 3857 });
381
+
382
+ VcsClassRegistry.registerClass(Projection.className, Projection);
@@ -162,6 +162,23 @@ class StyleItem extends VcsObject {
162
162
  return {};
163
163
  }
164
164
 
165
+ /**
166
+ * @inheritDoc
167
+ * @returns {StyleItemOptions}
168
+ */
169
+ toJSON() {
170
+ const config = { ...super.toJSON(), ...this.getOptions() };
171
+ if (this.title) {
172
+ config.title = this.title;
173
+ }
174
+
175
+ if (this.legend.length > 0) {
176
+ config.legend = this.legend.slice();
177
+ }
178
+
179
+ return config;
180
+ }
181
+
165
182
  /**
166
183
  * Clones this style
167
184
  * @param {StyleItem=} result
@@ -3,6 +3,7 @@ import { parseBoolean, parseNumber } from '@vcsuite/parsers';
3
3
  import Projection, { wgs84Projection } from './projection.js';
4
4
  import VcsObject from '../object.js';
5
5
  import Extent from './extent.js';
6
+ import { VcsClassRegistry } from '../classRegistry.js';
6
7
 
7
8
  /**
8
9
  * compares two numeric properties
@@ -158,9 +159,9 @@ class ViewPoint extends VcsObject {
158
159
  * @returns {ViewPointOptions} returns a options object. This object can be used to reconstruct a new viewpoint
159
160
  * @api stable
160
161
  */
161
- getConfigObject() {
162
+ toJSON() {
162
163
  return {
163
- ...super.getConfigObject(),
164
+ ...super.toJSON(),
164
165
  distance: this.distance,
165
166
  cameraPosition: this.cameraPosition ? this.cameraPosition.slice() : null,
166
167
  groundPosition: this.groundPosition ? this.groundPosition.slice() : null,
@@ -179,7 +180,7 @@ class ViewPoint extends VcsObject {
179
180
  * @api stable
180
181
  */
181
182
  clone() {
182
- return new ViewPoint(this.getConfigObject());
183
+ return new ViewPoint(this.toJSON());
183
184
  }
184
185
 
185
186
  /**
@@ -331,3 +332,5 @@ class ViewPoint extends VcsObject {
331
332
  }
332
333
 
333
334
  export default ViewPoint;
335
+
336
+ VcsClassRegistry.registerClass(ViewPoint.className, ViewPoint);