@disy/cadenza.js 10.4.1 → 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 +9 -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 +67 -71
- 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 +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 +2 -2
- package/apidoc/types/WorkbookLayerPath.html +2 -2
- package/cadenza.d.ts +88 -67
- package/cadenza.js +166 -78
- package/package.json +1 -1
- package/sandbox.html +98 -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
|
*
|
|
@@ -223,8 +235,6 @@ let firstEmbeddingTargetShown;
|
|
|
223
235
|
* When aborted, the result Promise is rejected with an {@link AbortError}.
|
|
224
236
|
* * If there's another error, the result Promise is rejected with a {@link CadenzaError}.
|
|
225
237
|
* * 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
238
|
*/
|
|
229
239
|
// Must be exported to be included in the docs.
|
|
230
240
|
export class CadenzaClient {
|
|
@@ -382,8 +392,6 @@ export class CadenzaClient {
|
|
|
382
392
|
* @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
|
|
383
393
|
* @param {boolean} [__namedParameters.hideWorkbookToolBar] - Whether to hide the workbook toolbar
|
|
384
394
|
* @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
395
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
388
396
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
389
397
|
* @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 +402,7 @@ export class CadenzaClient {
|
|
|
394
402
|
* - {@link CadenzaActionEvent}
|
|
395
403
|
* @embed
|
|
396
404
|
*/
|
|
397
|
-
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, } = {}) {
|
|
398
406
|
this.#log('CadenzaClient#showMap', ...arguments);
|
|
399
407
|
if (geometry) {
|
|
400
408
|
assertValidGeometryType(geometry.type);
|
|
@@ -402,8 +410,6 @@ export class CadenzaClient {
|
|
|
402
410
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
403
411
|
extentStrategy,
|
|
404
412
|
geometry,
|
|
405
|
-
locationFinder,
|
|
406
|
-
mapExtent,
|
|
407
413
|
});
|
|
408
414
|
const params = createParams({
|
|
409
415
|
disabledUiFeatures,
|
|
@@ -445,16 +451,19 @@ export class CadenzaClient {
|
|
|
445
451
|
*
|
|
446
452
|
* Currently, only map views are supported.
|
|
447
453
|
*
|
|
448
|
-
* @hidden
|
|
449
454
|
* @template {DataType} T
|
|
450
|
-
* @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.
|
|
451
460
|
* @return {Promise<T extends 'png' ? Blob : never>}
|
|
452
461
|
* @postMessage
|
|
453
462
|
*/
|
|
454
|
-
async getData(dataType) {
|
|
463
|
+
async getData(dataType, { width, height, withScale } = {}) {
|
|
455
464
|
this.#log('CadenzaClient#getData', ...arguments);
|
|
456
465
|
assertSupportedDataType(dataType, ['png']);
|
|
457
|
-
return this.#postRequest('getData', { dataType });
|
|
466
|
+
return this.#postRequest('getData', { dataType, width, height, withScale });
|
|
458
467
|
}
|
|
459
468
|
/**
|
|
460
469
|
* Set filter variables in the currently shown workbook.
|
|
@@ -557,19 +566,7 @@ export class CadenzaClient {
|
|
|
557
566
|
*
|
|
558
567
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
559
568
|
* @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
|
|
569
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
573
570
|
* @throws For invalid arguments
|
|
574
571
|
* @fires
|
|
575
572
|
* - {@link CadenzaEditGeometryUpdateEvent}
|
|
@@ -577,12 +574,10 @@ export class CadenzaClient {
|
|
|
577
574
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
578
575
|
* @embed
|
|
579
576
|
*/
|
|
580
|
-
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter,
|
|
577
|
+
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, useMapSrs, operationMode, signal, snapping, } = {}) {
|
|
581
578
|
this.#log('CadenzaClient#createGeometry', ...arguments);
|
|
582
579
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
583
580
|
extentStrategy,
|
|
584
|
-
locationFinder,
|
|
585
|
-
mapExtent,
|
|
586
581
|
});
|
|
587
582
|
const params = createParams({
|
|
588
583
|
action: 'editGeometry',
|
|
@@ -596,30 +591,18 @@ export class CadenzaClient {
|
|
|
596
591
|
validExtentStrategy,
|
|
597
592
|
});
|
|
598
593
|
await this.#show(resolvePath(backgroundMapView), params, signal);
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
this.#setExtentStrategy(validExtentStrategy);
|
|
594
|
+
await this.#setupEditorViaPostRequests({
|
|
595
|
+
additionalLayers,
|
|
596
|
+
validExtentStrategy,
|
|
597
|
+
});
|
|
598
|
+
await this.#setEditorStateToReady();
|
|
605
599
|
}
|
|
606
600
|
/**
|
|
607
601
|
* Edit a geometry.
|
|
608
602
|
*
|
|
609
603
|
* @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)
|
|
604
|
+
* @param {Geometry} geometry - The geometry to edit
|
|
605
|
+
* @param {CommonEditGeometryOptions} [editGeometryOptions] - Options for the initialization of the geometry editor.
|
|
623
606
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
624
607
|
* @throws For invalid arguments
|
|
625
608
|
* @fires
|
|
@@ -628,19 +611,99 @@ export class CadenzaClient {
|
|
|
628
611
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
629
612
|
* @embed
|
|
630
613
|
*/
|
|
631
|
-
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter,
|
|
614
|
+
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
632
615
|
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
633
|
-
|
|
616
|
+
const geometryType = geometry.type;
|
|
617
|
+
assertValidGeometryType(geometryType);
|
|
634
618
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
635
619
|
extentStrategy,
|
|
636
620
|
geometry,
|
|
637
|
-
locationFinder,
|
|
638
|
-
mapExtent,
|
|
639
621
|
});
|
|
640
622
|
const params = createParams({
|
|
641
623
|
action: 'editGeometry',
|
|
642
624
|
disabledUiFeatures,
|
|
643
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,
|
|
644
707
|
minScale,
|
|
645
708
|
operationMode,
|
|
646
709
|
snapping,
|
|
@@ -648,17 +711,41 @@ export class CadenzaClient {
|
|
|
648
711
|
validExtentStrategy,
|
|
649
712
|
});
|
|
650
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));
|
|
651
732
|
if (geometry) {
|
|
652
|
-
this.#
|
|
733
|
+
postRequests.push(this.#postRequest('setGeometry', {
|
|
653
734
|
geometry,
|
|
654
|
-
});
|
|
735
|
+
}));
|
|
655
736
|
}
|
|
656
737
|
if (additionalLayers) {
|
|
657
738
|
for (const layer of additionalLayers) {
|
|
658
|
-
|
|
739
|
+
postRequests.push(this.#postRequest('importLayer', layer));
|
|
659
740
|
}
|
|
660
741
|
}
|
|
661
|
-
|
|
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');
|
|
662
749
|
}
|
|
663
750
|
/**
|
|
664
751
|
* Set custom validity state of the geometry editor in addition to the default validation state (including errors and
|
|
@@ -682,8 +769,6 @@ export class CadenzaClient {
|
|
|
682
769
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
683
770
|
* @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
|
|
684
771
|
* (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
772
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
688
773
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
689
774
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
@@ -696,12 +781,9 @@ export class CadenzaClient {
|
|
|
696
781
|
* - {@link CadenzaSelectObjectsCancelEvent}
|
|
697
782
|
* @embed
|
|
698
783
|
*/
|
|
699
|
-
async selectObjects(backgroundMapView, { extentStrategy, filter, layers,
|
|
784
|
+
async selectObjects(backgroundMapView, { extentStrategy, filter, layers, useMapSrs, operationMode, signal } = {}) {
|
|
700
785
|
this.#log('CadenzaClient#selectObjects', ...arguments);
|
|
701
786
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
702
|
-
geometry: undefined,
|
|
703
|
-
locationFinder,
|
|
704
|
-
mapExtent,
|
|
705
787
|
extentStrategy,
|
|
706
788
|
});
|
|
707
789
|
const params = createParams({
|
|
@@ -719,7 +801,7 @@ export class CadenzaClient {
|
|
|
719
801
|
const type = extentStrategy?.type;
|
|
720
802
|
// Other extent strategies are handled via URL parameters.
|
|
721
803
|
if (type === 'geometry' || type === 'layerData') {
|
|
722
|
-
this.#
|
|
804
|
+
return this.#postRequest('setExtentStrategy', extentStrategy);
|
|
723
805
|
}
|
|
724
806
|
}
|
|
725
807
|
/**
|
|
@@ -1173,6 +1255,7 @@ function assertValidFilterVariables(/** @type {FilterVariables} */ filter) {
|
|
|
1173
1255
|
/**
|
|
1174
1256
|
* @param {object} params
|
|
1175
1257
|
* @param {string} [params.action]
|
|
1258
|
+
* @param {boolean} [params.batchModeEnabled]
|
|
1176
1259
|
* @param {DataType} [params.dataType]
|
|
1177
1260
|
* @param {UiFeature[]} [params.disabledUiFeatures]
|
|
1178
1261
|
* @param {boolean} [params.expandNavigator]
|
|
@@ -1194,7 +1277,7 @@ function assertValidFilterVariables(/** @type {FilterVariables} */ filter) {
|
|
|
1194
1277
|
* @param {Layout | undefined} [params.layout]
|
|
1195
1278
|
* @return {URLSearchParams}
|
|
1196
1279
|
*/
|
|
1197
|
-
function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, layout, }) {
|
|
1280
|
+
function createParams({ action, batchModeEnabled, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, layout, }) {
|
|
1198
1281
|
if (disabledUiFeatures) {
|
|
1199
1282
|
disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
|
|
1200
1283
|
}
|
|
@@ -1225,6 +1308,7 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
|
|
|
1225
1308
|
}
|
|
1226
1309
|
return new URLSearchParams({
|
|
1227
1310
|
...(action && { action }),
|
|
1311
|
+
...(batchModeEnabled && { batchModeEnabled: 'true' }),
|
|
1228
1312
|
...(dataType && { dataType }),
|
|
1229
1313
|
...(disabledUiFeatures && {
|
|
1230
1314
|
disabledUiFeatures: disabledUiFeatures.join(),
|
|
@@ -1259,31 +1343,27 @@ function array(/** @type unknown */ value) {
|
|
|
1259
1343
|
}
|
|
1260
1344
|
/**
|
|
1261
1345
|
* 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.
|
|
1346
|
+
* - `extentStrategy` trumps `geometry`.
|
|
1347
|
+
* - `geometry` is used as fallback for {@link GeometryExtentStrategy#geometry}.
|
|
1266
1348
|
*
|
|
1267
1349
|
* If the result is not a valid extent strategy, the return value is undefined.
|
|
1268
1350
|
*
|
|
1269
1351
|
* @param {object} __namedParameters
|
|
1270
1352
|
* @param {Geometry} [__namedParameters.geometry]
|
|
1271
|
-
* @param {string} [__namedParameters.locationFinder]
|
|
1272
|
-
* @param {Extent} [__namedParameters.mapExtent]
|
|
1273
1353
|
* @param {ExtentStrategy} [__namedParameters.extentStrategy]
|
|
1274
1354
|
* @return {ExtentStrategy | undefined}
|
|
1275
1355
|
*/
|
|
1276
|
-
function sanitizeExtentStrategy({ extentStrategy,
|
|
1356
|
+
function sanitizeExtentStrategy({ extentStrategy, geometry } = {}) {
|
|
1277
1357
|
if (extentStrategy) {
|
|
1278
1358
|
switch (extentStrategy.type) {
|
|
1279
1359
|
case 'static':
|
|
1280
|
-
const extent = extentStrategy.extent
|
|
1360
|
+
const extent = extentStrategy.extent;
|
|
1281
1361
|
if (extent) {
|
|
1282
1362
|
return { type: 'static', extent };
|
|
1283
1363
|
}
|
|
1284
1364
|
break;
|
|
1285
1365
|
case 'locationFinder':
|
|
1286
|
-
const query = extentStrategy.query
|
|
1366
|
+
const query = extentStrategy.query;
|
|
1287
1367
|
if (query) {
|
|
1288
1368
|
return { type: 'locationFinder', query };
|
|
1289
1369
|
}
|
|
@@ -1301,12 +1381,20 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
|
|
|
1301
1381
|
if (geometry) {
|
|
1302
1382
|
return { type: 'geometry', geometry };
|
|
1303
1383
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
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;
|
|
1310
1398
|
}
|
|
1311
1399
|
// Please do not add internal event types like 'ready' here.
|
|
1312
1400
|
/**
|