@geospatial-sdk/core 0.0.5-dev.47 → 0.0.5-dev.49
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-diff.d.ts +9 -1
- package/dist/model/map-context-diff.d.ts.map +1 -1
- package/dist/utils/map-context-diff.d.ts.map +1 -1
- package/dist/utils/map-context-diff.js +1 -1
- package/dist/utils/map-context-layer.d.ts.map +1 -1
- package/dist/utils/map-context-layer.js +3 -1
- package/dist/utils/map-context.d.ts +6 -3
- package/dist/utils/map-context.d.ts.map +1 -1
- package/dist/utils/map-context.js +7 -4
- package/lib/model/map-context-diff.ts +10 -1
- package/lib/utils/map-context-diff.test.ts +3 -0
- package/lib/utils/map-context-diff.ts +3 -2
- package/lib/utils/map-context-layer.test.ts +6 -0
- package/lib/utils/map-context-layer.ts +4 -1
- package/lib/utils/map-context.ts +7 -4
- package/package.json +2 -2
|
@@ -15,6 +15,14 @@ export interface MapContextLayerReordered {
|
|
|
15
15
|
newPosition: number;
|
|
16
16
|
previousPosition: number;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Describes a layer that was changed: both states before and after change are included
|
|
20
|
+
*/
|
|
21
|
+
export interface MapContextLayerChanged {
|
|
22
|
+
layer: MapContextLayer;
|
|
23
|
+
previousLayer: MapContextLayer;
|
|
24
|
+
position: number;
|
|
25
|
+
}
|
|
18
26
|
/**
|
|
19
27
|
* Describes a delta between two contexts, in order to be
|
|
20
28
|
* applied to an existing map.
|
|
@@ -26,7 +34,7 @@ export interface MapContextLayerReordered {
|
|
|
26
34
|
* 4. change layers
|
|
27
35
|
*/
|
|
28
36
|
export interface MapContextDiff {
|
|
29
|
-
layersChanged:
|
|
37
|
+
layersChanged: MapContextLayerChanged[];
|
|
30
38
|
layersReordered: MapContextLayerReordered[];
|
|
31
39
|
layersRemoved: MapContextLayerPositioned[];
|
|
32
40
|
layersAdded: MapContextLayerPositioned[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-context-diff.d.ts","sourceRoot":"","sources":["../../lib/model/map-context-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,eAAe,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"map-context-diff.d.ts","sourceRoot":"","sources":["../../lib/model/map-context-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,eAAe,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,eAAe,CAAC;IACvB,aAAa,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,sBAAsB,EAAE,CAAC;IACxC,eAAe,EAAE,wBAAwB,EAAE,CAAC;IAC5C,aAAa,EAAE,yBAAyB,EAAE,CAAC;IAC3C,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACzC,WAAW,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACrC"}
|
|
@@ -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,
|
|
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,CA0EhB"}
|
|
@@ -50,7 +50,7 @@ export function computeMapContextDiff(nextContext, previousContext) {
|
|
|
50
50
|
else {
|
|
51
51
|
const prevLayer = previousContext.layers[prevPosition];
|
|
52
52
|
if (!isLayerSameAndUnchanged(layer, prevLayer)) {
|
|
53
|
-
layersChanged.push({ layer, position: i });
|
|
53
|
+
layersChanged.push({ layer, previousLayer: prevLayer, position: i });
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-context-layer.d.ts","sourceRoot":"","sources":["../../lib/utils/map-context-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,EACtB,aAAa,UAAQ,GACpB,MAAM,CAER;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,GACtB,OAAO,CAKT;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,GACtB,OAAO,CAST;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAChC,eAAe,
|
|
1
|
+
{"version":3,"file":"map-context-layer.d.ts","sourceRoot":"","sources":["../../lib/utils/map-context-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,EACtB,aAAa,UAAQ,GACpB,MAAM,CAER;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,GACtB,OAAO,CAKT;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,eAAe,GACtB,OAAO,CAST;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,GAChC,eAAe,CAqBjB"}
|
|
@@ -28,9 +28,11 @@ export function updateLayer(layer, updates) {
|
|
|
28
28
|
...layer,
|
|
29
29
|
...updates,
|
|
30
30
|
};
|
|
31
|
+
const versionExplicitlyUpdated = "version" in updates && updates.version !== undefined;
|
|
31
32
|
if ("id" in updatedLayer &&
|
|
32
33
|
"version" in updatedLayer &&
|
|
33
|
-
typeof updatedLayer.version === "number"
|
|
34
|
+
typeof updatedLayer.version === "number" &&
|
|
35
|
+
!versionExplicitlyUpdated) {
|
|
34
36
|
updatedLayer.version = updatedLayer.version + 1;
|
|
35
37
|
}
|
|
36
38
|
for (const key in updatedLayer) {
|
|
@@ -27,11 +27,14 @@ export declare function removeLayerFromContext(context: MapContext, layerModel:
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function replaceLayerInContext(context: MapContext, layerModel: MapContextLayer, replacement: MapContextLayer): MapContext;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Updates an existing layer in the context by applying partial changes.
|
|
31
|
+
*
|
|
32
|
+
* Note: setting a property to `undefined` in the partial layer updates will remove that
|
|
33
|
+
* property from the existing layer.
|
|
31
34
|
*
|
|
32
35
|
* @param context The current map context.
|
|
33
|
-
* @param layerModel The layer to be
|
|
34
|
-
* @param layerUpdates
|
|
36
|
+
* @param layerModel The layer to be updated.
|
|
37
|
+
* @param layerUpdates A partial layer object containing the properties to update on the existing layer.
|
|
35
38
|
* @returns The new map context with the updated layer.
|
|
36
39
|
*/
|
|
37
40
|
export declare function updateLayerInContext(context: MapContext, layerModel: MapContextLayer, layerUpdates: Partial<MapContextLayer>): MapContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-context.d.ts","sourceRoot":"","sources":["../../lib/utils/map-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGhE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,GAC1B,MAAM,CAER;AAED;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,EAC3B,QAAQ,CAAC,EAAE,MAAM,GAChB,UAAU,CAQZ;AAED;;;;;;GAMG;AAEH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,GAC1B,UAAU,CAOZ;AAED;;;;;;;GAOG;AAEH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,EAC3B,WAAW,EAAE,eAAe,GAC3B,UAAU,CAOZ;AAED
|
|
1
|
+
{"version":3,"file":"map-context.d.ts","sourceRoot":"","sources":["../../lib/utils/map-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGhE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,GAC1B,MAAM,CAER;AAED;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,EAC3B,QAAQ,CAAC,EAAE,MAAM,GAChB,UAAU,CAQZ;AAED;;;;;;GAMG;AAEH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,GAC1B,UAAU,CAOZ;AAED;;;;;;;GAOG;AAEH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,EAC3B,WAAW,EAAE,eAAe,GAC3B,UAAU,CAOZ;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,EAC3B,YAAY,EAAE,OAAO,CAAC,eAAe,CAAC,GACrC,UAAU,CAUZ;AAED;;;;;;;GAOG;AAEH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,MAAM,GACf,UAAU,CAGZ"}
|
|
@@ -52,17 +52,20 @@ export function replaceLayerInContext(context, layerModel, replacement) {
|
|
|
52
52
|
return newContext;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* Updates an existing layer in the context by applying partial changes.
|
|
56
|
+
*
|
|
57
|
+
* Note: setting a property to `undefined` in the partial layer updates will remove that
|
|
58
|
+
* property from the existing layer.
|
|
56
59
|
*
|
|
57
60
|
* @param context The current map context.
|
|
58
|
-
* @param layerModel The layer to be
|
|
59
|
-
* @param layerUpdates
|
|
61
|
+
* @param layerModel The layer to be updated.
|
|
62
|
+
* @param layerUpdates A partial layer object containing the properties to update on the existing layer.
|
|
60
63
|
* @returns The new map context with the updated layer.
|
|
61
64
|
*/
|
|
62
65
|
export function updateLayerInContext(context, layerModel, layerUpdates) {
|
|
63
66
|
const position = getLayerPosition(context, layerModel);
|
|
64
67
|
if (position >= 0) {
|
|
65
|
-
const existing = context.layers[
|
|
68
|
+
const existing = context.layers[position];
|
|
66
69
|
const updated = updateLayer(existing, layerUpdates);
|
|
67
70
|
return replaceLayerInContext(context, layerModel, updated);
|
|
68
71
|
}
|
|
@@ -18,6 +18,15 @@ export interface MapContextLayerReordered {
|
|
|
18
18
|
previousPosition: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Describes a layer that was changed: both states before and after change are included
|
|
23
|
+
*/
|
|
24
|
+
export interface MapContextLayerChanged {
|
|
25
|
+
layer: MapContextLayer;
|
|
26
|
+
previousLayer: MapContextLayer;
|
|
27
|
+
position: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
/**
|
|
22
31
|
* Describes a delta between two contexts, in order to be
|
|
23
32
|
* applied to an existing map.
|
|
@@ -29,7 +38,7 @@ export interface MapContextLayerReordered {
|
|
|
29
38
|
* 4. change layers
|
|
30
39
|
*/
|
|
31
40
|
export interface MapContextDiff {
|
|
32
|
-
layersChanged:
|
|
41
|
+
layersChanged: MapContextLayerChanged[];
|
|
33
42
|
layersReordered: MapContextLayerReordered[];
|
|
34
43
|
layersRemoved: MapContextLayerPositioned[];
|
|
35
44
|
layersAdded: MapContextLayerPositioned[];
|
|
@@ -121,10 +121,12 @@ describe("Context diff utils", () => {
|
|
|
121
121
|
layersChanged: [
|
|
122
122
|
{
|
|
123
123
|
layer: contextNew.layers[0],
|
|
124
|
+
previousLayer: contextOld.layers[0],
|
|
124
125
|
position: 0,
|
|
125
126
|
},
|
|
126
127
|
{
|
|
127
128
|
layer: contextNew.layers[1],
|
|
129
|
+
previousLayer: contextOld.layers[1],
|
|
128
130
|
position: 1,
|
|
129
131
|
},
|
|
130
132
|
],
|
|
@@ -356,6 +358,7 @@ describe("Context diff utils", () => {
|
|
|
356
358
|
layersChanged: [
|
|
357
359
|
{
|
|
358
360
|
layer: changedLayer,
|
|
361
|
+
previousLayer: SAMPLE_LAYER3,
|
|
359
362
|
position: 1,
|
|
360
363
|
},
|
|
361
364
|
],
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
MapContext,
|
|
3
3
|
MapContextDiff,
|
|
4
4
|
MapContextLayer,
|
|
5
|
+
MapContextLayerChanged,
|
|
5
6
|
MapContextLayerPositioned,
|
|
6
7
|
MapContextLayerReordered,
|
|
7
8
|
} from "../model/index.js";
|
|
@@ -42,7 +43,7 @@ export function computeMapContextDiff(
|
|
|
42
43
|
return -1;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
const layersChanged:
|
|
46
|
+
const layersChanged: MapContextLayerChanged[] = [];
|
|
46
47
|
const layersReordered: MapContextLayerReordered[] = [];
|
|
47
48
|
const layersRemoved: MapContextLayerPositioned[] = [];
|
|
48
49
|
const layersAdded: MapContextLayerPositioned[] = [];
|
|
@@ -66,7 +67,7 @@ export function computeMapContextDiff(
|
|
|
66
67
|
} else {
|
|
67
68
|
const prevLayer = previousContext.layers[prevPosition];
|
|
68
69
|
if (!isLayerSameAndUnchanged(layer, prevLayer)) {
|
|
69
|
-
layersChanged.push({ layer, position: i });
|
|
70
|
+
layersChanged.push({ layer, previousLayer: prevLayer, position: i });
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -347,5 +347,11 @@ describe("Map context layer utils", () => {
|
|
|
347
347
|
const updated = updateLayer(layer, { opacity: 0.6 });
|
|
348
348
|
expect(updated).not.toHaveProperty("version");
|
|
349
349
|
});
|
|
350
|
+
|
|
351
|
+
it("does not change the version if it is explicitly specified in the partial changes", () => {
|
|
352
|
+
const layer = { ...SAMPLE_LAYER1, id: "123", version: 3 };
|
|
353
|
+
const updated = updateLayer(layer, { opacity: 0.6, version: 12 });
|
|
354
|
+
expect(updated.version).toBe(12);
|
|
355
|
+
});
|
|
350
356
|
});
|
|
351
357
|
});
|
|
@@ -47,10 +47,13 @@ export function updateLayer(
|
|
|
47
47
|
...layer,
|
|
48
48
|
...updates,
|
|
49
49
|
} as MapContextLayer;
|
|
50
|
+
const versionExplicitlyUpdated =
|
|
51
|
+
"version" in updates && updates.version !== undefined;
|
|
50
52
|
if (
|
|
51
53
|
"id" in updatedLayer &&
|
|
52
54
|
"version" in updatedLayer &&
|
|
53
|
-
typeof updatedLayer.version === "number"
|
|
55
|
+
typeof updatedLayer.version === "number" &&
|
|
56
|
+
!versionExplicitlyUpdated
|
|
54
57
|
) {
|
|
55
58
|
updatedLayer.version = updatedLayer.version + 1;
|
|
56
59
|
}
|
package/lib/utils/map-context.ts
CHANGED
|
@@ -74,11 +74,14 @@ export function replaceLayerInContext(
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* Updates an existing layer in the context by applying partial changes.
|
|
78
|
+
*
|
|
79
|
+
* Note: setting a property to `undefined` in the partial layer updates will remove that
|
|
80
|
+
* property from the existing layer.
|
|
78
81
|
*
|
|
79
82
|
* @param context The current map context.
|
|
80
|
-
* @param layerModel The layer to be
|
|
81
|
-
* @param layerUpdates
|
|
83
|
+
* @param layerModel The layer to be updated.
|
|
84
|
+
* @param layerUpdates A partial layer object containing the properties to update on the existing layer.
|
|
82
85
|
* @returns The new map context with the updated layer.
|
|
83
86
|
*/
|
|
84
87
|
|
|
@@ -89,7 +92,7 @@ export function updateLayerInContext(
|
|
|
89
92
|
): MapContext {
|
|
90
93
|
const position = getLayerPosition(context, layerModel);
|
|
91
94
|
if (position >= 0) {
|
|
92
|
-
const existing = context.layers[
|
|
95
|
+
const existing = context.layers[position];
|
|
93
96
|
const updated = updateLayer(existing, layerUpdates);
|
|
94
97
|
return replaceLayerInContext(context, layerModel, updated);
|
|
95
98
|
}
|
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.49+67854c5",
|
|
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": "67854c5bbe5b473e1a8160f5e8e56fe162e1d427",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"proj4": "^2.9.2"
|
|
28
28
|
},
|