@disy/cadenza.js 10.2.8 → 10.2.10
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 +10 -0
- package/apidoc/assets/hierarchy.js +1 -0
- package/apidoc/assets/icons.js +17 -14
- package/apidoc/assets/icons.svg +1 -1
- package/apidoc/assets/main.js +5 -4
- package/apidoc/assets/navigation.js +1 -1
- package/apidoc/assets/search.js +1 -1
- package/apidoc/assets/style.css +1423 -1224
- package/apidoc/classes/AbortError.html +60 -60
- package/apidoc/classes/CadenzaClient.html +164 -188
- package/apidoc/classes/CadenzaError.html +15 -16
- package/apidoc/functions/cadenza.html +10 -9
- package/apidoc/index.html +146 -118
- package/apidoc/interfaces/CadenzaClientOptions.html +14 -14
- package/apidoc/interfaces/CadenzaEvent.html +6 -6
- package/apidoc/interfaces/Distance.html +3 -3
- package/apidoc/interfaces/ExternalLinkKey.html +8 -7
- package/apidoc/interfaces/Feature.html +16 -16
- package/apidoc/interfaces/FeatureCollection.html +6 -6
- package/apidoc/interfaces/Geometry.html +6 -6
- package/apidoc/interfaces/GeometryExtentStrategy.html +6 -6
- package/apidoc/interfaces/LayerDataExtentStrategy.html +7 -7
- package/apidoc/interfaces/LayerDefinition.html +7 -7
- package/apidoc/interfaces/LocationFinderExtentStrategy.html +6 -6
- package/apidoc/interfaces/PageSource.html +4 -4
- package/apidoc/interfaces/SnappingOptions.html +5 -0
- package/apidoc/interfaces/StaticExtentStrategy.html +6 -6
- package/apidoc/modules.html +1 -46
- 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 +3 -3
- package/apidoc/types/Extent.html +2 -2
- package/apidoc/types/ExtentStrategy.html +5 -5
- package/apidoc/types/FilterVariables.html +2 -2
- package/apidoc/types/GeometryType.html +2 -2
- package/apidoc/types/GlobalId.html +2 -2
- package/apidoc/types/LengthUnit.html +1 -1
- package/apidoc/types/OpaqueString.html +4 -4
- package/apidoc/types/OperationMode.html +2 -2
- package/apidoc/types/TablePart.html +2 -2
- package/apidoc/types/UiFeature.html +3 -3
- package/apidoc/types/WorkbookLayerPath.html +3 -3
- package/cadenza.d.ts +71 -27
- package/cadenza.js +69 -36
- package/package.json +8 -8
- package/sandbox.html +69 -27
package/cadenza.js
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* Please ensure that the user has view privilege for that link!
|
|
11
11
|
* @property {boolean} [options.debug] - Whether to enable debug logging
|
|
12
12
|
*/
|
|
13
|
+
// This placeholder is replaced when Cadenza JS is released,
|
|
14
|
+
// i.e. during development, the version is not available.
|
|
15
|
+
const CADENZAJS_VERSION = '10.2.10';
|
|
13
16
|
/**
|
|
14
17
|
* Creates an instance of the Cadenza JS client.
|
|
15
18
|
*
|
|
@@ -40,9 +43,11 @@ export function cadenza(baseUrlOrOptions, options) {
|
|
|
40
43
|
: baseUrlOrOptions;
|
|
41
44
|
return new CadenzaClient(options);
|
|
42
45
|
}
|
|
46
|
+
cadenza.version = CADENZAJS_VERSION;
|
|
43
47
|
/* @ts-ignore */
|
|
44
48
|
const previousGlobalCadenza = globalThis.cadenza;
|
|
45
49
|
globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) => cadenza(...args), {
|
|
50
|
+
version: CADENZAJS_VERSION,
|
|
46
51
|
noConflict() {
|
|
47
52
|
globalThis.cadenza = previousGlobalCadenza;
|
|
48
53
|
return cadenza;
|
|
@@ -183,6 +188,11 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
|
|
|
183
188
|
* @property {Feature[]} features - The features within this collection
|
|
184
189
|
*/
|
|
185
190
|
/** @typedef {'error'|'warning'|'info'|'success'} CustomValidityType - The type of custom validity used for disclose on visual presentation and form submission behavior */
|
|
191
|
+
/**
|
|
192
|
+
* @typedef SnappingOptions
|
|
193
|
+
* @property {WorkbookLayerPath | string} layer - The layer to snap to
|
|
194
|
+
* @property {('toVertices' | 'toEdges' | 'lineTracing')[]} [types] - Snapping types; Without this option, the Cadenza default snapping types are used.
|
|
195
|
+
*/
|
|
186
196
|
let hasCadenzaSession = false;
|
|
187
197
|
/** @type {Promise<void> | undefined} */
|
|
188
198
|
let firstEmbeddingTargetShown;
|
|
@@ -190,7 +200,7 @@ let firstEmbeddingTargetShown;
|
|
|
190
200
|
* _Notes:_
|
|
191
201
|
* * Most public methods are tagged with one of these modifiers:
|
|
192
202
|
* * `Embed`: The method embeds Cadenza in the given iframe.
|
|
193
|
-
* * `Post Message`: The method communicates with an embedded
|
|
203
|
+
* * `Post Message`: The method communicates with an embedded Cadenza via postMessage.
|
|
194
204
|
* * `Post Message Parent`: The method communicates with a parent/opener Cadenza via postMessage.
|
|
195
205
|
* * `Server`: The method communicates with the Cadenza server via HTTP.
|
|
196
206
|
* * Most public methods can be aborted using an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
|
|
@@ -262,7 +272,7 @@ export class CadenzaClient {
|
|
|
262
272
|
const targetWindow = this.#iframe
|
|
263
273
|
? this.iframe?.contentWindow
|
|
264
274
|
: // If a window does not have a parent, its parent property is a reference to itself.
|
|
265
|
-
window.opener ?? (window.parent !== window ? window.parent : null);
|
|
275
|
+
(window.opener ?? (window.parent !== window ? window.parent : null));
|
|
266
276
|
return /** @type {WindowProxy | null} */ targetWindow;
|
|
267
277
|
}
|
|
268
278
|
get #requiredIframe() {
|
|
@@ -307,6 +317,7 @@ export class CadenzaClient {
|
|
|
307
317
|
source.page === 'welcome', 'labelSet is only supported on the welcome page');
|
|
308
318
|
}
|
|
309
319
|
const params = createParams({
|
|
320
|
+
dataType,
|
|
310
321
|
disabledUiFeatures,
|
|
311
322
|
expandNavigator,
|
|
312
323
|
filter,
|
|
@@ -314,7 +325,6 @@ export class CadenzaClient {
|
|
|
314
325
|
hideWorkbookToolBar,
|
|
315
326
|
highlightGlobalId,
|
|
316
327
|
labelSet,
|
|
317
|
-
dataType,
|
|
318
328
|
operationMode,
|
|
319
329
|
});
|
|
320
330
|
return this.#show(resolvePath(source), params, signal);
|
|
@@ -324,11 +334,12 @@ export class CadenzaClient {
|
|
|
324
334
|
* @param {object} [__namedParameters] - Options
|
|
325
335
|
* @param {boolean} [__namedParameters.invalidateCaches] - When true, caches will be invalidated for objecttypes used
|
|
326
336
|
* in the worksheet
|
|
337
|
+
* @return {Promise<void>} A `Promise` which resolves when the views of the worksheet have finished reloading
|
|
327
338
|
* @postMessage
|
|
328
339
|
*/
|
|
329
340
|
reload({ invalidateCaches = false } = {}) {
|
|
330
341
|
this.#log('CadenzaClient#reload', ...arguments);
|
|
331
|
-
this.#
|
|
342
|
+
return this.#postRequest('reload', { invalidateCaches });
|
|
332
343
|
}
|
|
333
344
|
/**
|
|
334
345
|
* Sends a message to parent Cadenza window to close the window containing this application
|
|
@@ -347,6 +358,7 @@ export class CadenzaClient {
|
|
|
347
358
|
* @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
348
359
|
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
349
360
|
* @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded.
|
|
361
|
+
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
350
362
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
351
363
|
* @param {Geometry} [__namedParameters.geometry] - A geometry to show on the map
|
|
352
364
|
* @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
|
|
@@ -357,7 +369,6 @@ export class CadenzaClient {
|
|
|
357
369
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
358
370
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
359
371
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
360
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
361
372
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
362
373
|
* @throws For invalid arguments
|
|
363
374
|
* @fires
|
|
@@ -365,16 +376,16 @@ export class CadenzaClient {
|
|
|
365
376
|
* - {@link CadenzaActionEvent}
|
|
366
377
|
* @embed
|
|
367
378
|
*/
|
|
368
|
-
async showMap(mapView, { disabledUiFeatures, expandNavigator, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs,
|
|
379
|
+
async showMap(mapView, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, } = {}) {
|
|
369
380
|
this.#log('CadenzaClient#showMap', ...arguments);
|
|
370
381
|
if (geometry) {
|
|
371
382
|
assertValidGeometryType(geometry.type);
|
|
372
383
|
}
|
|
373
384
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
385
|
+
extentStrategy,
|
|
374
386
|
geometry,
|
|
375
387
|
locationFinder,
|
|
376
388
|
mapExtent,
|
|
377
|
-
extentStrategy,
|
|
378
389
|
});
|
|
379
390
|
const params = createParams({
|
|
380
391
|
disabledUiFeatures,
|
|
@@ -465,12 +476,19 @@ export class CadenzaClient {
|
|
|
465
476
|
* @hidden
|
|
466
477
|
* @param {WorkbookLayerPath | string} layer - The data view layer to set the selection in
|
|
467
478
|
* @param {unknown[][]} values - The IDs of the objects to select
|
|
479
|
+
* @param {object} [__namedParameters]
|
|
480
|
+
* @param {GeometryExtentStrategy} [__namedParameters.extentStrategy] - Strategy to define the new map extent
|
|
468
481
|
* @return {Promise<void>} A `Promise` for when the selection was set.
|
|
469
482
|
* @postMessage
|
|
470
483
|
*/
|
|
471
|
-
setSelection(layer, values) {
|
|
484
|
+
setSelection(layer, values, { extentStrategy } = {}) {
|
|
472
485
|
this.#log('CadenzaClient#setSelection', ...arguments);
|
|
473
|
-
|
|
486
|
+
const selectionResult = this.#postRequest('setSelection', {
|
|
487
|
+
layer: array(layer),
|
|
488
|
+
values,
|
|
489
|
+
});
|
|
490
|
+
this.#setExtentStrategy(extentStrategy);
|
|
491
|
+
return selectionResult;
|
|
474
492
|
}
|
|
475
493
|
/**
|
|
476
494
|
* Add to the selection in the currently shown workbook map view.
|
|
@@ -478,12 +496,19 @@ export class CadenzaClient {
|
|
|
478
496
|
* @hidden
|
|
479
497
|
* @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
|
|
480
498
|
* @param {unknown[][]} values - The IDs of the objects to select
|
|
499
|
+
* @param {object} [__namedParameters]
|
|
500
|
+
* @param {GeometryExtentStrategy} [__namedParameters.extentStrategy] - Strategy to define the new map extent
|
|
481
501
|
* @return {Promise<void>} A `Promise` for when the selection was changed.
|
|
482
502
|
* @postMessage
|
|
483
503
|
*/
|
|
484
|
-
addSelection(layer, values) {
|
|
504
|
+
addSelection(layer, values, { extentStrategy } = {}) {
|
|
485
505
|
this.#log('CadenzaClient#addSelection', ...arguments);
|
|
486
|
-
|
|
506
|
+
const selectionResult = this.#postRequest('addSelection', {
|
|
507
|
+
layer: array(layer),
|
|
508
|
+
values,
|
|
509
|
+
});
|
|
510
|
+
this.#setExtentStrategy(extentStrategy);
|
|
511
|
+
return selectionResult;
|
|
487
512
|
}
|
|
488
513
|
/**
|
|
489
514
|
* Remove from the selection in the currently shown workbook map view.
|
|
@@ -491,15 +516,19 @@ export class CadenzaClient {
|
|
|
491
516
|
* @hidden
|
|
492
517
|
* @param {WorkbookLayerPath | string} layer - The data view layer to change the selection in
|
|
493
518
|
* @param {unknown[][]} values - The IDs of the objects to unselect
|
|
519
|
+
* @param {object} [__namedParameters]
|
|
520
|
+
* @param {GeometryExtentStrategy} [__namedParameters.extentStrategy] - Strategy to define the new map extent
|
|
494
521
|
* @return {Promise<void>} A `Promise` for when the selection was changed.
|
|
495
522
|
* @postMessage
|
|
496
523
|
*/
|
|
497
|
-
removeSelection(layer, values) {
|
|
524
|
+
removeSelection(layer, values, { extentStrategy } = {}) {
|
|
498
525
|
this.#log('CadenzaClient#removeSelection', ...arguments);
|
|
499
|
-
|
|
526
|
+
const selectionResult = this.#postRequest('removeSelection', {
|
|
500
527
|
layer: array(layer),
|
|
501
528
|
values,
|
|
502
529
|
});
|
|
530
|
+
this.#setExtentStrategy(extentStrategy);
|
|
531
|
+
return selectionResult;
|
|
503
532
|
}
|
|
504
533
|
/**
|
|
505
534
|
* Create a geometry.
|
|
@@ -512,14 +541,15 @@ export class CadenzaClient {
|
|
|
512
541
|
* @param {object} [__namedParameters] - Options
|
|
513
542
|
* @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
|
|
514
543
|
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
544
|
+
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
515
545
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
516
546
|
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
517
547
|
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
518
548
|
* @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.
|
|
519
549
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
520
550
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
551
|
+
* @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
|
|
521
552
|
* @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)
|
|
522
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
523
553
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
524
554
|
* @throws For invalid arguments
|
|
525
555
|
* @fires
|
|
@@ -528,12 +558,12 @@ export class CadenzaClient {
|
|
|
528
558
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
529
559
|
* @embed
|
|
530
560
|
*/
|
|
531
|
-
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal,
|
|
561
|
+
async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, snapping, } = {}) {
|
|
532
562
|
this.#log('CadenzaClient#createGeometry', ...arguments);
|
|
533
563
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
564
|
+
extentStrategy,
|
|
534
565
|
locationFinder,
|
|
535
566
|
mapExtent,
|
|
536
|
-
extentStrategy,
|
|
537
567
|
});
|
|
538
568
|
const params = createParams({
|
|
539
569
|
action: 'editGeometry',
|
|
@@ -542,6 +572,7 @@ export class CadenzaClient {
|
|
|
542
572
|
geometryType,
|
|
543
573
|
minScale,
|
|
544
574
|
operationMode,
|
|
575
|
+
snapping,
|
|
545
576
|
useMapSrs,
|
|
546
577
|
validExtentStrategy,
|
|
547
578
|
});
|
|
@@ -561,14 +592,15 @@ export class CadenzaClient {
|
|
|
561
592
|
* @param {object} [__namedParameters] - Options
|
|
562
593
|
* @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).
|
|
563
594
|
* @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
|
|
595
|
+
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
564
596
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
565
597
|
* @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
|
|
566
598
|
* @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
|
|
567
599
|
* @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
600
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
569
601
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
602
|
+
* @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
|
|
570
603
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
571
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
572
604
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
573
605
|
* @throws For invalid arguments
|
|
574
606
|
* @fires
|
|
@@ -577,14 +609,14 @@ export class CadenzaClient {
|
|
|
577
609
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
578
610
|
* @embed
|
|
579
611
|
*/
|
|
580
|
-
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, operationMode, signal,
|
|
612
|
+
async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
|
|
581
613
|
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
582
614
|
assertValidGeometryType(geometry.type);
|
|
583
615
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
616
|
+
extentStrategy,
|
|
584
617
|
geometry,
|
|
585
618
|
locationFinder,
|
|
586
619
|
mapExtent,
|
|
587
|
-
extentStrategy,
|
|
588
620
|
});
|
|
589
621
|
const params = createParams({
|
|
590
622
|
action: 'editGeometry',
|
|
@@ -592,6 +624,7 @@ export class CadenzaClient {
|
|
|
592
624
|
filter,
|
|
593
625
|
minScale,
|
|
594
626
|
operationMode,
|
|
627
|
+
snapping,
|
|
595
628
|
useMapSrs,
|
|
596
629
|
validExtentStrategy,
|
|
597
630
|
});
|
|
@@ -626,6 +659,7 @@ export class CadenzaClient {
|
|
|
626
659
|
*
|
|
627
660
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view
|
|
628
661
|
* @param {object} [__namedParameters] - Options
|
|
662
|
+
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
629
663
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
630
664
|
* @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
|
|
631
665
|
* (identified using layer paths or print names)
|
|
@@ -634,7 +668,6 @@ export class CadenzaClient {
|
|
|
634
668
|
* @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
635
669
|
* @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
|
|
636
670
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
|
|
637
|
-
* @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
|
|
638
671
|
* @return {Promise<void>} A `Promise` for when the iframe is loaded
|
|
639
672
|
* @throws For invalid arguments
|
|
640
673
|
* @fires
|
|
@@ -644,7 +677,7 @@ export class CadenzaClient {
|
|
|
644
677
|
* - {@link CadenzaSelectObjectsCancelEvent}
|
|
645
678
|
* @embed
|
|
646
679
|
*/
|
|
647
|
-
async selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal,
|
|
680
|
+
async selectObjects(backgroundMapView, { extentStrategy, filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, } = {}) {
|
|
648
681
|
this.#log('CadenzaClient#selectObjects', ...arguments);
|
|
649
682
|
const validExtentStrategy = sanitizeExtentStrategy({
|
|
650
683
|
geometry: undefined,
|
|
@@ -877,22 +910,22 @@ export class CadenzaClient {
|
|
|
877
910
|
* @param {unknown[][]} objectIds - The IDs of the objects to select
|
|
878
911
|
* @param {object} [__namedParameters] - Options
|
|
879
912
|
* @param {FilterVariables} [__namedParameters.filter] - Filter variables
|
|
913
|
+
* @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
|
|
880
914
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
|
|
881
915
|
* @param {Boolean} [__namedParameters.useMapSrs] - Use the map SRS instead of WGS84
|
|
882
|
-
* @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
|
|
883
916
|
* @return {Promise<FeatureCollection>} A `Promise` for the fetch response
|
|
884
917
|
* @throws For invalid arguments
|
|
885
918
|
*/
|
|
886
|
-
fetchObjectInfo(source, layerPath, objectIds, { filter, signal,
|
|
919
|
+
fetchObjectInfo(source, layerPath, objectIds, { filter, signal, fullGeometries, useMapSrs } = {}) {
|
|
887
920
|
this.#log('CadenzaClient#fetchObjectInfo', ...arguments);
|
|
888
921
|
const params = createParams({
|
|
889
922
|
filter,
|
|
890
923
|
});
|
|
891
924
|
return this.#fetch(resolvePath(source) + '/objectinfo', params, signal, JSON.stringify({
|
|
925
|
+
fullGeometries,
|
|
892
926
|
objectIds,
|
|
893
927
|
layerPath: array(layerPath),
|
|
894
928
|
useMapSrs,
|
|
895
|
-
fullGeometries,
|
|
896
929
|
})).then((response) => response.json());
|
|
897
930
|
}
|
|
898
931
|
/**
|
|
@@ -903,20 +936,20 @@ export class CadenzaClient {
|
|
|
903
936
|
* (identified using layer paths or print names)
|
|
904
937
|
* @param {Geometry} geometry - The intersection geometry
|
|
905
938
|
* @param {object} [__namedParameters] - Options
|
|
906
|
-
* @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
907
939
|
* @param {Distance} [__namedParameters.buffer] - Buffer size for geometry of the transition
|
|
908
940
|
* @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
|
|
941
|
+
* @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
|
|
909
942
|
* @return {Promise<FeatureCollection>} A `Promise` for the fetch response
|
|
910
943
|
* @server
|
|
911
944
|
*/
|
|
912
|
-
fetchAreaIntersections(source, layerPath, geometry, {
|
|
945
|
+
fetchAreaIntersections(source, layerPath, geometry, { buffer, signal, useMapSrs } = {}) {
|
|
913
946
|
this.#log('CadenzaClient#areaIntersections', ...arguments);
|
|
914
947
|
const params = createParams({});
|
|
915
948
|
return this.#fetch(resolvePath(source) + '/area-intersections', params, signal, JSON.stringify({
|
|
949
|
+
buffer,
|
|
916
950
|
layerPath: array(layerPath),
|
|
917
|
-
geometry
|
|
918
|
-
useMapSrs
|
|
919
|
-
buffer: buffer,
|
|
951
|
+
geometry,
|
|
952
|
+
useMapSrs,
|
|
920
953
|
})).then((response) => response.json());
|
|
921
954
|
}
|
|
922
955
|
async #fetch(
|
|
@@ -1109,11 +1142,12 @@ function assertSupportedDataType(
|
|
|
1109
1142
|
* @param {OperationMode} [params.operationMode]
|
|
1110
1143
|
* @param {TablePart[]} [params.parts]
|
|
1111
1144
|
* @param {'MAP'} [params.targetType]
|
|
1145
|
+
* @param {SnappingOptions} [params.snapping]
|
|
1112
1146
|
* @param {boolean} [params.useMapSrs]
|
|
1113
1147
|
* @param {ExtentStrategy | undefined} [params.validExtentStrategy]
|
|
1114
1148
|
* @return {URLSearchParams}
|
|
1115
1149
|
*/
|
|
1116
|
-
function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, useMapSrs, validExtentStrategy, }) {
|
|
1150
|
+
function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, }) {
|
|
1117
1151
|
if (disabledUiFeatures) {
|
|
1118
1152
|
disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
|
|
1119
1153
|
}
|
|
@@ -1157,15 +1191,14 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
|
|
|
1157
1191
|
...(hideWorkbookToolBar && { hideWorkbookToolBar: 'true' }),
|
|
1158
1192
|
...(highlightGlobalId && { highlightGlobalId }),
|
|
1159
1193
|
...(labelSet && { labelSet }),
|
|
1160
|
-
...(layers &&
|
|
1161
|
-
layers.length && {
|
|
1162
|
-
layers: JSON.stringify(layers),
|
|
1163
|
-
}),
|
|
1194
|
+
...(layers?.length && { layers: JSON.stringify(layers) }),
|
|
1164
1195
|
...(locationFinder && { locationFinder }),
|
|
1165
1196
|
...(mapExtent && { mapExtent: mapExtent.join() }),
|
|
1166
1197
|
...(minScale && { minScale: String(minScale) }),
|
|
1167
1198
|
...(operationMode && { operationMode }),
|
|
1168
1199
|
...(parts && { parts: parts.join() }),
|
|
1200
|
+
...(snapping && { snappingLayer: JSON.stringify(array(snapping.layer)) }),
|
|
1201
|
+
...(snapping?.types?.length && { snappingTypes: snapping.types.join() }),
|
|
1169
1202
|
...(targetType && { targetType }),
|
|
1170
1203
|
...(useMapSrs && { useMapSrs: 'true' }),
|
|
1171
1204
|
});
|
|
@@ -1233,9 +1266,9 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
|
|
|
1233
1266
|
* | 'editGeometry:update'
|
|
1234
1267
|
* | 'editGeometry:cancel'
|
|
1235
1268
|
* | 'objectInfo'
|
|
1269
|
+
* | 'reload'
|
|
1236
1270
|
* | 'selectObjects:ok'
|
|
1237
1271
|
* | 'selectObjects:cancel'
|
|
1238
|
-
* | 'reload'
|
|
1239
1272
|
* } CadenzaEventType - An event type to subscribe to using {@link CadenzaClient#on}
|
|
1240
1273
|
*/
|
|
1241
1274
|
/**
|
|
@@ -1247,9 +1280,9 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
|
|
|
1247
1280
|
* : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent
|
|
1248
1281
|
* : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent
|
|
1249
1282
|
* : T extends 'objectInfo' ? CadenzaObjectInfoEvent
|
|
1283
|
+
* : T extends 'reload' ? CadenzaReloadEvent
|
|
1250
1284
|
* : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent
|
|
1251
1285
|
* : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent
|
|
1252
|
-
* : T extends 'reload' ? CadenzaReloadEvent
|
|
1253
1286
|
* : never
|
|
1254
1287
|
* } CadenzaEventByType
|
|
1255
1288
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@disy/cadenza.js",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": "github:DisyInformationssysteme/cadenza.js",
|
|
6
6
|
"type": "module",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"sandbox": "node ./sandbox.cjs"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/jest": "29.5.
|
|
33
|
+
"@types/jest": "29.5.14",
|
|
34
34
|
"cross-env": "7.0.3",
|
|
35
|
-
"gh-pages": "6.
|
|
35
|
+
"gh-pages": "6.3.0",
|
|
36
36
|
"http-server": "14.1.1",
|
|
37
37
|
"jest": "29.7.0",
|
|
38
38
|
"jest-environment-jsdom": "29.7.0",
|
|
39
|
-
"keep-a-changelog": "2.
|
|
39
|
+
"keep-a-changelog": "2.6.1",
|
|
40
40
|
"npm-run-all": "4.1.5",
|
|
41
41
|
"onchange": "7.1.0",
|
|
42
|
-
"prettier": "3.
|
|
43
|
-
"ts-jest": "29.
|
|
44
|
-
"typedoc": "0.
|
|
42
|
+
"prettier": "3.5.3",
|
|
43
|
+
"ts-jest": "29.2.6",
|
|
44
|
+
"typedoc": "0.27.9"
|
|
45
45
|
},
|
|
46
46
|
"volta": {
|
|
47
|
-
"node": "
|
|
47
|
+
"node": "20.18.3"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/sandbox.html
CHANGED
|
@@ -162,11 +162,11 @@
|
|
|
162
162
|
},
|
|
163
163
|
setFilter: data => cadenzaClient.setFilter(parseFilterVariables(data.filter)),
|
|
164
164
|
setLayerVisibility: data => cadenzaClient.setLayerVisibility(JSON.parse(data.layer), data.visibility === 'on'),
|
|
165
|
-
setSelection: data => cadenzaClient.setSelection(JSON.parse(data.layer), JSON.parse(data.objectIds)),
|
|
166
|
-
addSelection: data => cadenzaClient.addSelection(JSON.parse(data.layer), JSON.parse(data.objectIds)),
|
|
167
|
-
removeSelection: data => cadenzaClient.removeSelection(JSON.parse(data.layer), JSON.parse(data.objectIds)),
|
|
168
|
-
createGeometry: data => cadenzaClient.createGeometry(data.embeddingTargetId, data.geometryType, getOptions(data)),
|
|
169
|
-
editGeometry: ({ geometry, ...data }) => cadenzaClient.editGeometry(data.embeddingTargetId, JSON.parse(geometry), getOptions(data)),
|
|
165
|
+
setSelection: data => cadenzaClient.setSelection(JSON.parse(data.layer), JSON.parse(data.objectIds), {extentStrategy: JSON.parse(data.extentStrategy)}),
|
|
166
|
+
addSelection: data => cadenzaClient.addSelection(JSON.parse(data.layer), JSON.parse(data.objectIds), { extentStrategy: JSON.parse(data.extentStrategy) }),
|
|
167
|
+
removeSelection: data => cadenzaClient.removeSelection(JSON.parse(data.layer), JSON.parse(data.objectIds), { extentStrategy: JSON.parse(data.extentStrategy) }),
|
|
168
|
+
createGeometry: (data, formData) => cadenzaClient.createGeometry(data.embeddingTargetId, data.geometryType, getOptions(data, formData)),
|
|
169
|
+
editGeometry: ({ geometry, ...data }, formData) => cadenzaClient.editGeometry(data.embeddingTargetId, JSON.parse(geometry), getOptions(data, formData)),
|
|
170
170
|
selectObjects: data => cadenzaClient.selectObjects(data.embeddingTargetId, getOptions(data)),
|
|
171
171
|
fetchData: data => {
|
|
172
172
|
console.log('Inspect the fetchData() request in the devtools.');
|
|
@@ -189,8 +189,9 @@
|
|
|
189
189
|
const form = document.getElementById('form');
|
|
190
190
|
form.onsubmit = (event) => {
|
|
191
191
|
event.preventDefault();
|
|
192
|
-
const
|
|
193
|
-
|
|
192
|
+
const formData = new FormData(form);
|
|
193
|
+
const { action, ...data } = Object.fromEntries(formData);
|
|
194
|
+
actionHandlers[action](data, formData);
|
|
194
195
|
localStorage.setItem(`cadenzajs-sandbox-${action}`, JSON.stringify(data));
|
|
195
196
|
};
|
|
196
197
|
|
|
@@ -212,47 +213,52 @@
|
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
function getOptions ({
|
|
216
|
+
additionalLayers,
|
|
215
217
|
disabledUiFeatures,
|
|
218
|
+
distance,
|
|
216
219
|
expandNavigator,
|
|
220
|
+
extentStrategy,
|
|
221
|
+
fullGeometries,
|
|
217
222
|
fileName,
|
|
218
223
|
filter,
|
|
219
224
|
geometry,
|
|
220
225
|
hideMainHeaderAndFooter,
|
|
221
226
|
hideWorkbookToolBar,
|
|
222
227
|
highlightGlobalId,
|
|
223
|
-
requestAsPdf,
|
|
224
228
|
labelSet,
|
|
229
|
+
layers,
|
|
230
|
+
lengthUnit,
|
|
225
231
|
minScale,
|
|
226
232
|
parts,
|
|
227
|
-
|
|
233
|
+
requestAsPdf,
|
|
228
234
|
simplifiedOperationMode,
|
|
235
|
+
snappingLayer,
|
|
229
236
|
useMapSrs,
|
|
230
|
-
|
|
231
|
-
extentStrategy,
|
|
232
|
-
distance,
|
|
233
|
-
lengthUnit,
|
|
234
|
-
additionalLayers
|
|
235
|
-
}) {
|
|
237
|
+
}, formData) {
|
|
236
238
|
return {
|
|
239
|
+
additionalLayers: additionalLayers && JSON.parse(additionalLayers),
|
|
240
|
+
buffer: distance ? { value: Number(distance), lengthUnit: lengthUnit ? lengthUnit : 'm' } : undefined,
|
|
241
|
+
...(requestAsPdf === 'on' && { dataType: 'pdf' }),
|
|
237
242
|
disabledUiFeatures: disabledUiFeatures && disabledUiFeatures.split(','),
|
|
238
243
|
expandNavigator: (expandNavigator === 'on'),
|
|
244
|
+
extentStrategy: extentStrategy && JSON.parse(extentStrategy),
|
|
239
245
|
fileName,
|
|
240
246
|
filter: filter && parseFilterVariables(filter),
|
|
247
|
+
fullGeometries: fullGeometries === 'on',
|
|
241
248
|
geometry: geometry && JSON.parse(geometry),
|
|
242
249
|
hideMainHeaderAndFooter: (hideMainHeaderAndFooter === 'on'),
|
|
243
250
|
hideWorkbookToolBar: (hideWorkbookToolBar === 'on'),
|
|
244
251
|
highlightGlobalId,
|
|
245
|
-
...(requestAsPdf === 'on' && { dataType: 'pdf' }),
|
|
246
252
|
labelSet,
|
|
253
|
+
layers: layers ? JSON.parse(layers) : undefined,
|
|
247
254
|
minScale: minScale && Number(minScale),
|
|
248
|
-
parts: parts && parts.split(','),
|
|
249
255
|
operationMode: (simplifiedOperationMode === 'on' ? 'simplified' : 'normal' ),
|
|
250
|
-
|
|
256
|
+
parts: parts && parts.split(','),
|
|
257
|
+
snapping: snappingLayer ? {
|
|
258
|
+
layer: JSON.parse(snappingLayer),
|
|
259
|
+
types: formData?.getAll('snappingTypes')
|
|
260
|
+
}: undefined,
|
|
251
261
|
useMapSrs: useMapSrs === 'on',
|
|
252
|
-
fullGeometries: fullGeometries === 'on',
|
|
253
|
-
extentStrategy: extentStrategy && JSON.parse(extentStrategy),
|
|
254
|
-
buffer: distance ? { value: Number(distance), lengthUnit: lengthUnit ? lengthUnit : 'm' } : undefined,
|
|
255
|
-
additionalLayers: additionalLayers && JSON.parse(additionalLayers)
|
|
256
262
|
};
|
|
257
263
|
}
|
|
258
264
|
|
|
@@ -481,7 +487,7 @@
|
|
|
481
487
|
|
|
482
488
|
<template data-action="setFilter" data-common="filter"></template>
|
|
483
489
|
|
|
484
|
-
<template data-action="createGeometry" data-common="additionalLayers,extentStrategy,map,disabledUiFeatures,filter">
|
|
490
|
+
<template data-action="createGeometry" data-common="additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
|
|
485
491
|
<div>
|
|
486
492
|
<label for="embeddingTargetId">Embedding target ID of the map view *</label>
|
|
487
493
|
<input name="embeddingTargetId" id="embeddingTargetId" required>
|
|
@@ -509,7 +515,7 @@
|
|
|
509
515
|
</div>
|
|
510
516
|
</template>
|
|
511
517
|
|
|
512
|
-
<template data-action="editGeometry" data-common="additionalLayers,extentStrategy,map,disabledUiFeatures,filter">
|
|
518
|
+
<template data-action="editGeometry" data-common="additionalLayers,extentStrategy,map,snapping,disabledUiFeatures,filter">
|
|
513
519
|
<div>
|
|
514
520
|
<label for="embeddingTargetId">Embedding target ID of the map view *</label>
|
|
515
521
|
<input name="embeddingTargetId" id="embeddingTargetId" required>
|
|
@@ -546,6 +552,42 @@
|
|
|
546
552
|
</div>
|
|
547
553
|
</template>
|
|
548
554
|
|
|
555
|
+
<template id="common-snapping">
|
|
556
|
+
<div>
|
|
557
|
+
<label for="snappingLayer">Snapping Layer</label>
|
|
558
|
+
<input name="snappingLayer" id="snappingLayer">
|
|
559
|
+
<small>
|
|
560
|
+
<p>
|
|
561
|
+
A JSON value like <code>"<layerPrintName>"</code> or
|
|
562
|
+
<code>["<layerGroupPrintName>","<layerPrintName>"]</code>
|
|
563
|
+
</p>
|
|
564
|
+
</small>
|
|
565
|
+
</div>
|
|
566
|
+
<div>
|
|
567
|
+
<label for="snappingTypes">Snapping Types</label>
|
|
568
|
+
<div role="group" id="snappingTypes">
|
|
569
|
+
<div>
|
|
570
|
+
<label>
|
|
571
|
+
<input type="checkbox" name="snappingTypes" value="toVertices">
|
|
572
|
+
To Vertices
|
|
573
|
+
</label>
|
|
574
|
+
</div>
|
|
575
|
+
<div>
|
|
576
|
+
<label>
|
|
577
|
+
<input type="checkbox" name="snappingTypes" value="toEdges">
|
|
578
|
+
To Edges
|
|
579
|
+
</label>
|
|
580
|
+
</div>
|
|
581
|
+
<div>
|
|
582
|
+
<label>
|
|
583
|
+
<input type="checkbox" name="snappingTypes" value="lineTracing">
|
|
584
|
+
Line Tracing
|
|
585
|
+
</label>
|
|
586
|
+
</div>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
</template>
|
|
590
|
+
|
|
549
591
|
<template data-action="selectObjects" data-common="extentStrategy,map,filter">
|
|
550
592
|
<div>
|
|
551
593
|
<label for="embeddingTargetId">Embedding target ID of the map view *</label>
|
|
@@ -578,9 +620,9 @@
|
|
|
578
620
|
</div>
|
|
579
621
|
</template>
|
|
580
622
|
|
|
581
|
-
<template data-action="setSelection" data-common="layer,object-ids"></template>
|
|
582
|
-
<template data-action="addSelection" data-common="layer,object-ids"></template>
|
|
583
|
-
<template data-action="removeSelection" data-common="layer,object-ids"></template>
|
|
623
|
+
<template data-action="setSelection" data-common="layer,object-ids,extentStrategy"></template>
|
|
624
|
+
<template data-action="addSelection" data-common="layer,object-ids,extentStrategy"></template>
|
|
625
|
+
<template data-action="removeSelection" data-common="layer,object-ids,extentStrategy"></template>
|
|
584
626
|
|
|
585
627
|
<template data-action="reload">
|
|
586
628
|
<div>
|