@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,29 +2,41 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
  import { DataSource } from '@loaders.gl/loader-utils';
5
- import { CSWCapabilitiesLoader } from "../../csw-capabilities-loader.js";
6
- import { CSWRecordsLoader } from "../../csw-records-loader.js";
7
- import { CSWDomainLoader } from "../../csw-domain-loader.js";
8
- import { WMSErrorLoader as CSWErrorLoader } from "../../wms-error-loader.js";
5
+ import { CSWCapabilitiesLoader } from "./csw-capabilities-loader.js";
6
+ import { CSWRecordsLoader } from "./csw-records-loader.js";
7
+ import { CSWDomainLoader } from "./csw-domain-loader.js";
8
+ import { WMSErrorLoader as CSWErrorLoader } from "./wms-error-loader.js";
9
+ export const CSWSource = {
10
+ name: 'CSW',
11
+ id: 'csw',
12
+ module: 'wms',
13
+ version: '0.0.0',
14
+ extensions: [],
15
+ mimeTypes: [],
16
+ type: 'csw',
17
+ fromUrl: true,
18
+ fromBlob: false,
19
+ defaultOptions: {
20
+ wfs: {}
21
+ },
22
+ testURL: (url) => url.toLowerCase().includes('wfs'),
23
+ createDataSource: (url, options) => new CSWCatalogSource(url, options)
24
+ };
9
25
  /**
10
- * The CSWService class
26
+ * The CSWCatalogSource class
11
27
  * - provides type safe methods to form URLs to a CSW service
12
28
  * - provides type safe methods to query and parse results (and errors) from a CSW service
13
29
  * @note Only the URL parameter conversion is supported. XML posts are not supported.
14
30
  */
