@loaders.gl/wms 4.3.0-alpha.2 → 4.3.0-alpha.3

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 (70) hide show
  1. package/dist/csw-capabilities-loader.js +1 -1
  2. package/dist/csw-domain-loader.js +1 -1
  3. package/dist/csw-records-loader.js +1 -1
  4. package/dist/gml-loader.js +1 -1
  5. package/dist/index.cjs +124 -299
  6. package/dist/index.cjs.map +4 -4
  7. package/dist/index.d.ts +7 -13
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +8 -10
  10. package/dist/lib/deprecated/create-image-source.d.ts +21 -0
  11. package/dist/lib/deprecated/create-image-source.d.ts.map +1 -0
  12. package/dist/lib/deprecated/create-image-source.js +44 -0
  13. package/dist/lib/parsers/wfs/parse-wfs-capabilities.d.ts.map +1 -0
  14. package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs-capabilities.js +5 -2
  15. package/dist/lib/parsers/wfs/parse-wfs.d.ts.map +1 -0
  16. package/dist/services/arcgis/arcgis-feature-server.d.ts +67 -0
  17. package/dist/services/arcgis/arcgis-feature-server.d.ts.map +1 -0
  18. package/dist/services/arcgis/arcgis-feature-server.js +446 -0
  19. package/dist/services/arcgis/{arcgis-image-service.d.ts → arcgis-image-server.d.ts} +25 -10
  20. package/dist/services/arcgis/arcgis-image-server.d.ts.map +1 -0
  21. package/dist/services/arcgis/{arcgis-image-service.js → arcgis-image-server.js} +28 -11
  22. package/dist/services/ogc/csw-service.d.ts +13 -13
  23. package/dist/services/ogc/csw-service.d.ts.map +1 -1
  24. package/dist/services/ogc/wfs-service.d.ts +279 -0
  25. package/dist/services/ogc/wfs-service.d.ts.map +1 -0
  26. package/dist/services/ogc/wfs-service.js +388 -0
  27. package/dist/services/ogc/wms-service.d.ts +42 -21
  28. package/dist/services/ogc/wms-service.d.ts.map +1 -1
  29. package/dist/services/ogc/wms-service.js +28 -13
  30. package/dist/{wip/wfs-capabilities-loader.d.ts → wfs-capabilities-loader.d.ts} +2 -1
  31. package/dist/wfs-capabilities-loader.d.ts.map +1 -0
  32. package/dist/{wip/wfs-capabilities-loader.js → wfs-capabilities-loader.js} +3 -2
  33. package/dist/wip/wcs-capabilities-loader.js +1 -1
  34. package/dist/wip/wmts-capabilities-loader.js +1 -1
  35. package/dist/wms-capabilities-loader.js +1 -1
  36. package/dist/wms-error-loader.js +1 -1
  37. package/package.json +6 -6
  38. package/src/index.ts +12 -24
  39. package/src/lib/{services/create-image-service.ts → deprecated/create-image-service.ts.disabled} +4 -4
  40. package/src/lib/deprecated/create-image-source.ts +70 -0
  41. package/src/{wip/lib → lib/parsers}/wfs/parse-wfs-capabilities.ts +8 -5
  42. package/src/services/arcgis/arcgis-feature-server.ts +506 -0
  43. package/src/services/arcgis/{arcgis-image-service.ts → arcgis-image-server.ts} +41 -18
  44. package/src/services/ogc/csw-service.ts +17 -15
  45. package/src/services/ogc/wfs-service.ts +624 -0
  46. package/src/services/ogc/wms-service.ts +53 -29
  47. package/src/{wip/wfs-capabilities-loader.ts → wfs-capabilities-loader.ts} +3 -2
  48. package/dist/lib/services/create-image-service.d.ts +0 -14
  49. package/dist/lib/services/create-image-service.d.ts.map +0 -1
  50. package/dist/lib/services/create-image-service.js +0 -39
  51. package/dist/lib/services/image-service.d.ts +0 -28
  52. package/dist/lib/services/image-service.d.ts.map +0 -1
  53. package/dist/lib/services/image-service.js +0 -45
  54. package/dist/services/arcgis/arcgis-image-service.d.ts.map +0 -1
  55. package/dist/services/create-image-source.d.ts +0 -18
  56. package/dist/services/create-image-source.d.ts.map +0 -1
  57. package/dist/services/create-image-source.js +0 -17
  58. package/dist/wip/lib/wfs/parse-wfs-capabilities.d.ts.map +0 -1
  59. package/dist/wip/lib/wfs/parse-wfs.d.ts.map +0 -1
  60. package/dist/wip/services/arcgis-feature-service.d.ts +0 -56
  61. package/dist/wip/services/arcgis-feature-service.d.ts.map +0 -1
  62. package/dist/wip/services/arcgis-feature-service.js +0 -27
  63. package/dist/wip/wfs-capabilities-loader.d.ts.map +0 -1
  64. package/src/services/create-image-source.ts +0 -33
  65. package/src/wip/services/arcgis-feature-service.ts +0 -89
  66. /package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs-capabilities.d.ts +0 -0
  67. /package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs.d.ts +0 -0
  68. /package/dist/{wip/lib → lib/parsers}/wfs/parse-wfs.js +0 -0
  69. /package/src/lib/{services/image-service.ts → deprecated/template-image-service.ts.disabled} +0 -0
  70. /package/src/{wip/lib → lib/parsers}/wfs/parse-wfs.ts +0 -0
