@loaders.gl/wms 4.3.2 → 4.4.0-alpha.2

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 (50) hide show
  1. package/dist/{services/arcgis/arcgis-feature-server.d.ts → arcgis/arcgis-feature-source.d.ts} +14 -21
  2. package/dist/arcgis/arcgis-feature-source.d.ts.map +1 -0
  3. package/dist/{services/arcgis/arcgis-feature-server.js → arcgis/arcgis-feature-source.js} +74 -79
  4. package/dist/{services/arcgis/arcgis-image-server.d.ts → arcgis/arcgis-image-source.d.ts} +10 -12
  5. package/dist/arcgis/arcgis-image-source.d.ts.map +1 -0
  6. package/dist/{services/arcgis/arcgis-image-server.js → arcgis/arcgis-image-source.js} +7 -13
  7. package/dist/arcgis/arcgis-server.d.ts.map +1 -0
  8. package/dist/csw-capabilities-loader.js +1 -1
  9. package/dist/csw-domain-loader.js +1 -1
  10. package/dist/csw-records-loader.js +1 -1
  11. package/dist/{services/ogc/csw-service.d.ts → csw-source.d.ts} +40 -26
  12. package/dist/csw-source.d.ts.map +1 -0
  13. package/dist/{services/ogc/csw-service.js → csw-source.js} +44 -32
  14. package/dist/gml-loader.js +1 -1
  15. package/dist/index.cjs +36 -45
  16. package/dist/index.cjs.map +3 -3
  17. package/dist/index.d.ts +3 -4
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +4 -5
  20. package/dist/lib/deprecated/create-image-source.d.ts +12 -8
  21. package/dist/lib/deprecated/create-image-source.d.ts.map +1 -1
  22. package/dist/lib/deprecated/create-image-source.js +6 -6
  23. package/dist/wfs-capabilities-loader.js +1 -1
  24. package/dist/{services/ogc/wfs-service.d.ts → wfs-source.d.ts} +43 -52
  25. package/dist/wfs-source.d.ts.map +1 -0
  26. package/dist/{services/ogc/wfs-service.js → wfs-source.js} +74 -106
  27. package/dist/wip/wcs-capabilities-loader.js +1 -1
  28. package/dist/wip/wmts-capabilities-loader.js +1 -1
  29. package/dist/wms-capabilities-loader.js +1 -1
  30. package/dist/wms-error-loader.js +1 -1
  31. package/dist/{services/ogc/wms-service.d.ts → wms-source.d.ts} +23 -32
  32. package/dist/wms-source.d.ts.map +1 -0
  33. package/dist/{services/ogc/wms-service.js → wms-source.js} +20 -25
  34. package/package.json +7 -7
  35. package/src/{services/arcgis/arcgis-feature-server.ts → arcgis/arcgis-feature-source.ts} +93 -97
  36. package/src/{services/arcgis/arcgis-image-server.ts → arcgis/arcgis-image-source.ts} +18 -23
  37. package/src/{services/ogc/csw-service.ts → csw-source.ts} +56 -41
  38. package/src/index.ts +4 -6
  39. package/src/lib/deprecated/create-image-source.ts +22 -18
  40. package/src/{services/ogc/wfs-service.ts → wfs-source.ts} +93 -133
  41. package/src/{services/ogc/wms-service.ts → wms-source.ts} +44 -56
  42. package/dist/services/arcgis/arcgis-feature-server.d.ts.map +0 -1
  43. package/dist/services/arcgis/arcgis-image-server.d.ts.map +0 -1
  44. package/dist/services/arcgis/arcgis-server.d.ts.map +0 -1
  45. package/dist/services/ogc/csw-service.d.ts.map +0 -1
  46. package/dist/services/ogc/wfs-service.d.ts.map +0 -1
  47. package/dist/services/ogc/wms-service.d.ts.map +0 -1
  48. /package/dist/{services/arcgis → arcgis}/arcgis-server.d.ts +0 -0
  49. /package/dist/{services/arcgis → arcgis}/arcgis-server.js +0 -0
  50. /package/src/{services/arcgis → arcgis}/arcgis-server.ts +0 -0
@@ -2,25 +2,36 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {Schema, GeoJSONTable} from '@loaders.gl/schema';
5
+ import type {Schema, GeoJSONTable} from '@loaders.gl/schema';
6
6
  import type {
7
- VectorSourceProps,
7
+ DataSourceOptions,
8
8
  VectorSourceMetadata,
9
- LoaderWithParser,
10
9
  GetFeaturesParameters
11
10
  } from '@loaders.gl/loader-utils';
