@geospatial-sdk/openlayers 0.0.5-dev.43 → 0.0.5-dev.44

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.
@@ -10,12 +10,12 @@ import {
10
10
  SAMPLE_LAYER3,
11
11
  SAMPLE_LAYER4,
12
12
  SAMPLE_LAYER5,
13
- } from "@geospatial-sdk/core/fixtures/map-context.fixtures";
14
- import Map from "ol/Map";
15
- import { createLayer, createMapFromContext } from "./create-map";
16
- import { applyContextDiffToMap } from "./apply-context-diff";
13
+ } from "@geospatial-sdk/core/fixtures/map-context.fixtures.js";
14
+ import Map from "ol/Map.js";
15
+ import { createLayer, createMapFromContext } from "./create-map.js";
16
+ import { applyContextDiffToMap } from "./apply-context-diff.js";
17
17
  import { beforeEach } from "vitest";
18
- import BaseLayer from "ol/layer/Base";
18
+ import BaseLayer from "ol/layer/Base.js";
19
19
 
20
20
  async function assertEqualsToModel(layer: any, layerModel: MapContextLayer) {
21
21
  const reference = (await createLayer(layerModel)) as any;
@@ -1,12 +1,12 @@
1
1
  import { FeatureCollection } from "geojson";
2
- import TileLayer from "ol/layer/Tile";
3
- import VectorLayer from "ol/layer/Vector";
4
- import Map from "ol/Map";
5
- import TileWMS from "ol/source/TileWMS";
6
- import VectorSource from "ol/source/Vector";
7
- import XYZ from "ol/source/XYZ";
8
- import View from "ol/View";
9
- import GeoJSON from "ol/format/GeoJSON";
2
+ import TileLayer from "ol/layer/Tile.js";
3
+ import VectorLayer from "ol/layer/Vector.js";
4
+ import Map from "ol/Map.js";
5
+ import TileWMS from "ol/source/TileWMS.js";
6
+ import VectorSource from "ol/source/Vector.js";
7
+ import XYZ from "ol/source/XYZ.js";
8
+ import View from "ol/View.js";
9
+ import GeoJSON from "ol/format/GeoJSON.js";
10
10
  import {
11
11
  MAP_CTX_EXTENT_FIXTURE,
12
12
  MAP_CTX_FIXTURE,
@@ -19,34 +19,35 @@ import {
19
19
  MAP_CTX_LAYER_WMS_FIXTURE,
20
20
  MAP_CTX_LAYER_WMTS_FIXTURE,
21
21
  MAP_CTX_LAYER_XYZ_FIXTURE,
22
- } from "@geospatial-sdk/core/fixtures/map-context.fixtures";
22
+ } from "@geospatial-sdk/core/fixtures/map-context.fixtures.js";
23
23
  import {
24
24
  MapContext,
25
25
  MapContextLayer,
26
26
  MapContextLayerGeojson,
27
27
  MapContextLayerWms,
28
- SourceLoadErrorEvent,
29
28
  } from "@geospatial-sdk/core";
30
- import Layer from "ol/layer/Layer";
29
+ import Layer from "ol/layer/Layer.js";
31
30
  import {
32
31
  createLayer,
33
32
  createMapFromContext,
34
33
  createView,
35
34
  resetMapFromContext,
36
- } from "./create-map";
37
- import WMTS from "ol/source/WMTS";
38
- import { VectorTile } from "ol/source";
35
+ } from "./create-map.js";
36
+ import WMTS from "ol/source/WMTS.js";
37
+ import { VectorTile } from "ol/source.js";
39
38
  import { MapboxVectorLayer } from "ol-mapbox-style";
40
39
  import {
41
40
  handleEndpointError,
42
41
  tileLoadErrorCatchFunction,
43
- } from "./handle-errors";
44
- import { ImageTile } from "ol";
42
+ } from "./handle-errors.js";
43
+ import ImageTile from "ol/ImageTile.js";
45
44
  import TileState from "ol/TileState.js";
46
- import VectorTileLayer from "ol/layer/VectorTile";
45
+ import VectorTileLayer from "ol/layer/VectorTile.js";
46
+ import { FeatureUrlFunction } from "ol/featureloader.js";
47
47
 
