@loaders.gl/wms 3.4.0-alpha.3 → 4.0.0-alpha.6

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 (196) hide show
  1. package/dist/dist.min.js +133 -80
  2. package/dist/es5/csw-capabilities-loader.js +1 -1
  3. package/dist/es5/csw-capabilities-loader.js.map +1 -1
  4. package/dist/es5/csw-domain-loader.js +1 -1
  5. package/dist/es5/csw-domain-loader.js.map +1 -1
  6. package/dist/es5/csw-records-loader.js +1 -1
  7. package/dist/es5/csw-records-loader.js.map +1 -1
  8. package/dist/es5/gml-loader.js +1 -1
  9. package/dist/es5/gml-loader.js.map +1 -1
  10. package/dist/es5/lerc-loader.js +1 -1
  11. package/dist/es5/lerc-loader.js.map +1 -1
  12. package/dist/es5/lib/create-image-source.js.map +1 -1
  13. package/dist/es5/lib/parsers/csw/parse-csw-capabilities.js +2 -1
  14. package/dist/es5/lib/parsers/csw/parse-csw-capabilities.js.map +1 -1
  15. package/dist/es5/lib/parsers/csw/parse-csw-domain.js +2 -1
  16. package/dist/es5/lib/parsers/csw/parse-csw-domain.js.map +1 -1
  17. package/dist/es5/lib/parsers/csw/parse-csw-records.js +6 -5
  18. package/dist/es5/lib/parsers/csw/parse-csw-records.js.map +1 -1
  19. package/dist/es5/lib/parsers/csw/parse-exception-report.js.map +1 -1
  20. package/dist/es5/lib/parsers/gml/deep-strict-equal.js.map +1 -1
  21. package/dist/es5/lib/parsers/gml/parse-gml.js +2 -1
  22. package/dist/es5/lib/parsers/gml/parse-gml.js.map +1 -1
  23. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js +2 -1
  24. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js.map +1 -1
  25. package/dist/es5/lib/parsers/wms/parse-wms-features.js +2 -2
  26. package/dist/es5/lib/parsers/wms/parse-wms-features.js.map +1 -1
  27. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js +2 -1
  28. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js.map +1 -1
  29. package/dist/es5/lib/parsers/xml/parse-xml-helpers.js.map +1 -1
  30. package/dist/es5/lib/services/arcgis/arcgis-image-service.js +1 -6
  31. package/dist/es5/lib/services/arcgis/arcgis-image-service.js.map +1 -1
  32. package/dist/es5/lib/services/arcgis/arcgis-server.js.map +1 -1
  33. package/dist/es5/lib/services/generic/image-service.js +1 -6
  34. package/dist/es5/lib/services/generic/image-service.js.map +1 -1
  35. package/dist/es5/lib/services/ogc/csw-service.js +0 -2
  36. package/dist/es5/lib/services/ogc/csw-service.js.map +1 -1
  37. package/dist/es5/lib/services/ogc/wms-service.js +62 -20
  38. package/dist/es5/lib/services/ogc/wms-service.js.map +1 -1
  39. package/dist/es5/lib/sources/data-source.js +36 -8
  40. package/dist/es5/lib/sources/data-source.js.map +1 -1
  41. package/dist/es5/lib/sources/image-source.js.map +1 -1
  42. package/dist/es5/lib/sources/tile-source.js.map +1 -1
  43. package/dist/es5/lib/wfs/parse-wfs.js +41 -0
  44. package/dist/es5/lib/wfs/parse-wfs.js.map +1 -0
  45. package/dist/es5/lib/wmts/parse-wmts.js +41 -0
  46. package/dist/es5/lib/wmts/parse-wmts.js.map +1 -0
  47. package/dist/es5/wip/arcgis-feature-service.js.map +1 -1
  48. package/dist/es5/wip/lib/wcs/parse-wcs-capabilities.js +2 -1
  49. package/dist/es5/wip/lib/wcs/parse-wcs-capabilities.js.map +1 -1
  50. package/dist/es5/wip/lib/wfs/parse-wfs-capabilities.js +2 -1
  51. package/dist/es5/wip/lib/wfs/parse-wfs-capabilities.js.map +1 -1
  52. package/dist/es5/wip/lib/wmts/parse-wmts-capabilities.js +2 -1
  53. package/dist/es5/wip/lib/wmts/parse-wmts-capabilities.js.map +1 -1
  54. package/dist/es5/wip/wcs-capabilities-loader.js +1 -1
  55. package/dist/es5/wip/wcs-capabilities-loader.js.map +1 -1
  56. package/dist/es5/wip/wfs-capabilities-loader.js +1 -1
  57. package/dist/es5/wip/wfs-capabilities-loader.js.map +1 -1
  58. package/dist/es5/wip/wms-feature-info-loader.js.map +1 -1
  59. package/dist/es5/wip/wms-layer-description-loader.js.map +1 -1
  60. package/dist/es5/wip/wmts-capabilities-loader.js +1 -1
  61. package/dist/es5/wip/wmts-capabilities-loader.js.map +1 -1
  62. package/dist/es5/wms-capabilities-loader.js +1 -1
  63. package/dist/es5/wms-capabilities-loader.js.map +1 -1
  64. package/dist/es5/wms-error-loader.js +1 -1
  65. package/dist/es5/wms-error-loader.js.map +1 -1
  66. package/dist/esm/csw-capabilities-loader.js +1 -1
  67. package/dist/esm/csw-capabilities-loader.js.map +1 -1
  68. package/dist/esm/csw-domain-loader.js +1 -1
  69. package/dist/esm/csw-domain-loader.js.map +1 -1
  70. package/dist/esm/csw-records-loader.js +1 -1
  71. package/dist/esm/csw-records-loader.js.map +1 -1
  72. package/dist/esm/gml-loader.js +1 -1
  73. package/dist/esm/gml-loader.js.map +1 -1
  74. package/dist/esm/lerc-loader.js +1 -1
  75. package/dist/esm/lerc-loader.js.map +1 -1
  76. package/dist/esm/lib/create-image-source.js.map +1 -1
  77. package/dist/esm/lib/parsers/csw/parse-csw-capabilities.js +2 -1
  78. package/dist/esm/lib/parsers/csw/parse-csw-capabilities.js.map +1 -1
  79. package/dist/esm/lib/parsers/csw/parse-csw-domain.js +2 -1
  80. package/dist/esm/lib/parsers/csw/parse-csw-domain.js.map +1 -1
  81. package/dist/esm/lib/parsers/csw/parse-csw-records.js +7 -6
  82. package/dist/esm/lib/parsers/csw/parse-csw-records.js.map +1 -1
  83. package/dist/esm/lib/parsers/csw/parse-exception-report.js.map +1 -1
  84. package/dist/esm/lib/parsers/gml/deep-strict-equal.js.map +1 -1
  85. package/dist/esm/lib/parsers/gml/parse-gml.js +2 -1
  86. package/dist/esm/lib/parsers/gml/parse-gml.js.map +1 -1
  87. package/dist/esm/lib/parsers/wms/parse-wms-capabilities.js +2 -1
  88. package/dist/esm/lib/parsers/wms/parse-wms-capabilities.js.map +1 -1
  89. package/dist/esm/lib/parsers/wms/parse-wms-features.js +2 -2
  90. package/dist/esm/lib/parsers/wms/parse-wms-features.js.map +1 -1
  91. package/dist/esm/lib/parsers/wms/parse-wms-layer-description.js +2 -1
  92. package/dist/esm/lib/parsers/wms/parse-wms-layer-description.js.map +1 -1
  93. package/dist/esm/lib/parsers/xml/parse-xml-helpers.js.map +1 -1
  94. package/dist/esm/lib/services/arcgis/arcgis-image-service.js +0 -2
  95. package/dist/esm/lib/services/arcgis/arcgis-image-service.js.map +1 -1
  96. package/dist/esm/lib/services/arcgis/arcgis-server.js.map +1 -1
  97. package/dist/esm/lib/services/generic/image-service.js +0 -2
  98. package/dist/esm/lib/services/generic/image-service.js.map +1 -1
  99. package/dist/esm/lib/services/ogc/csw-service.js +0 -2
  100. package/dist/esm/lib/services/ogc/csw-service.js.map +1 -1
  101. package/dist/esm/lib/services/ogc/wms-service.js +54 -14
  102. package/dist/esm/lib/services/ogc/wms-service.js.map +1 -1
  103. package/dist/esm/lib/sources/data-source.js +20 -0
  104. package/dist/esm/lib/sources/data-source.js.map +1 -1
  105. package/dist/esm/lib/sources/image-source.js.map +1 -1
  106. package/dist/esm/lib/sources/tile-source.js.map +1 -1
  107. package/dist/esm/lib/wfs/parse-wfs.js +28 -0
  108. package/dist/esm/lib/wfs/parse-wfs.js.map +1 -0
  109. package/dist/esm/lib/wmts/parse-wmts.js +28 -0
  110. package/dist/esm/lib/wmts/parse-wmts.js.map +1 -0
  111. package/dist/esm/wip/lib/wcs/parse-wcs-capabilities.js +2 -1
  112. package/dist/esm/wip/lib/wcs/parse-wcs-capabilities.js.map +1 -1
  113. package/dist/esm/wip/lib/wfs/parse-wfs-capabilities.js +2 -1
  114. package/dist/esm/wip/lib/wfs/parse-wfs-capabilities.js.map +1 -1
  115. package/dist/esm/wip/lib/wmts/parse-wmts-capabilities.js +2 -1
  116. package/dist/esm/wip/lib/wmts/parse-wmts-capabilities.js.map +1 -1
  117. package/dist/esm/wip/wcs-capabilities-loader.js +1 -1
  118. package/dist/esm/wip/wcs-capabilities-loader.js.map +1 -1
  119. package/dist/esm/wip/wfs-capabilities-loader.js +1 -1
  120. package/dist/esm/wip/wfs-capabilities-loader.js.map +1 -1
  121. package/dist/esm/wip/wms-feature-info-loader.js.map +1 -1
  122. package/dist/esm/wip/wms-layer-description-loader.js.map +1 -1
  123. package/dist/esm/wip/wmts-capabilities-loader.js +1 -1
  124. package/dist/esm/wip/wmts-capabilities-loader.js.map +1 -1
  125. package/dist/esm/wms-capabilities-loader.js +1 -1
  126. package/dist/esm/wms-capabilities-loader.js.map +1 -1
  127. package/dist/esm/wms-error-loader.js +1 -1
  128. package/dist/esm/wms-error-loader.js.map +1 -1
  129. package/dist/lib/create-image-source.d.ts +1 -1
  130. package/dist/lib/create-image-source.d.ts.map +1 -1
  131. package/dist/lib/parsers/csw/parse-csw-capabilities.js +1 -1
  132. package/dist/lib/parsers/csw/parse-csw-domain.js +1 -1
  133. package/dist/lib/parsers/csw/parse-csw-records.js +6 -6
  134. package/dist/lib/parsers/csw/parse-exception-report.js +1 -1
  135. package/dist/lib/parsers/gml/parse-gml.js +1 -1
  136. package/dist/lib/parsers/wms/parse-wms-capabilities.js +2 -1
  137. package/dist/lib/parsers/wms/parse-wms-features.js +1 -1
  138. package/dist/lib/parsers/wms/parse-wms-layer-description.js +1 -1
  139. package/dist/lib/services/arcgis/arcgis-image-service.d.ts +1 -2
  140. package/dist/lib/services/arcgis/arcgis-image-service.d.ts.map +1 -1
  141. package/dist/lib/services/arcgis/arcgis-image-service.js +0 -1
  142. package/dist/lib/services/generic/image-service.d.ts +2 -3
  143. package/dist/lib/services/generic/image-service.d.ts.map +1 -1
  144. package/dist/lib/services/generic/image-service.js +0 -1
  145. package/dist/lib/services/ogc/csw-service.d.ts +1 -2
  146. package/dist/lib/services/ogc/csw-service.d.ts.map +1 -1
  147. package/dist/lib/services/ogc/csw-service.js +0 -1
  148. package/dist/lib/services/ogc/wms-service.d.ts +84 -43
  149. package/dist/lib/services/ogc/wms-service.d.ts.map +1 -1
  150. package/dist/lib/services/ogc/wms-service.js +73 -27
  151. package/dist/lib/sources/data-source.d.ts +12 -2
  152. package/dist/lib/sources/data-source.d.ts.map +1 -1
  153. package/dist/lib/sources/data-source.js +22 -0
  154. package/dist/lib/sources/image-source.d.ts +6 -6
  155. package/dist/lib/sources/image-source.d.ts.map +1 -1
  156. package/dist/lib/sources/tile-source.d.ts +4 -2
  157. package/dist/lib/sources/tile-source.d.ts.map +1 -1
  158. package/dist/lib/wfs/parse-wfs.d.ts +7 -0
  159. package/dist/lib/wfs/parse-wfs.d.ts.map +1 -0
  160. package/dist/lib/wfs/parse-wfs.js +32 -0
  161. package/dist/lib/wmts/parse-wmts.d.ts +7 -0
  162. package/dist/lib/wmts/parse-wmts.d.ts.map +1 -0
  163. package/dist/lib/wmts/parse-wmts.js +35 -0
  164. package/dist/wip/lib/wcs/parse-wcs-capabilities.js +1 -1
  165. package/dist/wip/lib/wfs/parse-wfs-capabilities.js +1 -1
  166. package/dist/wip/lib/wmts/parse-wmts-capabilities.js +1 -1
  167. package/package.json +6 -6
  168. package/src/lib/create-image-source.ts +1 -1
  169. package/src/lib/parsers/csw/parse-csw-capabilities.ts +1 -1
  170. package/src/lib/parsers/csw/parse-csw-domain.ts +1 -1
  171. package/src/lib/parsers/csw/parse-csw-records.ts +6 -6
  172. package/src/lib/parsers/csw/parse-exception-report.ts +1 -1
  173. package/src/lib/parsers/gml/parse-gml.ts +1 -1
  174. package/src/lib/parsers/wms/parse-wms-capabilities.ts +2 -1
  175. package/src/lib/parsers/wms/parse-wms-features.ts +1 -1
  176. package/src/lib/parsers/wms/parse-wms-layer-description.ts +1 -1
  177. package/src/lib/services/arcgis/arcgis-image-service.ts +1 -4
  178. package/src/lib/services/generic/image-service.ts +2 -5
  179. package/src/lib/services/ogc/csw-service.ts +1 -3
  180. package/src/lib/services/ogc/wms-service.ts +165 -60
  181. package/src/lib/sources/data-source.ts +29 -2
  182. package/src/lib/sources/image-source.ts +6 -6
  183. package/src/lib/sources/tile-source.ts +4 -2
  184. package/src/lib/wfs/parse-wfs.ts +34 -0
  185. package/src/lib/wmts/parse-wmts.ts +37 -0
  186. package/src/wip/lib/wcs/parse-wcs-capabilities.ts +1 -1
  187. package/src/wip/lib/wfs/parse-wfs-capabilities.ts +1 -1
  188. package/src/wip/lib/wmts/parse-wmts-capabilities.ts +1 -1
  189. package/dist/es5/lib/services/generic/tile-service.js +0 -2
  190. package/dist/es5/lib/services/generic/tile-service.js.map +0 -1
  191. package/dist/esm/lib/services/generic/tile-service.js +0 -2
  192. package/dist/esm/lib/services/generic/tile-service.js.map +0 -1
  193. package/dist/lib/services/generic/tile-service.d.ts +0 -1
  194. package/dist/lib/services/generic/tile-service.d.ts.map +0 -1
  195. package/dist/lib/services/generic/tile-service.js +0 -1
  196. package/src/lib/services/generic/tile-service.ts +0 -0
