@geospatial-sdk/openlayers 0.0.5-dev.20 → 0.0.5-dev.22
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/map/apply-context-diff.d.ts.map +1 -1
- package/dist/map/apply-context-diff.js +7 -4
- package/dist/map/create-map.d.ts +1 -0
- package/dist/map/create-map.d.ts.map +1 -1
- package/dist/map/create-map.js +1 -0
- package/lib/map/apply-context-diff.test.ts +41 -28
- package/lib/map/apply-context-diff.ts +7 -4
- package/lib/map/create-map.ts +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-context-diff.d.ts","sourceRoot":"","sources":["../../lib/map/apply-context-diff.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,cAAc,GAC1B,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"apply-context-diff.d.ts","sourceRoot":"","sources":["../../lib/map/apply-context-diff.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQtD;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,cAAc,GAC1B,OAAO,CAAC,GAAG,CAAC,CA2Fd"}
|
|
@@ -63,8 +63,14 @@ export function applyContextDiffToMap(map, contextDiff) {
|
|
|
63
63
|
map.setView(createView(viewChanges, map));
|
|
64
64
|
return map;
|
|
65
65
|
}
|
|
66
|
+
if (viewChanges.maxZoom) {
|
|
67
|
+
view.setMaxZoom(viewChanges.maxZoom);
|
|
68
|
+
}
|
|
66
69
|
if ("geometry" in viewChanges) {
|
|
67
|
-
const geom = GEOJSON.readGeometry(viewChanges.geometry
|
|
70
|
+
const geom = GEOJSON.readGeometry(viewChanges.geometry, {
|
|
71
|
+
dataProjection: "EPSG:4326",
|
|
72
|
+
featureProjection: projection,
|
|
73
|
+
});
|
|
68
74
|
view.fit(geom, {
|
|
69
75
|
size: map.getSize(),
|
|
70
76
|
});
|
|
@@ -81,9 +87,6 @@ export function applyContextDiffToMap(map, contextDiff) {
|
|
|
81
87
|
: [0, 0];
|
|
82
88
|
view.setCenter(center);
|
|
83
89
|
view.setZoom(zoom);
|
|
84
|
-
if (viewChanges.maxZoom) {
|
|
85
|
-
view.setMaxZoom(viewChanges.maxZoom);
|
|
86
|
-
}
|
|
87
90
|
// TODO: factorize this better
|
|
88
91
|
// if (viewChanges.maxExtent) {
|
|
89
92
|
// map.setView(new View({
|
package/dist/map/create-map.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { MapContext, MapContextLayer, MapContextView } from "@geospatial-sdk/cor
|
|
|
2
2
|
import Map from "ol/Map";
|
|
3
3
|
import View from "ol/View";
|
|
4
4
|
import Layer from "ol/layer/Layer";
|
|
5
|
+
import "ol/ol.css";
|
|
5
6
|
export declare function createLayer(layerModel: MapContextLayer): Promise<Layer>;
|
|
6
7
|
export declare function createView(viewModel: MapContextView | null, map: Map): View;
|
|
7
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-map.d.ts","sourceRoot":"","sources":["../../lib/map/create-map.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"create-map.d.ts","sourceRoot":"","sources":["../../lib/map/create-map.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,KAAK,MAAM,gBAAgB,CAAC;AAwBnC,OAAO,WAAW,CAAC;AAKnB,wBAAsB,WAAW,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,CAuL7E;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CA+B3E;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,UAAU,EACnB,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,GAC5B,OAAO,CAAC,GAAG,CAAC,CAKd;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,GAAG,CAAC,CAQd"}
|
package/dist/map/create-map.js
CHANGED
|
@@ -26,6 +26,7 @@ import WMTS from "ol/source/WMTS";
|
|
|
26
26
|
import MVT from "ol/format/MVT";
|
|
27
27
|
import { OgcApiEndpoint, WfsEndpoint, WmtsEndpoint, } from "@camptocamp/ogc-client";
|
|
28
28
|
import { MapboxVectorLayer } from "ol-mapbox-style";
|
|
29
|
+
import "ol/ol.css";
|
|
29
30
|
const GEOJSON = new GeoJSON();
|
|
30
31
|
const WFS_MAX_FEATURES = 10000;
|
|
31
32
|
export function createLayer(layerModel) {
|
|
@@ -229,11 +229,7 @@ describe("applyContextDiffToMap", () => {
|
|
|
229
229
|
describe("view change", () => {
|
|
230
230
|
describe("set to default view", () => {
|
|
231
231
|
beforeEach(async () => {
|
|
232
|
-
|
|
233
|
-
...SAMPLE_CONTEXT,
|
|
234
|
-
layers: [SAMPLE_LAYER1, SAMPLE_LAYER2, SAMPLE_LAYER3],
|
|
235
|
-
};
|
|
236
|
-
map = await createMapFromContext(context);
|
|
232
|
+
map = await createMapFromContext(SAMPLE_CONTEXT);
|
|
237
233
|
diff = {
|
|
238
234
|
layersAdded: [],
|
|
239
235
|
layersChanged: [],
|
|
@@ -250,39 +246,56 @@ describe("applyContextDiffToMap", () => {
|
|
|
250
246
|
});
|
|
251
247
|
});
|
|
252
248
|
|
|
253
|
-
describe("
|
|
249
|
+
describe("set to view with extent", () => {
|
|
254
250
|
beforeEach(async () => {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
251
|
+
map = await createMapFromContext(SAMPLE_CONTEXT);
|
|
252
|
+
diff = {
|
|
253
|
+
layersAdded: [],
|
|
254
|
+
layersChanged: [],
|
|
255
|
+
layersRemoved: [],
|
|
256
|
+
layersReordered: [],
|
|
257
|
+
viewChanges: {
|
|
258
|
+
extent: [-10, -10, 20, 20],
|
|
259
|
+
},
|
|
258
260
|
};
|
|
259
|
-
map
|
|
261
|
+
applyContextDiffToMap(map, diff);
|
|
262
|
+
});
|
|
263
|
+
it("set the view to the given extent, transformed to the view projection", () => {
|
|
264
|
+
const view = map.getView();
|
|
265
|
+
expect(view.getCenter()).toEqual([
|
|
266
|
+
556597.4539663679, 577070.4760648644,
|
|
267
|
+
]);
|
|
268
|
+
expect(view.getZoom()).toEqual(2);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe("set to view with geometry", () => {
|
|
273
|
+
beforeEach(async () => {
|
|
274
|
+
map = await createMapFromContext(SAMPLE_CONTEXT);
|
|
260
275
|
diff = {
|
|
261
276
|
layersAdded: [],
|
|
262
277
|
layersChanged: [],
|
|
263
278
|
layersRemoved: [],
|
|
264
|
-
layersReordered: [
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
previousPosition: 0,
|
|
279
|
+
layersReordered: [],
|
|
280
|
+
viewChanges: {
|
|
281
|
+
geometry: {
|
|
282
|
+
type: "LineString",
|
|
283
|
+
coordinates: [
|
|
284
|
+
[0, 0],
|
|
285
|
+
[10, 10],
|
|
286
|
+
[40, 10],
|
|
287
|
+
],
|
|
274
288
|
},
|
|
275
|
-
|
|
289
|
+
},
|
|
276
290
|
};
|
|
277
291
|
applyContextDiffToMap(map, diff);
|
|
278
|
-
layersArray = map.getLayers().getArray();
|
|
279
292
|
});
|
|
280
|
-
it("
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
293
|
+
it("set the view to the given extent, transformed to the view projection", () => {
|
|
294
|
+
const view = map.getView();
|
|
295
|
+
expect(view.getCenter()).toEqual([
|
|
296
|
+
2226389.8158654715, 559444.9874289795,
|
|
297
|
+
]);
|
|
298
|
+
expect(view.getZoom()).toEqual(1);
|
|
286
299
|
});
|
|
287
300
|
});
|
|
288
301
|
});
|
|
@@ -74,8 +74,14 @@ export async function applyContextDiffToMap(
|
|
|
74
74
|
map.setView(createView(viewChanges, map));
|
|
75
75
|
return map;
|
|
76
76
|
}
|
|
77
|
+
if (viewChanges.maxZoom) {
|
|
78
|
+
view.setMaxZoom(viewChanges.maxZoom);
|
|
79
|
+
}
|
|
77
80
|
if ("geometry" in viewChanges) {
|
|
78
|
-
const geom = GEOJSON.readGeometry(viewChanges.geometry
|
|
81
|
+
const geom = GEOJSON.readGeometry(viewChanges.geometry, {
|
|
82
|
+
dataProjection: "EPSG:4326",
|
|
83
|
+
featureProjection: projection,
|
|
84
|
+
});
|
|
79
85
|
view.fit(geom as SimpleGeometry, {
|
|
80
86
|
size: map.getSize(),
|
|
81
87
|
});
|
|
@@ -90,9 +96,6 @@ export async function applyContextDiffToMap(
|
|
|
90
96
|
: [0, 0];
|
|
91
97
|
view.setCenter(center);
|
|
92
98
|
view.setZoom(zoom);
|
|
93
|
-
if (viewChanges.maxZoom) {
|
|
94
|
-
view.setMaxZoom(viewChanges.maxZoom);
|
|
95
|
-
}
|
|
96
99
|
// TODO: factorize this better
|
|
97
100
|
// if (viewChanges.maxExtent) {
|
|
98
101
|
// map.setView(new View({
|
package/lib/map/create-map.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geospatial-sdk/openlayers",
|
|
3
|
-
"version": "0.0.5-dev.
|
|
3
|
+
"version": "0.0.5-dev.22+e299e56",
|
|
4
4
|
"description": "OpenLayers-related utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ol",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"ol": ">6.x"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@geospatial-sdk/core": "^0.0.5-dev.
|
|
40
|
+
"@geospatial-sdk/core": "^0.0.5-dev.22+e299e56",
|
|
41
41
|
"chroma-js": "^2.4.2",
|
|
42
42
|
"lodash.throttle": "^4.1.1",
|
|
43
43
|
"ol-mapbox-style": "^12.3.5"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e299e562a3b36fafdf548d2014dcb7319a641241"
|
|
46
46
|
}
|