@opengeoweb/webmap 2.0.1

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.
Files changed (61) hide show
  1. package/README.md +11 -0
  2. package/index.d.ts +1 -0
  3. package/lib/components/WMAnimate.d.ts +14 -0
  4. package/lib/components/WMBBOX.d.ts +31 -0
  5. package/lib/components/WMBBOX.spec.d.ts +1 -0
  6. package/lib/components/WMCanvasBuffer.d.ts +116 -0
  7. package/lib/components/WMCanvasBuffer.spec.d.ts +1 -0
  8. package/lib/components/WMConstants.d.ts +28 -0
  9. package/lib/components/WMDrawMarker.d.ts +2 -0
  10. package/lib/components/WMDrawMarker.spec.d.ts +1 -0
  11. package/lib/components/WMFlyToBBox.d.ts +22 -0
  12. package/lib/components/WMFlyToBBox.spec.d.ts +1 -0
  13. package/lib/components/WMGetServiceFromStore.d.ts +3 -0
  14. package/lib/components/WMGlobals.d.ts +7 -0
  15. package/lib/components/WMImage.d.ts +72 -0
  16. package/lib/components/WMImage.spec.d.ts +1 -0
  17. package/lib/components/WMImageStore.d.ts +45 -0
  18. package/lib/components/WMImageStore.spec.d.ts +1 -0
  19. package/lib/components/WMJSDimension.d.ts +89 -0
  20. package/lib/components/WMJSDimension.spec.d.ts +1 -0
  21. package/lib/components/WMJSExternalDependencies.d.ts +3 -0
  22. package/lib/components/WMJSMap.d.ts +310 -0
  23. package/lib/components/WMJSMap.spec.d.ts +1 -0
  24. package/lib/components/WMJSMap.stories.d.ts +6 -0
  25. package/lib/components/WMJSMapHelpers.d.ts +7 -0
  26. package/lib/components/WMJSMapHelpers.spec.d.ts +1 -0
  27. package/lib/components/WMJSService.d.ts +77 -0
  28. package/lib/components/WMJSService.spec.d.ts +1 -0
  29. package/lib/components/WMJSTools.d.ts +60 -0
  30. package/lib/components/WMJSTools.spec.d.ts +1 -0
  31. package/lib/components/WMLayer.d.ts +200 -0
  32. package/lib/components/WMLayer.spec.d.ts +1 -0
  33. package/lib/components/WMLegend.d.ts +6 -0
  34. package/lib/components/WMLegend.spec.d.ts +1 -0
  35. package/lib/components/WMListener.d.ts +14 -0
  36. package/lib/components/WMMapPin.d.ts +24 -0
  37. package/lib/components/WMProjection.d.ts +10 -0
  38. package/lib/components/WMTileRenderer.d.ts +7 -0
  39. package/lib/components/WMTileRenderer.spec.d.ts +1 -0
  40. package/lib/components/WMTime.d.ts +41 -0
  41. package/lib/components/WMTime.spec.d.ts +1 -0
  42. package/lib/components/WMTimeTypes.d.ts +19 -0
  43. package/lib/components/WMTimer.d.ts +11 -0
  44. package/lib/components/WMTimer.spec.d.ts +1 -0
  45. package/lib/components/WMXMLParser.d.ts +9 -0
  46. package/lib/components/WMXMLParser.spec.d.ts +1 -0
  47. package/lib/components/index.d.ts +18 -0
  48. package/lib/components/types.d.ts +37 -0
  49. package/lib/utils/I18n/lang.en.d.ts +387 -0
  50. package/lib/utils/I18n/lang.nl.d.ts +387 -0
  51. package/lib/utils/specs/WMS111GetCapabilitiesGeoServicesRADAR.d.ts +2 -0
  52. package/lib/utils/specs/WMS130GetCapabilitiesHarmN25.d.ts +2 -0
  53. package/lib/utils/specs/WMS130GetCapabilitiesRadarTestWithInheritAndReplaceLayerprops.d.ts +2 -0
  54. package/lib/utils/specs/WMS130GetCapabilitiesRadarTestWithInheritLayerprops.d.ts +2 -0
  55. package/lib/utils/specs/WMS130GetCapabilitiesRadarTestWithoutInheritLayerprops.d.ts +2 -0
  56. package/lib/utils/specs/WMSSmartMet.d.ts +2 -0
  57. package/lib/utils/testUtils.d.ts +35 -0
  58. package/lib/utils/tilesettings.d.ts +335 -0
  59. package/package.json +21 -0
  60. package/webmap.esm.js +9017 -0
  61. package/webmap.umd.js +9014 -0
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ ![current version](https://img.shields.io/badge/dynamic/json?color=blue&label=version&query=version&url=https://gitlab.com/opengeoweb/opengeoweb/raw/master/libs/webmap/package.json)
2
+ ![coverage](https://gitlab.com/opengeoweb/opengeoweb/badges/master/coverage.svg?job=test-webmap)
3
+
4
+ # webmap
5
+
6
+ Library with webmap components for the opengeoweb project.
7
+ This library was generated with [Nx](https://nx.dev).
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test webmap` to execute the unit tests via [Jest](https://jestjs.io).
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/components';
@@ -0,0 +1,14 @@
1
+ import type WMJSMap from './WMJSMap';
2
+ export default class WMJSAnimate {
3
+ private _map;
4
+ private _divAnimationInfo;
5
+ private _callBack;
6
+ private _imageStore;
7
+ private isNextTimeCloseToWallClockTime;
8
+ constructor(_map: WMJSMap);
9
+ _isCurrentAnimationTimeCloseToWallClockTime(): boolean;
10
+ _animate(): void;
11
+ _animateLoop(): void;
12
+ checkAnimation(): void;
13
+ stopAnimating(): void;
14
+ }
@@ -0,0 +1,31 @@
1
+ export declare type Bbox = {
2
+ left: number;
3
+ right: number;
4
+ top: number;
5
+ bottom: number;
6
+ };
7
+ export default class WMBBOX {
8
+ left: number;
9
+ bottom: number;
10
+ right: number;
11
+ top: number;
12
+ constructor(left?: number | string | Bbox, bottom?: number, right?: number, top?: number);
13
+ /**
14
+ * Clone an existing BBOX
15
+ */
16
+ clone(): WMBBOX;
17
+ copy(bbox: WMBBOX): void;
18
+ /**
19
+ * setBBOX method
20
+ * Creates a WebMapJS bounding box based on 4 numeric values
21
+ * Creates a WebMapJS bounding box based on 1 string with commaseparated numeric values
22
+ * Creates a WebMapJS bounding box based on an exisiting WebMapJS bounding box.
23
+ * When no parameters are given, a global latlon bbox is generated.
24
+ */
25
+ setBBOX(left?: number | string | Bbox, bottom?: number, right?: number, top?: number): void;
26
+ equals(left: number | string | WMBBOX, bottom: number, right: number, top: number): boolean;
27
+ /**
28
+ * Returns the current BBOX as a string, useful for generating WMS requests.
29
+ */
30
+ toString(): string;
31
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,116 @@
1
+ import WMImage from './WMImage';
2
+ import WMImageStore from './WMImageStore';
3
+ import WMBBOX from './WMBBOX';
4
+ import WMListener from './WMListener';
5
+ import { LinkedInfo, LinkedInfoContent, WMPosition } from './types';
6
+ declare type InternalCallback = {
7
+ beforecanvasstartdraw?: (context: CanvasRenderingContext2D) => void;
8
+ beforecanvasdisplay?: (context: CanvasRenderingContext2D) => void;
9
+ canvasonerror?: (e: LinkedInfo[]) => void;
10
+ aftercanvasdisplay?: (c: CanvasRenderingContext2D) => void;
11
+ };
12
+ interface CanvasBBOX {
13
+ left: number;
14
+ right: number;
15
+ top: number;
16
+ bottom: number;
17
+ }
18
+ export interface CanvasGeoLayer {
19
+ bbox: CanvasBBOX;
20
+ opacity: number;
21
+ imageSource: string;
22
+ }
23
+ /**
24
+ * Function to find image url's which are similar to other images, without taking width, height and bbox into account
25
+ * @param imageSource The source / url of the image to check
26
+ * @returns A signature for this image, which is the same for images with different bbox and or width/height
27
+ */
28
+ export declare const makeQueryStringWithoutGeoInfo: (imageSource: string) => string;
29
+ /**
30
+ * Add an image to the sharedimages list
31
+ * @param newLayer A canvaslayer object to add.
32
+ */
33
+ export declare const addAlternativeImage: (newLayer: CanvasGeoLayer) => void;
34
+ /**
35
+ * Removes the image from the alternative imageslist (in case imagestore cache gets cleaned), this used when the imagestore triggers a delete event for an image
36
+ * @param imageUrl The url for the image to remove
37
+ */
38
+ export declare const removeAlternativeImage: (imageUrl: string) => void;
39
+ /**
40
+ * Made accessible for testing purposes
41
+ * @returns
42
+ */
43
+ export declare const getSharedImagesList: () => Record<string, CanvasGeoLayer[]>;
44
+ /**
45
+ * Algorithm two determine how much two bboxes are similar
46
+ * @param rect1
47
+ * @param rect2
48
+ * @returns
49
+ */
50
+ export declare const geClosestBBox: (rect1: CanvasBBOX, rect2: CanvasBBOX) => number;
51
+ /**
52
+ * Sort the imageslist by overlapping area, highest area first
53
+ * @param imagesList
54
+ * @param bbox
55
+ * @returns
56
+ */
57
+ export declare const sortByOverlappingArea: (imagesList: CanvasGeoLayer[], bbox: CanvasBBOX) => CanvasGeoLayer[];
58
+ /**
59
+ * Function to find the an alternative available image for an image url that is not yet loaded
60
+ * @param imageUrl The image source / url to find an alternative for
61
+ * @param imageStore The imagestore where the other images are located
62
+ * @param bbox The boundingbox to search this image for
63
+ * @returns A canvasLayer, containing the new image source with its geo properties
64
+ */
65
+ export declare const getAlternativeImage: (imageUrl: string, imageStore: WMImageStore, bbox: CanvasBBOX) => CanvasGeoLayer;
66
+ export default class WMCanvasBuffer {
67
+ canvas: HTMLCanvasElement;
68
+ _ctx: CanvasRenderingContext2D;
69
+ _imageStore: WMImageStore;
70
+ ready: boolean;
71
+ layers: CanvasGeoLayer[];
72
+ _defaultImage: WMImage;
73
+ _currentbbox: WMBBOX;
74
+ _currentnewbbox: WMBBOX;
75
+ _width: number;
76
+ _height: number;
77
+ _webmapJSCallback: WMListener;
78
+ nrLoading: number;
79
+ onLoadReadyFunction: (param: any) => void;
80
+ _internalCallbacks: InternalCallback;
81
+ srs: string;
82
+ bbox: WMBBOX;
83
+ _errorList: LinkedInfo[];
84
+ constructor(webmapJSCallback: WMListener, _imageStore: WMImageStore, w: number, h: number, internalCallbacks: InternalCallback);
85
+ getCanvasContext(): CanvasRenderingContext2D;
86
+ /**
87
+ * Triggered by the WMImageStore when an image completes loading
88
+ * @param image
89
+ */
90
+ imageLoadComplete(image: WMImage): void;
91
+ /**
92
+ * Checks if all images are loaded, if so it will call finishedLoading
93
+ * @returns
94
+ */
95
+ _statDivBufferImageLoaded(): void;
96
+ reset(): void;
97
+ _drawImage(canvasLayer: CanvasGeoLayer): void;
98
+ display(): void;
99
+ finishedLoading(): void;
100
+ resize(w: string, h: string): void;
101
+ /**
102
+ * Set's a layer inside the canvasbuffer with given index and imagesource.
103
+ * The image is directly loaded, but if loading is not complete when drawing, an alternative image is search in the alternative images list
104
+ * @param layerIndex The layer index, similar to z-Index, 0 drawn on the bottom, higher numbers on top
105
+ * @param imageSource The url of the image, usually a GetMap url
106
+ * @param linkedInfo A linkedinfo object to track properties for the image and layer, like errors
107
+ * @param opacity Opacity of this layer
108
+ * @param bbox The boundingbox for this layer
109
+ * @returns Void
110
+ */
111
+ setSrc(layerIndex: number, imageSource: string, linkedInfo: LinkedInfoContent, opacity: number, bbox: WMBBOX): void;
112
+ _getPixelCoordFromGeoCoord(coordinates: WMPosition, b: WMBBOX): WMPosition;
113
+ setBBOX(newbbox: WMBBOX, loadedbbox: WMBBOX): void;
114
+ getBuffer(): HTMLCanvasElement;
115
+ }
116
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ export declare const WMEmptyLayerName = "empty_layer";
2
+ export declare const WMEmptyLayerTitle = "empty layer";
3
+ export declare const WMDateOutSideRange = "outside range";
4
+ export declare const WMDateTooEarlyString = "date too early";
5
+ export declare const WMDateTooLateString = "date too late";
6
+ export declare const WMSVersion: {
7
+ version100: string;
8
+ version111: string;
9
+ version130: string;
10
+ };
11
+ export declare const WMProj4Defs: string[][];
12
+ export declare const epsgDescriptionLookup: {
13
+ 'EPSG:3411': string;
14
+ 'EPSG:3412': string;
15
+ 'EPSG:3575': string;
16
+ 'EPSG:3785': string;
17
+ 'EPSG:3857': string;
18
+ 'EPSG:4258': string;
19
+ 'EPSG:4326': string;
20
+ 'CRS:84': string;
21
+ 'EPSG:25831': string;
22
+ 'EPSG:25832': string;
23
+ 'EPSG:28992': string;
24
+ 'EPSG:32661': string;
25
+ };
26
+ export declare const mapImageStoreLength = 1000;
27
+ export declare const bgImageStoreLength = 360;
28
+ export declare const legendImageStoreLength = 500;
@@ -0,0 +1,2 @@
1
+ declare const WMDrawMarker: (context: CanvasRenderingContext2D, coordx: number, coordy: number, fillColor?: string, outlineColor?: string) => void;
2
+ export default WMDrawMarker;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import WMBBOX from './WMBBOX';
2
+ import type WMJSMap from './WMJSMap';
3
+ export default class WMFlyToBBox {
4
+ private wmMap;
5
+ private flyZoomToBBOXTimerStart;
6
+ private flyZoomToBBOXTimerSteps;
7
+ private flyZoomToBBOXTimerLoop;
8
+ private flyZoomToBBOXDebounced;
9
+ private flyZoomToBBOXScaler;
10
+ private flyZoomToBBOXCurrent;
11
+ flyZoomToBBOXFly: WMBBOX;
12
+ private flyZoomToBBOXNew;
13
+ private flyZoomToBBOXContinueNew;
14
+ private flyZoomToBBOXTimerFuncBusy;
15
+ private flyZoomToBBOXTimerFuncBusyAndContinue;
16
+ constructor(wmMap: WMJSMap);
17
+ flyZoomToBBOXTimerFuncReadyDebounced: () => void;
18
+ flyZoomToBBOXTimerFunc: () => void;
19
+ resetBBoxTimer: () => void;
20
+ flyZoomToBBOXStop: () => void;
21
+ flyZoomToBBOXStartZoom: (currentbox: WMBBOX, newbox: WMBBOX) => void;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { WMJSService } from './WMJSService';
2
+ declare const WMGetServiceFromStore: (serviceName: string, xml2jsonrequestURL?: string) => WMJSService;
3
+ export default WMGetServiceFromStore;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Global service store for re-use of services
3
+ */
4
+ export declare const WMServiceStore: any[];
5
+ export declare const WMServiceStoreXML2JSONRequest: {
6
+ proxy: string;
7
+ };
@@ -0,0 +1,72 @@
1
+ export interface WMImageOptions {
2
+ randomizer?: boolean;
3
+ headers: Headers[];
4
+ }
5
+ /**
6
+ * WMImage provides an API to the HTML image element. It is used for caching and easier access to images.
7
+ */
8
+ export default class WMImage {
9
+ imageLife: number;
10
+ randomize: boolean;
11
+ _srcLoaded: string;
12
+ _isLoaded: boolean;
13
+ _isLoading: boolean;
14
+ _hasError: boolean;
15
+ srcToLoad: string;
16
+ loadEventCallback: (image: WMImage) => void;
17
+ el: HTMLImageElement;
18
+ headers: Headers[];
19
+ /**
20
+ *
21
+ * @param src Optionally set the source URL to load
22
+ * @param callback Optionally set the callback function to trigger once image has loaded
23
+ * @param options Additional options to the image. You can set { randomizer: true } to force unique url's and prevent caching.
24
+ */
25
+ constructor(src: string, callback?: (image: WMImage) => void, options?: WMImageOptions);
26
+ private init;
27
+ /**
28
+ * Returns true if the image has been loaded
29
+ */
30
+ isLoaded(): boolean;
31
+ /**
32
+ * Returns true if the image is still loading
33
+ */
34
+ isLoading(): boolean;
35
+ /**
36
+ * Set source of image, but it will not load the image yet.
37
+ * @param src URL of the image to load
38
+ * @param options WMImageOptions to give to the image
39
+ */
40
+ setSource(src: string, options: WMImageOptions): void;
41
+ /**
42
+ * Re-intialize the image
43
+ */
44
+ clear(): void;
45
+ /**
46
+ * Get the URL of the image
47
+ */
48
+ getSrc(): string;
49
+ /**
50
+ * Check if the image has an error
51
+ */
52
+ hasError(): boolean;
53
+ /**
54
+ * Start loading the image
55
+ */
56
+ load(): void;
57
+ private _getImageWithHeaders;
58
+ private _load;
59
+ private _loadEvent;
60
+ /**
61
+ * Get the width of the current image
62
+ */
63
+ getWidth(): number;
64
+ /**
65
+ * Get the height of the current image
66
+ */
67
+ getHeight(): number;
68
+ /**
69
+ * Get the HTMLImageElement behind the WMImage
70
+ */
71
+ getElement(): HTMLImageElement;
72
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ import WMImage, { WMImageOptions } from './WMImage';
2
+ export declare enum WMImageEventType {
3
+ Loaded = 0,
4
+ Deleted = 1
5
+ }
6
+ export default class WMImageStore {
7
+ imagesbysrc: Record<string, WMImage>;
8
+ imageLife: number;
9
+ _imageLifeCounter: number;
10
+ _loadEventCallbackList: Array<{
11
+ id: string;
12
+ callback: (image: WMImage, id: string, imageEventType: WMImageEventType) => void;
13
+ }>;
14
+ _maxNumberOfImages: number;
15
+ _options: {
16
+ id: string;
17
+ };
18
+ emptyImage: WMImage;
19
+ /**
20
+ * Constructs a new WMImageStore with given amount of image cache.
21
+ * @param {*} maxNumberOfImages
22
+ * @param {*} options
23
+ */
24
+ constructor(maxNumberOfImages: number, options: {
25
+ id: string;
26
+ });
27
+ load(imageUrl: string): void;
28
+ imageLoadEventCallback(_img: WMImage, imageEventType: WMImageEventType): void;
29
+ /**
30
+ * Check if we have similar images with the same source in the pipeline
31
+ */
32
+ getImageForSrc(src: string): WMImage;
33
+ clear(): void;
34
+ addImageEventCallback(callback: (image: WMImage, id: string, imageEventType: WMImageEventType) => void, id: string): void;
35
+ removeAllEventCallbacks(): void;
36
+ removeEventCallback(id: string): void;
37
+ getNumImagesLoading(): number;
38
+ /**
39
+ * Get an WMImage object for given URL
40
+ * @param {*} src The url for the image
41
+ * @returns WMImage object
42
+ */
43
+ getImage(src: string, loadOptions?: WMImageOptions): WMImage;
44
+ }
45
+ export declare const getMapImageStore: WMImageStore;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ interface WMJSDimensionConfig {
2
+ name?: string;
3
+ units?: string;
4
+ values?: string;
5
+ currentValue?: string;
6
+ defaultValue?: string;
7
+ linked?: boolean;
8
+ unitSymbol?: string;
9
+ synced?: boolean;
10
+ }
11
+ /**
12
+ * WMJSDimension Class
13
+ * Keep all information for a single dimension, like time.
14
+ * Author : MaartenPlieger (plieger at knmi.nl)
15
+ * Copyright KNMI
16
+ */
17
+ export default class WMJSDimension {
18
+ currentValue: string;
19
+ defaultValue: string;
20
+ name: string;
21
+ units: string;
22
+ unitSymbol: string;
23
+ linked: boolean;
24
+ synced: boolean;
25
+ used?: boolean;
26
+ values?: string;
27
+ timeRangeDuration?: any;
28
+ private _initialized;
29
+ private _timeRangeDurationDate;
30
+ private _allDates;
31
+ private _type;
32
+ private _allValues;
33
+ dimMinValue: string;
34
+ dimMaxValue: string;
35
+ dimTimeInterval: any;
36
+ constructor(config?: WMJSDimensionConfig);
37
+ generateAllValues(): number[];
38
+ setTimeValuesForReferenceTime(referenceTimeValueToSet: string, referenceTimeDim: WMJSDimension): void;
39
+ reInitializeValues(values: string, forceReferenceTimeValue?: boolean): void;
40
+ initialize(forceothervalues?: any, forceReferenceTimeValue?: boolean): void;
41
+ /**
42
+ * Returns the current value of this dimensions.
43
+ * If a ISO8601 period is set, the getValue will return a timeRange using addTimeRangeDurationToValue instead of a single value
44
+ */
45
+ getValue(): string;
46
+ /**
47
+ * Set current value of this dimension
48
+ * @param value The new value for this dimension (string)
49
+ * @param forceValue When set to false,check if the given value is outside range, and do nothing if this is the case
50
+ */
51
+ setValue(value: string, forceValue?: boolean): void;
52
+ setClosestValue(newValue?: any, evenWhenOutsideRange?: boolean): void;
53
+ addTimeRangeDurationToValue(value: string): string;
54
+ setTimeRangeDuration(duration: string): void;
55
+ getClosestValue(_newValue: string, evenWhenOutsideRange?: boolean): string;
56
+ /**
57
+ * Get dimension value for specified index
58
+ */
59
+ getValueForIndex(index: number): string;
60
+ /**
61
+ * Shorthand functionf or getValueForIndex
62
+ */
63
+ get(index: number): string;
64
+ /**
65
+ * Returns the first dimension value
66
+ */
67
+ getFirstValue(): string;
68
+ /**
69
+ * Returns the last dimension value
70
+ */
71
+ getLastValue(): string;
72
+ /**
73
+ * Get index value for specified value. Returns the index in the store for the given time value, either a date or a iso8601 string can be passes as input.
74
+ * @param value Either a JS Date object or an ISO8601 String
75
+ * @return The index of the value. If outSideOfRangeFlag is false, a valid index will
76
+ * always be returned. If outSideOfRangeFlag is true: -1 if the index is not in the store,
77
+ * but is lower than available values, -2 if the index is not in store, but is higher than available values
78
+ */
79
+ getIndexForValue(value: string, outSideOfRangeFlag?: boolean): number;
80
+ /**
81
+ * Get number of values
82
+ */
83
+ size(): number;
84
+ /**
85
+ * Clone this dimension
86
+ */
87
+ clone(): WMJSDimension;
88
+ }
89
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import * as moment from 'moment';
2
+ import proj4 from 'proj4';
3
+ export { moment, proj4 };