@loaders.gl/wms 3.3.0-alpha.12 → 3.3.0-alpha.13

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 (199) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +6 -0
  4. package/dist/dist.min.js +4842 -5361
  5. package/dist/es5/index.js +41 -20
  6. package/dist/es5/index.js.map +1 -1
  7. package/dist/es5/lerc-loader.js +74 -0
  8. package/dist/es5/lerc-loader.js.map +1 -0
  9. package/dist/es5/lib/data-sources/adhoc-image-service.js +125 -0
  10. package/dist/es5/lib/data-sources/adhoc-image-service.js.map +1 -0
  11. package/dist/es5/lib/data-sources/image-source.js +14 -0
  12. package/dist/es5/lib/data-sources/image-source.js.map +1 -0
  13. package/dist/es5/lib/data-sources/wms-service.js +192 -173
  14. package/dist/es5/lib/data-sources/wms-service.js.map +1 -1
  15. package/dist/es5/lib/gml/deep-strict-equal.js +64 -0
  16. package/dist/es5/lib/gml/deep-strict-equal.js.map +1 -0
  17. package/dist/es5/lib/gml/parse-gml.js +3 -3
  18. package/dist/es5/lib/gml/parse-gml.js.map +1 -1
  19. package/dist/es5/lib/lerc/lerc-types.js +2 -0
  20. package/dist/es5/lib/lerc/lerc-types.js.map +1 -0
  21. package/dist/es5/lib/wcs/parse-wcs.js +43 -0
  22. package/dist/es5/lib/wcs/parse-wcs.js.map +1 -0
  23. package/dist/es5/lib/wcs/wcs-types.js +2 -0
  24. package/dist/es5/lib/wcs/wcs-types.js.map +1 -0
  25. package/dist/es5/lib/wms/parse-wms.js +6 -4
  26. package/dist/es5/lib/wms/parse-wms.js.map +1 -1
  27. package/dist/es5/wip/data-source.js +4 -0
  28. package/dist/es5/wip/data-source.js.map +1 -0
  29. package/dist/es5/{gml-loader.js → wip/gml-loader.js} +2 -2
  30. package/dist/es5/wip/gml-loader.js.map +1 -0
  31. package/dist/es5/{wcs-capabilities-loader.js → wip/wcs-capabilities-loader.js} +5 -5
  32. package/dist/es5/wip/wcs-capabilities-loader.js.map +1 -0
  33. package/dist/es5/{wfs-capabilities-loader.js → wip/wfs-capabilities-loader.js} +3 -3
  34. package/dist/es5/wip/wfs-capabilities-loader.js.map +1 -0
  35. package/dist/es5/{wms-feature-info-loader.js → wip/wms-feature-info-loader.js} +3 -3
  36. package/dist/es5/wip/wms-feature-info-loader.js.map +1 -0
  37. package/dist/es5/{wms-layer-description-loader.js → wip/wms-layer-description-loader.js} +3 -3
  38. package/dist/es5/wip/wms-layer-description-loader.js.map +1 -0
  39. package/dist/es5/wip/wms-layer-description-loader.md +47 -0
  40. package/dist/es5/{wmts-capabilities-loader.js → wip/wmts-capabilities-loader.js} +3 -3
  41. package/dist/es5/wip/wmts-capabilities-loader.js.map +1 -0
  42. package/dist/es5/wms-capabilities-loader.js +2 -2
  43. package/dist/es5/wms-capabilities-loader.js.map +1 -1
  44. package/dist/es5/wms-error-loader.js +22 -6
  45. package/dist/es5/wms-error-loader.js.map +1 -1
  46. package/dist/esm/index.js +11 -5
  47. package/dist/esm/index.js.map +1 -1
  48. package/dist/esm/lerc-loader.js +25 -0
  49. package/dist/esm/lerc-loader.js.map +1 -0
  50. package/dist/esm/lib/data-sources/adhoc-image-service.js +41 -0
  51. package/dist/esm/lib/data-sources/adhoc-image-service.js.map +1 -0
  52. package/dist/esm/lib/data-sources/image-source.js +4 -0
  53. package/dist/esm/lib/data-sources/image-source.js.map +1 -0
  54. package/dist/esm/lib/data-sources/wms-service.js +136 -116
  55. package/dist/esm/lib/data-sources/wms-service.js.map +1 -1
  56. package/dist/esm/lib/gml/deep-strict-equal.js +57 -0
  57. package/dist/esm/lib/gml/deep-strict-equal.js.map +1 -0
  58. package/dist/esm/lib/gml/parse-gml.js +1 -1
  59. package/dist/esm/lib/gml/parse-gml.js.map +1 -1
  60. package/dist/esm/lib/lerc/lerc-types.js +2 -0
  61. package/dist/esm/lib/lerc/lerc-types.js.map +1 -0
  62. package/dist/esm/lib/wcs/parse-wcs.js +32 -0
  63. package/dist/esm/lib/wcs/parse-wcs.js.map +1 -0
  64. package/dist/esm/lib/wcs/wcs-types.js +2 -0
  65. package/dist/esm/lib/wcs/wcs-types.js.map +1 -0
  66. package/dist/esm/lib/wms/parse-wms.js +6 -4
  67. package/dist/esm/lib/wms/parse-wms.js.map +1 -1
  68. package/dist/esm/wip/data-source.js +2 -0
  69. package/dist/esm/wip/data-source.js.map +1 -0
  70. package/dist/esm/{gml-loader.js → wip/gml-loader.js} +2 -2
  71. package/dist/esm/wip/gml-loader.js.map +1 -0
  72. package/dist/esm/{wcs-capabilities-loader.js → wip/wcs-capabilities-loader.js} +3 -3
  73. package/dist/esm/wip/wcs-capabilities-loader.js.map +1 -0
  74. package/dist/esm/{wfs-capabilities-loader.js → wip/wfs-capabilities-loader.js} +3 -3
  75. package/dist/esm/wip/wfs-capabilities-loader.js.map +1 -0
  76. package/dist/esm/{wms-feature-info-loader.js → wip/wms-feature-info-loader.js} +3 -3
  77. package/dist/esm/wip/wms-feature-info-loader.js.map +1 -0
  78. package/dist/esm/{wms-layer-description-loader.js → wip/wms-layer-description-loader.js} +3 -3
  79. package/dist/esm/wip/wms-layer-description-loader.js.map +1 -0
  80. package/dist/esm/wip/wms-layer-description-loader.md +47 -0
  81. package/dist/esm/{wmts-capabilities-loader.js → wip/wmts-capabilities-loader.js} +3 -3
  82. package/dist/esm/wip/wmts-capabilities-loader.js.map +1 -0
  83. package/dist/esm/wms-capabilities-loader.js +2 -2
  84. package/dist/esm/wms-capabilities-loader.js.map +1 -1
  85. package/dist/esm/wms-error-loader.js +20 -5
  86. package/dist/esm/wms-error-loader.js.map +1 -1
  87. package/dist/index.d.ts +25 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +27 -0
  90. package/dist/lerc-loader.d.ts +30 -0
  91. package/dist/lerc-loader.d.ts.map +1 -0
  92. package/dist/lerc-loader.js +56 -0
  93. package/dist/lib/data-sources/adhoc-image-service.d.ts +22 -0
  94. package/dist/lib/data-sources/adhoc-image-service.d.ts.map +1 -0
  95. package/dist/lib/data-sources/adhoc-image-service.js +44 -0
  96. package/dist/lib/data-sources/image-source.d.ts +73 -0
  97. package/dist/lib/data-sources/image-source.d.ts.map +1 -0
  98. package/dist/lib/data-sources/image-source.js +12 -0
  99. package/dist/lib/data-sources/wms-service.d.ts +193 -0
  100. package/dist/lib/data-sources/wms-service.d.ts.map +1 -0
  101. package/dist/lib/data-sources/wms-service.js +206 -0
  102. package/dist/lib/gml/deep-strict-equal.d.ts +3 -0
  103. package/dist/lib/gml/deep-strict-equal.d.ts.map +1 -0
  104. package/dist/lib/gml/deep-strict-equal.js +119 -0
  105. package/dist/lib/gml/parse-gml.d.ts +28 -0
  106. package/dist/lib/gml/parse-gml.d.ts.map +1 -0
  107. package/dist/lib/gml/parse-gml.js +371 -0
  108. package/dist/lib/lerc/lerc-types.d.ts +30 -0
  109. package/dist/lib/lerc/lerc-types.d.ts.map +1 -0
  110. package/dist/lib/lerc/lerc-types.js +3 -0
  111. package/dist/lib/wcs/parse-wcs.d.ts +7 -0
  112. package/dist/lib/wcs/parse-wcs.d.ts.map +1 -0
  113. package/dist/lib/wcs/parse-wcs.js +36 -0
  114. package/dist/lib/wcs/wcs-types.d.ts +73 -0
  115. package/dist/lib/wcs/wcs-types.d.ts.map +1 -0
  116. package/dist/lib/wcs/wcs-types.js +3 -0
  117. package/dist/lib/wfs/parse-wfs.d.ts +7 -0
  118. package/dist/lib/wfs/parse-wfs.d.ts.map +1 -0
  119. package/dist/lib/wfs/parse-wfs.js +36 -0
  120. package/dist/lib/wfs/wfs-types.d.ts +73 -0
  121. package/dist/lib/wfs/wfs-types.d.ts.map +1 -0
  122. package/dist/lib/wfs/wfs-types.js +3 -0
  123. package/dist/lib/wms/parse-wms.d.ts +24 -0
  124. package/dist/lib/wms/parse-wms.d.ts.map +1 -0
  125. package/dist/lib/wms/parse-wms.js +115 -0
  126. package/dist/lib/wms/wms-types.d.ts +100 -0
  127. package/dist/lib/wms/wms-types.d.ts.map +1 -0
  128. package/dist/lib/wms/wms-types.js +1908 -0
  129. package/dist/lib/wmts/parse-wmts.d.ts +7 -0
  130. package/dist/lib/wmts/parse-wmts.d.ts.map +1 -0
  131. package/dist/lib/wmts/parse-wmts.js +36 -0
  132. package/dist/lib/wmts/wmts-types.d.ts +73 -0
  133. package/dist/lib/wmts/wmts-types.d.ts.map +1 -0
  134. package/dist/lib/wmts/wmts-types.js +3 -0
  135. package/dist/wip/data-source.d.ts +53 -0
  136. package/dist/wip/data-source.d.ts.map +1 -0
  137. package/dist/wip/data-source.js +57 -0
  138. package/dist/wip/gml-loader.d.ts +26 -0
  139. package/dist/wip/gml-loader.d.ts.map +1 -0
  140. package/dist/wip/gml-loader.js +31 -0
  141. package/dist/wip/wcs-capabilities-loader.d.ts +26 -0
  142. package/dist/wip/wcs-capabilities-loader.d.ts.map +1 -0
  143. package/dist/wip/wcs-capabilities-loader.js +31 -0
  144. package/dist/wip/wfs-capabilities-loader.d.ts +26 -0
  145. package/dist/wip/wfs-capabilities-loader.d.ts.map +1 -0
  146. package/dist/wip/wfs-capabilities-loader.js +31 -0
  147. package/dist/wip/wms-feature-info-loader.d.ts +22 -0
  148. package/dist/wip/wms-feature-info-loader.d.ts.map +1 -0
  149. package/dist/wip/wms-feature-info-loader.js +17 -0
  150. package/dist/wip/wms-layer-description-loader.d.ts +22 -0
  151. package/dist/wip/wms-layer-description-loader.d.ts.map +1 -0
  152. package/dist/wip/wms-layer-description-loader.js +17 -0
  153. package/dist/wip/wmts-capabilities-loader.d.ts +26 -0
  154. package/dist/wip/wmts-capabilities-loader.d.ts.map +1 -0
  155. package/dist/wip/wmts-capabilities-loader.js +31 -0
  156. package/dist/wms-capabilities-loader.d.ts +26 -0
  157. package/dist/wms-capabilities-loader.d.ts.map +1 -0
  158. package/dist/wms-capabilities-loader.js +31 -0
  159. package/dist/wms-error-loader.d.ts +34 -0
  160. package/dist/wms-error-loader.d.ts.map +1 -0
  161. package/dist/wms-error-loader.js +43 -0
  162. package/package.json +9 -8
  163. package/src/index.ts +34 -13
  164. package/src/lerc-loader.ts +50 -0
  165. package/src/lib/data-sources/adhoc-image-service.ts +58 -0
  166. package/src/lib/data-sources/image-source.ts +82 -0
  167. package/src/lib/data-sources/wms-service.ts +211 -177
  168. package/src/lib/gml/deep-strict-equal.ts +119 -0
  169. package/src/lib/gml/parse-gml.ts +1 -1
  170. package/src/lib/lerc/lerc-types.ts +43 -0
  171. package/src/lib/wcs/parse-wcs.ts +39 -0
  172. package/src/lib/wcs/wcs-types.ts +77 -0
  173. package/src/lib/wms/parse-wms.ts +16 -3
  174. package/src/{lib/data-sources/image-data-source.ts → wip/data-source.ts} +6 -29
  175. package/src/{gml-loader.ts → wip/gml-loader.ts} +1 -1
  176. package/src/{wcs-capabilities-loader.ts → wip/wcs-capabilities-loader.ts} +2 -2
  177. package/src/{wfs-capabilities-loader.ts → wip/wfs-capabilities-loader.ts} +2 -2
  178. package/src/{wms-feature-info-loader.ts → wip/wms-feature-info-loader.ts} +3 -3
  179. package/src/wip/wms-layer-description-loader.md +47 -0
  180. package/src/{wms-layer-description-loader.ts → wip/wms-layer-description-loader.ts} +3 -3
  181. package/src/{wmts-capabilities-loader.ts → wip/wmts-capabilities-loader.ts} +2 -2
  182. package/src/wms-capabilities-loader.ts +1 -1
  183. package/src/wms-error-loader.ts +25 -6
  184. package/dist/es5/gml-loader.js.map +0 -1
  185. package/dist/es5/lib/data-sources/image-data-source.js +0 -4
  186. package/dist/es5/lib/data-sources/image-data-source.js.map +0 -1
  187. package/dist/es5/wcs-capabilities-loader.js.map +0 -1
  188. package/dist/es5/wfs-capabilities-loader.js.map +0 -1
  189. package/dist/es5/wms-feature-info-loader.js.map +0 -1
  190. package/dist/es5/wms-layer-description-loader.js.map +0 -1
  191. package/dist/es5/wmts-capabilities-loader.js.map +0 -1
  192. package/dist/esm/gml-loader.js.map +0 -1
  193. package/dist/esm/lib/data-sources/image-data-source.js +0 -2
  194. package/dist/esm/lib/data-sources/image-data-source.js.map +0 -1
  195. package/dist/esm/wcs-capabilities-loader.js.map +0 -1
  196. package/dist/esm/wfs-capabilities-loader.js.map +0 -1
  197. package/dist/esm/wms-feature-info-loader.js.map +0 -1
  198. package/dist/esm/wms-layer-description-loader.js.map +0 -1
  199. package/dist/esm/wmts-capabilities-loader.js.map +0 -1