@@ -4,7 +4,7 @@
4
4
  import { parseCSWCapabilities } from "./lib/parsers/csw/parse-csw-capabilities.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0-alpha.1" !== 'undefined' ? "4.3.0-alpha.1" : 'latest';
7
+ const VERSION = typeof "4.3.0-alpha.2" !== 'undefined' ? "4.3.0-alpha.2" : 'latest';
8
8
  /**
9
9
  * Loader for the response to the CSW GetCapability request
10
10
  */
@@ -4,7 +4,7 @@
4
4
  import { parseCSWDomain } from "./lib/parsers/csw/parse-csw-domain.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0-alpha.1" !== 'undefined' ? "4.3.0-alpha.1" : 'latest';
7
+ const VERSION = typeof "4.3.0-alpha.2" !== 'undefined' ? "4.3.0-alpha.2" : 'latest';
8
8
  /**
9
9
  * Loader for the response to the CSW GetCapability request
10
10
  */
@@ -4,7 +4,7 @@
4
4
  import { parseCSWRecords } from "./lib/parsers/csw/parse-csw-records.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0-alpha.1" !== 'undefined' ? "4.3.0-alpha.1" : 'latest';
7
+ const VERSION = typeof "4.3.0-alpha.2" !== 'undefined' ? "4.3.0-alpha.2" : 'latest';
8
8
  /**
9
9
  * Loader for the response to the CSW GetCapability request
10
10
  */
@@ -4,7 +4,7 @@
4
4
  import { parseGML } from "./lib/parsers/gml/parse-gml.js";
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0-alpha.1" !== 'undefined' ? "4.3.0-alpha.1" : 'latest';
7
+ const VERSION = typeof "4.3.0-alpha.2" !== 'undefined' ? "4.3.0-alpha.2" : 'latest';
8
8
  /**
9
9
  * Loader for the response to the GML GetCapability request
10
10
  */
package/dist/index.cjs CHANGED
@@ -5,7 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
8
  var __export = (target, all) => {
10
9
  for (var name in all)
11
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,10 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
26
  mod
28
27
  ));
29
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __publicField = (obj, key, value) => {
31
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
- return value;
33
- };
34
29
 
35
30
  // dist/index.js
36
31
  var dist_exports = {};
