@geospatial-sdk/core 0.0.5-dev.71 → 0.0.5-dev.73
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/dist/model/map-context.d.ts +6 -0
- package/dist/model/map-context.d.ts.map +1 -1
- package/dist/utils/map-context-diff.d.ts.map +1 -1
- package/dist/utils/map-context-diff.js +12 -7
- package/lib/model/map-context.ts +7 -0
- package/lib/utils/map-context-diff.test.ts +111 -0
- package/lib/utils/map-context-diff.ts +11 -7
- package/package.json +2 -2
|
@@ -76,6 +76,12 @@ export interface MapContextLayerWms extends MapContextBaseLayer {
|
|
|
76
76
|
name: string;
|
|
77
77
|
dimensionValues?: LayerDimensionValues;
|
|
78
78
|
style?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Vendor-specific WMS parameters that are appended as-is to every GetMap request.
|
|
81
|
+
* Use this for non-standard server extensions such as NcWMS (`COLORSCALERANGE`, `LOGSCALE`).
|
|
82
|
+
* Keys are case-sensitive; they are passed without transformation.
|
|
83
|
+
*/
|
|
84
|
+
customParams?: Record<string, string>;
|
|
79
85
|
/**
|
|
80
86
|
* Whether to use tiled WMS requests. Tiled requests include a `TILED=true` parameter as per https://wiki.osgeo.org/wiki/WMS_Tiling_Client_Recommendation
|
|
81
87
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-context.d.ts","sourceRoot":"","sources":["../../lib/model/map-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAC/D,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACxC,GAAG,EAAE,yBAAyB,GAAG,IAAI,CAAC;CACvC,CAAC;AAE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;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-context-diff.d.ts","sourceRoot":"","sources":["../../lib/utils/map-context-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EAKf,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,UAAU,EACvB,eAAe,EAAE,UAAU,GAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"map-context-diff.d.ts","sourceRoot":"","sources":["../../lib/utils/map-context-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,cAAc,EAKf,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,UAAU,EACvB,eAAe,EAAE,UAAU,GAC1B,cAAc,CA8EhB"}
|
|
@@ -54,17 +54,22 @@ export function computeMapContextDiff(nextContext, previousContext) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
// look for moved layers
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
for (let i = 0; i <
|
|
61
|
-
const layer =
|
|
62
|
-
|
|
57
|
+
// look for moved layers (ignore removed and added ones)
|
|
58
|
+
const movedLayersInPrevious = previousContext.layers.filter((l) => !layersRemoved.find(({ layer }) => l === layer));
|
|
59
|
+
const movedLayersInNext = nextContext.layers.filter((l) => !layersAdded.find(({ layer }) => l === layer));
|
|
60
|
+
for (let i = 0; i < movedLayersInNext.length; i++) {
|
|
61
|
+
const layer = movedLayersInNext[i];
|
|
62
|
+
let prevPosition = getLayerPosition(layer, movedLayersInPrevious);
|
|
63
63
|
if (i !== prevPosition) {
|
|
64
|
+
// shift prevPosition of a move layer when others layers were added before them
|
|
65
|
+
for (const { position: addedPos } of layersAdded) {
|
|
66
|
+
if (addedPos <= prevPosition)
|
|
67
|
+
prevPosition++;
|
|
68
|
+
}
|
|
64
69
|
layersReordered.push({
|
|
65
70
|
layer,
|
|
66
71
|
newPosition: getLayerPosition(layer, nextContext.layers),
|
|
67
|
-
previousPosition:
|
|
72
|
+
previousPosition: prevPosition,
|
|
68
73
|
});
|
|
69
74
|
}
|
|
70
75
|
}
|
package/lib/model/map-context.ts
CHANGED
|
@@ -92,6 +92,13 @@ export interface MapContextLayerWms extends MapContextBaseLayer {
|
|
|
92
92
|
dimensionValues?: LayerDimensionValues;
|
|
93
93
|
style?: string;
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Vendor-specific WMS parameters that are appended as-is to every GetMap request.
|
|
97
|
+
* Use this for non-standard server extensions such as NcWMS (`COLORSCALERANGE`, `LOGSCALE`).
|
|
98
|
+
* Keys are case-sensitive; they are passed without transformation.
|
|
99
|
+
*/
|
|
100
|
+
customParams?: Record<string, string>;
|
|
101
|
+
|
|
95
102
|
/**
|
|
96
103
|
* Whether to use tiled WMS requests. Tiled requests include a `TILED=true` parameter as per https://wiki.osgeo.org/wiki/WMS_Tiling_Client_Recommendation
|
|
97
104
|
*
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
SAMPLE_LAYER3,
|
|
8
8
|
SAMPLE_LAYER4,
|
|
9
9
|
SAMPLE_LAYER5,
|
|
10
|
+
SAMPLE_LAYER6,
|
|
11
|
+
SAMPLE_LAYER7,
|
|
10
12
|
} from "../../fixtures/map-context.fixtures.js";
|
|
11
13
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
12
14
|
|
|
@@ -390,5 +392,114 @@ describe("Context diff utils", () => {
|
|
|
390
392
|
});
|
|
391
393
|
});
|
|
392
394
|
});
|
|
395
|
+
|
|
396
|
+
describe("combined changes (2)", () => {
|
|
397
|
+
beforeEach(() => {
|
|
398
|
+
contextOld = {
|
|
399
|
+
...SAMPLE_CONTEXT,
|
|
400
|
+
layers: [
|
|
401
|
+
SAMPLE_LAYER1,
|
|
402
|
+
SAMPLE_LAYER5,
|
|
403
|
+
SAMPLE_LAYER3,
|
|
404
|
+
SAMPLE_LAYER4,
|
|
405
|
+
SAMPLE_LAYER6,
|
|
406
|
+
],
|
|
407
|
+
};
|
|
408
|
+
contextNew = {
|
|
409
|
+
...SAMPLE_CONTEXT,
|
|
410
|
+
layers: [SAMPLE_LAYER3, SAMPLE_LAYER1],
|
|
411
|
+
};
|
|
412
|
+
});
|
|
413
|
+
it("outputs the correct diff", async () => {
|
|
414
|
+
diff = computeMapContextDiff(contextNew, contextOld);
|
|
415
|
+
expect(diff).toEqual({
|
|
416
|
+
layersAdded: [],
|
|
417
|
+
layersChanged: [],
|
|
418
|
+
layersRemoved: [
|
|
419
|
+
{
|
|
420
|
+
layer: SAMPLE_LAYER5,
|
|
421
|
+
position: 1,
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
layer: SAMPLE_LAYER4,
|
|
425
|
+
position: 3,
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
layer: SAMPLE_LAYER6,
|
|
429
|
+
position: 4,
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
layersReordered: [
|
|
433
|
+
{
|
|
434
|
+
layer: SAMPLE_LAYER3,
|
|
435
|
+
newPosition: 0,
|
|
436
|
+
previousPosition: 1,
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
layer: SAMPLE_LAYER1,
|
|
440
|
+
newPosition: 1,
|
|
441
|
+
previousPosition: 0,
|
|
442
|
+
},
|
|
443
|
+
],
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
describe("combined changes (3)", () => {
|
|
449
|
+
beforeEach(() => {
|
|
450
|
+
contextOld = {
|
|
451
|
+
...SAMPLE_CONTEXT,
|
|
452
|
+
layers: [SAMPLE_LAYER5, SAMPLE_LAYER1, SAMPLE_LAYER2],
|
|
453
|
+
};
|
|
454
|
+
contextNew = {
|
|
455
|
+
...SAMPLE_CONTEXT,
|
|
456
|
+
layers: [
|
|
457
|
+
SAMPLE_LAYER2,
|
|
458
|
+
SAMPLE_LAYER3,
|
|
459
|
+
SAMPLE_LAYER6,
|
|
460
|
+
SAMPLE_LAYER1,
|
|
461
|
+
SAMPLE_LAYER7,
|
|
462
|
+
],
|
|
463
|
+
};
|
|
464
|
+
});
|
|
465
|
+
it("outputs the correct diff", async () => {
|
|
466
|
+
diff = computeMapContextDiff(contextNew, contextOld);
|
|
467
|
+
expect(diff).toEqual({
|
|
468
|
+
layersAdded: [
|
|
469
|
+
{
|
|
470
|
+
layer: SAMPLE_LAYER3,
|
|
471
|
+
position: 1,
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
layer: SAMPLE_LAYER6,
|
|
475
|
+
position: 2,
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
layer: SAMPLE_LAYER7,
|
|
479
|
+
position: 4,
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
layersChanged: [],
|
|
483
|
+
layersRemoved: [
|
|
484
|
+
{
|
|
485
|
+
layer: SAMPLE_LAYER5,
|
|
486
|
+
position: 0,
|
|
487
|
+
},
|
|
488
|
+
],
|
|
489
|
+
layersReordered: [
|
|
490
|
+
{
|
|
491
|
+
layer: SAMPLE_LAYER2,
|
|
492
|
+
previousPosition: 3,
|
|
493
|
+
newPosition: 0,
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
layer: SAMPLE_LAYER1,
|
|
497
|
+
previousPosition: 0,
|
|
498
|
+
newPosition: 3,
|
|
499
|
+
},
|
|
500
|
+
],
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
});
|
|
393
504
|
});
|
|
394
505
|
});
|
|
@@ -72,21 +72,25 @@ export function computeMapContextDiff(
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// look for moved layers
|
|
76
|
-
const
|
|
75
|
+
// look for moved layers (ignore removed and added ones)
|
|
76
|
+
const movedLayersInPrevious = previousContext.layers.filter(
|
|
77
77
|
(l) => !layersRemoved.find(({ layer }) => l === layer),
|
|
78
78
|
);
|
|
79
|
-
const
|
|
79
|
+
const movedLayersInNext = nextContext.layers.filter(
|
|
80
80
|
(l) => !layersAdded.find(({ layer }) => l === layer),
|
|
81
81
|
);
|
|
82
|
-
for (let i = 0; i <
|
|
83
|
-
const layer =
|
|
84
|
-
|
|
82
|
+
for (let i = 0; i < movedLayersInNext.length; i++) {
|
|
83
|
+
const layer = movedLayersInNext[i];
|
|
84
|
+
let prevPosition = getLayerPosition(layer, movedLayersInPrevious);
|
|
85
85
|
if (i !== prevPosition) {
|
|
86
|
+
// shift prevPosition of a move layer when others layers were added before them
|
|
87
|
+
for (const { position: addedPos } of layersAdded) {
|
|
88
|
+
if (addedPos <= prevPosition) prevPosition++;
|
|
89
|
+
}
|
|
86
90
|
layersReordered.push({
|
|
87
91
|
layer,
|
|
88
92
|
newPosition: getLayerPosition(layer, nextContext.layers),
|
|
89
|
-
previousPosition:
|
|
93
|
+
previousPosition: prevPosition,
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geospatial-sdk/core",
|
|
3
|
-
"version": "0.0.5-dev.
|
|
3
|
+
"version": "0.0.5-dev.73+ab5eeda",
|
|
4
4
|
"description": "Core functions and models for the SDK",
|
|
5
5
|
"author": "Olivia <olivia.guyot@camptocamp.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "vitest",
|
|
23
23
|
"build": "tsc"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "ab5eeda03b33655a59a9a97fb47ef6233527e19e",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"chroma-js": "^2.4.2",
|
|
28
28
|
"proj4": "^2.9.2"
|