@geospatial-sdk/core 0.0.5-dev.38 → 0.0.5-dev.40
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/events.d.ts +12 -5
- package/dist/model/events.d.ts.map +1 -1
- package/dist/model/events.js +1 -0
- package/dist/utils/map-context-diff.d.ts.map +1 -1
- package/dist/utils/map-context-diff.js +1 -4
- package/lib/model/events.ts +13 -5
- package/lib/utils/map-context-diff.test.ts +32 -1
- package/lib/utils/map-context-diff.ts +1 -4
- package/package.json +2 -2
package/dist/model/events.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EndpointError } from "@camptocamp/ogc-client";
|
|
2
2
|
import { Feature } from "geojson";
|
|
3
3
|
import BaseEvent from "ol/events/Event";
|
|
4
|
+
import { Extent } from "ol/extent";
|
|
4
5
|
export declare const FeaturesClickEventType = "features-click";
|
|
5
6
|
export interface FeaturesClickEvent {
|
|
6
7
|
type: typeof FeaturesClickEventType;
|
|
@@ -16,11 +17,10 @@ export interface MapClickEvent {
|
|
|
16
17
|
type: typeof MapClickEventType;
|
|
17
18
|
coordinate: [number, number];
|
|
18
19
|
}
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
[SourceLoadErrorType]: SourceLoadErrorEvent;
|
|
20
|
+
export declare const MapExtentChangeEventType = "map-extent-change";
|
|
21
|
+
export interface MapExtentChangeEvent {
|
|
22
|
+
type: typeof MapExtentChangeEventType;
|
|
23
|
+
extent: Extent;
|
|
24
24
|
}
|
|
25
25
|
export declare const SourceLoadErrorType = "source-load-error";
|
|
26
26
|
export declare class SourceLoadErrorEvent extends BaseEvent {
|
|
@@ -28,4 +28,11 @@ export declare class SourceLoadErrorEvent extends BaseEvent {
|
|
|
28
28
|
httpStatus?: number;
|
|
29
29
|
constructor(error: EndpointError | Error | Response);
|
|
30
30
|
}
|
|
31
|
+
export interface MapEventsByType {
|
|
32
|
+
[FeaturesClickEventType]: FeaturesClickEvent;
|
|
33
|
+
[FeaturesHoverEventType]: FeaturesHoverEvent;
|
|
34
|
+
[MapClickEventType]: MapClickEvent;
|
|
35
|
+
[MapExtentChangeEventType]: MapExtentChangeEvent;
|
|
36
|
+
[SourceLoadErrorType]: SourceLoadErrorEvent;
|
|
37
|
+
}
|
|
31
38
|
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../lib/model/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,SAAS,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../lib/model/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AACvD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,sBAAsB,CAAC;IACpC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AACvD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,OAAO,sBAAsB,CAAC;IACpC,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAC7C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,iBAAiB,CAAC;IAC/B,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAC5D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,wBAAwB,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AACvD,qBAAa,oBAAqB,SAAQ,SAAS;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;gBACR,KAAK,EAAE,aAAa,GAAG,KAAK,GAAG,QAAQ;CAiBpD;AAED,MAAM,WAAW,eAAe;IAC9B,CAAC,sBAAsB,CAAC,EAAE,kBAAkB,CAAC;IAC7C,CAAC,sBAAsB,CAAC,EAAE,kBAAkB,CAAC;IAC7C,CAAC,iBAAiB,CAAC,EAAE,aAAa,CAAC;IACnC,CAAC,wBAAwB,CAAC,EAAE,oBAAoB,CAAC;IACjD,CAAC,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;CAC7C"}
|
package/dist/model/events.js
CHANGED
|
@@ -2,6 +2,7 @@ import BaseEvent from "ol/events/Event";
|
|
|
2
2
|
export const FeaturesClickEventType = "features-click";
|
|
3
3
|
export const FeaturesHoverEventType = "features-hover";
|
|
4
4
|
export const MapClickEventType = "map-click";
|
|
5
|
+
export const MapExtentChangeEventType = "map-extent-change";
|
|
5
6
|
export const SourceLoadErrorType = "source-load-error";
|
|
6
7
|
export class SourceLoadErrorEvent extends BaseEvent {
|
|
7
8
|
constructor(error) {
|
|
@@ -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,EAIf,MAAM,UAAU,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,EAIf,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,UAAU,EACvB,eAAe,EAAE,UAAU,GAC1B,cAAc,CA0EhB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isLayerSame, isLayerSameAndUnchanged } from "./map-context";
|
|
2
|
-
import { getHash } from "./hash";
|
|
3
2
|
/**
|
|
4
3
|
* The following logic is produced by identifying layers in both context
|
|
5
4
|
* and determining whether they have been added, removed, changed or reordered.
|
|
@@ -69,9 +68,7 @@ export function computeMapContextDiff(nextContext, previousContext) {
|
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
|
-
let viewChanges =
|
|
73
|
-
? nextContext.view
|
|
74
|
-
: undefined;
|
|
71
|
+
let viewChanges = nextContext.view !== previousContext.view ? nextContext.view : undefined;
|
|
75
72
|
if (viewChanges !== null && viewChanges !== undefined) {
|
|
76
73
|
viewChanges = Object.assign({}, viewChanges); // copy the view to avoid unexpected mutations
|
|
77
74
|
}
|
package/lib/model/events.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EndpointError } from "@camptocamp/ogc-client";
|
|
2
2
|
import { Feature } from "geojson";
|
|
3
3
|
import BaseEvent from "ol/events/Event";
|
|
4
|
+
import { Extent } from "ol/extent";
|
|
4
5
|
|
|
5
6
|
export const FeaturesClickEventType = "features-click";
|
|
6
7
|
export interface FeaturesClickEvent {
|
|
@@ -20,11 +21,10 @@ export interface MapClickEvent {
|
|
|
20
21
|
coordinate: [number, number]; // expressed in lon/lat
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[SourceLoadErrorType]: SourceLoadErrorEvent;
|
|
24
|
+
export const MapExtentChangeEventType = "map-extent-change";
|
|
25
|
+
export interface MapExtentChangeEvent {
|
|
26
|
+
type: typeof MapExtentChangeEventType;
|
|
27
|
+
extent: Extent;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export const SourceLoadErrorType = "source-load-error";
|
|
@@ -49,3 +49,11 @@ export class SourceLoadErrorEvent extends BaseEvent {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
export interface MapEventsByType {
|
|
54
|
+
[FeaturesClickEventType]: FeaturesClickEvent;
|
|
55
|
+
[FeaturesHoverEventType]: FeaturesHoverEvent;
|
|
56
|
+
[MapClickEventType]: MapClickEvent;
|
|
57
|
+
[MapExtentChangeEventType]: MapExtentChangeEvent;
|
|
58
|
+
[SourceLoadErrorType]: SourceLoadErrorEvent;
|
|
59
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SAMPLE_LAYER4,
|
|
9
9
|
SAMPLE_LAYER5,
|
|
10
10
|
} from "../../fixtures/map-context.fixtures";
|
|
11
|
-
import { describe } from "vitest";
|
|
11
|
+
import { describe, it, expect, beforeEach } from "vitest";
|
|
12
12
|
|
|
13
13
|
describe("Context diff utils", () => {
|
|
14
14
|
describe("computeMapContextDiff", () => {
|
|
@@ -295,6 +295,37 @@ describe("Context diff utils", () => {
|
|
|
295
295
|
});
|
|
296
296
|
});
|
|
297
297
|
});
|
|
298
|
+
describe("same content but different reference", () => {
|
|
299
|
+
beforeEach(() => {
|
|
300
|
+
contextOld = {
|
|
301
|
+
...SAMPLE_CONTEXT,
|
|
302
|
+
view: {
|
|
303
|
+
center: [5, 10],
|
|
304
|
+
zoom: 3,
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
contextNew = {
|
|
308
|
+
...SAMPLE_CONTEXT,
|
|
309
|
+
view: {
|
|
310
|
+
center: [5, 10],
|
|
311
|
+
zoom: 3,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
it("output the correct diff", () => {
|
|
316
|
+
diff = computeMapContextDiff(contextNew, contextOld);
|
|
317
|
+
expect(diff).toEqual({
|
|
318
|
+
layersAdded: [],
|
|
319
|
+
layersChanged: [],
|
|
320
|
+
layersRemoved: [],
|
|
321
|
+
layersReordered: [],
|
|
322
|
+
viewChanges: {
|
|
323
|
+
center: [5, 10],
|
|
324
|
+
zoom: 3,
|
|
325
|
+
},
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
});
|
|
298
329
|
});
|
|
299
330
|
|
|
300
331
|
describe("combined changes", () => {
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
MapContextLayerReordered,
|
|
7
7
|
} from "../model";
|
|
8
8
|
import { isLayerSame, isLayerSameAndUnchanged } from "./map-context";
|
|
9
|
-
import { getHash } from "./hash";
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
11
|
* The following logic is produced by identifying layers in both context
|
|
@@ -92,9 +91,7 @@ export function computeMapContextDiff(
|
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
let viewChanges =
|
|
95
|
-
|
|
96
|
-
? nextContext.view
|
|
97
|
-
: undefined;
|
|
94
|
+
nextContext.view !== previousContext.view ? nextContext.view : undefined;
|
|
98
95
|
if (viewChanges !== null && viewChanges !== undefined) {
|
|
99
96
|
viewChanges = { ...viewChanges }; // copy the view to avoid unexpected mutations
|
|
100
97
|
}
|
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.40+17bad88",
|
|
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": "17bad885319e693911c2219422bfe3fca4437fa2",
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"proj4": "^2.9.2"
|
|
28
28
|
},
|