48
48
  vi.mock("./handle-errors", async (importOriginal) => {
49
- const actual = await importOriginal();
49
+ const actual =
50
+ (await importOriginal()) as typeof import("./handle-errors.js");
50
51
  return {
51
52
  ...actual,
52
53
  tileLoadErrorCatchFunction: vi.fn(),
@@ -144,7 +145,7 @@ describe("MapContextService", () => {
144
145
  expect(layer.getVisible()).toBe(false);
145
146
  expect(layer.getOpacity()).toBe(0.5);
146
147
  expect(layer.get("label")).toBe("Communes");
147
- // @ts-ignore
148
+ // @ts-expect-error TS2554 we're not providing a view extent here
148
149
  expect(layer.getSource()?.getAttributions()!()).toEqual(["camptocamp"]);
149
150
  });
150
151
  it("create a TileWMS source", () => {
@@ -204,7 +205,7 @@ describe("MapContextService", () => {
204
205
 
205
206
  const attributions = layer.getSource()?.getAttributions();
206
207
  expect(attributions).not.toBeNull();
207
- // @ts-ignore
208
+ // @ts-expect-error TS2554 we're not providing a view extent here
208
209
  expect(attributions!()).toEqual(["camptocamp"]);
209
210
  });
210
211
  it("create a Vector source", () => {
@@ -213,7 +214,8 @@ describe("MapContextService", () => {
213
214
  });
214
215
  it("set correct url load function", () => {
215
216
  const source = layer.getSource() as VectorSource;
216
- const urlLoader = source.getUrl() as Function;
217
+ const urlLoader = source.getUrl() as FeatureUrlFunction;
218
+ // @ts-expect-error TS2345
217
219
  expect(urlLoader([10, 20, 30, 40])).toBe(
218
220
  "https://www.datagrandest.fr/geoserver/region-grand-est/ows?service=WFS&version=1.1.0&request=GetFeature&outputFormat=application%2Fjson&typename=ms%3Acommune_actuelle_3857&srsname=EPSG%3A3857&bbox=10%2C20%2C30%2C40%2CEPSG%3A3857&maxFeatures=10000",
219
221
  );
@@ -1,11 +1,13 @@
1
1
  import { ImageTile, Tile } from "ol";
2
2
  import TileState from "ol/TileState.js";
3
3
  import { SourceLoadErrorEvent } from "@geospatial-sdk/core";
4
- import { handleTileError, tileLoadErrorCatchFunction } from "./handle-errors";
5
- import { Map } from "ol";
4
+ import {
5
+ handleTileError,
6
+ tileLoadErrorCatchFunction,
7
+ } from "./handle-errors.js";
6
8
  import { describe } from "node:test";
7
- import TileLayer from "ol/layer/Tile";
8
- import VectorLayer from "ol/layer/Vector";
9
+ import TileLayer from "ol/layer/Tile.js";
10
+ import VectorLayer from "ol/layer/Vector.js";
9
11
  import { EndpointError } from "@camptocamp/ogc-client";
10
12
 
11
13
  global.URL.createObjectURL = vi.fn(() => "blob:http://example.com/blob");
@@ -25,11 +27,9 @@ global.fetch = vi.fn().mockImplementation((url: string) => {
25
27
  });
26
28
 
27
29
  describe("handle-errors", () => {
28
- let map: Map;
29
30
  let tile: Tile;
30
31
 
31
32
  beforeEach(() => {
32
- map = new Map();
33
33
  tile = new ImageTile(
34
34
  [0, 0, 0],
35
35
  TileState.IDLE,
@@ -1,20 +1,20 @@
1
- import Map from "ol/Map";
1
+ import Map from "ol/Map.js";
2
2
  import { Mock } from "vitest";
3
3
  import {
4
4
  getFeaturesFromVectorSources,
5
5
  getFeaturesFromWmsSources,
6
6
  getGFIUrl,
7
7
  listen,
8
- } from "./register-events";
8
+ } from "./register-events.js";
9
9
  import { Collection, MapBrowserEvent, Object as BaseObject } from "ol";
10
- import View from "ol/View";
11
- import { toLonLat } from "ol/proj";
12
- import TileWMS from "ol/source/TileWMS";
13
- import VectorSource from "ol/source/Vector";
14
- import VectorLayer from "ol/layer/Vector";
15
- import Point from "ol/geom/Point";
16
- import TileLayer from "ol/layer/Tile";
17
- import OlFeature from "ol/Feature";
10
+ import View from "ol/View.js";
11
+ import { toLonLat } from "ol/proj.js";
12
+ import TileWMS from "ol/source/TileWMS.js";
13
+ import VectorSource from "ol/source/Vector.js";
14
+ import VectorLayer from "ol/layer/Vector.js";
15
+ import Point from "ol/geom/Point.js";
16
+ import TileLayer from "ol/layer/Tile.js";
17
+ import OlFeature from "ol/Feature.js";
18
18
 
19
19
  const EXPECTED_MAP_EXTENT_EPSG4326 = [
20
20
  -0.0035932611364780857, -0.0026949458513598756, 0.0035932611364780857,
@@ -1,15 +1,15 @@
1
1
  import chroma from "chroma-js";
2
- import Style from "ol/style/Style";
3
- import Feature from "ol/Feature";
4
- import { LineString, Point, Polygon } from "ol/geom";
2
+ import Style, { StyleFunction } from "ol/style/Style.js";
3
+ import Feature from "ol/Feature.js";
4
+ import { LineString, Point, Polygon } from "ol/geom.js";
5
5
  import {
6
6
  createGeometryStyles,
7
7
  createStyleFunction,
8
8
  defaultHighlightStyle,
9
9
  defaultStyle,
10
10
  StyleByGeometryType,
11
- } from "./styles";
12
- import CircleStyle from "ol/style/Circle";
11
+ } from "./styles.js";
12
+ import CircleStyle from "ol/style/Circle.js";
13
13
 
14
14
  describe("MapStyleService", () => {
15
15
  describe("#createGeometryStyles", () => {
@@ -139,7 +139,7 @@ describe("MapStyleService", () => {
139
139
  });
140
140
 
141
141
  describe("#createStyleFunction", () => {
142
- let styleFn: Function;
142
+ let styleFn: StyleFunction;
143
143
  let feature: Feature;
144
144
  it("returns a function", () => {
145
145
  styleFn = createStyleFunction(
@@ -154,7 +154,7 @@ describe("MapStyleService", () => {
154
154
  feature.setGeometry(new LineString([]));
155
155
  });
156
156
  it("resolves to a double style with stroke", () => {
157
- const style = styleFn(feature, 1);
157
+ const style = styleFn(feature, 1) as Style[];
158
158
  expect(style).toEqual([expect.any(Style), expect.any(Style)]);
159
159
  expect(style[0].getStroke()).toBeTruthy();
160
160
  expect(style[0].getFill()).toBeFalsy();
@@ -166,7 +166,7 @@ describe("MapStyleService", () => {
166
166
  feature.setGeometry(new Point([]));
167
167
  });
168
168
  it("resolves to a style with image", () => {
169
- const style = styleFn(feature, 1);
169
+ const style = styleFn(feature, 1) as Style;
170
170
  expect(style.getImage()).toBeTruthy();
171
171
  expect(style.getFill()).toBeFalsy();
172
172
  expect(style.getStroke()).toBeFalsy();
@@ -177,7 +177,7 @@ describe("MapStyleService", () => {
177
177
  feature.setGeometry(new Polygon([]));
178
178
  });
179
179
  it("resolves to a style with fill and stroke", () => {
180
- const style = styleFn(feature, 1);
180
+ const style = styleFn(feature, 1) as Style;
181
181
  expect(style.getFill()).toBeTruthy();
182
182
  expect(style.getStroke()).toBeTruthy();
183
183
  expect(style.getImage()).toBeFalsy();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geospatial-sdk/openlayers",
3
- "version": "0.0.5-dev.43+a7f100d",
3
+ "version": "0.0.5-dev.44+44c94a2",
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.43+a7f100d",
40
+ "@geospatial-sdk/core": "^0.0.5-dev.44+44c94a2",
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": "a7f100dfebe66dff0f44abb4c630917db89453fd"
45
+ "gitHead": "44c94a2e3458beb7e3f3ffc98ed170c21a0fc460"
46
46
  }