@@ -38,20 +33,17 @@ __export(dist_exports, {
38
33
  CSWCapabilitiesLoader: () => CSWCapabilitiesLoader,
39
34
  CSWDomainLoader: () => CSWDomainLoader,
40
35
  CSWRecordsLoader: () => CSWRecordsLoader,
41
- CSWService: () => CSWService,
42
- ImageService: () => ImageService,
43
- ImageSource: () => import_loader_utils5.ImageSource,
36
+ ImageSource: () => import_loader_utils4.ImageSource,
44
37
  WMSCapabilitiesLoader: () => WMSCapabilitiesLoader,
45
38
  WMSErrorLoader: () => WMSErrorLoader,
46
- WMSService: () => WMSService,
39
+ WMSImageSource: () => WMSImageSource,
47
40
  WMSSource: () => WMSSource,
48
- _ArcGISImageService: () => ArcGISImageService,
41
+ _ArcGISImageServerSource: () => ArcGISImageServerSource,
49
42
  _GMLLoader: () => GMLLoader,
50
43
  _WFSCapabilitiesLoader: () => WFSCapabilitiesLoader,
51
44
  _WMSFeatureInfoLoader: () => WMSFeatureInfoLoader,
52
45
  _WMSLayerDescriptionLoader: () => WMSLayerDescriptionLoader,
53
46
  _getArcGISServices: () => getArcGISServices,
54
- createImageService: () => createImageService,
55
47
  createImageSource: () => createImageSource
56
48
  });
57
49
  module.exports = __toCommonJS(dist_exports);
@@ -87,7 +79,7 @@ function parseCSWCapabilities(text, options) {
87
79
  }
88
80
 
89
81
  // dist/csw-capabilities-loader.js
