@geospatial-sdk/openlayers 0.0.5-dev.36 → 0.0.5-dev.38
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.
|
@@ -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;AAkCnC,wBAAsB,WAAW,CAAC,UAAU,EAAE,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,CA8N7E;AAED,wBAAgB,UAAU,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAkC3E;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
|
@@ -27,6 +27,7 @@ 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
29
|
import { handleEndpointError, tileLoadErrorCatchFunction, } from "./handle-errors";
|
|
30
|
+
import VectorTile from "ol/source/VectorTile";
|
|
30
31
|
const GEOJSON = new GeoJSON();
|
|
31
32
|
const WFS_MAX_FEATURES = 10000;
|
|
32
33
|
export function createLayer(layerModel) {
|
|
@@ -37,15 +38,26 @@ export function createLayer(layerModel) {
|
|
|
37
38
|
switch (type) {
|
|
38
39
|
case "xyz":
|
|
39
40
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
if (layerModel.tileFormat === "application/vnd.mapbox-vector-tile") {
|
|
42
|
+
layer = new VectorTileLayer({
|
|
43
|
+
source: new VectorTile({
|
|
44
|
+
format: new MVT(),
|
|
45
|
+
url: layerModel.url,
|
|
46
|
+
attributions: layerModel.attributions,
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
layer = new TileLayer({});
|
|
52
|
+
const source = new XYZ({
|
|
53
|
+
url: layerModel.url,
|
|
54
|
+
attributions: layerModel.attributions,
|
|
55
|
+
});
|
|
56
|
+
source.setTileLoadFunction(function (tile, src) {
|
|
57
|
+
return tileLoadErrorCatchFunction(layer, tile, src);
|
|
58
|
+
});
|
|
59
|
+
layer.setSource(source);
|
|
60
|
+
}
|
|
49
61
|
}
|
|
50
62
|
break;
|
|
51
63
|
case "wms":
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
MAP_CTX_LAYER_GEOJSON_FIXTURE,
|
|
14
14
|
MAP_CTX_LAYER_GEOJSON_REMOTE_FIXTURE,
|
|
15
15
|
MAP_CTX_LAYER_MAPBLIBRE_STYLE_FIXTURE,
|
|
16
|
+
MAP_CTX_LAYER_MVT_FIXTURE,
|
|
16
17
|
MAP_CTX_LAYER_OGCAPI_FIXTURE,
|
|
17
18
|
MAP_CTX_LAYER_WFS_FIXTURE,
|
|
18
19
|
MAP_CTX_LAYER_WMS_FIXTURE,
|
|
@@ -42,6 +43,7 @@ import {
|
|
|
42
43
|
} from "./handle-errors";
|
|
43
44
|
import { ImageTile } from "ol";
|
|
44
45
|
import TileState from "ol/TileState.js";
|
|
46
|
+
import VectorTileLayer from "ol/layer/VectorTile";
|
|
45
47
|
|
|
46
48
|
vi.mock("./handle-errors", async (importOriginal) => {
|
|
47
49
|
const actual = await importOriginal();
|
|
@@ -394,6 +396,26 @@ describe("MapContextService", () => {
|
|
|
394
396
|
expect(source).toBeInstanceOf(VectorTile);
|
|
395
397
|
});
|
|
396
398
|
});
|
|
399
|
+
|
|
400
|
+
describe("MVT", () => {
|
|
401
|
+
beforeEach(async () => {
|
|
402
|
+
(layerModel = MAP_CTX_LAYER_MVT_FIXTURE),
|
|
403
|
+
(layer = await createLayer(layerModel));
|
|
404
|
+
});
|
|
405
|
+
it("create a VectorTileLayer", () => {
|
|
406
|
+
expect(layer).toBeTruthy();
|
|
407
|
+
expect(layer).toBeInstanceOf(VectorTileLayer);
|
|
408
|
+
});
|
|
409
|
+
it("create a VectorTile source", () => {
|
|
410
|
+
const source = layer.getSource();
|
|
411
|
+
expect(source).toBeInstanceOf(VectorTile);
|
|
412
|
+
});
|
|
413
|
+
it("set correct layer properties", () => {
|
|
414
|
+
expect(layer.getVisible()).toBe(true);
|
|
415
|
+
expect(layer.getOpacity()).toBe(1);
|
|
416
|
+
expect(layer.get("label")).toBeUndefined();
|
|
417
|
+
});
|
|
418
|
+
});
|
|
397
419
|
});
|
|
398
420
|
|
|
399
421
|
describe("#createView", () => {
|
package/lib/map/create-map.ts
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
handleEndpointError,
|
|
36
36
|
tileLoadErrorCatchFunction,
|
|
37
37
|
} from "./handle-errors";
|
|
38
|
+
import VectorTile from "ol/source/VectorTile";
|
|
38
39
|
|
|
39
40
|
const GEOJSON = new GeoJSON();
|
|
40
41
|
const WFS_MAX_FEATURES = 10000;
|
|
@@ -45,15 +46,29 @@ export async function createLayer(layerModel: MapContextLayer): Promise<Layer> {
|
|
|
45
46
|
switch (type) {
|
|
46
47
|
case "xyz":
|
|
47
48
|
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
if (layerModel.tileFormat === "application/vnd.mapbox-vector-tile") {
|
|
50
|
+
layer = new VectorTileLayer({
|
|
51
|
+
source: new VectorTile({
|
|
52
|
+
format: new MVT(),
|
|
53
|
+
url: layerModel.url,
|
|
54
|
+
attributions: layerModel.attributions,
|
|
55
|
+
}),
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
layer = new TileLayer({});
|
|
59
|
+
const source = new XYZ({
|
|
60
|
+
url: layerModel.url,
|
|
61
|
+
attributions: layerModel.attributions,
|
|
62
|
+
});
|
|
63
|
+
source.setTileLoadFunction(function (tile: Tile, src: string) {
|
|
64
|
+
return tileLoadErrorCatchFunction(
|
|
65
|
+
layer as TileLayer<XYZ>,
|
|
66
|
+
tile,
|
|
67
|
+
src,
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
layer.setSource(source);
|
|
71
|
+
}
|
|
57
72
|
}
|
|
58
73
|
break;
|
|
59
74
|
case "wms":
|
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.38+fe1fda8",
|
|
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.38+fe1fda8",
|
|
41
41
|
"chroma-js": "^2.4.2",
|
|
42
42
|
"lodash.throttle": "^4.1.1",
|
|
43
43
|
"ol-mapbox-style": "12.4.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "fe1fda8882b1113ac9a52059a992836dd87cf23e"
|
|
46
46
|
}
|