@disy/cadenza.js 10.4.0 → 10.4.2
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 +13 -0
- package/apidoc/assets/navigation.js +1 -1
- package/apidoc/assets/search.js +1 -1
- package/apidoc/classes/AbortError.html +3 -3
- package/apidoc/classes/CadenzaClient.html +69 -72
- package/apidoc/classes/CadenzaError.html +5 -5
- package/apidoc/functions/cadenza.html +4 -4
- package/apidoc/index.html +9 -16
- package/apidoc/interfaces/CadenzaClientOptions.html +5 -5
- package/apidoc/interfaces/CadenzaEvent.html +4 -4
- package/apidoc/interfaces/CommonEditGeometryOptions.html +20 -0
- package/apidoc/interfaces/Distance.html +2 -2
- package/apidoc/interfaces/ExternalLinkKey.html +4 -4
- package/apidoc/interfaces/Feature.html +9 -9
- package/apidoc/interfaces/FeatureCollection.html +4 -4
- package/apidoc/interfaces/Geometry.html +4 -4
- package/apidoc/interfaces/GeometryExtentStrategy.html +4 -4
- package/apidoc/interfaces/LayerDataExtentStrategy.html +4 -4
- package/apidoc/interfaces/LayerDefinition.html +4 -4
- package/apidoc/interfaces/LocationFinderExtentStrategy.html +4 -4
- package/apidoc/interfaces/PageSource.html +3 -3
- package/apidoc/interfaces/SnappingOptions.html +3 -3
- package/apidoc/interfaces/SpatialFilterValue.html +4 -4
- package/apidoc/interfaces/StaticExtentStrategy.html +4 -4
- package/apidoc/modules.html +1 -1
- package/apidoc/types/CadenzaActionEvent.html +2 -2
- package/apidoc/types/CadenzaChangeSelectionEvent.html +2 -2
- package/apidoc/types/CadenzaDrillThroughEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryCancelEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryOkEvent.html +2 -2
- package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +2 -2
- package/apidoc/types/CadenzaErrorEvent.html +2 -2
- package/apidoc/types/CadenzaEventByType.html +1 -1
- package/apidoc/types/CadenzaEventType.html +2 -2
- package/apidoc/types/CadenzaObjectInfoEvent.html +2 -2
- package/apidoc/types/CadenzaReloadEvent.html +2 -2
- package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +2 -2
- package/apidoc/types/CadenzaSelectObjectsOkEvent.html +2 -2
- package/apidoc/types/Coordinate.html +2 -2
- package/apidoc/types/CustomValidityType.html +2 -2
- package/apidoc/types/DataType.html +2 -2
- package/apidoc/types/EmbeddingTargetId.html +2 -2
- package/apidoc/types/Extent.html +2 -2
- package/apidoc/types/ExtentStrategy.html +2 -2
- package/apidoc/types/FilterVariables.html +2 -2
- package/apidoc/types/GeometryType.html +2 -2
- package/apidoc/types/GlobalId.html +2 -2
- package/apidoc/types/Layout.html +6 -0
- package/apidoc/types/LengthUnit.html +1 -1
- package/apidoc/types/OpaqueString.html +2 -2
- package/apidoc/types/OperationMode.html +2 -2
- package/apidoc/types/Polygon.html +1 -1
- package/apidoc/types/SpatialRelation.html +2 -2
- package/apidoc/types/TablePart.html +2 -2
- package/apidoc/types/UiFeature.html +2 -2
- package/apidoc/types/WorkbookLayerPath.html +2 -2
- package/cadenza.d.ts +97 -68
- package/cadenza.js +182 -79
- package/package.json +1 -1
- package/sandbox.html +108 -40
package/cadenza.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
// This placeholder is replaced when Cadenza JS is released,
|
|
14
14
|
// i.e. during development, the version is not available.
|
|
15
|
-
const CADENZAJS_VERSION = '10.4.
|
|
15
|
+
const CADENZAJS_VERSION = '10.4.2';
|
|
16
16
|
/**
|
|
17
17
|
* Creates an instance of the Cadenza JS client.
|
|
18
18
|
*
|
|
@@ -158,6 +158,18 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
|
|
|
158
158
|
* @property {'static'} type - The extent strategy type
|
|
159
159
|
* @property {Extent} extent - This extent takes precedence over another extent that might be given in an API call.
|
|
160
160
|
*/
|
|
161
|
+
/**
|
|
162
|
+
* @typedef CommonEditGeometryOptions - Common options for the initialization of the geometry editor.
|
|
163
|
+
* @property {LayerDefinition[]} [additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
164
|
+
* @property {UiFeature[]} [disabledUiFeatures] - Cadenza UI features to disable
|
|
165
|
+
* @property {ExtentStrategy} [extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
166
|
+
* @property {FilterVariables} [filter] - Filter variables
|
|
167
|
+
* @property {number} [minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
|
|
168
|
+
* @property {OperationMode} [operationMode] - The mode in which a workbook should be operated
|
|
169
|
+
* @property {AbortSignal} [signal] - A signal to abort the iframe loading
|
|
170
|
+
* @property {SnappingOptions} [snapping] - Passing these options enables snapping
|
|
171
|
+
* @property {boolean} [useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS and the created geometry should use the map's SRS (otherwise EPSG:4326 is assumed)
|
|
172
|
+
*/
|
|
161
173
|
/**
|
|
162
174
|
* @typedef {'csv' | 'excel' | 'json' | 'pdf' | 'png'} DataType - A data type
|
|
163
175
|
*
|
|
@@ -204,6 +216,11 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
|
|
|
204
216
|
* @property {WorkbookLayerPath | string} layer - The layer to snap to
|
|
205
217
|
* @property {('toVertices' | 'toEdges' | 'lineTracing')[]} [types] - Snapping types; Without this option, the Cadenza default snapping types are used.
|
|
206
218
|
*/
|
|
219
|
+
/**
|
|
220
|
+
* @typedef {'dashboard'|'linear'} Layout - Layout of a worksheet
|
|
221
|
+
* - `dashboard`: Views are shown in a two-dimensional dashboard grid.
|
|
222
|
+
* - `linear`: Views are shown linearly, one after another in one column.
|
|
223
|
+
*/
|
|
207
224
|
let hasCadenzaSession = false;
|
|
208
225
|
/** @type {Promise<void> | undefined} */
|
|
209
226
|
let firstEmbeddingTargetShown;
|
|
@@ -218,8 +235,6 @@ let firstEmbeddingTargetShown;
|
|
|
218
235
|
* When aborted, the result Promise is rejected with an {@link AbortError}.
|
|
219
236
|
* * If there's another error, the result Promise is rejected with a {@link CadenzaError}.
|
|
220
237
|
* * For methods that support the `hideMainHeaderAndFooter` and `hideWorkbookToolBar` parameters - the parameters cannot override the configuration of an embedding target.
|
|
221
|
-
* * For methods that support the _deprecated_ `locationFinder` and `mapExtent` parameters - when both are given, the `mapExtent` takes precedence.
|
|
222
|
-
* * Both `locationFinder` and `mapExtent` parameters are _deprecated_ - Use {@link LocationFinderExtentStrategy} or {@link StaticExtentStrategy} instead.
|
|
223
238
|
*/
|
|
224
239
|
// Must be exported to be included in the docs.
|
|
225
240
|
export class CadenzaClient {
|
|
@@ -309,6 +324,7 @@ export class CadenzaClient {
|
|
|
309
324
|
* @param {GlobalId} [__namedParameters.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
|
|
310
325
|
* @param {String} [__namedParameters.labelSet] - The name of a label set defined in the `basicweb-config.xml` (only supported for the welcome page)
|
|
311
326
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
327
|
+
* @param {Layout} [__namedParameters.layout] - The layout to be used; the dashboard layout is used by default or the linear layout if there is not enough space.
|
|
312
328
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
313
329
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
314
330
|
* @throws For invalid arguments
|
|
@@ -317,7 +333,7 @@ export class CadenzaClient {
|
|
|
317
333
|
* - {@link CadenzaActionEvent}
|
|
318
334
|
* @embed
|
|
319
335
|
*/
|
|
320
|
-
show(source, { dataType, disabledUiFeatures, expandNavigator, filter, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, operationMode, signal, } = {}) {
|
|
336
|
+
show(source, { dataType, disabledUiFeatures, expandNavigator, filter, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, operationMode, layout, signal, } = {}) {
|
|
321
337
|
this.#log('CadenzaClient#show', ...arguments);
|
|
322
338
|
if (dataType) {
|
|
323
339
|
assertSupportedDataType(dataType, ['pdf']);
|
|
@@ -337,6 +353,7 @@ export class CadenzaClient {
|
|
|
337
353
|
highlightGlobalId,
|
|
338
354
|
labelSet,
|
|
339
355
|
operationMode,
|
|
356
|
+
layout,
|
|
340
357
|
});
|
|
341
358
|
return this.#show(resolvePath(source), params, signal);
|
|
342
359
|
}
|
|
@@ -375,8 +392,6 @@ export class CadenzaClient {
|
|
|
375
392
|
* @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
|
|
376
393
|
* @param {boolean} [__namedParameters.hideWorkbookToolBar] - Whether to hide the workbook toolbar
|
|
377
394
|
* @param {GlobalId} [__namedParameters.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
|
|
378
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
379
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
380
395
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
381
396
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
382
397
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
@@ -387,7 +402,7 @@ export class CadenzaClient {
|
|
|
387
402
|
* - {@link CadenzaActionEvent}
|
|
388
403
|
* @embed
|
|
389
404
|
*/
|
|
390
|
-
async showMap(mapView, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId,
|
|
405
|
+
async showMap(mapView, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, operationMode, useMapSrs, signal, } = {}) {
|
|
391
406
|
this.#log('CadenzaClient#showMap', ...arguments);
|
|
392
407
|
if (geometry) {
|
|
393
408
|
assertValidGeometryType(geometry.type);
|
|
@@ -395,8 +410,6 @@ export class CadenzaClient {
|
|
|
395
410
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
396
411
|
extentStrategy,
|
|
397
412
|
geometry,
|
|
398
|
-
locationFinder,
|
|
399
|
-
mapExtent,
|
|
400
413
|
});
|
|
401
414
|
const params = createParams({
|
|
402
415
|
disabledUiFeatures,
|
|
@@ -438,16 +451,19 @@ export class CadenzaClient {
|
|
|
438
451
|
*
|
|
439
452
|
* Currently, only map views are supported.
|
|
440
453
|
*
|
|
441
|
-
* @hidden
|
|
442
454
|
* @template {DataType} T
|
|
443
|
-
* @param {
|
|
455
|
+
* @param {DataType} dataType - The requested data type. Currently, only `"png"` is
|
|
456
|
+
* @param {object} [__namedParameters] - Options
|
|
457
|
+
* @param {number} [__namedParameters.width] - The width of the resulting map image in px.
|
|
458
|
+
* @param {number} [__namedParameters.height] - The height of the resulting map image in px.
|
|
459
|
+
* @param {boolean} [__namedParameters.withScale] - Whether to show the scale line and the scale on the map image.
|
|
444
460
|
* @return {Promise<T extends 'png' ? Blob : never>}
|
|
445
461
|
* @postMessage
|
|
446
462
|
*/
|
|
447
|
-
async getData(dataType) {
|
|
463
|
+
async getData(dataType, { width, height, withScale } = {}) {
|
|
448
464
|
this.#log('CadenzaClient#getData', ...arguments);
|
|
449
465
|
assertSupportedDataType(dataType, ['png']);
|
|
450
|
-
return this.#postRequest('getData', { dataType });
|
|
466
|
+
return this.#postRequest('getData', { dataType, width, height, withScale });
|
|
451
467
|
}
|
|
452
468
|
/**
|
|
453
469
|
* Set filter variables in the currently shown workbook.
|
|
@@ -550,19 +566,7 @@ export class CadenzaClient {
|
|
|
550
566
|
*
|
|
551
567
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
552
568
|
* @param {GeometryType} geometryType - The geometry type
|
|
553
|
-
* @param {
|
|
554
|
-
* @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
555
|
-
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
556
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
557
|
-
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
558
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
559
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
560
|
-
* @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
|
|
561
|
-
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
562
|
-
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
563
|
-
* @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
|
|
564
|
-
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS and the created geometry should use the map's SRS (otherwise EPSG:4326 is assumed)
|
|
565
|
-
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
569
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
566
570
|
* @throws For invalid arguments
|
|
567
571
|
* @fires
|
|
568
572
|
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
@@ -570,12 +574,10 @@ export class CadenzaClient {
|
|
|
570
574
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
571
575
|
* @embed
|
|
572
576
|
*/
|
|
573
|
-
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter,
|
|
577
|
+
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, useMapSrs, operationMode, signal, snapping, } = {}) {
|
|
574
578
|
this.#log('CadenzaClient#createGeometry', ...arguments);
|
|
575
579
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
576
580
|
extentStrategy,
|
|
577
|
-
locationFinder,
|
|
578
|
-
mapExtent,
|
|
579
581
|
});
|
|
580
582
|
const params = createParams({
|
|
581
583
|
action: 'editGeometry',
|
|
@@ -589,30 +591,18 @@ export class CadenzaClient {
|
|
|
589
591
|
validExtentStrategy,
|
|
590
592
|
});
|
|
591
593
|
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
this.#setExtentStrategy(validExtentStrategy);
|
|
594
|
+
await this.#setupEditorViaPostRequests({
|
|
595
|
+
additionalLayers,
|
|
596
|
+
validExtentStrategy,
|
|
597
|
+
});
|
|
598
|
+
await this.#setEditorStateToReady();
|
|
598
599
|
}
|
|
599
600
|
/**
|
|
600
601
|
* Edit a geometry.
|
|
601
602
|
*
|
|
602
603
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
603
|
-
* @param {Geometry} geometry - The geometry
|
|
604
|
-
* @param {
|
|
605
|
-
* @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. Each is a layer definition, with name, type and content (a Geojson featureCollection).
|
|
606
|
-
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
607
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
608
|
-
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
609
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
610
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
611
|
-
* @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
|
|
612
|
-
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
613
|
-
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
614
|
-
* @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
|
|
615
|
-
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
604
|
+
* @param {Geometry} geometry - The geometry to edit
|
|
605
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
616
606
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
617
607
|
* @throws For invalid arguments
|
|
618
608
|
* @fires
|
|
@@ -621,19 +611,99 @@ export class CadenzaClient {
|
|
|
621
611
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
622
612
|
* @embed
|
|
623
613
|
*/
|
|
624
|
-
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter,
|
|
614
|
+
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
625
615
|
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
626
|
-
|
|
616
|
+
const geometryType = geometry.type;
|
|
617
|
+
assertValidGeometryType(geometryType);
|
|
627
618
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
628
619
|
extentStrategy,
|
|
629
620
|
geometry,
|
|
630
|
-
locationFinder,
|
|
631
|
-
mapExtent,
|
|
632
621
|
});
|
|
633
622
|
const params = createParams({
|
|
634
623
|
action: 'editGeometry',
|
|
635
624
|
disabledUiFeatures,
|
|
636
625
|
filter,
|
|
626
|
+
geometryType,
|
|
627
|
+
minScale,
|
|
628
|
+
operationMode,
|
|
629
|
+
snapping,
|
|
630
|
+
useMapSrs,
|
|
631
|
+
validExtentStrategy,
|
|
632
|
+
});
|
|
633
|
+
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
634
|
+
await this.#setupEditorViaPostRequests({
|
|
635
|
+
additionalLayers,
|
|
636
|
+
validExtentStrategy,
|
|
637
|
+
geometry,
|
|
638
|
+
});
|
|
639
|
+
await this.#setEditorStateToReady();
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Create multiple geometries.
|
|
643
|
+
*
|
|
644
|
+
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
645
|
+
* @param {GeometryType} geometryType - The type of geometries to create
|
|
646
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
647
|
+
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
648
|
+
* @throws For invalid arguments
|
|
649
|
+
* @fires
|
|
650
|
+
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
651
|
+
* - {@link CadenzaEditGeometryOkEvent}
|
|
652
|
+
* - {@link CadenzaEditGeometryCancelEvent}
|
|
653
|
+
* @embed
|
|
654
|
+
*/
|
|
655
|
+
async batchCreateGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
656
|
+
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
657
|
+
assertValidGeometryType(geometryType);
|
|
658
|
+
const validExtentStrategy = sanitizeExtentStrategy({
|
|
659
|
+
extentStrategy,
|
|
660
|
+
});
|
|
661
|
+
const params = createParams({
|
|
662
|
+
action: 'editGeometry',
|
|
663
|
+
batchModeEnabled: true,
|
|
664
|
+
disabledUiFeatures,
|
|
665
|
+
filter,
|
|
666
|
+
geometryType,
|
|
667
|
+
minScale,
|
|
668
|
+
operationMode,
|
|
669
|
+
snapping,
|
|
670
|
+
useMapSrs,
|
|
671
|
+
validExtentStrategy,
|
|
672
|
+
});
|
|
673
|
+
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
674
|
+
await this.#setupEditorViaPostRequests({
|
|
675
|
+
additionalLayers,
|
|
676
|
+
validExtentStrategy,
|
|
677
|
+
});
|
|
678
|
+
await this.#setEditorStateToReady();
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Edit multiple geometries.
|
|
682
|
+
*
|
|
683
|
+
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
684
|
+
* @param {FeatureCollection} features - The features to edit. The last feature in this collection is directly set up for editing.
|
|
685
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
686
|
+
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
687
|
+
* @throws For invalid arguments
|
|
688
|
+
* @fires
|
|
689
|
+
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
690
|
+
* - {@link CadenzaEditGeometryOkEvent}
|
|
691
|
+
* - {@link CadenzaEditGeometryCancelEvent}
|
|
692
|
+
* @embed
|
|
693
|
+
*/
|
|
694
|
+
async batchEditGeometry(backgroundMapView, features, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
695
|
+
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
696
|
+
const geometryType = getGeometryTypeFromFeatureCollection(features);
|
|
697
|
+
const validExtentStrategy = sanitizeExtentStrategy({
|
|
698
|
+
extentStrategy,
|
|
699
|
+
geometry: features.features[features.features.length - 1].geometry,
|
|
700
|
+
});
|
|
701
|
+
const params = createParams({
|
|
702
|
+
action: 'editGeometry',
|
|
703
|
+
batchModeEnabled: true,
|
|
704
|
+
disabledUiFeatures,
|
|
705
|
+
filter,
|
|
706
|
+
geometryType,
|
|
637
707
|
minScale,
|
|
638
708
|
operationMode,
|
|
639
709
|
snapping,
|
|
@@ -641,17 +711,41 @@ export class CadenzaClient {
|
|
|
641
711
|
validExtentStrategy,
|
|
642
712
|
});
|
|
643
713
|
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
714
|
+
await this.#setupEditorViaPostRequests({
|
|
715
|
+
additionalLayers,
|
|
716
|
+
validExtentStrategy,
|
|
717
|
+
features,
|
|
718
|
+
});
|
|
719
|
+
await this.#setEditorStateToReady();
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* @param {object} __namedParameters - Options
|
|
723
|
+
* @param [__namedParameters.geometry] {Geometry} - The geometry to edit
|
|
724
|
+
* @param [__namedParameters.additionalLayers] {LayerDefinition[]} - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
725
|
+
* @param [__namedParameters.validExtentStrategy] {ExtentStrategy} - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
726
|
+
* @param [__namedParameters.features] {FeatureCollection} - The features to edit. The last feature in this collection is directly set up for editing.
|
|
727
|
+
* @returns {Promise<Awaited<unknown>[]>}
|
|
728
|
+
*/
|
|
729
|
+
#setupEditorViaPostRequests({ geometry, additionalLayers, validExtentStrategy, features, }) {
|
|
730
|
+
const postRequests = [];
|
|
731
|
+
postRequests.push(this.#setExtentStrategy(validExtentStrategy));
|
|
644
732
|
if (geometry) {
|
|
645
|
-
this.#
|
|
733
|
+
postRequests.push(this.#postRequest('setGeometry', {
|
|
646
734
|
geometry,
|
|
647
|
-
});
|
|
735
|
+
}));
|
|
648
736
|
}
|
|
649
737
|
if (additionalLayers) {
|
|
650
738
|
for (const layer of additionalLayers) {
|
|
651
|
-
|
|
739
|
+
postRequests.push(this.#postRequest('importLayer', layer));
|
|
652
740
|
}
|
|
653
741
|
}
|
|
654
|
-
|
|
742
|
+
if (features) {
|
|
743
|
+
postRequests.push(this.#postRequest('addFeatures', features));
|
|
744
|
+
}
|
|
745
|
+
return Promise.all(postRequests);
|
|
746
|
+
}
|
|
747
|
+
#setEditorStateToReady() {
|
|
748
|
+
return this.#postRequest('setEditorState', 'READY');
|
|
655
749
|
}
|
|
656
750
|
/**
|
|
657
751
|
* Set custom validity state of the geometry editor in addition to the default validation state (including errors and
|
|
@@ -675,8 +769,6 @@ export class CadenzaClient {
|
|
|
675
769
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
676
770
|
* @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
|
|
677
771
|
* (identified using layer paths or print names)
|
|
678
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
679
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
680
772
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
681
773
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
682
774
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
@@ -689,12 +781,9 @@ export class CadenzaClient {
|
|
|
689
781
|
* - {@link CadenzaSelectObjectsCancelEvent}
|
|
690
782
|
* @embed
|
|
691
783
|
*/
|
|
692
|
-
async selectObjects(backgroundMapView, { extentStrategy, filter, layers,
|
|
784
|
+
async selectObjects(backgroundMapView, { extentStrategy, filter, layers, useMapSrs, operationMode, signal } = {}) {
|
|
693
785
|
this.#log('CadenzaClient#selectObjects', ...arguments);
|
|
694
786
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
695
|
-
geometry: undefined,
|
|
696
|
-
locationFinder,
|
|
697
|
-
mapExtent,
|
|
698
787
|
extentStrategy,
|
|
699
788
|
});
|
|
700
789
|
const params = createParams({
|
|
@@ -712,7 +801,7 @@ export class CadenzaClient {
|
|
|
712
801
|
const type = extentStrategy?.type;
|
|
713
802
|
// Other extent strategies are handled via URL parameters.
|
|
714
803
|
if (type === 'geometry' || type === 'layerData') {
|
|
715
|
-
this.#
|
|
804
|
+
return this.#postRequest('setExtentStrategy', extentStrategy);
|
|
716
805
|
}
|
|
717
806
|
}
|
|
718
807
|
/**
|
|
@@ -1126,6 +1215,9 @@ function validTablePart(/** @type TablePart */ value) {
|
|
|
1126
1215
|
function validOperationMode(/** @type string */ value) {
|
|
1127
1216
|
return ['normal', 'simplified'].includes(value);
|
|
1128
1217
|
}
|
|
1218
|
+
function validLayout(/** @type string */ value) {
|
|
1219
|
+
return ['linear', 'dashboard'].includes(value);
|
|
1220
|
+
}
|
|
1129
1221
|
function validUiFeature(/** @type string */ value) {
|
|
1130
1222
|
return [
|
|
1131
1223
|
'workbook-design',
|
|
@@ -1163,6 +1255,7 @@ function assertValidFilterVariables(/** @type {FilterVariables} */ filter) {
|
|
|
1163
1255
|
/**
|
|
1164
1256
|
* @param {object} params
|
|
1165
1257
|
* @param {string} [params.action]
|
|
1258
|
+
* @param {boolean} [params.batchModeEnabled]
|
|
1166
1259
|
* @param {DataType} [params.dataType]
|
|
1167
1260
|
* @param {UiFeature[]} [params.disabledUiFeatures]
|
|
1168
1261
|
* @param {boolean} [params.expandNavigator]
|
|
@@ -1181,9 +1274,10 @@ function assertValidFilterVariables(/** @type {FilterVariables} */ filter) {
|
|
|
1181
1274
|
* @param {SnappingOptions} [params.snapping]
|
|
1182
1275
|
* @param {boolean} [params.useMapSrs]
|
|
1183
1276
|
* @param {ExtentStrategy | undefined} [params.validExtentStrategy]
|
|
1277
|
+
* @param {Layout | undefined} [params.layout]
|
|
1184
1278
|
* @return {URLSearchParams}
|
|
1185
1279
|
*/
|
|
1186
|
-
function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, }) {
|
|
1280
|
+
function createParams({ action, batchModeEnabled, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, layout, }) {
|
|
1187
1281
|
if (disabledUiFeatures) {
|
|
1188
1282
|
disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
|
|
1189
1283
|
}
|
|
@@ -1196,6 +1290,9 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
|
|
|
1196
1290
|
if (operationMode) {
|
|
1197
1291
|
assert(validOperationMode(operationMode), `Invalid operation mode: ${operationMode}`);
|
|
1198
1292
|
}
|
|
1293
|
+
if (layout) {
|
|
1294
|
+
assert(validLayout(layout), `Invalid layout: ${layout}`);
|
|
1295
|
+
}
|
|
1199
1296
|
if (parts) {
|
|
1200
1297
|
parts.forEach((part) => assert(validTablePart(part), `Invalid table part: ${part}`));
|
|
1201
1298
|
}
|
|
@@ -1211,6 +1308,7 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
|
|
|
1211
1308
|
}
|
|
1212
1309
|
return new URLSearchParams({
|
|
1213
1310
|
...(action && { action }),
|
|
1311
|
+
...(batchModeEnabled && { batchModeEnabled: 'true' }),
|
|
1214
1312
|
...(dataType && { dataType }),
|
|
1215
1313
|
...(disabledUiFeatures && {
|
|
1216
1314
|
disabledUiFeatures: disabledUiFeatures.join(),
|
|
@@ -1237,6 +1335,7 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
|
|
|
1237
1335
|
...(snapping?.types?.length && { snappingTypes: snapping.types.join() }),
|
|
1238
1336
|
...(targetType && { targetType }),
|
|
1239
1337
|
...(useMapSrs && { useMapSrs: 'true' }),
|
|
1338
|
+
...(layout && { layout }),
|
|
1240
1339
|
});
|
|
1241
1340
|
}
|
|
1242
1341
|
function array(/** @type unknown */ value) {
|
|
@@ -1244,31 +1343,27 @@ function array(/** @type unknown */ value) {
|
|
|
1244
1343
|
}
|
|
1245
1344
|
/**
|
|
1246
1345
|
* Creates a valid extent strategy based on these rules:
|
|
1247
|
-
* - `extentStrategy` trumps `geometry
|
|
1248
|
-
* - `
|
|
1249
|
-
* {@link StaticExtentStrategy#extent}, {@link LocationFinderExtentStrategy#query},
|
|
1250
|
-
* and {@link GeometryExtentStrategy#geometry} respectively.
|
|
1346
|
+
* - `extentStrategy` trumps `geometry`.
|
|
1347
|
+
* - `geometry` is used as fallback for {@link GeometryExtentStrategy#geometry}.
|
|
1251
1348
|
*
|
|
1252
1349
|
* If the result is not a valid extent strategy, the return value is undefined.
|
|
1253
1350
|
*
|
|
1254
1351
|
* @param {object} __namedParameters
|
|
1255
1352
|
* @param {Geometry} [__namedParameters.geometry]
|
|
1256
|
-
* @param {string} [__namedParameters.locationFinder]
|
|
1257
|
-
* @param {Extent} [__namedParameters.mapExtent]
|
|
1258
1353
|
* @param {ExtentStrategy} [__namedParameters.extentStrategy]
|
|
1259
1354
|
* @return {ExtentStrategy | undefined}
|
|
1260
1355
|
*/
|
|
1261
|
-
function sanitizeExtentStrategy({ extentStrategy,
|
|
1356
|
+
function sanitizeExtentStrategy({ extentStrategy, geometry } = {}) {
|
|
1262
1357
|
if (extentStrategy) {
|
|
1263
1358
|
switch (extentStrategy.type) {
|
|
1264
1359
|
case 'static':
|
|
1265
|
-
const extent = extentStrategy.extent
|
|
1360
|
+
const extent = extentStrategy.extent;
|
|
1266
1361
|
if (extent) {
|
|
1267
1362
|
return { type: 'static', extent };
|
|
1268
1363
|
}
|
|
1269
1364
|
break;
|
|
1270
1365
|
case 'locationFinder':
|
|
1271
|
-
const query = extentStrategy.query
|
|
1366
|
+
const query = extentStrategy.query;
|
|
1272
1367
|
if (query) {
|
|
1273
1368
|
return { type: 'locationFinder', query };
|
|
1274
1369
|
}
|
|
@@ -1286,12 +1381,20 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
|
|
|
1286
1381
|
if (geometry) {
|
|
1287
1382
|
return { type: 'geometry', geometry };
|
|
1288
1383
|
}
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Retrieves the {@link GeometryType} of the provided feature collection.
|
|
1387
|
+
* All provided features must have geometries of the same type.
|
|
1388
|
+
*
|
|
1389
|
+
* @param {FeatureCollection} featureCollection - The feature collection to validate.
|
|
1390
|
+
*/
|
|
1391
|
+
function getGeometryTypeFromFeatureCollection(featureCollection) {
|
|
1392
|
+
const features = featureCollection.features;
|
|
1393
|
+
assert(features.length > 0, 'Feature collection is empty');
|
|
1394
|
+
const geometryType = features[0].geometry.type;
|
|
1395
|
+
assertValidGeometryType(geometryType);
|
|
1396
|
+
assert(features.every((feature) => feature.geometry.type === geometryType), 'Geometries are not of the same type');
|
|
1397
|
+
return geometryType;
|
|
1295
1398
|
}
|
|
1296
1399
|
// Please do not add internal event types like 'ready' here.
|
|
1297
1400
|
/**
|