12
- import {Source, VectorSource, mergeLoaderOptions} from '@loaders.gl/loader-utils';
11
+ import {Source, DataSource, VectorSource, mergeOptions} from '@loaders.gl/loader-utils';
13
12
 
14
- import type {WFSCapabilities} from '../../wfs-capabilities-loader';
15
- import {WFSCapabilitiesLoader} from '../../wfs-capabilities-loader';
13
+ import type {WFSCapabilities} from './wfs-capabilities-loader';
14
+ import {WFSCapabilitiesLoader} from './wfs-capabilities-loader';
16
15
 
17
- import type {WMSLoaderOptions} from '../../wms-error-loader';
18
- import {WMSErrorLoader} from '../../wms-error-loader';
16
+ import type {WMSLoaderOptions} from './wms-error-loader';
17
+ import {WMSErrorLoader} from './wms-error-loader';
19
18
 
20
19
  /* eslint-disable camelcase */ // WFS XML parameters use snake_case
21
20
 
21
+ /** Properties for creating a enw WFS service */
22
+ export type WFSourceOptions = DataSourceOptions & {
23
+ wfs?: {
24
+ /** In 1.3.0, replaces references to EPSG:4326 with CRS:84 */
25
+ substituteCRS84?: boolean;
26
+ /** Default WFS parameters. If not provided here, must be provided in the various request */
27
+ wfsParameters?: WFSParameters;
28
+ /** Any additional service specific parameters */
29
+ vendorParameters?: Record<string, unknown>;
30
+ };
31
+ };
32
+
22
33
  /**
23
- * @ndeprecated This is a WIP, not fully implemented
34
+ * @deprecated This is a WIP, not fully implemented
24
35
  * @see https://developers.arcgis.com/rest/services-reference/enterprise/feature-service.htm
25
36
  */
26
37
  export const WFSSource = {
@@ -30,36 +41,18 @@ export const WFSSource = {
30
41
  version: '0.0.0',
31
42
  extensions: [],
32
43
  mimeTypes: [],
33
- options: {
34
- url: undefined!,
35
- wfs: {
36
- /** Tabular loaders, normally the GeoJSONLoader */
37
- loaders: []
38
- }
39
- },
40
-
41
44
  type: 'wfs',
42
45
  fromUrl: true,
43
46
  fromBlob: false,
44
47
 
45
- testURL: (url: string): boolean => url.toLowerCase().includes('wfs'),
46
- createDataSource: (url, props: WFSVectorSourceProps): WFSVectorSource =>
47
- new WFSVectorSource(props)
48
- } as const satisfies Source<WFSVectorSource, WFSVectorSourceProps>;
48
+ defaultOptions: {
49
+ wfs: {}
50
+ },
49
51
 
50
- /** Properties for creating a enw WFS service */
51
- export type WFSVectorSourceProps = VectorSourceProps & {
52
- url: string;
53
- wfs?: {
54
- loaders: LoaderWithParser[];
55
- /** In 1.3.0, replaces references to EPSG:4326 with CRS:84 */
56
- substituteCRS84?: boolean;
57
- /** Default WFS parameters. If not provided here, must be provided in the various request */
58
- wmsParameters?: WFSParameters;
59
- /** Any additional service specific parameters */
60
- vendorParameters?: Record<string, unknown>;
61
- };
62
- };
52
+ testURL: (url: string): boolean => url.toLowerCase().includes('wfs'),
53
+ createDataSource: (url: string, options: WFSourceOptions): WFSVectorSource =>
54
+ new WFSVectorSource(url, options)
55
+ } as const satisfies Source<WFSVectorSource>;
63
56
 
64
57
  // PARAMETER TYPES FOR WFS SOURCE
65
58
 