@@ -2,36 +2,38 @@
2
2
 
3
3
  /* eslint-disable camelcase */
4
4
 
5
- import type {WMSCapabilities, WMSFeatureInfo, WMSLayerDescription} from '@loaders.gl/wms';
6
- import {
7
- WMSCapabilitiesLoader,
8
- WMSFeatureInfoLoader,
9
- WMSLayerDescriptionLoader,
10
- WMSErrorLoader
11
- } from '@loaders.gl/wms';
12
- import {ImageLoader, ImageType} from '@loaders.gl/images';
5
+ import type {ImageType} from '@loaders.gl/images';
6
+ import {ImageLoader} from '@loaders.gl/images';
13
7
  import {LoaderOptions} from '@loaders.gl/loader-utils';
14
8
 
9
+ import type {ImageSourceMetadata, GetImageParameters} from './image-source';
10
+ import {ImageSource} from './image-source';
11
+
12
+ import type {WMSCapabilities, WMSFeatureInfo, WMSLayerDescription} from '../wms/wms-types';
13
+ import {WMSCapabilitiesLoader} from '../../wms-capabilities-loader';
14
+ import {WMSFeatureInfoLoader} from '../../wip/wms-feature-info-loader';
15
+ import {WMSLayerDescriptionLoader} from '../../wip/wms-layer-description-loader';
16
+ import {WMSErrorLoader} from '../../wms-error-loader';
17
+
15
18
  type FetchLike = (url: string, options?: RequestInit) => Promise<Response>;
