@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.
- package/dist/{services/arcgis/arcgis-feature-server.d.ts → arcgis/arcgis-feature-source.d.ts} +14 -21
- package/dist/arcgis/arcgis-feature-source.d.ts.map +1 -0
- package/dist/{services/arcgis/arcgis-feature-server.js → arcgis/arcgis-feature-source.js} +74 -79
- package/dist/{services/arcgis/arcgis-image-server.d.ts → arcgis/arcgis-image-source.d.ts} +10 -12
- package/dist/arcgis/arcgis-image-source.d.ts.map +1 -0
- package/dist/{services/arcgis/arcgis-image-server.js → arcgis/arcgis-image-source.js} +7 -13
- package/dist/arcgis/arcgis-server.d.ts.map +1 -0
- package/dist/csw-capabilities-loader.js +1 -1
- package/dist/csw-domain-loader.js +1 -1
- package/dist/csw-records-loader.js +1 -1
- package/dist/{services/ogc/csw-service.d.ts → csw-source.d.ts} +40 -26
- package/dist/csw-source.d.ts.map +1 -0
- package/dist/{services/ogc/csw-service.js → csw-source.js} +44 -32
- package/dist/gml-loader.js +1 -1
- package/dist/index.cjs +36 -45
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -5
- package/dist/lib/deprecated/create-image-source.d.ts +12 -8
- package/dist/lib/deprecated/create-image-source.d.ts.map +1 -1
- package/dist/lib/deprecated/create-image-source.js +6 -6
- package/dist/wfs-capabilities-loader.js +1 -1
- package/dist/{services/ogc/wfs-service.d.ts → wfs-source.d.ts} +43 -52
- package/dist/wfs-source.d.ts.map +1 -0
- package/dist/{services/ogc/wfs-service.js → wfs-source.js} +74 -106
- package/dist/wip/wcs-capabilities-loader.js +1 -1
- package/dist/wip/wmts-capabilities-loader.js +1 -1
- package/dist/wms-capabilities-loader.js +1 -1
- package/dist/wms-error-loader.js +1 -1
- package/dist/{services/ogc/wms-service.d.ts → wms-source.d.ts} +23 -32
- package/dist/wms-source.d.ts.map +1 -0
- package/dist/{services/ogc/wms-service.js → wms-source.js} +20 -25
- package/package.json +7 -7
- package/src/{services/arcgis/arcgis-feature-server.ts → arcgis/arcgis-feature-source.ts} +93 -97
- package/src/{services/arcgis/arcgis-image-server.ts → arcgis/arcgis-image-source.ts} +18 -23
- package/src/{services/ogc/csw-service.ts → csw-source.ts} +56 -41
- package/src/index.ts +4 -6
- package/src/lib/deprecated/create-image-source.ts +22 -18
- package/src/{services/ogc/wfs-service.ts → wfs-source.ts} +93 -133
- package/src/{services/ogc/wms-service.ts → wms-source.ts} +44 -56
- package/dist/services/arcgis/arcgis-feature-server.d.ts.map +0 -1
- package/dist/services/arcgis/arcgis-image-server.d.ts.map +0 -1
- package/dist/services/arcgis/arcgis-server.d.ts.map +0 -1
- package/dist/services/ogc/csw-service.d.ts.map +0 -1
- package/dist/services/ogc/wfs-service.d.ts.map +0 -1
- package/dist/services/ogc/wms-service.d.ts.map +0 -1
- /package/dist/{services/arcgis → arcgis}/arcgis-server.d.ts +0 -0
- /package/dist/{services/arcgis → arcgis}/arcgis-server.js +0 -0
- /package/src/{services/arcgis → arcgis}/arcgis-server.ts +0 -0
|
@@ -4,23 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
/* eslint-disable camelcase */
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type {Source, DataSourceOptions} from '@loaders.gl/loader-utils';
|
|
8
8
|
import {DataSource} from '@loaders.gl/loader-utils';
|
|
9
9
|
|
|
10
|
-
import type {CSWCapabilities} from '
|
|
11
|
-
import {CSWCapabilitiesLoader} from '
|
|
10
|
+
import type {CSWCapabilities} from './csw-capabilities-loader';
|
|
11
|
+
import {CSWCapabilitiesLoader} from './csw-capabilities-loader';
|
|
12
12
|
|
|
13
|
-
import type {CSWRecords} from '
|
|
14
|
-
import {CSWRecordsLoader} from '
|
|
13
|
+
import type {CSWRecords} from './csw-records-loader';
|
|
14
|
+
import {CSWRecordsLoader} from './csw-records-loader';
|
|
15
15
|
|
|
16
|
-
import type {CSWDomain} from '
|
|
17
|
-
import {CSWDomainLoader} from '
|
|
16
|
+
import type {CSWDomain} from './csw-domain-loader';
|
|
17
|
+
import {CSWDomainLoader} from './csw-domain-loader';
|
|
18
18
|
|
|
19
|
-
import {WMSErrorLoader as CSWErrorLoader} from '
|
|
20
|
-
|
|
21
|
-
export type CSWServiceProps = DataSourceProps & {
|
|
22
|
-
url: string;
|
|
23
|
-
};
|
|
19
|
+
import {WMSErrorLoader as CSWErrorLoader} from './wms-error-loader';
|
|
24
20
|
|
|
25
21
|
/** Describes a service or resource exposed by the catalog */
|
|
26
22
|
export type Service = {
|
|
@@ -60,28 +56,47 @@ export type CSWGetDomainParameters = CSWCommonParameters & {
|
|
|
60
56
|
// TBA
|
|
61
57
|
};
|
|
62
58
|
|
|
59
|
+
export type CSWSourceOptions = DataSourceOptions & {
|
|
60
|
+
csw?: {};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const CSWSource = {
|
|
64
|
+
name: 'CSW',
|
|
65
|
+
id: 'csw',
|
|
66
|
+
module: 'wms',
|
|
67
|
+
version: '0.0.0',
|
|
68
|
+
extensions: [],
|
|
69
|
+
mimeTypes: [],
|
|
70
|
+
type: 'csw',
|
|
71
|
+
fromUrl: true,
|
|
72
|
+
fromBlob: false,
|
|
73
|
+
|
|
74
|
+
defaultOptions: {
|
|
75
|
+
wfs: {}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
testURL: (url: string): boolean => url.toLowerCase().includes('wfs'),
|
|
79
|
+
createDataSource: (url: string, options: CSWSourceOptions): CSWCatalogSource =>
|
|
80
|
+
new CSWCatalogSource(url, options)
|
|
81
|
+
} as const satisfies Source<CSWCatalogSource>;
|
|
82
|
+
|
|
63
83
|
/**
|
|
64
|
-
* The
|
|
84
|
+
* The CSWCatalogSource class
|
|
65
85
|
* - provides type safe methods to form URLs to a CSW service
|
|
66
86
|
* - provides type safe methods to query and parse results (and errors) from a CSW service
|
|
67
87
|
* @note Only the URL parameter conversion is supported. XML posts are not supported.
|
|
68
88
|
*/
|
|
69
|
-
export class
|
|
89
|
+
export class CSWCatalogSource extends DataSource<string, CSWSourceOptions> {
|
|
70
90
|
static readonly type = 'csw';
|
|
71
91
|
static testURL = (url: string): boolean => url.toLowerCase().includes('csw');
|
|
72
92
|
|
|
73
93
|
capabilities: CSWCapabilities | null = null;
|
|
74
|
-
|
|
75
|
-
url: string;
|
|
76
|
-
|
|
77
|
-
/** A list of loaders used by the CSWService methods */
|
|
94
|
+
/** A list of loaders used by the CSWCatalogSource methods */
|
|
78
95
|
readonly loaders = [CSWErrorLoader, CSWCapabilitiesLoader];
|
|
79
96
|
|
|
80
|
-
/** Create a
|
|
81
|
-
constructor(
|
|
82
|
-
super(
|
|
83
|
-
this.url = props.url;
|
|
84
|
-
this.data = props.url;
|
|
97
|
+
/** Create a CSWCatalogSource */
|
|
98
|
+
constructor(url: string, options: CSWSourceOptions) {
|
|
99
|
+
super(url, options, CSWSource.defaultOptions);
|
|
85
100
|
}
|
|
86
101
|
|
|
87
102
|
async getMetadata(): Promise<CSWCapabilities> {
|
|
@@ -141,39 +156,39 @@ export class CSWService extends DataSource<CSWServiceProps> {
|
|
|
141
156
|
|
|
142
157
|
/** Get Capabilities */
|
|
143
158
|
async getCapabilities(
|
|
144
|
-
|
|
159
|
+
cswParameters?: CSWGetCapabilitiesParameters,
|
|
145
160
|
vendorParameters?: Record<string, unknown>
|
|
146
161
|
): Promise<CSWCapabilities> {
|
|
147
|
-
const url = this.getCapabilitiesURL(
|
|
162
|
+
const url = this.getCapabilitiesURL(cswParameters, vendorParameters);
|
|
148
163
|
const response = await this.fetch(url);
|
|
149
164
|
const arrayBuffer = await response.arrayBuffer();
|
|
150
165
|
this._checkResponse(response, arrayBuffer);
|
|
151
|
-
const capabilities = await CSWCapabilitiesLoader.parse(arrayBuffer, this.
|
|
166
|
+
const capabilities = await CSWCapabilitiesLoader.parse(arrayBuffer, this.options.loadOptions);
|
|
152
167
|
return capabilities;
|
|
153
168
|
}
|
|
154
169
|
|
|
155
170
|
/** Get Records */
|
|
156
171
|
async getRecords(
|
|
157
|
-
|
|
172
|
+
cswParameters?: CSWGetRecordsParameters,
|
|
158
173
|
vendorParameters?: Record<string, unknown>
|
|
159
174
|
): Promise<CSWRecords> {
|
|
160
|
-
const url = this.getRecordsURL(
|
|
175
|
+
const url = this.getRecordsURL(cswParameters, vendorParameters);
|
|
161
176
|
const response = await this.fetch(url);
|
|
162
177
|
const arrayBuffer = await response.arrayBuffer();
|
|
163
178
|
this._checkResponse(response, arrayBuffer);
|
|
164
|
-
return await CSWRecordsLoader.parse(arrayBuffer, this.
|
|
179
|
+
return await CSWRecordsLoader.parse(arrayBuffer, this.options.loadOptions);
|
|
165
180
|
}
|
|
166
181
|
|
|
167
182
|
/** Get Domain */
|
|
168
183
|
async getDomain(
|
|
169
|
-
|
|
184
|
+
cswParameters?: CSWGetDomainParameters,
|
|
170
185
|
vendorParameters?: Record<string, unknown>
|
|
171
186
|
): Promise<CSWDomain> {
|
|
172
|
-
const url = this.getDomainURL(
|
|
187
|
+
const url = this.getDomainURL(cswParameters, vendorParameters);
|
|
173
188
|
const response = await this.fetch(url);
|
|
174
189
|
const arrayBuffer = await response.arrayBuffer();
|
|
175
190
|
this._checkResponse(response, arrayBuffer);
|
|
176
|
-
return await CSWDomainLoader.parse(arrayBuffer, this.
|
|
191
|
+
return await CSWDomainLoader.parse(arrayBuffer, this.options.loadOptions);
|
|
177
192
|
}
|
|
178
193
|
|
|
179
194
|
// Typed URL creators
|
|
@@ -181,12 +196,12 @@ export class CSWService extends DataSource<CSWServiceProps> {
|
|
|
181
196
|
|
|
182
197
|
/** Generate a URL for the GetCapabilities request */
|
|
183
198
|
getCapabilitiesURL(
|
|
184
|
-
|
|
199
|
+
cswParameters?: CSWGetCapabilitiesParameters,
|
|
185
200
|
vendorParameters?: Record<string, unknown>
|
|
186
201
|
): string {
|
|
187
202
|
const options: Required<CSWGetCapabilitiesParameters> = {
|
|
188
203
|
version: '3.0.0',
|
|
189
|
-
...
|
|
204
|
+
...cswParameters,
|
|
190
205
|
...vendorParameters,
|
|
191
206
|
service: 'CSW',
|
|
192
207
|
request: 'GetCapabilities'
|
|
@@ -196,13 +211,13 @@ export class CSWService extends DataSource<CSWServiceProps> {
|
|
|
196
211
|
|
|
197
212
|
/** Generate a URL for the GetCapabilities request */
|
|
198
213
|
getRecordsURL(
|
|
199
|
-
|
|
214
|
+
cswParameters?: CSWGetRecordsParameters,
|
|
200
215
|
vendorParameters?: Record<string, unknown>
|
|
201
216
|
): string {
|
|
202
217
|
const options: Required<CSWGetRecordsParameters> = {
|
|
203
218
|
version: '3.0.0',
|
|
204
219
|
typenames: 'csw:Record',
|
|
205
|
-
...
|
|
220
|
+
...cswParameters,
|
|
206
221
|
...vendorParameters,
|
|
207
222
|
service: 'CSW',
|
|
208
223
|
request: 'GetRecords'
|
|
@@ -212,12 +227,12 @@ export class CSWService extends DataSource<CSWServiceProps> {
|
|
|
212
227
|
|
|
213
228
|
/** Generate a URL for the GetCapabilities request */
|
|
214
229
|
getDomainURL(
|
|
215
|
-
|
|
230
|
+
cswParameters?: CSWGetDomainParameters,
|
|
216
231
|
vendorParameters?: Record<string, unknown>
|
|
217
232
|
): string {
|
|
218
233
|
const options: Required<CSWGetDomainParameters> = {
|
|
219
234
|
version: '3.0.0',
|
|
220
|
-
...
|
|
235
|
+
...cswParameters,
|
|
221
236
|
...vendorParameters,
|
|
222
237
|
service: 'CSW',
|
|
223
238
|
request: 'GetDomain'
|
|
@@ -234,7 +249,7 @@ export class CSWService extends DataSource<CSWServiceProps> {
|
|
|
234
249
|
options: Record<string, unknown>,
|
|
235
250
|
vendorParameters?: Record<string, unknown>
|
|
236
251
|
): string {
|
|
237
|
-
let url = this.
|
|
252
|
+
let url = this.url;
|
|
238
253
|
let first = true;
|
|
239
254
|
for (const [key, value] of Object.entries(options)) {
|
|
240
255
|
url += first ? '?' : '&';
|
|
@@ -252,14 +267,14 @@ export class CSWService extends DataSource<CSWServiceProps> {
|
|
|
252
267
|
protected _checkResponse(response: Response, arrayBuffer: ArrayBuffer): void {
|
|
253
268
|
const contentType = response.headers['content-type'];
|
|
254
269
|
if (!response.ok || CSWErrorLoader.mimeTypes.includes(contentType)) {
|
|
255
|
-
const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.
|
|
270
|
+
const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.options.loadOptions);
|
|
256
271
|
throw new Error(error);
|
|
257
272
|
}
|
|
258
273
|
}
|
|
259
274
|
|
|
260
275
|
/** Error situation detected */
|
|
261
276
|
protected _parseError(arrayBuffer: ArrayBuffer): Error {
|
|
262
|
-
const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.
|
|
277
|
+
const error = CSWErrorLoader.parseSync?.(arrayBuffer, this.options.loadOptions);
|
|
263
278
|
return new Error(error);
|
|
264
279
|
}
|
|
265
280
|
}
|
package/src/index.ts
CHANGED
|
@@ -56,16 +56,14 @@ export {GMLLoader as _GMLLoader} from './gml-loader';
|
|
|
56
56
|
|
|
57
57
|
// OGC Services
|
|
58
58
|
|
|
59
|
-
// export {CSWSource} from './
|
|
60
|
-
export {WMSSource, WMSImageSource} from './
|
|
59
|
+
// export {CSWSource} from './csw-source';
|
|
60
|
+
export {WMSSource, WMSImageSource} from './wms-source';
|
|
61
61
|
|
|
62
62
|
// ArcGIS SourceLoaders
|
|
63
63
|
|
|
64
|
-
export {getArcGISServices as _getArcGISServices} from './
|
|
65
|
-
export {ArcGISImageServerSource as _ArcGISImageServerSource} from './
|
|
64
|
+
export {getArcGISServices as _getArcGISServices} from './arcgis/arcgis-server';
|
|
65
|
+
export {ArcGISImageServerSource as _ArcGISImageServerSource} from './arcgis/arcgis-image-source';
|
|
66
66
|
|
|
67
|
-
// DEPRECATED: TODO - remove once deck.gl has been udpated
|
|
68
67
|
export {ImageSource} from '@loaders.gl/loader-utils';
|
|
69
68
|
export type {ImageType} from '@loaders.gl/images';
|
|
70
|
-
export type {ImageServiceType} from './lib/deprecated/create-image-source';
|
|
71
69
|
export {createImageSource} from './lib/deprecated/create-image-source';
|
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {Source,
|
|
6
|
-
import type {
|
|
7
|
-
import {WMSSource} from '../../
|
|
8
|
-
import {ArcGISImageServerSource} from '../../
|
|
5
|
+
import type {Source, SourceArrayDataSourceType, DataSourceOptions} from '@loaders.gl/loader-utils';
|
|
6
|
+
import type {WMSSourceOptions} from '../../wms-source';
|
|
7
|
+
import {WMSSource} from '../../wms-source';
|
|
8
|
+
import {ArcGISImageServerSource} from '../../arcgis/arcgis-image-source';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
export type ImageServiceType = 'wms' | 'arcgis-image-server' | 'template';
|
|
10
|
+
export type ImageSourceType = 'wms' | 'arcgis-image-server' | 'template';
|
|
12
11
|
|
|
13
|
-
const SOURCES
|
|
12
|
+
const SOURCES = [WMSSource, ArcGISImageServerSource] as const;
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* * @deprecated Use createDataSource from @loaders.gl/core
|
|
17
16
|
*/
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
type?: ImageServiceType | 'auto';
|
|
17
|
+
type CreateImageSourceOptions = DataSourceOptions &
|
|
18
|
+
WMSSourceOptions & {
|
|
19
|
+
type?: ImageSourceType | 'auto';
|
|
22
20
|
};
|
|
23
21
|
|
|
24
22
|
/**
|
|
@@ -30,19 +28,25 @@ type CreateImageSourceProps = ImageSourceProps &
|
|
|
30
28
|
*
|
|
31
29
|
* @deprecated Use createDataSource from @loaders.gl/core
|
|
32
30
|
*/
|
|
33
|
-
export function createImageSource
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
export function createImageSource<SourceArrayT extends Source[]>(options: {
|
|
32
|
+
url: string;
|
|
33
|
+
type: string;
|
|
34
|
+
loadOptions: any;
|
|
35
|
+
options: Readonly<CreateImageSourceOptions>; // Readonly<SourceArrayOptionsType<SourceArrayT>>,
|
|
36
|
+
sources: Readonly<Source[]>;
|
|
37
|
+
}): SourceArrayDataSourceType<SourceArrayT> {
|
|
38
|
+
const {type = 'auto', url, sources = SOURCES, loadOptions} = options;
|
|
39
|
+
const source: SourceArrayT[number] | null =
|
|
40
|
+
type === 'auto' ? guessSourceType(url, sources) : getSourceOfType(type, sources);
|
|
37
41
|
|
|
38
42
|
if (!source) {
|
|
39
43
|
throw new Error('Not a valid image source type');
|
|
40
44
|
}
|
|
41
|
-
return source.createDataSource(
|
|
45
|
+
return source.createDataSource(url, {core: {loadOptions}});
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
/** Guess service type from URL */
|
|
45
|
-
function getSourceOfType(type: string, sources: Source[]): Source | null {
|
|
49
|
+
function getSourceOfType(type: string, sources: Readonly<Source[]>): Source | null {
|
|
46
50
|
// if (type === 'template') {
|
|
47
51
|
// return ImageSource;
|
|
48
52
|
// }
|
|
@@ -57,7 +61,7 @@ function getSourceOfType(type: string, sources: Source[]): Source | null {
|
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
/** Guess source type from URL */
|
|
60
|
-
function guessSourceType(url: string, sources: Source[]): Source | null {
|
|
64
|
+
function guessSourceType(url: string, sources: Readonly<Source[]>): Source | null {
|
|
61
65
|
for (const source of sources) {
|
|
62
66
|
if (source.testURL && source.testURL(url)) {
|
|
63
67
|
return source;
|