@@ -203,52 +196,19 @@ export type WFSGetLegendGraphicParameters = {
203
196
  * - implements the VectorSource interface
204
197
  * @note Only the URL parameter conversion is supported. XML posts are not supported.
205
198
  */
206
- export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
207
- /** Base URL to the service */
208
- readonly url: string;
209
- readonly data: string;
210
-
211
- // /** In WFS 1.3.0, replaces references to EPSG:4326 with CRS:84. But not always supported. Default: false */
212
- // substituteCRS84: boolean;
213
- // /** In WFS 1.3.0, flips x,y (lng, lat) coordinates for the supplied coordinate systems. Default: ['ESPG:4326'] */
214
- // flipCRS: string[];
215
-
216
- // /** Default static WFS parameters */
217
- // wmsParameters: Required<WFSParameters>;
199
+ export class WFSVectorSource extends DataSource<string, WFSourceOptions> implements VectorSource {
218
200
  /** Default static vendor parameters */
219
201
  vendorParameters?: Record<string, unknown>;
220
202
 
221
203
  capabilities: WFSCapabilities | null = null;
222
204
 
223
205
  /** Create a WFSVectorSource */
224
- constructor(props: WFSVectorSourceProps) {
225
- super(props);
206
+ constructor(data: string, options: WFSourceOptions) {
207
+ super(data, options, WFSSource.defaultOptions);
226
208
 
227
209
  // TODO - defaults such as version, layers etc could be extracted from a base URL with parameters
228
210
  // This would make pasting in any WFS URL more likely to make this class just work.
229
- // const {baseUrl, parameters} = this._parseWFSUrl(props.url);
230
-
231
- this.url = props.url;
232
- this.data = props.url;
233
-
234
- // this.substituteCRS84 = props.substituteCRS84 ?? false;
235
- // this.flipCRS = ['EPSG:4326'];
236
-
237
- // this.wmsParameters = {
238
- // layers: undefined!,
239
- // query_layers: undefined!,
240
- // styles: undefined,
241
- // version: '1.3.0',
242
- // crs: 'EPSG:4326',
243
- // format: 'image/png',
244
- // info_format: 'text/plain',
245
- // transparent: undefined!,
246
- // time: undefined!,
247
- // elevation: undefined!,
248
- // ...props.wmsParameters
249
- // };
250
-
251
- // this.vendorParameters = props.vendorParameters || {};
211
+ // const {baseUrl, parameters} = this._parseWFSUrl(options.url);
252
212
  }
253
213
 
254
214
  async getSchema(): Promise<Schema> {
@@ -264,7 +224,7 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
264
224
  async getFeatures(parameters: GetFeaturesParameters): Promise<GeoJSONTable> {
265
225
  // Replace the GetImage `boundingBox` parameter with the WFS flat `bbox` parameter.
266
226
  // const {boundingBox, bbox, ...rest} = parameters;
267
- // const wmsParameters: WFSGetMapParameters = {
227
+ // const wfsParameters: WFSGetMapParameters = {
268
228
  // bbox: boundingBox ? [...boundingBox[0], ...boundingBox[1]] : bbox!,
269
229
  // ...rest
270
230
  // };
@@ -279,10 +239,10 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
279
239
 
280
240
  /** Get Capabilities */
281
241
  async getCapabilities(
282
- wmsParameters?: WFSGetCapabilitiesParameters,
242
+ wfsParameters?: WFSGetCapabilitiesParameters,
283
243
  vendorParameters?: Record<string, unknown>
284
244
  ): Promise<WFSCapabilities> {
285
- const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
245
+ const url = this.getCapabilitiesURL(wfsParameters, vendorParameters);
286
246
  const response = await this.fetch(url);
287
247
  const arrayBuffer = await response.arrayBuffer();
288
248
  this._checkResponse(response, arrayBuffer);
@@ -293,10 +253,10 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
293
253
 
294
254
  /** Get a map image *
295
255
  async getMap(
296
- wmsParameters: WFSGetMapParameters,
256
+ wfsParameters: WFSGetMapParameters,
297
257
  vendorParameters?: Record<string, unknown>
298
258
  ): Promise<ImageType> {
299
- const url = this.getMapURL(wmsParameters, vendorParameters);
259
+ const url = this.getMapURL(wfsParameters, vendorParameters);
300
260
  const response = await this.fetch(url);
301
261
  const arrayBuffer = await response.arrayBuffer();
302
262
  this._checkResponse(response, arrayBuffer);
@@ -309,10 +269,10 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
309
269
 
310
270
  /** Get Feature Info for a coordinate *
311
271
  async getFeatureInfo(
312
- wmsParameters: WFSGetFeatureInfoParameters,
272
+ wfsParameters: WFSGetFeatureInfoParameters,
313
273
  vendorParameters?: Record<string, unknown>
314
274
  ): Promise<WFSFeatureInfo> {
315
- const url = this.getFeatureInfoURL(wmsParameters, vendorParameters);
275
+ const url = this.getFeatureInfoURL(wfsParameters, vendorParameters);
316
276
  const response = await this.fetch(url);
317
277
  const arrayBuffer = await response.arrayBuffer();
318
278
  this._checkResponse(response, arrayBuffer);
@@ -321,10 +281,10 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
321
281
 
322
282
  /** Get Feature Info for a coordinate *
323
283
  async getFeatureInfoText(
324
- wmsParameters: WFSGetFeatureInfoParameters,
284
+ wfsParameters: WFSGetFeatureInfoParameters,
325
285
  vendorParameters?: Record<string, unknown>
326
286
  ): Promise<string> {
327
- const url = this.getFeatureInfoURL(wmsParameters, vendorParameters);
287
+ const url = this.getFeatureInfoURL(wfsParameters, vendorParameters);
328
288
  const response = await this.fetch(url);
329
289
  const arrayBuffer = await response.arrayBuffer();
330
290
  this._checkResponse(response, arrayBuffer);
@@ -333,10 +293,10 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
333
293
 
334
294
  /** Get more information about a layer *
335
295
  async describeLayer(
336
- wmsParameters: WFSDescribeLayerParameters,
296
+ wfsParameters: WFSDescribeLayerParameters,
337
297
  vendorParameters?: Record<string, unknown>
338
298
  ): Promise<WFSLayerDescription> {
339
- const url = this.describeLayerURL(wmsParameters, vendorParameters);
299
+ const url = this.describeLayerURL(wfsParameters, vendorParameters);
340
300
  const response = await this.fetch(url);
341
301
  const arrayBuffer = await response.arrayBuffer();
342
302
  this._checkResponse(response, arrayBuffer);
@@ -345,10 +305,10 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
345
305
 
346
306
  /** Get an image with a semantic legend *
347
307
  async getLegendGraphic(
348
- wmsParameters: WFSGetLegendGraphicParameters,
308
+ wfsParameters: WFSGetLegendGraphicParameters,
349
309
  vendorParameters?: Record<string, unknown>
350
310
  ): Promise<ImageType> {
351
- const url = this.getLegendGraphicURL(wmsParameters, vendorParameters);
311
+ const url = this.getLegendGraphicURL(wfsParameters, vendorParameters);
352
312
  const response = await this.fetch(url);
353
313
  const arrayBuffer = await response.arrayBuffer();
354
314
  this._checkResponse(response, arrayBuffer);
@@ -365,94 +325,94 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
365
325
 
366
326
  /** Generate a URL for the GetCapabilities request */
367
327
  getCapabilitiesURL(
368
- wmsParameters?: WFSGetCapabilitiesParameters,
328
+ wfsParameters?: WFSGetCapabilitiesParameters,
369
329
  vendorParameters?: Record<string, unknown>
370
330
  ): string {
371
331
  // @ts-expect-error
372
332
  const options: Required<WFSGetCapabilitiesParameters> = {
373
- // version: this.wmsParameters.version,
374
- ...wmsParameters
333
+ // version: this.wfsParameters.version,
334
+ ...wfsParameters
375
335
  };
376
336
  return this._getWFSUrl('GetCapabilities', options, vendorParameters);
377
337
  }
378
338
 
379
339
  /** Generate a URL for the GetMap request */
380
340
  getMapURL(
381
- wmsParameters: WFSGetMapParameters,
341
+ wfsParameters: WFSGetMapParameters,
382
342
  vendorParameters?: Record<string, unknown>
383
343
  ): string {
384
- wmsParameters = this._getWFS130Parameters(wmsParameters);
344
+ wfsParameters = this._getWFS130Parameters(wfsParameters);
385
345
  // @ts-expect-error
386
346
  const options: Required<WFSGetMapParameters> = {
387
- // version: this.wmsParameters.version,
388
- // format: this.wmsParameters.format,
389
- // transparent: this.wmsParameters.transparent,
390
- // time: this.wmsParameters.time,
391
- // elevation: this.wmsParameters.elevation,
392
- // layers: this.wmsParameters.layers,
393
- // styles: this.wmsParameters.styles,
394
- // crs: this.wmsParameters.crs,
347
+ // version: this.wfsParameters.version,
348
+ // format: this.wfsParameters.format,
349
+ // transparent: this.wfsParameters.transparent,
350
+ // time: this.wfsParameters.time,
351
+ // elevation: this.wfsParameters.elevation,
352
+ // layers: this.wfsParameters.layers,
353
+ // styles: this.wfsParameters.styles,
354
+ // crs: this.wfsParameters.crs,
395
355
  // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
396
356
  // width: 1200,
397
357
  // height: 900,
398
- ...wmsParameters
358
+ ...wfsParameters
399
359
  };
400
360
  return this._getWFSUrl('GetMap', options, vendorParameters);
401
361
  }
402
362
 
403
363
  /** Generate a URL for the GetFeatureInfo request */
404
364
  getFeatureInfoURL(
405
- wmsParameters: WFSGetFeatureInfoParameters,
365
+ wfsParameters: WFSGetFeatureInfoParameters,
406
366
  vendorParameters?: Record<string, unknown>
407
367
  ): string {
408
- wmsParameters = this._getWFS130Parameters(wmsParameters);
368
+ wfsParameters = this._getWFS130Parameters(wfsParameters);
409
369
 
410
370
  // Replace the GetImage `boundingBox` parameter with the WFS flat `bbox` parameter.
411
- const {boundingBox, bbox} = wmsParameters as any;
412
- wmsParameters.bbox = boundingBox ? [...boundingBox[0], ...boundingBox[1]] : bbox!;
371
+ const {boundingBox, bbox} = wfsParameters as any;
372
+ wfsParameters.bbox = boundingBox ? [...boundingBox[0], ...boundingBox[1]] : bbox!;
413
373
 
414
374
  // @ts-expect-error
415
375
  const options: Required<WFSGetFeatureInfoParameters> = {
416
- // version: this.wmsParameters.version,
376
+ // version: this.wfsParameters.version,
417
377
  // // query_layers: [],
418
- // // format: this.wmsParameters.format,
419
- // info_format: this.wmsParameters.info_format,
420
- // layers: this.wmsParameters.layers,
421
- // query_layers: this.wmsParameters.query_layers,
422
- // styles: this.wmsParameters.styles,
423
- // crs: this.wmsParameters.crs,
378
+ // // format: this.wfsParameters.format,
379
+ // info_format: this.wfsParameters.info_format,
380
+ // layers: this.wfsParameters.layers,
381
+ // query_layers: this.wfsParameters.query_layers,
382
+ // styles: this.wfsParameters.styles,
383
+ // crs: this.wfsParameters.crs,
424
384
  // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
425
385
  // width: 1200,
426
386
  // height: 900,
427
387
  // x: undefined!,
428
388
  // y: undefined!,
429
- ...wmsParameters
389
+ ...wfsParameters
430
390
  };
431
391
  return this._getWFSUrl('GetFeatureInfo', options, vendorParameters);
432
392
  }
433
393
 
434
394
  /** Generate a URL for the GetFeatureInfo request */
435
395
  describeLayerURL(
436
- wmsParameters: WFSDescribeLayerParameters,
396
+ wfsParameters: WFSDescribeLayerParameters,
437
397
  vendorParameters?: Record<string, unknown>
438
398
  ): string {
439
399
  // @ts-expect-error
440
400
  const options: Required<WFSDescribeLayerParameters> = {
441
- // version: this.wmsParameters.version,
442
- ...wmsParameters
401
+ // version: this.wfsParameters.version,
402
+ ...wfsParameters
443
403
  };
444
404
  return this._getWFSUrl('DescribeLayer', options, vendorParameters);
445
405
  }
446
406
 
447
407
  getLegendGraphicURL(
448
- wmsParameters: WFSGetLegendGraphicParameters,
408
+ wfsParameters: WFSGetLegendGraphicParameters,
449
409
  vendorParameters?: Record<string, unknown>
450
410
  ): string {
451
411
  // @ts-expect-error
452
412
  const options: Required<WFSGetLegendGraphicParameters> = {
453
- // version: this.wmsParameters.version,
413
+ // version: this.wfsParameters.version,
454
414
  // format?
455
- ...wmsParameters
415
+ ...wfsParameters
456
416
  };
457
417
  return this._getWFSUrl('GetLegendGraphic', options, vendorParameters);
458
418
  }
@@ -479,7 +439,7 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
479
439
  * */
480
440
  protected _getWFSUrl(
481
441
  request: string,
482
- wmsParameters: {version?: '1.3.0' | '1.1.1'; [key: string]: unknown},
442
+ wfsParameters: {version?: '1.3.0' | '1.1.1'; [key: string]: unknown},
483
443
  vendorParameters?: Record<string, unknown>
484
444
  ): string {
485
445
  let url = this.url;
@@ -488,9 +448,9 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
488
448
  // Add any vendor searchParams
489
449
  const allParameters = {
490
450
  service: 'WFS',
491
- version: wmsParameters.version,
451
+ version: wfsParameters.version,
492
452
  request,
493
- ...wmsParameters,
453
+ ...wfsParameters,
494
454
  ...this.vendorParameters,
495
455
  ...vendorParameters
496
456
  };
@@ -502,7 +462,7 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
502
462
  if (!IGNORE_EMPTY_KEYS.includes(key) || value) {
503
463
  url += first ? '?' : '&';
504
464
  first = false;
505
- url += this._getURLParameter(key, value, wmsParameters);
465
+ url += this._getURLParameter(key, value, wfsParameters);
506
466
  }
507
467
  }
508
468
 
@@ -510,9 +470,9 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
510
470
  }
511
471
 
512
472
  _getWFS130Parameters<ParametersT extends {crs?: string; srs?: string}>(
513
- wmsParameters: ParametersT
473
+ wfsParameters: ParametersT
514
474
  ): ParametersT {
515
- const newParameters = {...wmsParameters};
475
+ const newParameters = {...wfsParameters};
516
476
  if (newParameters.srs) {
517
477
  newParameters.crs = newParameters.crs || newParameters.srs;
518
478
  delete newParameters.srs;
@@ -521,12 +481,12 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
521
481
  }
522
482
 
523
483
  // eslint-disable-next-line complexity
524
- _getURLParameter(key: string, value: unknown, wmsParameters: WFSParameters): string {
484
+ _getURLParameter(key: string, value: unknown, wfsParameters: WFSParameters): string {
525
485
  // Substitute by key
526
486
  switch (key) {
527
487
  case 'crs':
528
488
  // CRS was called SRS before WFS 1.3.0
529
- if (wmsParameters.version !== '1.3.0') {
489
+ if (wfsParameters.version !== '1.3.0') {
530
490
  key = 'srs';
531
491
  // } else if (this.substituteCRS84 && value === 'EPSG:4326') {
532
492
  // /** In 1.3.0, replaces references to 'EPSG:4326' with the new backwards compatible CRS:84 */
@@ -537,14 +497,14 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
537
497
 
538
498
  case 'srs':
539
499
  // CRS was called SRS before WFS 1.3.0
540
- if (wmsParameters.version === '1.3.0') {
500
+ if (wfsParameters.version === '1.3.0') {
541
501
  key = 'crs';
542
502
  }
543
503
  break;
544
504
 
545
505
  case 'bbox':
546
506
  // Coordinate order is flipped for certain CRS in WFS 1.3.0
547
- const bbox = this._flipBoundingBox(value, wmsParameters);
507
+ const bbox = this._flipBoundingBox(value, wfsParameters);
548
508
  if (bbox) {
549
509
  value = bbox;
550
510
  }
@@ -553,7 +513,7 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
553
513
  case 'x':
554
514
  // i is the parameter used in WFS 1.3
555
515
  // TODO - change parameter to `i` and convert to `x` if not 1.3
556
- if (wmsParameters.version === '1.3.0') {
516
+ if (wfsParameters.version === '1.3.0') {
557
517
  key = 'i';
558
518
  }
559
519
  break;
@@ -561,7 +521,7 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
561
521
  case 'y':
562
522
  // j is the parameter used in WFS 1.3
563
523
  // TODO - change parameter to `j` and convert to `y` if not 1.3
564
- if (wmsParameters.version === '1.3.0') {
524
+ if (wfsParameters.version === '1.3.0') {
565
525
  key = 'j';
566
526
  }
567
527
  break;
@@ -580,7 +540,7 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
580
540
  /** Coordinate order is flipped for certain CRS in WFS 1.3.0 */
581
541
  _flipBoundingBox(
582
542
  bboxValue: unknown,
583
- wmsParameters: WFSParameters
543
+ wfsParameters: WFSParameters
584
544
  ): [number, number, number, number] | null {
585
545
  // Sanity checks
586
546
  if (!Array.isArray(bboxValue) || bboxValue.length !== 4) {
@@ -589,11 +549,11 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
589
549
 
590
550
  const flipCoordinates = false;
591
551
  // // Only affects WFS 1.3.0
592
- // wmsParameters.version === '1.3.0' &&
552
+ // wfsParameters.version === '1.3.0' &&
593
553
  // // Flip if we are dealing with a CRS that was flipped in 1.3.0
594
- // this.flipCRS.includes(wmsParameters.crs || '') &&
554
+ // this.flipCRS.includes(wfsParameters.crs || '') &&
595
555
  // // Don't flip if we are substituting EPSG:4326 with CRS:84
596
- // !(this.substituteCRS84 && wmsParameters.crs === 'EPSG:4326');
556
+ // !(this.substituteCRS84 && wfsParameters.crs === 'EPSG:4326');
597
557
 
598
558
  const bbox = bboxValue as [number, number, number, number];
599
559
  return flipCoordinates ? [bbox[1], bbox[0], bbox[3], bbox[2]] : bbox;
@@ -612,7 +572,7 @@ export class WFSVectorSource extends VectorSource<WFSVectorSourceProps> {
612
572
  const contentType = response.headers['content-type'];
613
573
  if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
614
574
  // We want error responses to throw exceptions, the WMSErrorLoader can do this
615
- const loadOptions = mergeLoaderOptions<WMSLoaderOptions>(this.loadOptions, {
575
+ const loadOptions = mergeOptions<WMSLoaderOptions>(this.loadOptions, {
616
576
  wms: {throwOnError: true}
617
577
  });
618
578
  const error = WMSErrorLoader.parseSync?.(arrayBuffer, loadOptions);
@@ -3,27 +3,40 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  /* eslint-disable camelcase */
6
- import type {ImageType} from '@loaders.gl/images';
7
- import {ImageLoader} from '@loaders.gl/images';
8
- import {mergeLoaderOptions, ImageSource} from '@loaders.gl/loader-utils';
9
-
10
6
  import type {
11
7
  Source,
8
+ DataSourceOptions,
12
9
  ImageSourceMetadata,
13
- GetImageParameters,
14
- ImageSourceProps
10
+ GetImageParameters
15
11
  } from '@loaders.gl/loader-utils';
12
+ import {DataSource, ImageSource, mergeOptions} from '@loaders.gl/loader-utils';
13
+
14
+ import type {ImageType} from '@loaders.gl/images';
15
+ import {ImageLoader} from '@loaders.gl/images';
16
+
17
+ import type {WMSCapabilities} from './wms-capabilities-loader';
18
+ import type {WMSFeatureInfo} from './wip/wms-feature-info-loader';
19
+ import type {WMSLayerDescription} from './wip/wms-layer-description-loader';
16
20
 
17
- import type {WMSCapabilities} from '../../wms-capabilities-loader';
18
- import type {WMSFeatureInfo} from '../../wip/wms-feature-info-loader';
19
- import type {WMSLayerDescription} from '../../wip/wms-layer-description-loader';
21
+ import {WMSCapabilitiesLoader} from './wms-capabilities-loader';
22
+ import {WMSFeatureInfoLoader} from './wip/wms-feature-info-loader';
23
+ import {WMSLayerDescriptionLoader} from './wip/wms-layer-description-loader';
20
24
 
21
- import {WMSCapabilitiesLoader} from '../../wms-capabilities-loader';
22
- import {WMSFeatureInfoLoader} from '../../wip/wms-feature-info-loader';
23
- import {WMSLayerDescriptionLoader} from '../../wip/wms-layer-description-loader';
25
+ import type {WMSLoaderOptions} from './wms-error-loader';
26
+ import {WMSErrorLoader} from './wms-error-loader';
24
27
 
25
- import type {WMSLoaderOptions} from '../../wms-error-loader';
26
- import {WMSErrorLoader} from '../../wms-error-loader';
28
+ /** Properties for creating a enw WMS service */
29
+ export type WMSSourceOptions = DataSourceOptions & {
30
+ wms?: {
31
+ // TODO - move parameters inside WMS scope
32
+ /** In 1.3.0, replaces references to EPSG:4326 with CRS:84 */
33
+ substituteCRS84?: boolean;
34
+ /** Default WMS parameters. If not provided here, must be provided in the various request */
35
+ wmsParameters?: WMSParameters;
36
+ /** Any additional service specific parameters */
37
+ vendorParameters?: Record<string, unknown>;
38
+ };
39
+ };
27
40
 
28
41
  export const WMSSource = {
29
42
  name: 'Web Map Service (OGC WMS)',
@@ -32,37 +45,19 @@ export const WMSSource = {
32
45
  version: '0.0.0',
33
46
  extensions: [],
34
47
  mimeTypes: [],
35
- options: {
48
+ type: 'wms',
49
+ fromUrl: true,
50
+ fromBlob: false,
51
+
52
+ defaultOptions: {
36
53
  wms: {
37
54
  // TODO - add options here
38
55
  }
39
56
  },
40
- type: 'wms',
41
- fromUrl: true,
42
- fromBlob: false,
43
57
 
44
58
  testURL: (url: string): boolean => url.toLowerCase().includes('wms'),
45
- createDataSource: (url, props: WMSImageSourceProps) => new WMSImageSource(url as string, props)
46
- } as const satisfies Source<WMSImageSource, WMSImageSourceProps>;
47
-
48
- /** Properties for creating a enw WMS service */
49
- export type WMSImageSourceProps = ImageSourceProps & {
50
- /** @deprecated Use props.wms.substituteCRS84 */
51
- substituteCRS84?: boolean;
52
- /** @deprecated Use props.wms.wmsParameters */
53
- wmsParameters?: WMSParameters;
54
- /** @deprecated Use props.wms.vendorParameters */
55
- vendorParameters?: Record<string, unknown>;
56
- wms?: {
57
- // TODO - move parameters inside WMS scope
58
- /** In 1.3.0, replaces references to EPSG:4326 with CRS:84 */
59
- substituteCRS84?: boolean;
60
- /** Default WMS parameters. If not provided here, must be provided in the various request */
61
- wmsParameters?: WMSParameters;
62
- /** Any additional service specific parameters */
63
- vendorParameters?: Record<string, unknown>;
64
- };
65
- };
59
+ createDataSource: (url, options: WMSSourceOptions) => new WMSImageSource(url as string, options)
60
+ } as const satisfies Source<WMSImageSource>;
66
61
 
67
62
  // PARAMETER TYPES FOR WMS SOURCE
68
63
 
@@ -206,11 +201,7 @@ export type WMSGetLegendGraphicParameters = {
206
201
  * - implements the ImageSource interface
207
202
  * @note Only the URL parameter conversion is supported. XML posts are not supported.
208
203
  */
209
- export class WMSImageSource extends ImageSource<WMSImageSourceProps> {
210
- /** Base URL to the service */
211
- readonly url: string;
212
- readonly data: string;
213
-
204
+ export class WMSImageSource extends DataSource<string, WMSSourceOptions> implements ImageSource {
214
205
  /** In WMS 1.3.0, replaces references to EPSG:4326 with CRS:84. But not always supported. Default: false */
215
206
  substituteCRS84: boolean;
216
207
  /** In WMS 1.3.0, flips x,y (lng, lat) coordinates for the supplied coordinate systems. Default: ['ESPG:4326'] */
@@ -224,17 +215,14 @@ export class WMSImageSource extends ImageSource<WMSImageSourceProps> {
224
215
  capabilities: WMSCapabilities | null = null;
225
216
 
226
217
  /** Create a WMSImageSource */
227
- constructor(url: string, props: WMSImageSourceProps) {
228
- super(props);
218
+ constructor(url: string, options: WMSSourceOptions) {
219
+ super(url, options, WMSSource.defaultOptions);
229
220
 
230
221
  // TODO - defaults such as version, layers etc could be extracted from a base URL with parameters
231
222
  // This would make pasting in any WMS URL more likely to make this class just work.
232
- // const {baseUrl, parameters} = this._parseWMSUrl(props.url);
233
-
234
- this.url = url;
235
- this.data = url;
223
+ // const {baseUrl, parameters} = this._parseWMSUrl(options.url);
236
224
 
237
- this.substituteCRS84 = props.wms?.substituteCRS84 ?? props.substituteCRS84 ?? false;
225
+ this.substituteCRS84 = options.wms?.substituteCRS84 ?? false;
238
226
  this.flipCRS = ['EPSG:4326'];
239
227
 
240
228
  this.wmsParameters = {
@@ -248,11 +236,11 @@ export class WMSImageSource extends ImageSource<WMSImageSourceProps> {
248
236
  transparent: undefined!,
249
237
  time: undefined!,
250
238
  elevation: undefined!,
251
- ...props.wmsParameters, // deprecated
252
- ...props.wms?.wmsParameters
239
+ ...options.wmsParameters, // deprecated
240
+ ...options.wms?.wmsParameters
253
241
  };
254
242
 
255
- this.vendorParameters = props.wms?.vendorParameters || props.vendorParameters || {};
243
+ this.vendorParameters = options.wms?.vendorParameters || options.vendorParameters || {};
256
244
  }
257
245
 
258
246
  // ImageSource implementation
@@ -606,7 +594,7 @@ export class WMSImageSource extends ImageSource<WMSImageSourceProps> {
606
594
  const contentType = response.headers['content-type'];
607
595
  if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
608
596
  // We want error responses to throw exceptions, the WMSErrorLoader can do this
609
- const loadOptions = mergeLoaderOptions<WMSLoaderOptions>(this.loadOptions, {
597
+ const loadOptions = mergeOptions<WMSLoaderOptions>(this.loadOptions, {
610
598
  wms: {throwOnError: true}
611
599
  });
612
600
  const error = WMSErrorLoader.parseSync?.(arrayBuffer, loadOptions);
@@ -616,7 +604,7 @@ export class WMSImageSource extends ImageSource<WMSImageSourceProps> {
616
604
 
617
605
  /** Error situation detected */
618
606
  protected _parseError(arrayBuffer: ArrayBuffer): Error {
619
- const error = WMSErrorLoader.parseSync?.(arrayBuffer, this.loadOptions);
607
+ const error = WMSErrorLoader.parseSync?.(arrayBuffer, this.options.core?.loadOptions);
620
608
  return new Error(error);
621
609
  }
622
610
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"arcgis-feature-server.d.ts","sourceRoot":"","sources":["../../../src/services/arcgis/arcgis-feature-server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAS,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAW9D,MAAM,MAAM,8BAA8B,GAAG;IAC3C,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;IAC/C,YAAY,EAAE,sBAAsB,CAAC;IACrC,UAAU,EAAE,0BAA0B,CAAC;IACvC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,CAAC,EAAE,SAAS,CAAC;CACf,CAAC;AAuEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;YAUhC,kDAAkD;;;;;;;4BASvC,MAAM,KAAG,OAAO;2DACA,uBAAuB,KAAG,kBAAkB;CAEL,CAAC;AAEzE,MAAM,MAAM,uBAAuB,GAA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