@@ -33,8 +33,11 @@ class WMSService extends image_source_1.ImageSource {
33
33
  // This would make pasting in any WMS URL more likely to make this class just work.
34
34
  // const {baseUrl, parameters} = this._parseWMSUrl(props.url);
35
35
  this.url = props.url;
36
+ this.substituteCRS84 = props.substituteCRS84 ?? false;
37
+ this.flipCRS = ['EPSG:4326'];
36
38
  this.wmsParameters = {
37
39
  layers: undefined,
40
+ query_layers: undefined,
38
41
  styles: undefined,
39
42
  version: '1.3.0',
40
43
  crs: 'EPSG:4326',
@@ -51,10 +54,7 @@ class WMSService extends image_source_1.ImageSource {
51
54
  return this.normalizeMetadata(capabilities);
52
55
  }
53
56
  async getImage(parameters) {
54
- // WMS 1.3.0 renamed SRS to CRS (sigh...)
55
- const wmsParameters = { ...parameters, crs: parameters.srs };
56
- delete wmsParameters.srs;
57
- return await this.getMap(wmsParameters);
57
+ return await this.getMap(parameters);
58
58
  }
59
59
  normalizeMetadata(capabilities) {
60
60
  return capabilities;
@@ -132,16 +132,17 @@ class WMSService extends image_source_1.ImageSource {
132
132
  }
133
133
  /** Generate a URL for the GetMap request */
134
134
  getMapURL(wmsParameters, vendorParameters) {
135
+ wmsParameters = this._getWMS130Parameters(wmsParameters);
135
136
  const options = {
136
137
  version: this.wmsParameters.version,
137
- // layers: [],
138
+ format: this.wmsParameters.format,
139
+ transparent: this.wmsParameters.transparent,
140
+ layers: this.wmsParameters.layers,
141
+ styles: this.wmsParameters.styles,
142
+ crs: this.wmsParameters.crs,
138
143
  // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
139
144
  // width: 1200,
140
145
  // height: 900,
141
- styles: this.wmsParameters.styles,
142
- crs: this.wmsParameters.crs,
143
- format: this.wmsParameters.format,
144
- transparent: this.wmsParameters.transparent,
145
146
  ...wmsParameters
146
147
  };
147
148
  return this._getWMSUrl('GetMap', options, vendorParameters);
@@ -150,17 +151,18 @@ class WMSService extends image_source_1.ImageSource {
150
151
  getFeatureInfoURL(wmsParameters, vendorParameters) {
151
152
  const options = {
152
153
  version: this.wmsParameters.version,
153
- // layers: this.props.layers,
154
+ // query_layers: [],
155
+ // format: this.wmsParameters.format,
156
+ info_format: this.wmsParameters.info_format,
157
+ layers: this.wmsParameters.layers,
158
+ query_layers: this.wmsParameters.query_layers,
159
+ styles: this.wmsParameters.styles,
160
+ crs: this.wmsParameters.crs,
154
161
  // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
155
162
  // width: 1200,
156
163
  // height: 900,
157
164
  // x: undefined!,
158
165
  // y: undefined!,
159
- // query_layers: [],
160
- srs: this.wmsParameters.crs,
161
- format: this.wmsParameters.format,
162
- info_format: this.wmsParameters.info_format,
163
- styles: this.wmsParameters.styles,
164
166
  ...wmsParameters
165
167
  };
166
168
  return this._getWMSUrl('GetFeatureInfo', options, vendorParameters);
@@ -215,28 +217,72 @@ class WMSService extends image_source_1.ImageSource {
215
217
  if (key !== 'transparent' || value) {
216
218
  url += first ? '?' : '&';
217
219
  first = false;
218
- url += this._getParameterValue(wmsParameters.version, key, value);
220
+ url += this._getURLParameter(key, value, wmsParameters);
219
221
  }
220
222
  }
221
223
  return encodeURI(url);
222
224
  }
223
- _getParameterValue(version, key, value) {
224
- // SRS parameter changed to CRS in 1.3.0, in non-backwards compatible way (sigh...)
225
- if (key === 'crs' && version !== '1.3.0') {
226
- key = 'srs';
225
+ _getWMS130Parameters(wmsParameters) {
226
+ const newParameters = { ...wmsParameters };
227
+ if (newParameters.srs) {
228
+ newParameters.crs = newParameters.crs || newParameters.srs;
229
+ delete newParameters.srs;
230
+ }
231
+ return newParameters;
232
+ }
233
+ // eslint-disable-complexity
234
+ _getURLParameter(key, value, wmsParameters) {
235
+ // Substitute by key
236
+ switch (key) {
237
+ case 'crs':
238
+ // CRS was called SRS before WMS 1.3.0
239
+ if (wmsParameters.version !== '1.3.0') {
240
+ key = 'srs';
241
+ }
242
+ else if (this.substituteCRS84 && value === 'EPSG:4326') {
243
+ /** In 1.3.0, replaces references to 'EPSG:4326' with the new backwards compatible CRS:84 */
244
+ // Substitute by value
245
+ value = 'CRS:84';
246
+ }
247
+ break;
248
+ case 'srs':
249
+ // CRS was called SRS before WMS 1.3.0
250
+ if (wmsParameters.version === '1.3.0') {
251
+ key = 'crs';
252
+ }
253
+ break;
254
+ case 'bbox':
255
+ // Coordinate order is flipped for certain CRS in WMS 1.3.0
256
+ const bbox = this._flipBoundingBox(value, wmsParameters);
257
+ if (bbox) {
258
+ value = bbox;
259
+ }
260
+ break;
261
+ default:
262
+ // do nothing
227
263
  }
228
264
  key = key.toUpperCase();
229
- // TODO - in v1.3.0 only, the order of parameters for BBOX depends on whether the CRS definition has flipped axes
230
- // You will see this in the GetCapabilities request at 1.3.0 - the response should show the flipped axes.
231
- // BBOX=xmin,ymin,xmax,ymax NON-FLIPPED
232
- // BBOX=ymin,xmin,ymax,xmax FLIPPED
233
- // / EPSG:4326 needs to have flipped axes. 4326 1 WGS 84 Latitude North Longitude East
234
- // In WMS 1.1.1 EPSG:4326 is wrongly defined as having long/lat coordinate axes. In WMS 1.3.0 the correct axes lat/long are used. CRS:84 is defined by OGC as having the same datum as EPSG:4326 (that is the World Geodetic System 1984 datum ~ EPSG::6326) but axis order of long/lat.
235
- // CRS:84 was introduced with the publication of the WMS 1.3.0 specification, to overcome this issue.
236
265
  return Array.isArray(value)
237
266
  ? `${key}=${value.join(',')}`
238
267
  : `${key}=${value ? String(value) : ''}`;
239
268
  }
269
+ /** Coordinate order is flipped for certain CRS in WMS 1.3.0 */
270
+ _flipBoundingBox(bboxValue, wmsParameters) {
271
+ // Sanity checks
272
+ if (!Array.isArray(bboxValue) || bboxValue.length !== 4) {
273
+ return null;
274
+ }
275
+ const flipCoordinates =
276
+ // Only affects WMS 1.3.0
277
+ wmsParameters.version === '1.3.0' &&
278
+ // Flip if we are dealing with a CRS that was flipped in 1.3.0
279
+ this.flipCRS.includes(wmsParameters.crs || '') &&
280
+ // Don't flip if we are subsituting EPSG:4326 with CRS:84
281
+ !(this.substituteCRS84 && wmsParameters.crs === 'EPSG:4326');
282
+ const bbox = bboxValue;
283
+ return flipCoordinates ? [bbox[1], bbox[0], bbox[3], bbox[2]] : bbox;
284
+ }
285
+ /** Fetches an array buffer and checks the response (boilerplate reduction) */
240
286
  async _fetchArrayBuffer(url) {
241
287
  const response = await this.fetch(url);
242
288
  const arrayBuffer = await response.arrayBuffer();
@@ -4,12 +4,22 @@ export type DataSourceProps = {
4
4
  loadOptions?: LoaderOptions;
5
5
  };
6
6
  /** base class of all data sources */
7
- export declare abstract class DataSource {
7
+ export declare abstract class DataSource<PropsT extends DataSourceProps> {
8
8
  /** A resolved fetch function extracted from loadOptions prop */
9
9
  fetch: (url: string, options?: RequestInit) => Promise<Response>;
10
10
  /** The actual load options, if calling a loaders.gl loader */
11
11
  loadOptions: LoaderOptions;
12
- constructor(props: DataSourceProps);
12
+ _needsRefresh: boolean;
13
+ props: PropsT;
14
+ constructor(props: PropsT);
15
+ setProps(props: PropsT): void;
16
+ /** Mark this data source as needing a refresh (redraw) */
17
+ setNeedsRefresh(): void;
18
+ /**
19
+ * Does this data source need refreshing?
20
+ * @note The specifics of the refresh mechanism depends on type of data source
21
+ */
22
+ getNeedsRefresh(clear?: boolean): boolean;
13
23
  }
14
24
  /**
15
25
  * Gets the current fetch function from options
@@ -1 +1 @@
1
- {"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/data-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC5B,kGAAkG;IAClG,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,qCAAqC;AACrC,8BAAsB,UAAU;IAC9B,gEAAgE;IAChE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,8DAA8D;IAC9D,WAAW,EAAE,aAAa,CAAC;gBAEf,KAAK,EAAE,eAAe;CAInC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,SAKvC,MAAM,iBAAiB,WAAW,uBAWlD"}
1
+ {"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/data-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE5D,MAAM,MAAM,eAAe,GAAG;IAC5B,kGAAkG;IAClG,WAAW,CAAC,EAAE,aAAa,CAAC;CAC7B,CAAC;AAEF,qCAAqC;AACrC,8BAAsB,UAAU,CAAC,MAAM,SAAS,eAAe;IAC7D,gEAAgE;IAChE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjE,8DAA8D;IAC9D,WAAW,EAAE,aAAa,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAQ;IAE9B,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,MAAM;IAMzB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAMtB,0DAA0D;IAC1D,eAAe,IAAI,IAAI;IAIvB;;;OAGG;IACH,eAAe,CAAC,KAAK,GAAE,OAAc;CAOtC;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,SAKvC,MAAM,iBAAiB,WAAW,uBAWlD"}
@@ -5,9 +5,31 @@ exports.getFetchFunction = exports.DataSource = void 0;
5
5
  /** base class of all data sources */
6
6
  class DataSource {
7
7
  constructor(props) {
8
+ this._needsRefresh = true;
9
+ this.props = { ...props };
8
10
  this.loadOptions = { ...props.loadOptions };
9
11
  this.fetch = getFetchFunction(this.loadOptions);
10
12
  }
13
+ setProps(props) {
14
+ this.props = Object.assign(this.props, props);
15
+ // TODO - add a shallow compare to avoid setting refresh if no change?
16
+ this.setNeedsRefresh();
17
+ }
18
+ /** Mark this data source as needing a refresh (redraw) */
19
+ setNeedsRefresh() {
20
+ this._needsRefresh = true;
21
+ }
22
+ /**
23
+ * Does this data source need refreshing?
24
+ * @note The specifics of the refresh mechanism depends on type of data source
25
+ */
26
+ getNeedsRefresh(clear = true) {
27
+ const needsRefresh = this._needsRefresh;
28
+ if (clear) {
29
+ this._needsRefresh = false;
30
+ }
31
+ return needsRefresh;
32
+ }
11
33
  }
12
34
  exports.DataSource = DataSource;
13
35
  /**
@@ -17,7 +17,7 @@ export type ImageSourceMetadata = {
17
17
  export type ImageSourceLayer = {
18
18
  name?: string;
19
19
  title?: string;
20
- srs?: string[];
20
+ crs?: string[];
21
21
  boundingBox?: [number, number, number, number];
22
22
  layers?: ImageSourceLayer[];
23
23
  };
@@ -32,8 +32,8 @@ export type GetImageParameters = {
32
32
  width: number;
33
33
  /** pixels */
34
34
  height: number;
35
- /** srs for the image (not the bounding box) */
36
- srs?: string;
35
+ /** crs for the image (not the bounding box) */
36
+ crs?: string;
37
37
  /** requested format for the return image */
38
38
  format?: 'image/png';
39
39
  };
@@ -52,8 +52,8 @@ export type ImageFormat = {
52
52
  width: number;
53
53
  /** pixels */
54
54
  height: number;
55
- /** srs for the image (not the bounding box) */
56
- srs?: string;
55
+ /** crs for the image (not the bounding box) */
56
+ crs?: string;
57
57
  /** requested format for the return image */
58
58
  format?: 'image/png';
59
59
  };
@@ -63,7 +63,7 @@ export type ImageSourceProps = DataSourceProps;
63
63
  * @note
64
64
  * - If geospatial, bounding box is expected to be in web mercator coordinates
65
65
  */
66
- export declare abstract class ImageSource extends DataSource {
66
+ export declare abstract class ImageSource<PropsT extends ImageSourceProps> extends DataSource<PropsT> {
67
67
  abstract getMetadata(): Promise<ImageSourceMetadata>;
68
68
  abstract getImage(parameters: GetImageParameters): Promise<ImageType>;
69
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"image-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/image-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAAC;AAE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G,MAAM,EAAE,CAAC;IAC1B,cAAc;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,8CAA8C;IAC9C,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa;IACb,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAE/C;;;;GAIG;AACH,8BAAsB,WAAW,CAAC,MAAM,SAAS,gBAAgB,CAAE,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC3F,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IACpD,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,SAAS,CAAC;CACtE"}
@@ -1,5 +1,5 @@
1
1
  import type { ImageType } from '@loaders.gl/images';
2
- import { DataSource } from './data-source';
2
+ import { DataSource, DataSourceProps } from './data-source';
3
3
  /**
4
4
  * Normalized capabilities of an Image service
5
5
  * @example
@@ -42,13 +42,15 @@ export type GetTileParameters = {
42
42
  /** requested format for the return image */
43
43
  format?: 'image/png';
44
44
  };
45
+ type TileSourceProps = DataSourceProps;
45
46
  /**
46
47
  * MapTileSource - data sources that allow data to be queried by (geospatial) extents
47
48
  * @note
48
49
  * - If geospatial, bounding box is expected to be in web mercator coordinates
49
50
  */
50
- export declare abstract class TileSource extends DataSource {
51
+ export declare abstract class TileSource<PropsT extends TileSourceProps> extends DataSource<PropsT> {
51
52
  abstract getMetadata(): Promise<TileSourceMetadata>;
52
53
  abstract getTile(parameters: GetTileParameters): Promise<ImageType>;
53
54
  }
55
+ export {};
54
56
  //# sourceMappingURL=tile-source.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tile-source.d.ts","sourceRoot":"","sources":["../../../src/lib/sources/tile-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/C,MAAM,EAAE,eAAe,EAAE,CAAC;KAC3B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uBAAuB;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,cAAc;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,CAAC,EAAE,MAAM,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;IAC/C,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,uBAAuB;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,cAAc;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,wBAAwB;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,wBAAwB;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,KAAK,eAAe,GAAG,eAAe,CAAC;AAEvC;;;;GAIG;AACH,8BAAsB,UAAU,CAAC,MAAM,SAAS,eAAe,CAAE,SAAQ,UAAU,CAAC,MAAM,CAAC;IACzF,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,kBAAkB,CAAC;IACnD,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,CAAC;CACpE"}
@@ -0,0 +1,7 @@
1
+ export type WFSCapabilities = {};
2
+ /**
3
+ * Parses a typed data structure from raw XML for `GetCapabilities` response
4
+ * @note Error handlings is fairly weak
5
+ */
6
+ export declare function parseWFSCapabilities(text: string, options: any): WFSCapabilities;
7
+ //# sourceMappingURL=parse-wfs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-wfs.d.ts","sourceRoot":"","sources":["../../../src/lib/wfs/parse-wfs.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,KAAA,GAAG,eAAe,CAM3E"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ // loaders.gl, MIT license
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parseWFSCapabilities = void 0;
5
+ const xml_1 = require("@loaders.gl/xml");
6
+ /**
7
+ * Parses a typed data structure from raw XML for `GetCapabilities` response
8
+ * @note Error handlings is fairly weak
9
+ */
10
+ function parseWFSCapabilities(text, options) {
11
+ // Remove namespaces in XML
12
+ options = { ...options, xml: { ...options?.xml, removeNSPrefix: true } };
13
+ const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, options);
14
+ const xmlCapabilities = parsedXML.Capabilities || parsedXML;
15
+ return uncapitalizeKeys(xmlCapabilities);
16
+ }
17
+ exports.parseWFSCapabilities = parseWFSCapabilities;
18
+ /** Uncapitalize all keys of an object */
19
+ function uncapitalizeKeys(object) {
20
+ if (object && typeof object === 'object') {
21
+ const newObject = {};
22
+ for (const [key, value] of Object.entries(object)) {
23
+ newObject[uncapitalize(key)] = uncapitalizeKeys(value);
24
+ }
25
+ return newObject;
26
+ }
27
+ return object;
28
+ }
29
+ /** Uncapitalize first letter of a string */
30
+ function uncapitalize(str) {
31
+ return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;
32
+ }
@@ -0,0 +1,7 @@
1
+ export type WMTSCapabilities = {};
2
+ /**
3
+ * Parses a typed data structure from raw XML for `GetCapabilities` response
4
+ * @note Error handlings is fairly weak
5
+ */
6
+ export declare function parseWMTSCapabilities(text: string, options: any): WMTSCapabilities;
7
+ //# sourceMappingURL=parse-wmts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-wmts.d.ts","sourceRoot":"","sources":["../../../src/lib/wmts/parse-wmts.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAElC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,KAAA,GAAG,gBAAgB,CAM7E"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // loaders.gl, MIT license
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parseWMTSCapabilities = void 0;
5
+ const xml_1 = require("@loaders.gl/xml");
6
+ /**
7
+ * Parses a typed data structure from raw XML for `GetCapabilities` response
8
+ * @note Error handlings is fairly weak
9
+ */
10
+ function parseWMTSCapabilities(text, options) {
11
+ // Remove namespaces in XML
12
+ options = { ...options, xml: { ...options?.xml, removeNSPrefix: true } };
13
+ const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, options);
14
+ const xmlCapabilities = parsedXML.Capabilities || parsedXML;
15
+ return uncapitalizeKeys(xmlCapabilities);
16
+ }
17
+ exports.parseWMTSCapabilities = parseWMTSCapabilities;
18
+ function uncapitalizeKeys(object) {
19
+ if (object && typeof object === 'object') {
20
+ const newObject = {};
21
+ for (const [key, value] of Object.entries(object)) {
22
+ newObject[uncapitalize(key)] = uncapitalizeKeys(value);
23
+ }
24
+ return newObject;
25
+ }
26
+ return object;
27
+ }
28
+ /**
29
+ * Uncapitalize first letter of a string
30
+ * @param {string} str
31
+ * @returns {string}
32
+ */
33
+ function uncapitalize(str) {
34
+ return typeof str === 'string' ? str.charAt(0).toLowerCase() + str.slice(1) : str;
35
+ }
@@ -8,7 +8,7 @@ const xml_1 = require("@loaders.gl/xml");
8
8
  * @note Error handlings is fairly weak
9
9
  */
10
10
  function parseWCSCapabilities(text, options) {
11
- const parsedXML = xml_1.XMLLoader.parseTextSync(text, { ...options, xml: { ...options?.xml, removeNSPrefix: true } });
11
+ const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, { ...options, xml: { ...options?.xml, removeNSPrefix: true } });
12
12
  const xmlCapabilities = parsedXML.Capabilities || parsedXML;
13
13
  return xmlCapabilities;
14
14
  }
@@ -8,7 +8,7 @@ const xml_1 = require("@loaders.gl/xml");
8
8
  * @note Error handlings is fairly weak
9
9
  */
10
10
  function parseWFSCapabilities(text, options) {
11
- const parsedXML = xml_1.XMLLoader.parseTextSync(text, { ...options, xml: {
11
+ const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, { ...options, xml: {
12
12
  ...options?.xml,
13
13
  removeNSPrefix: true,
14
14
  uncapitalizeKeys: true
@@ -8,7 +8,7 @@ const xml_1 = require("@loaders.gl/xml");
8
8
  * @note Error handlings is fairly weak
9
9
  */
10
10
  function parseWMTSCapabilities(text, options) {
11
- const parsedXML = xml_1.XMLLoader.parseTextSync(text, { ...options, xml: {
11
+ const parsedXML = xml_1.XMLLoader.parseTextSync?.(text, { ...options, xml: {
12
12
  ...options?.xml,
13
13
  removeNSPrefix: true,
14
14
  uncapitalizeKeys: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/wms",
3
- "version": "3.4.0-alpha.3",
3
+ "version": "4.0.0-alpha.6",
4
4
  "description": "Framework-independent loaders for the WMS (Web Map Service) standard",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -39,10 +39,10 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@babel/runtime": "^7.3.1",
42
- "@loaders.gl/images": "3.4.0-alpha.3",
43
- "@loaders.gl/loader-utils": "3.4.0-alpha.3",
44
- "@loaders.gl/schema": "3.4.0-alpha.3",
45
- "@loaders.gl/xml": "3.4.0-alpha.3",
42
+ "@loaders.gl/images": "4.0.0-alpha.6",
43
+ "@loaders.gl/loader-utils": "4.0.0-alpha.6",
44
+ "@loaders.gl/schema": "4.0.0-alpha.6",
45
+ "@loaders.gl/xml": "4.0.0-alpha.6",
46
46
  "@turf/rewind": "^5.1.5",
47
47
  "deep-strict-equal": "^0.2.0",
48
48
  "lerc": "^4.0.1"
@@ -50,5 +50,5 @@
50
50
  "devDependencies": {
51
51
  "xmldom": "0.6.0"
52
52
  },
53
- "gitHead": "a954528dd1d78a1f128d8f6b07e4baeb7a296924"
53
+ "gitHead": "acc1985050dfaa0f1f0c066f8da5bce7454a046c"
54
54
  }
@@ -22,7 +22,7 @@ type ImageSourceProps = ImageServiceProps &
22
22
  * @param type type of source. if not known, set to 'auto'
23
23
  * @returns an ImageSource instance
24
24
  */
25
- export function createImageSource(props: ImageSourceProps): ImageSource {
25
+ export function createImageSource(props: ImageSourceProps): ImageSource<ImageSourceProps> {
26
26
  const {type = 'auto'} = props;
27
27
  const serviceType = type === 'auto' ? guessServiceType(props.url) : type;
28
28
  switch (serviceType) {
@@ -87,7 +87,7 @@ export type CSWCapabilities = {
87
87
  * @note Error handlings is fairly weak
88
88
  */
89
89
  export function parseCSWCapabilities(text: string, options?: XMLLoaderOptions): CSWCapabilities {
90
- const parsedXML = XMLLoader.parseTextSync(text, {
90
+ const parsedXML = XMLLoader.parseTextSync?.(text, {
91
91
  ...options,
92
92
  xml: {
93
93
  ...options?.xml,
@@ -20,7 +20,7 @@ export type CSWDomain = {
20
20
  * @note Error handlings is fairly weak
21
21
  */
22
22
  export function parseCSWDomain(text: string, options?: XMLLoaderOptions): CSWDomain {
23
- const parsedXML = XMLLoader.parseTextSync(text, {
23
+ const parsedXML = XMLLoader.parseTextSync?.(text, {
24
24
  ...options,
25
25
  xml: {
26
26
  ...options?.xml,
@@ -35,17 +35,17 @@ export type CSWRecords = {
35
35
  * @note Error handlings is fairly weak
36
36
  */
37
37
  export function parseCSWRecords(text: string, options?: XMLLoaderOptions): CSWRecords {
38
- const parsedXML = XMLLoader.parseTextSync(text, {
38
+ const parsedXML = XMLLoader.parseTextSync?.(text, {
39
39
  ...options,
40
40
  xml: {
41
41
  ...options?.xml,
42
42
  removeNSPrefix: true,
43
43
  uncapitalizeKeys: true,
44
- arrayPaths: []
45
- },
46
- _fastXML: {
47
- ...options?._fastXML,
48
- parseAttributeValue: true
44
+ arrayPaths: [],
45
+ _fastXML: {
46
+ ...options?.xml?._fastXML,
47
+ parseAttributeValue: true
48
+ }
49
49
  }
50
50
  });
51
51
 
@@ -8,7 +8,7 @@
8
8
  * @note Error handlings is fairly weak
9
9
  */
10
10
  export function parseExceptionReport(parsedXML: any): void {
11
- // const parsedXML = XMLLoader.parseTextSync(text, {
11
+ // const parsedXML = XMLLoader.parseTextSync?.(text, {
12
12
  // ...options,
13
13
  // xml: {
14
14
  // ...options?.xml,
@@ -45,7 +45,7 @@ export type ParseGMLContext = {
45
45
  */
46
46
  export function parseGML(text: string, options) {
47
47
  // GeoJSON | null {
48
- const parsedXML = XMLLoader.parseTextSync(text, options);
48
+ const parsedXML = XMLLoader.parseTextSync?.(text, options);
49
49
 
50
50
  options = {transformCoords: noTransform, stride: 2, ...options};
51
51
  const context = createChildContext(parsedXML, options, {});
@@ -137,7 +137,7 @@ export function parseWMSCapabilities(
137
137
  xmlText: string,
138
138
  options?: parseWMSCapabilitiesOptions
139
139
  ): WMSCapabilities {
140
- const parsedXML = XMLLoader.parseTextSync(xmlText, options);
140
+ const parsedXML = XMLLoader.parseTextSync?.(xmlText, options);
141
141
  const xmlCapabilities: any =
142
142
  parsedXML.WMT_MS_Capabilities || parsedXML.WMS_Capabilities || parsedXML;
143
143
  const capabilities = extractCapabilities(xmlCapabilities);
@@ -340,6 +340,7 @@ function extractWMSBoundingBox(xmlBoundingBox: any): WMSBoundingBox {
340
340
  }
341
341
 
342
342
  /** Traverse layers and inject missing props from parents */
343
+ // eslint-disable-next-line complexity
343
344
  function addInheritedLayerProps(layer: WMSLayer, parent: WMSLayer | null): void {
344
345
  if (parent && parent.geographicBoundingBox && !layer.geographicBoundingBox) {
345
346
  layer.geographicBoundingBox = [...parent.geographicBoundingBox];
@@ -18,7 +18,7 @@ export type WMSFeature = {
18
18
  * @note Error handlings is fairly weak
19
19
  */
20
20
  export function parseWMSFeatureInfo(text: string, options): WMSFeatureInfo {
21
- const parsedXML = XMLLoader.parseTextSync(text, options);
21
+ const parsedXML = XMLLoader.parseTextSync?.(text, options);
22
22
  const xmlFeatureInfo: any = parsedXML.FeatureInfoResponse?.FIELDS || [];
23
23
 
24
24
  const xmlFeatures = Array.isArray(xmlFeatureInfo) ? xmlFeatureInfo : [xmlFeatureInfo];
@@ -12,7 +12,7 @@ export type WMSLayerDescription = {
12
12
  * @note Error handlings is fairly weak
13
13
  */
14
14
  export function parseWMSLayerDescription(text: string, options): WMSLayerDescription {
15
- const parsedXML = XMLLoader.parseTextSync(text, options);
15
+ const parsedXML = XMLLoader.parseTextSync?.(text, options);
16
16
  // TODO - implement parser
17
17
  return parsedXML as unknown as WMSLayerDescription;
18
18
  }
@@ -14,15 +14,12 @@ export type ArcGISImageServerProps = ImageSourceProps & {
14
14
  * Note - exports a big API, that could be exposed here if there is a use case
15
15
  * @see https://developers.arcgis.com/rest/services-reference/enterprise/image-service.htm
16
16
  */
17
- export class ArcGISImageServer extends ImageSource {
17
+ export class ArcGISImageServer extends ImageSource<ArcGISImageServerProps> {
18
18
  static type: 'arcgis-image-server' = 'arcgis-image-server';
19
19
  static testURL = (url: string): boolean => url.toLowerCase().includes('ImageServer');
20
20
 
21
- props: ArcGISImageServerProps;
22
-
23
21
  constructor(props: ArcGISImageServerProps) {
24
22
  super(props);
25
- this.props = props;
26
23
  }
27
24
 
28
25
  // ImageSource (normalized endpoints)
@@ -20,15 +20,12 @@ export type ImageServiceProps = {
20
20
  * ImageSource allows template url strings to be used to ad hoc connect to arbitrary image data sources
21
21
  * Accepts a template url string and builds requests URLs
22
22
  */
23
- export class ImageService extends ImageSource {
23
+ export class ImageService<PropsT extends ImageServiceProps> extends ImageSource<PropsT> {
24
24
  static type: 'template' = 'template';
25
25
  static testURL = (url: string): boolean => url.toLowerCase().includes('{');
26
26
 
27
- props: ImageServiceProps;
28
-
29
- constructor(props: ImageServiceProps) {
27
+ constructor(props: PropsT) {
30
28
  super(props);
31
- this.props = props;
32
29
  }
33
30
 
34
31
  // IMAGE SOURCE API
@@ -54,11 +54,10 @@ export type CSWServiceProps = DataSourceProps & {
54
54
  * - implements the ImageService interface
55
55
  * @note Only the URL parameter conversion is supported. XML posts are not supported.
56
56
  */
57
- export class CSWService extends DataSource {
57
+ export class CSWService extends DataSource<CSWServiceProps> {
58
58
  static type: 'csw' = 'csw';
59
59
  static testURL = (url: string): boolean => url.toLowerCase().includes('csw');
60
60
 
61
- props: CSWServiceProps;
62
61
  capabilities: CSWCapabilities | null = null;
63
62
 
64
63
  /** A list of loaders used by the CSWService methods */
@@ -67,7 +66,6 @@ export class CSWService extends DataSource {
67
66
  /** Create a CSWService */
68
67
  constructor(props: CSWServiceProps) {
69
68
  super(props);
70
- this.props = props;
71
69
  }
72
70
 
73
71
  async getMetadata(): Promise<CSWCapabilities> {