90
- var VERSION = true ? "4.3.0-alpha.1" : "latest";
82
+ var VERSION = true ? "4.3.0-alpha.2" : "latest";
91
83
  var CSWCapabilitiesLoader = {
92
84
  dataType: null,
93
85
  batchType: null,
@@ -135,7 +127,7 @@ function parseCSWDomain(text, options) {
135
127
  }
136
128
 
137
129
  // dist/csw-domain-loader.js
138
- var VERSION2 = true ? "4.3.0-alpha.1" : "latest";
130
+ var VERSION2 = true ? "4.3.0-alpha.2" : "latest";
139
131
  var CSWDomainLoader = {
140
132
  dataType: null,
141
133
  batchType: null,
@@ -201,7 +193,7 @@ function parseCSWRecords(text, options) {
201
193
  }
202
194
 
203
195
  // dist/csw-records-loader.js
204
- var VERSION3 = true ? "4.3.0-alpha.1" : "latest";
196
+ var VERSION3 = true ? "4.3.0-alpha.2" : "latest";
205
197
  var CSWRecordsLoader = {
206
198
  dataType: null,
207
199
  batchType: null,
@@ -234,7 +226,7 @@ function parseWMSError(text, options) {
234
226
  }
235
227
 
236
228
  // dist/wms-error-loader.js
237
- var VERSION4 = true ? "4.3.0-alpha.1" : "latest";
229
+ var VERSION4 = true ? "4.3.0-alpha.2" : "latest";
238
230
  var WMSErrorLoader = {
239
231
  dataType: null,
240
232
  batchType: null,
@@ -519,7 +511,7 @@ function addInheritedLayerProps(layer, parent) {
519
511
  }
520
512
 
521
513
  // dist/wms-capabilities-loader.js
522
- var VERSION5 = true ? "4.3.0-alpha.1" : "latest";
514
+ var VERSION5 = true ? "4.3.0-alpha.2" : "latest";
523
515
  var WMSCapabilitiesLoader = {
524
516
  dataType: null,
525
517
  batchType: null,
@@ -595,21 +587,24 @@ var WMSLayerDescriptionLoader = {
595
587
  parseTextSync: (text, options) => parseWMSLayerDescription(text, options)
596
588
  };
597
589
 
598
- // dist/wip/lib/wfs/parse-wfs-capabilities.js
590
+ // dist/lib/parsers/wfs/parse-wfs-capabilities.js
599
591
  var import_xml9 = require("@loaders.gl/xml");
600
592
  function parseWFSCapabilities(text, options) {
601
593
  var _a, _b;
602
- const parsedXML = (_b = (_a = import_xml9.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, { ...options, xml: {
603
- ...options == null ? void 0 : options.xml,
604
- removeNSPrefix: true,
605
- uncapitalizeKeys: true
606
- } });
594
+ const parsedXML = (_b = (_a = import_xml9.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, {
595
+ ...options,
596
+ xml: {
597
+ ...options == null ? void 0 : options.xml,
598
+ removeNSPrefix: true,
599
+ uncapitalizeKeys: true
600
+ }
601
+ });
607
602
  const xmlCapabilities = parsedXML.Capabilities || parsedXML;
608
603
  return xmlCapabilities;
609
604
  }
610
605
 
611
- // dist/wip/wfs-capabilities-loader.js
612
- var VERSION6 = true ? "4.3.0-alpha.1" : "latest";
606
+ // dist/wfs-capabilities-loader.js
607
+ var VERSION6 = true ? "4.3.0-alpha.2" : "latest";
613
608
  var WFSCapabilitiesLoader = {
614
609
  dataType: null,
615
610
  batchType: null,
@@ -1013,7 +1008,7 @@ function createChildContext(xml, options, context) {
1013
1008
  }
1014
1009
 
1015
1010
  // dist/gml-loader.js
1016
- var VERSION7 = true ? "4.3.0-alpha.1" : "latest";
1011
+ var VERSION7 = true ? "4.3.0-alpha.2" : "latest";
1017
1012
  var GMLLoader = {
1018
1013
  dataType: null,
1019
1014
  batchType: null,
@@ -1035,45 +1030,29 @@ function testXMLFile7(text) {
1035
1030
  return text.startsWith("<?xml");
1036
1031
  }
1037
1032
 
1038
- // dist/index.js
1039
- var import_loader_utils5 = require("@loaders.gl/loader-utils");
1040
-
1041
- // dist/lib/services/create-image-service.js
1042
- function createImageService(props, services) {
1043
- const { type = "auto" } = props;
1044
- const service = type === "auto" ? guessServiceType(props.url, services) : getServiceOfType(type, services);
1045
- if (!service) {
1046
- throw new Error("Not a valid image source type");
1047
- }
1048
- return service.create(props);
1049
- }
1050
- function getServiceOfType(type, services) {
1051
- for (const service of services) {
1052
- if (service.type === type) {
1053
- return service;
1054
- }
1055
- }
1056
- return null;
1057
- }
1058
- function guessServiceType(url, services) {
1059
- for (const service of services) {
1060
- if (service.testURL && service.testURL(url)) {
1061
- return service;
1062
- }
1063
- }
1064
- return null;
1065
- }
1066
-
1067
1033
  // dist/services/ogc/wms-service.js
1068
1034
  var import_images = require("@loaders.gl/images");
1069
1035
  var import_loader_utils = require("@loaders.gl/loader-utils");
1070
1036
  var import_loader_utils2 = require("@loaders.gl/loader-utils");
1071
- var WMSService = {
1037
+ var WMSSource = {
1038
+ name: "Web Map Service (OGC WMS)",
1039
+ id: "wms",
1040
+ module: "wms",
1041
+ version: "0.0.0",
1042
+ extensions: [],
1043
+ mimeTypes: [],
1044
+ options: {
1045
+ wms: {
1046
+ // TODO - add options here
1047
+ }
1048
+ },
1072
1049
  type: "wms",
1050
+ fromUrl: true,
1051
+ fromBlob: false,
1073
1052
  testURL: (url) => url.toLowerCase().includes("wms"),
1074
- create: (props) => new WMSSource(props)
1053
+ createDataSource: (url, props) => new WMSImageSource(url, props)
1075
1054
  };
1076
- var WMSSource = class extends import_loader_utils2.ImageSource {
1055
+ var WMSImageSource = class extends import_loader_utils2.ImageSource {
1077
1056
  /** Base URL to the service */
1078
1057
  url;
1079
1058
  data;
@@ -1086,12 +1065,13 @@ var WMSSource = class extends import_loader_utils2.ImageSource {
1086
1065
  /** Default static vendor parameters */
1087
1066
  vendorParameters;
1088
1067
  capabilities = null;
1089
- /** Create a WMSSource */
1090
- constructor(props) {
1068
+ /** Create a WMSImageSource */
1069
+ constructor(url, props) {
1070
+ var _a, _b, _c;
1091
1071
  super(props);
1092
- this.url = props.url;
1093
- this.data = props.url;
1094
- this.substituteCRS84 = props.substituteCRS84 ?? false;
1072
+ this.url = url;
1073
+ this.data = url;
1074
+ this.substituteCRS84 = ((_a = props.wms) == null ? void 0 : _a.substituteCRS84) ?? props.substituteCRS84 ?? false;
1095
1075
  this.flipCRS = ["EPSG:4326"];
1096
1076
  this.wmsParameters = {
1097
1077
  layers: void 0,
@@ -1104,11 +1084,13 @@ var WMSSource = class extends import_loader_utils2.ImageSource {
1104
1084
  transparent: void 0,
1105
1085
  time: void 0,
1106
1086
  elevation: void 0,
1107
- ...props.wmsParameters
1087
+ ...props.wmsParameters,
1088
+ // deprecated
1089
+ ...(_b = props.wms) == null ? void 0 : _b.wmsParameters
1108
1090
  };
1109
- this.vendorParameters = props.vendorParameters || {};
1091
+ this.vendorParameters = ((_c = props.wms) == null ? void 0 : _c.vendorParameters) || props.vendorParameters || {};
1110
1092
  }
1111
- // ImageService implementation
1093
+ // ImageSource implementation
1112
1094
  async getMetadata() {
1113
1095
  const capabilities = await this.getCapabilities();
1114
1096
  return this.normalizeMetadata(capabilities);
@@ -1373,49 +1355,66 @@ var WMSSource = class extends import_loader_utils2.ImageSource {
1373
1355
  }
1374
1356
  };
1375
1357
 
1376
- // dist/lib/services/image-service.js
1377
- var import_images2 = require("@loaders.gl/images");
1378
- var import_loader_utils3 = require("@loaders.gl/loader-utils");
1379
- var ImageService = class extends import_loader_utils3.ImageSource {
1380
- constructor(props) {
1381
- super(props);
1358
+ // dist/services/arcgis/arcgis-server.js
1359
+ async function getArcGISServices(url, fetchFile = fetch) {
1360
+ if (url.includes("rest/services")) {
1361
+ const serverUrl = url.replace(/rest\/services.*$/i, "rest/services");
1362
+ return loadServiceDirectory(serverUrl, fetchFile, []);
1382
1363
  }
1383
- // IMAGE SOURCE API
1384
- async getMetadata() {
1385
- throw new Error("ImageSource.getMetadata not implemented");
1364
+ return null;
1365
+ }
1366
+ async function loadServiceDirectory(serverUrl, fetch2, path) {
1367
+ const serviceUrl = `${serverUrl}/${path.join("/")}`;
1368
+ const response = await fetch2(`${serviceUrl}?f=pjson`);
1369
+ const directory = await response.json();
1370
+ const services = extractServices(directory, serviceUrl);
1371
+ const folders = directory.folders || [];
1372
+ const promises = folders.map((folder) => loadServiceDirectory(`${serverUrl}`, fetch2, [...path, folder]));
1373
+ for (const folderServices of await Promise.all(promises)) {
1374
+ services.push(...folderServices);
1386
1375
  }
1387
- async getImage(parameters) {
1388
- const granularParameters = this.getGranularParameters(parameters);
1389
- const url = this.getURLFromTemplate(granularParameters);
1390
- const response = await this.fetch(url);
1391
- const arrayBuffer = await response.arrayBuffer();
1392
- return await import_images2.ImageLoader.parse(arrayBuffer);
1393
- }
1394
- // HELPERS
1395
- /** Break up bounding box in east, north, south, west */
1396
- getGranularParameters(parameters) {
1397
- const [[east, north], [west, south]] = parameters.boundingBox;
1398
- return { ...parameters, east, north, south, west };
1399
- }
1400
- /** Supports both ${} and {} notations */
1401
- getURLFromTemplate(parameters) {
1402
- let url = this.props.url;
1403
- for (const [key, value] of Object.entries(parameters)) {
1404
- url = url.replace(`\${${key}}`, String(value));
1405
- url = url.replace(`{${key}}`, String(value));
1406
- }
1407
- return url;
1376
+ return services;
1377
+ }
1378
+ function extractServices(directory, url) {
1379
+ const arcgisServices = directory.services || [];
1380
+ const services = [];
1381
+ for (const service of arcgisServices) {
1382
+ services.push({
1383
+ name: service.name,
1384
+ type: `arcgis-${service.type.toLocaleLowerCase().replace("server", "-server")}`,
1385
+ url: `${url}${service.name}/${service.type}`
1386
+ });
1408
1387
  }
1409
- };
1410
- __publicField(ImageService, "type", "template");
1411
- __publicField(ImageService, "testURL", (url) => url.toLowerCase().includes("{"));
1388
+ return services;
1389
+ }
1412
1390
 
1413
- // dist/services/arcgis/arcgis-image-service.js
1414
- var ArcGISImageSource = class extends ImageService {
1391
+ // dist/services/arcgis/arcgis-image-server.js
1392
+ var import_loader_utils3 = require("@loaders.gl/loader-utils");
1393
+ var ArcGISImageServerSource = {
1394
+ name: "ArcGISImageServer",
1395
+ id: "arcgis-image-server",
1396
+ module: "wms",
1397
+ version: "0.0.0",
1398
+ extensions: [],
1399
+ mimeTypes: [],
1400
+ options: {
1401
+ "arcgis-image-server": {
1402
+ // TODO - add options here
1403
+ }
1404
+ },
1405
+ type: "arcgis-image-server",
1406
+ fromUrl: true,
1407
+ fromBlob: false,
1408
+ testURL: (url) => url.toLowerCase().includes("ImageServer"),
1409
+ createDataSource: (url, props) => new ArcGISImageSource(url, props)
1410
+ };
1411
+ var ArcGISImageSource = class extends import_loader_utils3.ImageSource {
1412
+ url;
1415
1413
  data;
1416
- constructor(props) {
1414
+ constructor(url, props) {
1417
1415
  super(props);
1418
- this.data = props.url;
1416
+ this.url = url;
1417
+ this.data = url;
1419
1418
  }
1420
1419
  // ImageSource (normalized endpoints)
1421
1420
  async getMetadata() {
@@ -1437,7 +1436,7 @@ var ArcGISImageSource = class extends ImageService {
1437
1436
  }
1438
1437
  // URL creators
1439
1438
  metadataURL(options) {
1440
- return `${this.props.url}?f=pjson`;
1439
+ return `${this.url}?f=pjson`;
1441
1440
  }
1442
1441
  /**
1443
1442
  * Form a URL to an ESRI ImageServer
@@ -1462,7 +1461,7 @@ var ArcGISImageSource = class extends ImageService {
1462
1461
  * @note if override is common, maybe add a callback prop?
1463
1462
  * */
1464
1463
  getUrl(path, options, extra) {
1465
- let url = `${this.props.url}/${path}`;
1464
+ let url = `${this.url}/${path}`;
1466
1465
  let first = true;
1467
1466
  for (const [key, value] of Object.entries(options)) {
1468
1467
  url += first ? "?" : "&";
@@ -1482,208 +1481,34 @@ var ArcGISImageSource = class extends ImageService {
1482
1481
  }
1483
1482
  }
1484
1483
  };
1485
- var ArcGISImageService = {
1486
- type: "arcgis-image-server",
1487
- testURL: (url) => url.toLowerCase().includes("ImageServer"),
1488
- create: (props) => new ArcGISImageSource(props)
1489
- };
1490
1484
 
1491
- // dist/services/create-image-source.js
1492
- var SERVICES = [WMSService, ArcGISImageService];
1493
- function createImageSource(props) {
1494
- return createImageService(props, SERVICES);
1495
- }
1496
-
1497
- // dist/services/ogc/csw-service.js
1485
+ // dist/index.js
1498
1486
  var import_loader_utils4 = require("@loaders.gl/loader-utils");
1499
- var CSWService = class extends import_loader_utils4.DataSource {
1500
- capabilities = null;
1501
- data;
1502
- url;
1503
- /** A list of loaders used by the CSWService methods */
1504
- loaders = [WMSErrorLoader, CSWCapabilitiesLoader];
1505
- /** Create a CSWService */
1506
- constructor(props) {
1507
- super(props);
1508
- this.url = props.url;
1509
- this.data = props.url;
1510
- }
1511
- async getMetadata() {
1512
- const capabilities = await this.getCapabilities();
1513
- return this.normalizeMetadata(capabilities);
1514
- }
1515
- normalizeMetadata(capabilities) {
1516
- return capabilities;
1517
- }
1518
- async getServiceDirectory(options) {
1519
- const services = [];
1520
- const unknownServices = [];
1521
- const records = await this.getRecords();
1522
- for (const record of records.records) {
1523
- for (const reference of record.references) {
1524
- const url = reference.value;
1525
- switch (reference.scheme) {
1526
- case "OGC:WMS":
1527
- services.push({ name: record.title, type: "ogc-wms-service", ...this._parseOGCUrl(url) });
1528
- break;
1529
- case "OGC:WMTS":
1530
- services.push({
1531
- name: record.title,
1532
- type: "ogc-wmts-service",
1533
- ...this._parseOGCUrl(url)
1534
- });
1535
- break;
1536
- case "OGC:WFS":
1537
- services.push({ name: record.title, type: "ogc-wfs-service", ...this._parseOGCUrl(url) });
1538
- break;
1539
- default:
1540
- unknownServices.push({
1541
- name: record.title,
1542
- type: "unknown",
1543
- url: reference.value,
1544
- scheme: reference.scheme
1545
- });
1546
- }
1547
- }
1548
- }
1549
- return (options == null ? void 0 : options.includeUnknown) ? services.concat(unknownServices) : services;
1550
- }
1551
- _parseOGCUrl(url) {
1552
- const parts = url.split("?");
1553
- return {
1554
- url: parts[0],
1555
- params: parts[1] || ""
1556
- };
1557
- }
1558
- // CSW Service API Stubs
1559
- /** Get Capabilities */
1560
- async getCapabilities(wmsParameters, vendorParameters) {
1561
- const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
1562
- const response = await this.fetch(url);
1563
- const arrayBuffer = await response.arrayBuffer();
1564
- this._checkResponse(response, arrayBuffer);
1565
- const capabilities = await CSWCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);
1566
- return capabilities;
1567
- }
1568
- /** Get Records */
1569
- async getRecords(wmsParameters, vendorParameters) {
1570
- const url = this.getRecordsURL(wmsParameters, vendorParameters);
1571
- const response = await this.fetch(url);
1572
- const arrayBuffer = await response.arrayBuffer();
1573
- this._checkResponse(response, arrayBuffer);
1574
- return await CSWRecordsLoader.parse(arrayBuffer, this.props.loadOptions);
1575
- }
1576
- /** Get Domain */
1577
- async getDomain(wmsParameters, vendorParameters) {
1578
- const url = this.getDomainURL(wmsParameters, vendorParameters);
1579
- const response = await this.fetch(url);
1580
- const arrayBuffer = await response.arrayBuffer();
1581
- this._checkResponse(response, arrayBuffer);
1582
- return await CSWDomainLoader.parse(arrayBuffer, this.props.loadOptions);
1583
- }
1584
- // Typed URL creators
1585
- // For applications that want full control of fetching and parsing
1586
- /** Generate a URL for the GetCapabilities request */
1587
- getCapabilitiesURL(wmsParameters, vendorParameters) {
1588
- const options = {
1589
- version: "3.0.0",
1590
- ...wmsParameters,
1591
- ...vendorParameters,
1592
- service: "CSW",
1593
- request: "GetCapabilities"
1594
- };
1595
- return this._getCSWUrl(options, vendorParameters);
1596
- }
1597
- /** Generate a URL for the GetCapabilities request */
1598
- getRecordsURL(wmsParameters, vendorParameters) {
1599
- const options = {
1600
- version: "3.0.0",
1601
- typenames: "csw:Record",
1602
- ...wmsParameters,
1603
- ...vendorParameters,
1604
- service: "CSW",
1605
- request: "GetRecords"
1606
- };
1607
- return this._getCSWUrl(options, vendorParameters);
1608
- }
1609
- /** Generate a URL for the GetCapabilities request */
1610
- getDomainURL(wmsParameters, vendorParameters) {
1611
- const options = {
1612
- version: "3.0.0",
1613
- ...wmsParameters,
1614
- ...vendorParameters,
1615
- service: "CSW",
1616
- request: "GetDomain"
1617
- };
1618
- return this._getCSWUrl(options, vendorParameters);
1619
- }
1620
- // INTERNAL METHODS
1621
- /**
1622
- * @note case _getCSWUrl may need to be overridden to handle certain backends?
1623
- * */
1624
- _getCSWUrl(options, vendorParameters) {
1625
- let url = this.props.url;
1626
- let first = true;
1627
- for (const [key, value] of Object.entries(options)) {
1628
- url += first ? "?" : "&";
1629
- first = false;
1630
- if (Array.isArray(value)) {
1631
- url += `${key.toUpperCase()}=${value.join(",")}`;
1632
- } else {
1633
- url += `${key.toUpperCase()}=${value ? String(value) : ""}`;
1634
- }
1635
- }
1636
- return encodeURI(url);
1637
- }
1638
- /** Checks for and parses a CSW XML formatted ServiceError and throws an exception */
1639
- _checkResponse(response, arrayBuffer) {
1640
- var _a, _b;
1641
- const contentType = response.headers["content-type"];
1642
- if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
1643
- const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, this.props.loadOptions);
1644
- throw new Error(error);
1645
- }
1646
- }
1647
- /** Error situation detected */
1648
- _parseError(arrayBuffer) {
1649
- var _a, _b;
1650
- const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, this.props.loadOptions);
1651
- return new Error(error);
1652
- }
1653
- };
1654
- __publicField(CSWService, "type", "csw");
1655
- __publicField(CSWService, "testURL", (url) => url.toLowerCase().includes("csw"));
1656
1487
 
1657
- // dist/services/arcgis/arcgis-server.js
1658
- async function getArcGISServices(url, fetchFile = fetch) {
1659
- if (url.includes("rest/services")) {
1660
- const serverUrl = url.replace(/rest\/services.*$/i, "rest/services");
1661
- return loadServiceDirectory(serverUrl, fetchFile, []);
1488
+ // dist/lib/deprecated/create-image-source.js
1489
+ var SOURCES = [WMSSource, ArcGISImageServerSource];
1490
+ function createImageSource(url, props, sources = SOURCES) {
1491
+ const { type = "auto" } = props;
1492
+ const source = type === "auto" ? guessSourceType(url, sources) : getSourceOfType(type, sources);
1493
+ if (!source) {
1494
+ throw new Error("Not a valid image source type");
1662
1495
  }
1663
- return null;
1496
+ return source.createDataSource(url, props);
1664
1497
  }
1665
- async function loadServiceDirectory(serverUrl, fetch2, path) {
1666
- const serviceUrl = `${serverUrl}/${path.join("/")}`;
1667
- const response = await fetch2(`${serviceUrl}?f=pjson`);
1668
- const directory = await response.json();
1669
- const services = extractServices(directory, serviceUrl);
1670
- const folders = directory.folders || [];
1671
- const promises = folders.map((folder) => loadServiceDirectory(`${serverUrl}`, fetch2, [...path, folder]));
1672
- for (const folderServices of await Promise.all(promises)) {
1673
- services.push(...folderServices);
1498
+ function getSourceOfType(type, sources) {
1499
+ for (const source of sources) {
1500
+ if (source.type === type) {
1501
+ return source;
1502
+ }
1674
1503
  }
1675
- return services;
1504
+ return null;
1676
1505
  }
1677
- function extractServices(directory, url) {
1678
- const arcgisServices = directory.services || [];
1679
- const services = [];
1680
- for (const service of arcgisServices) {
1681
- services.push({
1682
- name: service.name,
1683
- type: `arcgis-${service.type.toLocaleLowerCase().replace("server", "-server")}`,
1684
- url: `${url}${service.name}/${service.type}`
1685
- });
1506
+ function guessSourceType(url, sources) {
1507
+ for (const source of sources) {
1508
+ if (source.testURL && source.testURL(url)) {
1509
+ return source;
1510
+ }
1686
1511
  }
1687
- return services;
1512
+ return null;
1688
1513
  }
1689
1514
  //# sourceMappingURL=index.cjs.map