15
- export class CSWService extends DataSource {
31
+ export class CSWCatalogSource extends DataSource {
16
32
  static type = 'csw';
17
33
  static testURL = (url) => url.toLowerCase().includes('csw');
18
34
  capabilities = null;
19
- data;
20
- url;
21
- /** A list of loaders used by the CSWService methods */
35
+ /** A list of loaders used by the CSWCatalogSource methods */
22
36
  loaders = [CSWErrorLoader, CSWCapabilitiesLoader];
23
- /** Create a CSWService */
24
- constructor(props) {
25
- super(props);
26
- this.url = props.url;
27
- this.data = props.url;
37
+ /** Create a CSWCatalogSource */
38
+ constructor(url, options) {
39
+ super(url, options, CSWSource.defaultOptions);
28
40
  }
29
41
  async getMetadata() {
30
42
  const capabilities = await this.getCapabilities();
@@ -75,37 +87,37 @@ export class CSWService extends DataSource {
75
87
  }
76
88
  // CSW Service API Stubs
77
89
  /** Get Capabilities */
78
- async getCapabilities(wmsParameters, vendorParameters) {
79
- const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
90
+ async getCapabilities(cswParameters, vendorParameters) {
91
+ const url = this.getCapabilitiesURL(cswParameters, vendorParameters);
80
92
  const response = await this.fetch(url);
81
93
  const arrayBuffer = await response.arrayBuffer();
82
94
  this._checkResponse(response, arrayBuffer);
83
- const capabilities = await CSWCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);
95
+ const capabilities = await CSWCapabilitiesLoader.parse(arrayBuffer, this.options.loadOptions);
84
96
  return capabilities;
85
97
  }
86
98
  /** Get Records */
87
- async getRecords(wmsParameters, vendorParameters) {
88
- const url = this.getRecordsURL(wmsParameters, vendorParameters);
99
+ async getRecords(cswParameters, vendorParameters) {
100
+ const url = this.getRecordsURL(cswParameters, vendorParameters);
89
101
  const response = await this.fetch(url);
90
102
  const arrayBuffer = await response.arrayBuffer();
91
103
  this._checkResponse(response, arrayBuffer);
92
- return await CSWRecordsLoader.parse(arrayBuffer, this.props.loadOptions);
104
+ return await CSWRecordsLoader.parse(arrayBuffer, this.options.loadOptions);
93
105
  }
94
106
  /** Get Domain */
95
- async getDomain(wmsParameters, vendorParameters) {
96
- const url = this.getDomainURL(wmsParameters, vendorParameters);
107
+ async getDomain(cswParameters, vendorParameters) {
108
+ const url = this.getDomainURL(cswParameters, vendorParameters);
97
109
  const response = await this.fetch(url);
98
110
  const arrayBuffer = await response.arrayBuffer();
99
111
  this._checkResponse(response, arrayBuffer);
100
- return await CSWDomainLoader.parse(arrayBuffer, this.props.loadOptions);
112
+ return await CSWDomainLoader.parse(arrayBuffer, this.options.loadOptions);
101
113
  }
102
114
  // Typed URL creators
103
115
  // For applications that want full control of fetching and parsing
104
116
  /** Generate a URL for the GetCapabilities request */
105
- getCapabilitiesURL(wmsParameters, vendorParameters) {
117
+ getCapabilitiesURL(cswParameters, vendorParameters) {
106
118
  const options = {
107
119
  version: '3.0.0',
108
- ...wmsParameters,
120
+ ...cswParameters,
109
121
  ...vendorParameters,
110
122
  service: 'CSW',
111
123
  request: 'GetCapabilities'
@@ -113,11 +125,11 @@ export class CSWService extends DataSource {
113
125
  return this._getCSWUrl(options, vendorParameters);
114
126
  }
115
127
  /** Generate a URL for the GetCapabilities request */
116
- getRecordsURL(wmsParameters, vendorParameters) {
128
+ getRecordsURL(cswParameters, vendorParameters) {
117
129
  const options = {
118
130
  version: '3.0.0',
119
131
  typenames: 'csw:Record',
120
- ...wmsParameters,
132
+ ...cswParameters,
121
133
  ...vendorParameters,
122
134
  service: 'CSW',
123
135
  request: 'GetRecords'
@@ -125,10 +137,10 @@ export class CSWService extends DataSource {
125
137
  return this._getCSWUrl(options, vendorParameters);
126
138
  }
127
139
  /** Generate a URL for the GetCapabilities request */
128
- getDomainURL(wmsParameters, vendorParameters) {
140
+ getDomainURL(cswParameters, vendorParameters) {
129
141
  const options = {
130
142
  version: '3.0.0',
131
- ...wmsParameters,
143
+ ...cswParameters,
132
144
  ...vendorParameters,
133
145
  service: 'CSW',
134
146
  request: 'GetDomain'
@@ -140,7 +152,7 @@ export class CSWService extends DataSource {
140
152
  * @note case _getCSWUrl may need to be overridden to handle certain backends?
141
153
  * */
142
154
  _getCSWUrl(options, vendorParameters) {
143
- let url = this.props.url;
155
+ let url = this.url;
144
156
  let first = true;
145
157
  for (const [key, value] of Object.entries(options)) {
146
158
  url += first ? '?' : '&';
@@ -158,13 +170,13 @@ export class CSWService extends DataSource {
158
170
  _checkResponse(response, arrayBuffer) {
159
171
  const contentType = response.headers['content-type'];
160
172
  if (!response.ok || CSWErrorLoader.mimeTypes.includes(contentType)) {
161
- const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.props.loadOptions);
173
+ const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.options.loadOptions);
162
174
  throw new Error(error);
163
175
  }
164
176
  }
165
177
  /** Error situation detected */
166
178
  _parseError(arrayBuffer) {
167
- const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.props.loadOptions);
179
+ const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.options.loadOptions);
168
180
  return new Error(error);
169
181
  }
170
182
  }
@@ -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.1" !== 'undefined' ? "4.3.1" : 'latest';
7
+ const VERSION = typeof "4.4.0-alpha.1" !== 'undefined' ? "4.4.0-alpha.1" : 'latest';
8
8
  /**
9
9
  * Loader for the response to the GML GetCapability request
10
10
  */
package/dist/index.cjs CHANGED
@@ -79,7 +79,7 @@ function parseCSWCapabilities(text, options) {
79
79
  }
80
80
 
81
81
  // dist/csw-capabilities-loader.js
82
- var VERSION = true ? "4.3.1" : "latest";
82
+ var VERSION = true ? "4.4.0-alpha.1" : "latest";
83
83
  var CSWCapabilitiesLoader = {
84
84
  dataType: null,
85
85
  batchType: null,
@@ -127,7 +127,7 @@ function parseCSWDomain(text, options) {
127
127
  }
128
128
 
129
129
  // dist/csw-domain-loader.js
130
- var VERSION2 = true ? "4.3.1" : "latest";
130
+ var VERSION2 = true ? "4.4.0-alpha.1" : "latest";
131
131
  var CSWDomainLoader = {
132
132
  dataType: null,
133
133
  batchType: null,
@@ -192,7 +192,7 @@ function parseCSWRecords(text, options) {
192
192
  }
193
193
 
194
194
  // dist/csw-records-loader.js
195
- var VERSION3 = true ? "4.3.1" : "latest";
195
+ var VERSION3 = true ? "4.4.0-alpha.1" : "latest";
196
196
  var CSWRecordsLoader = {
197
197
  dataType: null,
198
198
  batchType: null,
@@ -225,7 +225,7 @@ function parseWMSError(text, options) {
225
225
  }
226
226
 
227
227
  // dist/wms-error-loader.js
228
- var VERSION4 = true ? "4.3.1" : "latest";
228
+ var VERSION4 = true ? "4.4.0-alpha.1" : "latest";
229
229
  var WMSErrorLoader = {
230
230
  dataType: null,
231
231
  batchType: null,
@@ -510,7 +510,7 @@ function addInheritedLayerProps(layer, parent) {
510
510
  }
511
511
 
512
512
  // dist/wms-capabilities-loader.js
513
- var VERSION5 = true ? "4.3.1" : "latest";
513
+ var VERSION5 = true ? "4.4.0-alpha.1" : "latest";
514
514
  var WMSCapabilitiesLoader = {
515
515
  dataType: null,
516
516
  batchType: null,
@@ -603,7 +603,7 @@ function parseWFSCapabilities(text, options) {
603
603
  }
604
604
 
605
605
  // dist/wfs-capabilities-loader.js
606
- var VERSION6 = true ? "4.3.1" : "latest";
606
+ var VERSION6 = true ? "4.4.0-alpha.1" : "latest";
607
607
  var WFSCapabilitiesLoader = {
608
608
  dataType: null,
609
609
  batchType: null,
@@ -1007,7 +1007,7 @@ function createChildContext(xml, options, context) {
1007
1007
  }
1008
1008
 
1009
1009
  // dist/gml-loader.js
1010
- var VERSION7 = true ? "4.3.1" : "latest";
1010
+ var VERSION7 = true ? "4.4.0-alpha.1" : "latest";
1011
1011
  var GMLLoader = {
1012
1012
  dataType: null,
1013
1013
  batchType: null,
@@ -1029,9 +1029,9 @@ function testXMLFile7(text) {
1029
1029
  return text.startsWith("<?xml");
1030
1030
  }
1031
1031
 
1032
- // dist/services/ogc/wms-service.js
1033
- var import_images = require("@loaders.gl/images");
1032
+ // dist/wms-source.js
1034
1033
  var import_loader_utils = require("@loaders.gl/loader-utils");
1034
+ var import_images = require("@loaders.gl/images");
1035
1035
  var WMSSource = {
1036
1036
  name: "Web Map Service (OGC WMS)",
1037
1037
  id: "wms",
@@ -1039,21 +1039,18 @@ var WMSSource = {
1039
1039
  version: "0.0.0",
1040
1040
  extensions: [],
1041
1041
  mimeTypes: [],
1042
- options: {
1042
+ type: "wms",
1043
+ fromUrl: true,
1044
+ fromBlob: false,
1045
+ defaultOptions: {
1043
1046
  wms: {
1044
1047
  // TODO - add options here
1045
1048
  }
1046
1049
  },
1047
- type: "wms",
1048
- fromUrl: true,
1049
- fromBlob: false,
1050
1050
  testURL: (url) => url.toLowerCase().includes("wms"),
1051
- createDataSource: (url, props) => new WMSImageSource(url, props)
1051
+ createDataSource: (url, options) => new WMSImageSource(url, options)
1052
1052
  };
1053
- var WMSImageSource = class extends import_loader_utils.ImageSource {
1054
- /** Base URL to the service */
1055
- url;
1056
- data;
1053
+ var WMSImageSource = class extends import_loader_utils.DataSource {
1057
1054
  /** In WMS 1.3.0, replaces references to EPSG:4326 with CRS:84. But not always supported. Default: false */
1058
1055
  substituteCRS84;
1059
1056
  /** In WMS 1.3.0, flips x,y (lng, lat) coordinates for the supplied coordinate systems. Default: ['ESPG:4326'] */
@@ -1064,12 +1061,10 @@ var WMSImageSource = class extends import_loader_utils.ImageSource {
1064
1061
  vendorParameters;
1065
1062
  capabilities = null;
1066
1063
  /** Create a WMSImageSource */
1067
- constructor(url, props) {
1064
+ constructor(url, options) {
1068
1065
  var _a, _b, _c;
1069
- super(props);
1070
- this.url = url;
1071
- this.data = url;
1072
- this.substituteCRS84 = ((_a = props.wms) == null ? void 0 : _a.substituteCRS84) ?? props.substituteCRS84 ?? false;
1066
+ super(url, options, WMSSource.defaultOptions);
1067
+ this.substituteCRS84 = ((_a = options.wms) == null ? void 0 : _a.substituteCRS84) ?? false;
1073
1068
  this.flipCRS = ["EPSG:4326"];
1074
1069
  this.wmsParameters = {
1075
1070
  layers: void 0,
@@ -1082,11 +1077,11 @@ var WMSImageSource = class extends import_loader_utils.ImageSource {
1082
1077
  transparent: void 0,
1083
1078
  time: void 0,
1084
1079
  elevation: void 0,
1085
- ...props.wmsParameters,
1080
+ ...options.wmsParameters,
1086
1081
  // deprecated
1087
- ...(_b = props.wms) == null ? void 0 : _b.wmsParameters
1082
+ ...(_b = options.wms) == null ? void 0 : _b.wmsParameters
1088
1083
  };
1089
- this.vendorParameters = ((_c = props.wms) == null ? void 0 : _c.vendorParameters) || props.vendorParameters || {};
1084
+ this.vendorParameters = ((_c = options.wms) == null ? void 0 : _c.vendorParameters) || options.vendorParameters || {};
1090
1085
  }
1091
1086
  // ImageSource implementation
1092
1087
  async getMetadata() {
@@ -1338,7 +1333,7 @@ var WMSImageSource = class extends import_loader_utils.ImageSource {
1338
1333
  var _a, _b;
1339
1334
  const contentType = response.headers["content-type"];
1340
1335
  if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
1341
- const loadOptions = (0, import_loader_utils.mergeLoaderOptions)(this.loadOptions, {
1336
+ const loadOptions = (0, import_loader_utils.mergeOptions)(this.loadOptions, {
1342
1337
  wms: { throwOnError: true }
1343
1338
  });
1344
1339
  const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, loadOptions);
@@ -1347,13 +1342,13 @@ var WMSImageSource = class extends import_loader_utils.ImageSource {
1347
1342
  }
1348
1343
  /** Error situation detected */
1349
1344
  _parseError(arrayBuffer) {
1350
- var _a, _b;
1351
- const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, this.loadOptions);
1345
+ var _a, _b, _c;
1346
+ const error = (_c = (_b = WMSErrorLoader).parseSync) == null ? void 0 : _c.call(_b, arrayBuffer, (_a = this.options.core) == null ? void 0 : _a.loadOptions);
1352
1347
  return new Error(error);
1353
1348
  }
1354
1349
  };
1355
1350
 
1356
- // dist/services/arcgis/arcgis-server.js
1351
+ // dist/arcgis/arcgis-server.js
1357
1352
  async function getArcGISServices(url, fetchFile = fetch) {
1358
1353
  if (url.includes("rest/services")) {
1359
1354
  const serverUrl = url.replace(/rest\/services.*$/i, "rest/services");
@@ -1386,7 +1381,7 @@ function extractServices(directory, url) {
1386
1381
  return services;
1387
1382
  }
1388
1383
 
1389
- // dist/services/arcgis/arcgis-image-server.js
1384
+ // dist/arcgis/arcgis-image-source.js
1390
1385
  var import_loader_utils2 = require("@loaders.gl/loader-utils");
1391
1386
  var ArcGISImageServerSource = {
1392
1387
  name: "ArcGISImageServer",
@@ -1395,24 +1390,20 @@ var ArcGISImageServerSource = {
1395
1390
  version: "0.0.0",
1396
1391
  extensions: [],
1397
1392
  mimeTypes: [],
1398
- options: {
1393
+ type: "arcgis-image-server",
1394
+ fromUrl: true,
1395
+ fromBlob: false,
1396
+ defaultOptions: {
1399
1397
  "arcgis-image-server": {
1400
1398
  // TODO - add options here
1401
1399
  }
1402
1400
  },
1403
- type: "arcgis-image-server",
1404
- fromUrl: true,
1405
- fromBlob: false,
1406
1401
  testURL: (url) => url.toLowerCase().includes("ImageServer"),
1407
1402
  createDataSource: (url, props) => new ArcGISImageSource(url, props)
1408
1403
  };
1409
- var ArcGISImageSource = class extends import_loader_utils2.ImageSource {
1410
- url;
1411
- data;
1404
+ var ArcGISImageSource = class extends import_loader_utils2.DataSource {
1412
1405
  constructor(url, props) {
1413
- super(props);
1414
- this.url = url;
1415
- this.data = url;
1406
+ super(url, props, ArcGISImageServerSource.defaultOptions);
1416
1407
  }
1417
1408
  // ImageSource (normalized endpoints)
1418
1409
  async getMetadata() {
@@ -1485,13 +1476,13 @@ var import_loader_utils3 = require("@loaders.gl/loader-utils");
1485
1476
 
1486
1477
  // dist/lib/deprecated/create-image-source.js
1487
1478
  var SOURCES = [WMSSource, ArcGISImageServerSource];
1488
- function createImageSource(props, sources = SOURCES) {
1489
- const { type = "auto" } = props;
1490
- const source = type === "auto" ? guessSourceType(props.url, sources) : getSourceOfType(type, sources);
1479
+ function createImageSource(options) {
1480
+ const { type = "auto", url, sources = SOURCES, loadOptions } = options;
1481
+ const source = type === "auto" ? guessSourceType(url, sources) : getSourceOfType(type, sources);
1491
1482
  if (!source) {
1492
1483
  throw new Error("Not a valid image source type");
1493
1484
  }
1494
- return source.createDataSource(props.url, props);
1485
+ return source.createDataSource(url, { core: { loadOptions } });
1495
1486
  }
1496
1487
  function getSourceOfType(type, sources) {
1497
1488
  for (const source of sources) {