16
19
 
17
- export type WMSGetCapabilitiesParameters = {
20
+ type WMSCommonParameters = {
18
21
  /** In case the endpoint supports multiple services */
19
22
  service?: 'WMS';
20
23
  /** In case the endpoint supports multiple WMS versions */
21
24
  version?: '1.1.1' | '1.3.0';
25
+ };
26
+
27
+ export type WMSGetCapabilitiesParameters = WMSCommonParameters & {
22
28
  /** Request type */
23
29
  request?: 'GetCapabilities';
24
30
  };
25
31
 
26
- export type WMSGetMapParameters = {
27
- /** In case the endpoint supports multiple services */
28
- service?: 'WMS';
29
- /** In case the endpoint supports multiple WMS versions */
30
- version?: '1.1.1' | '1.3.0';
32
+ export type WMSGetMapParameters = WMSCommonParameters & {
31
33
  /** Request type */
32
34
  request?: 'GetMap';
33
35
  /** Layers to render */
34
- layers: string[];
36
+ layers: string | string[];
35
37
  /** Styling */
36
38
  styles?: unknown;
37
39
  /** bounding box of the requested map image */
@@ -47,11 +49,7 @@ export type WMSGetMapParameters = {
47
49
  };
48
50
 
49
51
  // https://imagery.pasda.psu.edu/arcgis/services/pasda/UrbanTreeCanopy_Landcover/MapServer/WmsServer?SERVICE=WMS&
50
- export type WMSGetFeatureInfoParameters = {
51
- /** In case the endpoint supports multiple services */
52
- service?: 'WMS';
53
- /** In case the endpoint supports multiple WMS versions */
54
- version?: '1.1.1' | '1.3.0';
52
+ export type WMSGetFeatureInfoParameters = WMSCommonParameters & {
55
53
  /** Request type */
56
54
  request?: 'GetFeatureInfo';
57
55
 
@@ -62,7 +60,7 @@ export type WMSGetFeatureInfoParameters = {
62
60
  /** list of layers to query (could be different from rendered layers) */
63
61
  query_layers: string[];
64
62
  /** MIME type of returned feature info */
65
- info_format: 'text/plain';
63
+ info_format?: 'text/plain';
66
64
 
67
65
  /** Layers to render */
68
66
  layers: string[];
@@ -80,234 +78,270 @@ export type WMSGetFeatureInfoParameters = {
80
78
  format?: 'image/png';
81
79
  };
82
80
 
83
- export type WMSDescribeLayerParameters = {
84
- /** In case the endpoint supports multiple services */
85
- service?: 'WMS';
86
- /** In case the endpoint supports multiple WMS versions */
87
- version?: '1.1.1' | '1.3.0';
81
+ export type WMSDescribeLayerParameters = WMSCommonParameters & {
88
82
  /** Request type */
89
83
  request?: 'DescribeLayer';
90
84
  };
91
85
 
92
- export type WMSGetLegendGraphicParameters = {
93
- /** In case the endpoint supports multiple services */
94
- service?: 'WMS';
95
- /** In case the endpoint supports multiple WMS versions */
96
- version?: '1.1.1' | '1.3.0';
86
+ export type WMSGetLegendGraphicParameters = WMSCommonParameters & {
97
87
  /** Request type */
98
88
  request?: 'GetLegendGraphic';
99
89
  };
100
90
 
101
- const WMS_GET_CAPABILITIES_DEFAULT_PARAMETERS: Required<WMSGetCapabilitiesParameters> = {
102
- service: 'WMS',
103
- version: '1.1.1',
104
- request: 'GetCapabilities'
105
- };
106
-
107
- const WMS_GET_MAP_DEFAULT_PARAMETERS: Required<WMSGetMapParameters> = {
108
- service: 'WMS',
109
- version: '1.1.1',
110
- request: 'GetMap',
111
- layers: [],
112
- styles: undefined,
113
- bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
114
- width: 1200,
115
- height: 900,
116
- srs: 'EPSG:4326',
117
- format: 'image/png'
118
- };
119
-
120
- const WMS_GET_FEATURE_INFO_DEFAULT_PARAMETERS: Required<WMSGetFeatureInfoParameters> = {
121
- service: 'WMS',
122
- version: '1.1.1',
123
- request: 'GetFeatureInfo',
124
- layers: [],
125
- styles: undefined,
126
- bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
127
- width: 1200,
128
- height: 900,
129
- srs: 'EPSG:4326',
130
- format: 'image/png',
131
-
132
- x: undefined!,
133
- y: undefined!,
134
- query_layers: [],
135
- info_format: 'text/plain'
136
- };
137
-
138
- const WMS_DESCRIBE_LAYER_DEFAULT_PARAMETERS: Required<WMSDescribeLayerParameters> = {
139
- service: 'WMS',
140
- version: '1.1.1',
141
- request: 'DescribeLayer'
142
- };
143
-
144
- const WMS_GET_LEGEND_GRAPHIC_DEFAULT_PARAMETERS: Required<WMSGetLegendGraphicParameters> = {
145
- service: 'WMS',
146
- version: '1.1.1',
147
- request: 'GetLegendGraphic'
148
- };
149
-
91
+ /** Properties that can be specified when creating a new WMS service */
150
92
  export type WMSServiceProps = {
151
- url: string;
93
+ /** Base URL to the service */
94
+ serviceUrl: string;
95
+ /** Any load options to the loaders.gl Loaders used by the WMSService methods */
152
96
  loadOptions?: LoaderOptions;
97
+ /** Override the fetch function if required */
153
98
  fetch?: typeof fetch | FetchLike;
154
99
  };
155
100
 
156
- export class WMSService {
157
- url: string;
158
- loadOptions: LoaderOptions;
101
+ /**
102
+ * The WMSService class provides
103
+ * - provides type safe methods to form URLs to a WMS service
104
+ * - provides type safe methods to query and parse results (and errors) from a WMS service
105
+ * - implements the ImageService interface
106
+ * @note Only the URL parameter conversion is supported. XML posts are not supported.
107
+ */
108
+ export class WMSService extends ImageSource {
109
+ serviceUrl: string;
110
+ loadOptions: LoaderOptions = {
111
+ // We want error responses to throw exceptions, the WMSErrorLoader can do this
112
+ wms: {throwOnError: true}
113
+ };
159
114
  fetch: typeof fetch | FetchLike;
160
115
 
116
+ /** A list of loaders used by the WMSService methods */
117
+ readonly loaders = [
118
+ ImageLoader,
119
+ WMSErrorLoader,
120
+ WMSCapabilitiesLoader,
121
+ WMSFeatureInfoLoader,
122
+ WMSLayerDescriptionLoader
123
+ ];
124
+
125
+ /** Create a WMSService */
161
126
  constructor(props: WMSServiceProps) {
162
- this.url = props.url;
163
- this.loadOptions = props.loadOptions || {};
127
+ super();
128
+ this.serviceUrl = props.serviceUrl;
129
+ // TODO Need an options merge function from loaders.gl to merge subobjects
130
+ Object.assign(this.loadOptions, props.loadOptions);
164
131
  this.fetch = props.fetch || fetch;
165
132
  }
166
133
 
167
- // Typed URL creators
168
-
169
- getCapabilitiesURL(
170
- parameters?: WMSGetCapabilitiesParameters,
171
- extra?: Record<string, unknown>
172
- ): string {
173
- const options: Required<WMSGetCapabilitiesParameters> = {
174
- ...WMS_GET_CAPABILITIES_DEFAULT_PARAMETERS,
175
- ...parameters,
176
- ...extra
177
- };
178
- return this.getWMSUrl(options, extra);
179
- }
180
-
181
- getMapURL(parameters: WMSGetMapParameters, extra?: Record<string, unknown>): string {
182
- const options: Required<WMSGetMapParameters> = {
183
- ...WMS_GET_MAP_DEFAULT_PARAMETERS,
184
- ...parameters,
185
- ...extra
186
- };
187
- return this.getWMSUrl(options, extra);
188
- }
189
-
190
- getFeatureInfoURL(
191
- parameters: WMSGetFeatureInfoParameters,
192
- extra?: Record<string, unknown>
193
- ): string {
194
- const options: Required<WMSGetFeatureInfoParameters> = {
195
- ...WMS_GET_FEATURE_INFO_DEFAULT_PARAMETERS,
196
- ...parameters,
197
- ...extra
198
- };
199
- return this.getWMSUrl(options, extra);
200
- }
201
-
202
- describeLayerURL(
203
- parameters: WMSDescribeLayerParameters,
204
- extra?: Record<string, unknown>
205
- ): string {
206
- const options: Required<WMSDescribeLayerParameters> = {
207
- ...WMS_DESCRIBE_LAYER_DEFAULT_PARAMETERS,
208
- ...parameters,
209
- ...extra
210
- };
211
- return this.getWMSUrl(options, extra);
134
+ // ImageSource implementation
135
+ getMetadata(): Promise<ImageSourceMetadata> {
136
+ return this.getCapabilities();
212
137
  }
213
138
 
214
- getLegendGraphicURL(
215
- parameters: WMSGetLegendGraphicParameters,
216
- extra?: Record<string, unknown>
217
- ): string {
218
- const options: Required<WMSGetLegendGraphicParameters> = {
219
- ...WMS_GET_LEGEND_GRAPHIC_DEFAULT_PARAMETERS,
220
- ...parameters,
221
- ...extra
222
- };
223
- return this.getWMSUrl(options, extra);
139
+ getImage(parameters: GetImageParameters): Promise<ImageType> {
140
+ return this.getMap(parameters);
224
141
  }
225
142
 
226
143
  // WMS Service API Stubs
227
144
 
228
145
  /** Get Capabilities */
229
146
  async getCapabilities(
230
- parameters?: WMSGetCapabilitiesParameters,
231
- extra?: Record<string, unknown>
147
+ wmsParameters?: WMSGetCapabilitiesParameters,
148
+ vendorParameters?: Record<string, unknown>
232
149
  ): Promise<WMSCapabilities> {
233
- const url = this.getCapabilitiesURL(parameters, extra);
234
- const response = await this.fetch(url, this.loadOptions);
235
- await this.checkResponse(response);
150
+ const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
151
+ const {fetch} = this;
152
+ const response = await fetch(url, this.loadOptions);
236
153
  const arrayBuffer = await response.arrayBuffer();
154
+ this._checkResponse(response, arrayBuffer);
237
155
  return await WMSCapabilitiesLoader.parse(arrayBuffer, this.loadOptions);
238
156
  }
239
157
 
240
158
  /** Get a map image */
241
- async getMap(options: WMSGetMapParameters, extra?: Record<string, unknown>): Promise<ImageType> {
242
- const url = this.getMapURL(options, extra);
243
- const response = await this.fetch(url, this.loadOptions);
244
- await this.checkResponse(response);
159
+ async getMap(
160
+ options: WMSGetMapParameters,
161
+ vendorParameters?: Record<string, unknown>
162
+ ): Promise<ImageType> {
163
+ const url = this.getMapURL(options, vendorParameters);
164
+ const {fetch} = this;
165
+ const response = await fetch(url, this.loadOptions);
245
166
  const arrayBuffer = await response.arrayBuffer();
246
- return await ImageLoader.parse(arrayBuffer, this.loadOptions);
167
+ this._checkResponse(response, arrayBuffer);
168
+ try {
169
+ return await ImageLoader.parse(arrayBuffer, this.loadOptions);
170
+ } catch {
171
+ throw this._parseError(arrayBuffer);
172
+ }
247
173
  }
248
174
 
249
175
  /** Get Feature Info for a coordinate */
250
176
  async getFeatureInfo(
251
177
  options: WMSGetFeatureInfoParameters,
252
- extra?: Record<string, unknown>
178
+ vendorParameters?: Record<string, unknown>
253
179
  ): Promise<WMSFeatureInfo> {
254
- const url = this.getFeatureInfoURL(options, extra);
180
+ const url = this.getFeatureInfoURL(options, vendorParameters);
255
181
  const response = await this.fetch(url, this.loadOptions);
256
- await this.checkResponse(response);
257
182
  const arrayBuffer = await response.arrayBuffer();
183
+ this._checkResponse(response, arrayBuffer);
258
184
  return await WMSFeatureInfoLoader.parse(arrayBuffer, this.loadOptions);
259
185
  }
260
186
 
261
187
  /** Get more information about a layer */
262
188
  async describeLayer(
263
189
  options: WMSDescribeLayerParameters,
264
- extra?: Record<string, unknown>
190
+ vendorParameters?: Record<string, unknown>
265
191
  ): Promise<WMSLayerDescription> {
266
- const url = this.describeLayerURL(options, extra);
192
+ const url = this.describeLayerURL(options, vendorParameters);
267
193
  const response = await this.fetch(url, this.loadOptions);
268
- await this.checkResponse(response);
269
194
  const arrayBuffer = await response.arrayBuffer();
195
+ this._checkResponse(response, arrayBuffer);
270
196
  return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.loadOptions);
271
197
  }
272
198
 
273
199
  /** Get an image with a semantic legend */
274
200
  async getLegendGraphic(
275
201
  options: WMSGetLegendGraphicParameters,
276
- extra?: Record<string, unknown>
202
+ vendorParameters?: Record<string, unknown>
277
203
  ): Promise<ImageType> {
278
- const url = this.getLegendGraphicURL(options, extra);
204
+ const url = this.getLegendGraphicURL(options, vendorParameters);
279
205
  const response = await this.fetch(url, this.loadOptions);
280
- await this.checkResponse(response);
281
206
  const arrayBuffer = await response.arrayBuffer();
282
- return await ImageLoader.parse(arrayBuffer, this.loadOptions);
207
+ this._checkResponse(response, arrayBuffer);
208
+ try {
209
+ return await ImageLoader.parse(arrayBuffer, this.loadOptions);
210
+ } catch {
211
+ throw this._parseError(arrayBuffer);
212
+ }
213
+ }
214
+
215
+ // Typed URL creators
216
+ // For applications that want full control of fetching and parsing
217
+
218
+ /** Generate a URL for the GetCapabilities request */
219
+ getCapabilitiesURL(
220
+ wmsParameters?: WMSGetCapabilitiesParameters,
221
+ vendorParameters?: Record<string, unknown>
222
+ ): string {
223
+ const options: Required<WMSGetCapabilitiesParameters> = {
224
+ service: 'WMS',
225
+ version: '1.1.1',
226
+ request: 'GetCapabilities',
227
+ ...wmsParameters,
228
+ ...vendorParameters
229
+ };
230
+ return this._getWMSUrl(options, vendorParameters);
231
+ }
232
+
233
+ /** Generate a URL for the GetMap request */
234
+ getMapURL(
235
+ wmsParameters: WMSGetMapParameters,
236
+ vendorParameters?: Record<string, unknown>
237
+ ): string {
238
+ const options: Required<WMSGetMapParameters> = {
239
+ service: 'WMS',
240
+ version: '1.1.1',
241
+ request: 'GetMap',
242
+ // layers: [],
243
+ // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
244
+ // width: 1200,
245
+ // height: 900,
246
+ styles: undefined,
247
+ srs: 'EPSG:4326',
248
+ format: 'image/png',
249
+ ...wmsParameters,
250
+ ...vendorParameters
251
+ };
252
+ return this._getWMSUrl(options, vendorParameters);
253
+ }
254
+
255
+ /** Generate a URL for the GetFeatureInfo request */
256
+ getFeatureInfoURL(
257
+ wmsParameters: WMSGetFeatureInfoParameters,
258
+ vendorParameters?: Record<string, unknown>
259
+ ): string {
260
+ const options: Required<WMSGetFeatureInfoParameters> = {
261
+ service: 'WMS',
262
+ version: '1.1.1',
263
+ request: 'GetFeatureInfo',
264
+ // layers: [],
265
+ // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
266
+ // width: 1200,
267
+ // height: 900,
268
+ // x: undefined!,
269
+ // y: undefined!,
270
+ // query_layers: [],
271
+ srs: 'EPSG:4326',
272
+ format: 'image/png',
273
+ info_format: 'text/plain',
274
+ styles: undefined,
275
+ ...wmsParameters,
276
+ ...vendorParameters
277
+ };
278
+ return this._getWMSUrl(options, vendorParameters);
279
+ }
280
+
281
+ /** Generate a URL for the GetFeatureInfo request */
282
+ describeLayerURL(
283
+ wmsParameters: WMSDescribeLayerParameters,
284
+ vendorParameters?: Record<string, unknown>
285
+ ): string {
286
+ const options: Required<WMSDescribeLayerParameters> = {
287
+ service: 'WMS',
288
+ version: '1.1.1',
289
+ request: 'DescribeLayer',
290
+ ...wmsParameters,
291
+ ...vendorParameters
292
+ };
293
+ return this._getWMSUrl(options, vendorParameters);
294
+ }
295
+
296
+ getLegendGraphicURL(
297
+ wmsParameters: WMSGetLegendGraphicParameters,
298
+ vendorParameters?: Record<string, unknown>
299
+ ): string {
300
+ const options: Required<WMSGetLegendGraphicParameters> = {
301
+ service: 'WMS',
302
+ version: '1.1.1',
303
+ request: 'GetLegendGraphic',
304
+ ...wmsParameters,
305
+ ...vendorParameters
306
+ };
307
+ return this._getWMSUrl(options, vendorParameters);
283
308
  }
284
309
 
285
310
  // INTERNAL METHODS
286
311
 
287
312
  /**
288
- * @note protected, since perhaps getWMSUrl may need to be overridden to handle certain backends?
289
- * @note if override is common, maybe add a callback prop?
313
+ * @note case _getWMSUrl may need to be overridden to handle certain backends?
290
314
  * */
291
- protected getWMSUrl(
292
- options: {
293
- request: string;
294
- layers?: string[];
295
- },
296
- extra?: Record<string, unknown>
315
+ protected _getWMSUrl(
316
+ options: Record<string, unknown>,
317
+ vendorParameters?: Record<string, unknown>
297
318
  ): string {
298
- let url = `${this.url}?REQUEST=${options.request}`;
299
- if (options.layers?.length) {
300
- url += `&LAYERS=[${options.layers.join(',')}]`;
319
+ let url = `${this.serviceUrl}`;
320
+ let first = true;
321
+ for (const [key, value] of Object.entries(options)) {
322
+ url += first ? '?' : '&';
323
+ first = false;
324
+ if (Array.isArray(value)) {
325
+ url += `${key.toUpperCase()}=${value.join(',')}`;
326
+ } else {
327
+ url += `${key.toUpperCase()}=${value ? String(value) : ''}`;
328
+ }
301
329
  }
302
- return url;
330
+ return encodeURI(url);
303
331
  }
304
332
 
305
333
  /** Checks for and parses a WMS XML formatted ServiceError and throws an exception */
306
- protected async checkResponse(response: Response) {
307
- if (!response.ok || response.headers['content-type'] === WMSErrorLoader.mimeTypes[0]) {
308
- const arrayBuffer = await response.arrayBuffer();
309
- const error = await WMSErrorLoader.parse(arrayBuffer, this.loadOptions);
334
+ protected _checkResponse(response: Response, arrayBuffer: ArrayBuffer): void {
335
+ const contentType = response.headers['content-type'];
336
+ if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
337
+ const error = WMSErrorLoader.parseSync(arrayBuffer, this.loadOptions);
310
338
  throw new Error(error);
311
339
  }
312
340
  }
341
+
342
+ /** Error situation detected */
343
+ protected _parseError(arrayBuffer: ArrayBuffer): Error {
344
+ const error = WMSErrorLoader.parseSync(arrayBuffer, this.loadOptions);
345
+ return new Error(error);
346
+ }
313
347
  }
@@ -0,0 +1,119 @@
1
+ // https://github.com/nodejs/node/commit/c1d82ac2ff15594840e2a1b9531b506ae067ed27;
2
+
3
+ // http://wiki.commonjs.org/wiki/Unit_Testing/1.0
4
+ //
5
+ // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
6
+ //
7
+ // Originally from narwhal.js (http://narwhaljs.org)
8
+ // Copyright (c) 2009 Thomas Robinson <280north.com>
9
+ //
10
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ // of this software and associated documentation files (the 'Software'), to
12
+ // deal in the Software without restriction, including without limitation the
13
+ // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14
+ // sell copies of the Software, and to permit persons to whom the Software is
15
+ // furnished to do so, subject to the following conditions:
16
+ //
17
+ // The above copyright notice and this permission notice shall be included in
18
+ // all copies or substantial portions of the Software.
19
+ //
20
+ // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24
+ // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+
27
+ /** @todo replace this ridiculous choice of deepStrictEqual */
28
+ // eslint-disable-next-line complexity
29
+ export function deepStrictEqual(actual: unknown, expected: unknown, strict?: boolean) {
30
+ // 7.1. All identical values are equivalent, as determined by ===.
31
+ if (actual === expected) {
32
+ return true;
33
+ // } else if (actual instanceof Buffer && expected instanceof Buffer) {
34
+ // return compare(actual, expected) === 0;
35
+
36
+ // // 7.2. If the expected value is a Date object, the actual value is
37
+ // // equivalent if it is also a Date object that refers to the same time.
38
+ } else if (actual instanceof Date && expected instanceof Date) {
39
+ return actual.getTime() === expected.getTime();
40
+
41
+ // 7.3 If the expected value is a RegExp object, the actual value is
42
+ // equivalent if it is also a RegExp object with the same source and
43
+ // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
44
+ } else if (actual instanceof RegExp && expected instanceof RegExp) {
45
+ return (
46
+ actual.source === expected.source &&
47
+ actual.global === expected.global &&
48
+ actual.multiline === expected.multiline &&
49
+ actual.lastIndex === expected.lastIndex &&
50
+ actual.ignoreCase === expected.ignoreCase
51
+ );
52
+
53
+ // 7.4. Other pairs that do not both pass typeof value == 'object',
54
+ // equivalence is determined by ==.
55
+ } else if (
56
+ (actual === null || typeof actual !== 'object') &&
57
+ (expected === null || typeof expected !== 'object')
58
+ ) {
59
+ // eslint-disable-next-line eqeqeq
60
+ return strict ? actual === expected : actual == expected;
61
+
62
+ // 7.5 For all other Object pairs, including Array objects, equivalence is
63
+ // determined by having the same number of owned properties (as verified
64
+ // with Object.prototype.hasOwnProperty.call), the same set of keys
65
+ // (although not necessarily the same order), equivalent values for every
66
+ // corresponding key, and an identical 'prototype' property. Note: this
67
+ // accounts for both named and indexed properties on Arrays.
68
+ }
69
+ return objEquiv(actual, expected, strict);
70
+ }
71
+
72
+ // eslint-disable-next-line @typescript-eslint/unbound-method
73
+ const pSlice = Array.prototype.slice;
74
+
75
+ function isPrimitive(arg) {
76
+ return arg === null || (typeof arg !== 'object' && typeof arg !== 'function');
77
+ }
78
+
79
+ function isArguments(object) {
80
+ // eslint-disable-next-line eqeqeq
81
+ return Object.prototype.toString.call(object) == '[object Arguments]';
82
+ }
83
+
84
+ // eslint-disable-next-line complexity
85
+ function objEquiv(a: unknown, b: unknown, strict) {
86
+ if (a === null || a === undefined || b === null || b === undefined) return false;
87
+ // if one is a primitive, the other must be same
88
+ if (isPrimitive(a) || isPrimitive(b)) return a === b;
89
+ if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
90
+ const aIsArgs = isArguments(a);
91
+ const bIsArgs = isArguments(b);
92
+ if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) return false;
93
+ if (aIsArgs) {
94
+ a = pSlice.call(a);
95
+ b = pSlice.call(b);
96
+ return deepStrictEqual(a, b, strict);
97
+ }
98
+ const ka = Object.keys(a);
99
+ const kb = Object.keys(b);
100
+ let key;
101
+ let i;
102
+ // having the same number of owned properties (keys incorporates
103
+ // hasOwnProperty)
104
+ if (ka.length !== kb.length) return false;
105
+ // the same set of keys (although not necessarily the same order),
106
+ ka.sort();
107
+ kb.sort();
108
+ // ~~~cheap key test
109
+ for (i = ka.length - 1; i >= 0; i--) {
110
+ if (ka[i] !== kb[i]) return false;
111
+ }
112
+ // equivalent values for every corresponding key, and
113
+ // ~~~possibly expensive deep test
114
+ for (i = ka.length - 1; i >= 0; i--) {
115
+ key = ka[i];
116
+ if (!deepStrictEqual(a[key], b[key], strict)) return false;
117
+ }
118
+ return true;
119
+ }
@@ -22,7 +22,7 @@ import type {
22
22
  } from '@loaders.gl/schema';
23
23
 
24
24
  import {XMLLoader} from '@loaders.gl/xml';
25
- import deepStrictEqual from 'deep-strict-equal';
25
+ import {deepStrictEqual} from './deep-strict-equal';
26
26
  import rewind from '@turf/rewind';
27
27
 
28
28
  function noTransform(...coords) {
@@ -0,0 +1,43 @@
1
+ // loaders.gl, MIT license
2
+
3
+ /** Data returned by LERC loader */
4
+ export type LERCData = {
5
+ /** Width of decoded image */
6
+ width: number;
7
+ /** Height of decoded image */
8
+ height: number;
9
+ /** The type of pixels represented in the output */
10
+ pixelType: LercPixelType;
11
+ /** [statistics_band1, statistics_band2, …] Each element is a statistics object representing min and max values */
12
+ statistics: BandStats[];
13
+ /** [band1, band2, …] Each band is a typed array of width * height * depthCount */
14
+ pixels: TypedArray[];
15
+ /** Typed array with a size of width*height, or null if all pixels are valid */
16
+ mask: Uint8Array;
17
+ /** Depth count */
18
+ depthCount: number;
19
+ /** array [band1_mask, band2_mask, …] Each band is a Uint8Array of width * height * depthCount */
20
+ bandMasks?: Uint8Array[];
21
+ };
22
+
23
+ export type LercPixelType = 'S8' | 'U8' | 'S16' | 'U16' | 'S32' | 'U32' | 'F32' | 'F64';
24
+
25
+ export interface BandStats {
26
+ minValue: number;
27
+ maxValue: number;
28
+ depthStats?: {
29
+ minValues: Float64Array;
30
+ maxValues: Float64Array;
31
+ };
32
+ }
33
+
34
+ export type TypedArray =
35
+ | Int8Array
36
+ | Uint8Array
37
+ | Uint8ClampedArray
38
+ | Int16Array
39
+ | Uint16Array
40
+ | Int32Array
41
+ | Uint32Array
42
+ | Float32Array
43
+ | Float64Array;