@disy/cadenza.js 10.4.1 → 10.4.3
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 +16 -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 +47 -77
- 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 +2 -2
- 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 +5 -2
- package/apidoc/types/WorkbookLayerPath.html +2 -2
- package/cadenza.d.ts +97 -71
- package/cadenza.js +176 -80
- package/package.json +1 -1
- package/sandbox.html +106 -45
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.3';
|
|
16
16
|
/**
|
|
17
17
|
* Creates an instance of the Cadenza JS client.
|
|
18
18
|
*
|
|
@@ -95,12 +95,15 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
|
|
|
95
95
|
*/
|
|
96
96
|
/** @typedef {'normal'|'simplified'} OperationMode - The mode in which a workbook should be operated */
|
|
97
97
|
/**
|
|
98
|
-
* @typedef {'workbook-design'|'workbook-map-add-layer'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature
|
|
98
|
+
* @typedef {'workbook-design'|'workbook-map-add-layer'|'workbook-view-management'|'embedded-dialog-footer-buttons'|'embedded-dialog-apply-button'|'embedded-dialog-cancel-button'} UiFeature - The name of a Cadenza UI feature
|
|
99
99
|
*
|
|
100
100
|
* _Note:_ Supported features are:
|
|
101
101
|
* * `"workbook-design"` - The workbook designer
|
|
102
102
|
* * `"workbook-map-add-layer"`- Add layers to the map
|
|
103
103
|
* * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
|
|
104
|
+
* * `"embedded-dialog-footer-buttons"` - All footer buttons for Create/Edit Geometries and Select Objects dialogs
|
|
105
|
+
* * `"embedded-dialog-apply-button"` - Apply button for Create/Edit Geometries and Select Objects dialogs
|
|
106
|
+
* * `"embedded-dialog-cancel-button"` - Cancel button for Create/Edit Geometries and Select Objects dialogs
|
|
104
107
|
* */
|
|
105
108
|
/**
|
|
106
109
|
* @typedef LayerDefinition
|
|
@@ -158,6 +161,18 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
|
|
|
158
161
|
* @property {'static'} type - The extent strategy type
|
|
159
162
|
* @property {Extent} extent - This extent takes precedence over another extent that might be given in an API call.
|
|
160
163
|
*/
|
|
164
|
+
/**
|
|
165
|
+
* @typedef CommonEditGeometryOptions - Common options for the initialization of the geometry editor.
|
|
166
|
+
* @property {LayerDefinition[]} [additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
167
|
+
* @property {UiFeature[]} [disabledUiFeatures] - Cadenza UI features to disable
|
|
168
|
+
* @property {ExtentStrategy} [extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
169
|
+
* @property {FilterVariables} [filter] - Filter variables
|
|
170
|
+
* @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.
|
|
171
|
+
* @property {OperationMode} [operationMode] - The mode in which a workbook should be operated
|
|
172
|
+
* @property {AbortSignal} [signal] - A signal to abort the iframe loading
|
|
173
|
+
* @property {SnappingOptions} [snapping] - Passing these options enables snapping
|
|
174
|
+
* @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)
|
|
175
|
+
*/
|
|
161
176
|
/**
|
|
162
177
|
* @typedef {'csv' | 'excel' | 'json' | 'pdf' | 'png'} DataType - A data type
|
|
163
178
|
*
|
|
@@ -223,8 +238,6 @@ let firstEmbeddingTargetShown;
|
|
|
223
238
|
* When aborted, the result Promise is rejected with an {@link AbortError}.
|
|
224
239
|
* * If there's another error, the result Promise is rejected with a {@link CadenzaError}.
|
|
225
240
|
* * For methods that support the `hideMainHeaderAndFooter` and `hideWorkbookToolBar` parameters - the parameters cannot override the configuration of an embedding target.
|
|
226
|
-
* * For methods that support the _deprecated_ `locationFinder` and `mapExtent` parameters - when both are given, the `mapExtent` takes precedence.
|
|
227
|
-
* * Both `locationFinder` and `mapExtent` parameters are _deprecated_ - Use {@link LocationFinderExtentStrategy} or {@link StaticExtentStrategy} instead.
|
|
228
241
|
*/
|
|
229
242
|
// Must be exported to be included in the docs.
|
|
230
243
|
export class CadenzaClient {
|
|
@@ -382,8 +395,6 @@ export class CadenzaClient {
|
|
|
382
395
|
* @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
|
|
383
396
|
* @param {boolean} [__namedParameters.hideWorkbookToolBar] - Whether to hide the workbook toolbar
|
|
384
397
|
* @param {GlobalId} [__namedParameters.highlightGlobalId] - The ID of an item to highlight / expand in the navigator
|
|
385
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
386
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
387
398
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
388
399
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
389
400
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
@@ -394,7 +405,7 @@ export class CadenzaClient {
|
|
|
394
405
|
* - {@link CadenzaActionEvent}
|
|
395
406
|
* @embed
|
|
396
407
|
*/
|
|
397
|
-
async showMap(mapView, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId,
|
|
408
|
+
async showMap(mapView, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, operationMode, useMapSrs, signal, } = {}) {
|
|
398
409
|
this.#log('CadenzaClient#showMap', ...arguments);
|
|
399
410
|
if (geometry) {
|
|
400
411
|
assertValidGeometryType(geometry.type);
|
|
@@ -402,8 +413,6 @@ export class CadenzaClient {
|
|
|
402
413
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
403
414
|
extentStrategy,
|
|
404
415
|
geometry,
|
|
405
|
-
locationFinder,
|
|
406
|
-
mapExtent,
|
|
407
416
|
});
|
|
408
417
|
const params = createParams({
|
|
409
418
|
disabledUiFeatures,
|
|
@@ -445,16 +454,19 @@ export class CadenzaClient {
|
|
|
445
454
|
*
|
|
446
455
|
* Currently, only map views are supported.
|
|
447
456
|
*
|
|
448
|
-
* @hidden
|
|
449
457
|
* @template {DataType} T
|
|
450
|
-
* @param {
|
|
458
|
+
* @param {DataType} dataType - The requested data type. Currently, only `"png"` is
|
|
459
|
+
* @param {object} [__namedParameters] - Options
|
|
460
|
+
* @param {number} [__namedParameters.width] - The width of the resulting map image in px.
|
|
461
|
+
* @param {number} [__namedParameters.height] - The height of the resulting map image in px.
|
|
462
|
+
* @param {boolean} [__namedParameters.withScale] - Whether to show the scale line and the scale on the map image.
|
|
451
463
|
* @return {Promise<T extends 'png' ? Blob : never>}
|
|
452
464
|
* @postMessage
|
|
453
465
|
*/
|
|
454
|
-
async getData(dataType) {
|
|
466
|
+
async getData(dataType, { width, height, withScale } = {}) {
|
|
455
467
|
this.#log('CadenzaClient#getData', ...arguments);
|
|
456
468
|
assertSupportedDataType(dataType, ['png']);
|
|
457
|
-
return this.#postRequest('getData', { dataType });
|
|
469
|
+
return this.#postRequest('getData', { dataType, width, height, withScale });
|
|
458
470
|
}
|
|
459
471
|
/**
|
|
460
472
|
* Set filter variables in the currently shown workbook.
|
|
@@ -557,19 +569,7 @@ export class CadenzaClient {
|
|
|
557
569
|
*
|
|
558
570
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
559
571
|
* @param {GeometryType} geometryType - The geometry type
|
|
560
|
-
* @param {
|
|
561
|
-
* @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
562
|
-
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
563
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
564
|
-
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
565
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
566
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
567
|
-
* @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.
|
|
568
|
-
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
569
|
-
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
570
|
-
* @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
|
|
571
|
-
* @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)
|
|
572
|
-
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
572
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
573
573
|
* @throws For invalid arguments
|
|
574
574
|
* @fires
|
|
575
575
|
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
@@ -577,12 +577,10 @@ export class CadenzaClient {
|
|
|
577
577
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
578
578
|
* @embed
|
|
579
579
|
*/
|
|
580
|
-
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter,
|
|
580
|
+
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, useMapSrs, operationMode, signal, snapping, } = {}) {
|
|
581
581
|
this.#log('CadenzaClient#createGeometry', ...arguments);
|
|
582
582
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
583
583
|
extentStrategy,
|
|
584
|
-
locationFinder,
|
|
585
|
-
mapExtent,
|
|
586
584
|
});
|
|
587
585
|
const params = createParams({
|
|
588
586
|
action: 'editGeometry',
|
|
@@ -596,30 +594,18 @@ export class CadenzaClient {
|
|
|
596
594
|
validExtentStrategy,
|
|
597
595
|
});
|
|
598
596
|
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
this.#setExtentStrategy(validExtentStrategy);
|
|
597
|
+
await this.#setupEditorViaPostRequests({
|
|
598
|
+
additionalLayers,
|
|
599
|
+
validExtentStrategy,
|
|
600
|
+
});
|
|
601
|
+
await this.#setEditorStateToReady();
|
|
605
602
|
}
|
|
606
603
|
/**
|
|
607
604
|
* Edit a geometry.
|
|
608
605
|
*
|
|
609
606
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
610
|
-
* @param {Geometry} geometry - The geometry
|
|
611
|
-
* @param {
|
|
612
|
-
* @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).
|
|
613
|
-
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
614
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
615
|
-
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
616
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
617
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
618
|
-
* @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.
|
|
619
|
-
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
620
|
-
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
621
|
-
* @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
|
|
622
|
-
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
607
|
+
* @param {Geometry} geometry - The geometry to edit
|
|
608
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
623
609
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
624
610
|
* @throws For invalid arguments
|
|
625
611
|
* @fires
|
|
@@ -628,19 +614,59 @@ export class CadenzaClient {
|
|
|
628
614
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
629
615
|
* @embed
|
|
630
616
|
*/
|
|
631
|
-
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter,
|
|
617
|
+
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
632
618
|
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
633
|
-
|
|
619
|
+
const geometryType = geometry.type;
|
|
620
|
+
assertValidGeometryType(geometryType);
|
|
634
621
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
635
622
|
extentStrategy,
|
|
636
623
|
geometry,
|
|
637
|
-
locationFinder,
|
|
638
|
-
mapExtent,
|
|
639
624
|
});
|
|
640
625
|
const params = createParams({
|
|
641
626
|
action: 'editGeometry',
|
|
642
627
|
disabledUiFeatures,
|
|
643
628
|
filter,
|
|
629
|
+
geometryType,
|
|
630
|
+
minScale,
|
|
631
|
+
operationMode,
|
|
632
|
+
snapping,
|
|
633
|
+
useMapSrs,
|
|
634
|
+
validExtentStrategy,
|
|
635
|
+
});
|
|
636
|
+
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
637
|
+
await this.#setupEditorViaPostRequests({
|
|
638
|
+
additionalLayers,
|
|
639
|
+
validExtentStrategy,
|
|
640
|
+
geometry,
|
|
641
|
+
});
|
|
642
|
+
await this.#setEditorStateToReady();
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Create multiple geometries.
|
|
646
|
+
*
|
|
647
|
+
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
648
|
+
* @param {GeometryType} geometryType - The type of geometries to create
|
|
649
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
650
|
+
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
651
|
+
* @throws For invalid arguments
|
|
652
|
+
* @fires
|
|
653
|
+
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
654
|
+
* - {@link CadenzaEditGeometryOkEvent}
|
|
655
|
+
* - {@link CadenzaEditGeometryCancelEvent}
|
|
656
|
+
* @embed
|
|
657
|
+
*/
|
|
658
|
+
async batchCreateGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
659
|
+
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
660
|
+
assertValidGeometryType(geometryType);
|
|
661
|
+
const validExtentStrategy = sanitizeExtentStrategy({
|
|
662
|
+
extentStrategy,
|
|
663
|
+
});
|
|
664
|
+
const params = createParams({
|
|
665
|
+
action: 'editGeometry',
|
|
666
|
+
batchModeEnabled: true,
|
|
667
|
+
disabledUiFeatures,
|
|
668
|
+
filter,
|
|
669
|
+
geometryType,
|
|
644
670
|
minScale,
|
|
645
671
|
operationMode,
|
|
646
672
|
snapping,
|
|
@@ -648,17 +674,81 @@ export class CadenzaClient {
|
|
|
648
674
|
validExtentStrategy,
|
|
649
675
|
});
|
|
650
676
|
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
677
|
+
await this.#setupEditorViaPostRequests({
|
|
678
|
+
additionalLayers,
|
|
679
|
+
validExtentStrategy,
|
|
680
|
+
});
|
|
681
|
+
await this.#setEditorStateToReady();
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Edit multiple geometries.
|
|
685
|
+
*
|
|
686
|
+
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
687
|
+
* @param {FeatureCollection} features - The features to edit. The last feature in this collection is directly set up for editing.
|
|
688
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
689
|
+
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
690
|
+
* @throws For invalid arguments
|
|
691
|
+
* @fires
|
|
692
|
+
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
693
|
+
* - {@link CadenzaEditGeometryOkEvent}
|
|
694
|
+
* - {@link CadenzaEditGeometryCancelEvent}
|
|
695
|
+
* @embed
|
|
696
|
+
*/
|
|
697
|
+
async batchEditGeometry(backgroundMapView, features, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
698
|
+
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
699
|
+
const geometryType = getGeometryTypeFromFeatureCollection(features);
|
|
700
|
+
const validExtentStrategy = sanitizeExtentStrategy({
|
|
701
|
+
extentStrategy,
|
|
702
|
+
geometry: features.features[features.features.length - 1].geometry,
|
|
703
|
+
});
|
|
704
|
+
const params = createParams({
|
|
705
|
+
action: 'editGeometry',
|
|
706
|
+
batchModeEnabled: true,
|
|
707
|
+
disabledUiFeatures,
|
|
708
|
+
filter,
|
|
709
|
+
geometryType,
|
|
710
|
+
minScale,
|
|
711
|
+
operationMode,
|
|
712
|
+
snapping,
|
|
713
|
+
useMapSrs,
|
|
714
|
+
validExtentStrategy,
|
|
715
|
+
});
|
|
716
|
+
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
717
|
+
await this.#setupEditorViaPostRequests({
|
|
718
|
+
additionalLayers,
|
|
719
|
+
validExtentStrategy,
|
|
720
|
+
features,
|
|
721
|
+
});
|
|
722
|
+
await this.#setEditorStateToReady();
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* @param {object} __namedParameters - Options
|
|
726
|
+
* @param [__namedParameters.geometry] {Geometry} - The geometry to edit
|
|
727
|
+
* @param [__namedParameters.additionalLayers] {LayerDefinition[]} - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
728
|
+
* @param [__namedParameters.validExtentStrategy] {ExtentStrategy} - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
729
|
+
* @param [__namedParameters.features] {FeatureCollection} - The features to edit. The last feature in this collection is directly set up for editing.
|
|
730
|
+
* @returns {Promise<Awaited<unknown>[]>}
|
|
731
|
+
*/
|
|
732
|
+
#setupEditorViaPostRequests({ geometry, additionalLayers, validExtentStrategy, features, }) {
|
|
733
|
+
const postRequests = [];
|
|
734
|
+
postRequests.push(this.#setExtentStrategy(validExtentStrategy));
|
|
651
735
|
if (geometry) {
|
|
652
|
-
this.#
|
|
736
|
+
postRequests.push(this.#postRequest('setGeometry', {
|
|
653
737
|
geometry,
|
|
654
|
-
});
|
|
738
|
+
}));
|
|
655
739
|
}
|
|
656
740
|
if (additionalLayers) {
|
|
657
741
|
for (const layer of additionalLayers) {
|
|
658
|
-
|
|
742
|
+
postRequests.push(this.#postRequest('importLayer', layer));
|
|
659
743
|
}
|
|
660
744
|
}
|
|
661
|
-
|
|
745
|
+
if (features) {
|
|
746
|
+
postRequests.push(this.#postRequest('addFeatures', features));
|
|
747
|
+
}
|
|
748
|
+
return Promise.all(postRequests);
|
|
749
|
+
}
|
|
750
|
+
#setEditorStateToReady() {
|
|
751
|
+
return this.#postRequest('setEditorState', 'READY');
|
|
662
752
|
}
|
|
663
753
|
/**
|
|
664
754
|
* Set custom validity state of the geometry editor in addition to the default validation state (including errors and
|
|
@@ -678,12 +768,11 @@ export class CadenzaClient {
|
|
|
678
768
|
*
|
|
679
769
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view
|
|
680
770
|
* @param {object} [__namedParameters] - Options
|
|
771
|
+
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
681
772
|
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
682
773
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
683
774
|
* @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
|
|
684
775
|
* (identified using layer paths or print names)
|
|
685
|
-
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
686
|
-
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
687
776
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
688
777
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
689
778
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
@@ -696,16 +785,14 @@ export class CadenzaClient {
|
|
|
696
785
|
* - {@link CadenzaSelectObjectsCancelEvent}
|
|
697
786
|
* @embed
|
|
698
787
|
*/
|
|
699
|
-
async selectObjects(backgroundMapView, { extentStrategy, filter, layers,
|
|
788
|
+
async selectObjects(backgroundMapView, { disabledUiFeatures, extentStrategy, filter, layers, useMapSrs, operationMode, signal, } = {}) {
|
|
700
789
|
this.#log('CadenzaClient#selectObjects', ...arguments);
|
|
701
790
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
702
|
-
geometry: undefined,
|
|
703
|
-
locationFinder,
|
|
704
|
-
mapExtent,
|
|
705
791
|
extentStrategy,
|
|
706
792
|
});
|
|
707
793
|
const params = createParams({
|
|
708
794
|
action: 'selectObjects',
|
|
795
|
+
disabledUiFeatures,
|
|
709
796
|
filter,
|
|
710
797
|
layers: layers?.map(array),
|
|
711
798
|
useMapSrs,
|
|
@@ -719,7 +806,7 @@ export class CadenzaClient {
|
|
|
719
806
|
const type = extentStrategy?.type;
|
|
720
807
|
// Other extent strategies are handled via URL parameters.
|
|
721
808
|
if (type === 'geometry' || type === 'layerData') {
|
|
722
|
-
this.#
|
|
809
|
+
return this.#postRequest('setExtentStrategy', extentStrategy);
|
|
723
810
|
}
|
|
724
811
|
}
|
|
725
812
|
/**
|
|
@@ -1141,6 +1228,9 @@ function validUiFeature(/** @type string */ value) {
|
|
|
1141
1228
|
'workbook-design',
|
|
1142
1229
|
'workbook-map-add-layer',
|
|
1143
1230
|
'workbook-view-management',
|
|
1231
|
+
'embedded-dialog-footer-buttons',
|
|
1232
|
+
'embedded-dialog-apply-button',
|
|
1233
|
+
'embedded-dialog-cancel-button',
|
|
1144
1234
|
].includes(value);
|
|
1145
1235
|
}
|
|
1146
1236
|
function assertSupportedDataType(
|
|
@@ -1173,6 +1263,7 @@ function assertValidFilterVariables(/** @type {FilterVariables} */ filter) {
|
|
|
1173
1263
|
/**
|
|
1174
1264
|
* @param {object} params
|
|
1175
1265
|
* @param {string} [params.action]
|
|
1266
|
+
* @param {boolean} [params.batchModeEnabled]
|
|
1176
1267
|
* @param {DataType} [params.dataType]
|
|
1177
1268
|
* @param {UiFeature[]} [params.disabledUiFeatures]
|
|
1178
1269
|
* @param {boolean} [params.expandNavigator]
|
|
@@ -1194,7 +1285,7 @@ function assertValidFilterVariables(/** @type {FilterVariables} */ filter) {
|
|
|
1194
1285
|
* @param {Layout | undefined} [params.layout]
|
|
1195
1286
|
* @return {URLSearchParams}
|
|
1196
1287
|
*/
|
|
1197
|
-
function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, layout, }) {
|
|
1288
|
+
function createParams({ action, batchModeEnabled, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, layout, }) {
|
|
1198
1289
|
if (disabledUiFeatures) {
|
|
1199
1290
|
disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
|
|
1200
1291
|
}
|
|
@@ -1225,6 +1316,7 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
|
|
|
1225
1316
|
}
|
|
1226
1317
|
return new URLSearchParams({
|
|
1227
1318
|
...(action && { action }),
|
|
1319
|
+
...(batchModeEnabled && { batchModeEnabled: 'true' }),
|
|
1228
1320
|
...(dataType && { dataType }),
|
|
1229
1321
|
...(disabledUiFeatures && {
|
|
1230
1322
|
disabledUiFeatures: disabledUiFeatures.join(),
|
|
@@ -1259,31 +1351,27 @@ function array(/** @type unknown */ value) {
|
|
|
1259
1351
|
}
|
|
1260
1352
|
/**
|
|
1261
1353
|
* Creates a valid extent strategy based on these rules:
|
|
1262
|
-
* - `extentStrategy` trumps `geometry
|
|
1263
|
-
* - `
|
|
1264
|
-
* {@link StaticExtentStrategy#extent}, {@link LocationFinderExtentStrategy#query},
|
|
1265
|
-
* and {@link GeometryExtentStrategy#geometry} respectively.
|
|
1354
|
+
* - `extentStrategy` trumps `geometry`.
|
|
1355
|
+
* - `geometry` is used as fallback for {@link GeometryExtentStrategy#geometry}.
|
|
1266
1356
|
*
|
|
1267
1357
|
* If the result is not a valid extent strategy, the return value is undefined.
|
|
1268
1358
|
*
|
|
1269
1359
|
* @param {object} __namedParameters
|
|
1270
1360
|
* @param {Geometry} [__namedParameters.geometry]
|
|
1271
|
-
* @param {string} [__namedParameters.locationFinder]
|
|
1272
|
-
* @param {Extent} [__namedParameters.mapExtent]
|
|
1273
1361
|
* @param {ExtentStrategy} [__namedParameters.extentStrategy]
|
|
1274
1362
|
* @return {ExtentStrategy | undefined}
|
|
1275
1363
|
*/
|
|
1276
|
-
function sanitizeExtentStrategy({ extentStrategy,
|
|
1364
|
+
function sanitizeExtentStrategy({ extentStrategy, geometry } = {}) {
|
|
1277
1365
|
if (extentStrategy) {
|
|
1278
1366
|
switch (extentStrategy.type) {
|
|
1279
1367
|
case 'static':
|
|
1280
|
-
const extent = extentStrategy.extent
|
|
1368
|
+
const extent = extentStrategy.extent;
|
|
1281
1369
|
if (extent) {
|
|
1282
1370
|
return { type: 'static', extent };
|
|
1283
1371
|
}
|
|
1284
1372
|
break;
|
|
1285
1373
|
case 'locationFinder':
|
|
1286
|
-
const query = extentStrategy.query
|
|
1374
|
+
const query = extentStrategy.query;
|
|
1287
1375
|
if (query) {
|
|
1288
1376
|
return { type: 'locationFinder', query };
|
|
1289
1377
|
}
|
|
@@ -1301,12 +1389,20 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
|
|
|
1301
1389
|
if (geometry) {
|
|
1302
1390
|
return { type: 'geometry', geometry };
|
|
1303
1391
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1394
|
+
* Retrieves the {@link GeometryType} of the provided feature collection.
|
|
1395
|
+
* All provided features must have geometries of the same type.
|
|
1396
|
+
*
|
|
1397
|
+
* @param {FeatureCollection} featureCollection - The feature collection to validate.
|
|
1398
|
+
*/
|
|
1399
|
+
function getGeometryTypeFromFeatureCollection(featureCollection) {
|
|
1400
|
+
const features = featureCollection.features;
|
|
1401
|
+
assert(features.length > 0, 'Feature collection is empty');
|
|
1402
|
+
const geometryType = features[0].geometry.type;
|
|
1403
|
+
assertValidGeometryType(geometryType);
|
|
1404
|
+
assert(features.every((feature) => feature.geometry.type === geometryType), 'Geometries are not of the same type');
|
|
1405
|
+
return geometryType;
|
|
1310
1406
|
}
|
|
1311
1407
|
// Please do not add internal event types like 'ready' here.
|
|
1312
1408
|
/**
|
|
@@ -1367,7 +1463,7 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
|
|
|
1367
1463
|
* See also: <a href="../index.html#md:json-representation-of-cadenza-object-data">JSON Representation of Cadenza Object Data</a>
|
|
1368
1464
|
*/
|
|
1369
1465
|
/** @typedef {CadenzaEvent<'editGeometry:update', FeatureCollection | Feature | undefined>} CadenzaEditGeometryUpdateEvent - When the user changed the geometry. `FeatureCollection` if multiple features are present on the edit layer, but the original defined type is not multi-geometry. This is also the case if the dialog was instantiated from a geometry and the original defined type is inherited. `undefined` if no feature is present on the edit layer. */
|
|
1370
|
-
/** @typedef {CadenzaEvent<'editGeometry:ok', Feature>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */
|
|
1466
|
+
/** @typedef {CadenzaEvent<'editGeometry:ok', FeatureCollection | Feature>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. `FeatureCollection` if batch editing is enabled. */
|
|
1371
1467
|
/** @typedef {CadenzaEvent<'editGeometry:cancel'>} CadenzaEditGeometryCancelEvent - When the user cancelled the geometry editing. */
|
|
1372
1468
|
/** @typedef {CadenzaEvent<'error', {type: string, message?: string}>} CadenzaErrorEvent - An error event that is mapped to a {@link CadenzaError} */
|
|
1373
1469
|
/** @typedef {CadenzaEvent<'objectInfo', {layer: WorkbookLayerPath, objectInfos: {selectionIndex: number, elements: {attributePrintName: string, formattedValue: string}[]}}>} CadenzaObjectInfoEvent - When the user opened the object info flyout. */
|