@loaders.gl/wms 3.3.0-alpha.13 → 3.3.0-alpha.14
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/dist.min.js +182 -1046
- package/dist/es5/index.js +20 -13
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lerc-loader.js +1 -1
- package/dist/es5/lib/data-sources/adhoc-image-service.js +4 -0
- package/dist/es5/lib/data-sources/adhoc-image-service.js.map +1 -1
- package/dist/es5/lib/data-sources/arcgis-image-service.js +180 -0
- package/dist/es5/lib/data-sources/arcgis-image-service.js.map +1 -0
- package/dist/es5/lib/data-sources/create-image-source.js +45 -0
- package/dist/es5/lib/data-sources/create-image-source.js.map +1 -0
- package/dist/es5/lib/data-sources/image-services/arcgis-image-service.js +179 -0
- package/dist/es5/lib/data-sources/image-services/arcgis-image-service.js.map +1 -0
- package/dist/es5/lib/data-sources/image-services/image-service.js +163 -0
- package/dist/es5/lib/data-sources/image-services/image-service.js.map +1 -0
- package/dist/es5/lib/data-sources/{wms-service.js → image-services/wms-service.js} +116 -75
- package/dist/es5/lib/data-sources/image-services/wms-service.js.map +1 -0
- package/dist/es5/wip/arcgis-feature-service.js +45 -0
- package/dist/es5/wip/arcgis-feature-service.js.map +1 -0
- package/dist/es5/wip/data-source.js.map +1 -1
- package/dist/es5/wip/gml-loader.js +1 -1
- package/dist/es5/wip/wcs-capabilities-loader.js +1 -1
- package/dist/es5/wip/wfs-capabilities-loader.js +1 -1
- package/dist/es5/wip/wmts-capabilities-loader.js +1 -1
- package/dist/es5/wms-capabilities-loader.js +1 -1
- package/dist/es5/wms-error-loader.js +1 -1
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lerc-loader.js +1 -1
- package/dist/esm/lib/data-sources/adhoc-image-service.js +2 -0
- package/dist/esm/lib/data-sources/adhoc-image-service.js.map +1 -1
- package/dist/esm/lib/data-sources/arcgis-image-service.js +62 -0
- package/dist/esm/lib/data-sources/arcgis-image-service.js.map +1 -0
- package/dist/esm/lib/data-sources/create-image-source.js +30 -0
- package/dist/esm/lib/data-sources/create-image-source.js.map +1 -0
- package/dist/esm/lib/data-sources/image-services/arcgis-image-service.js +61 -0
- package/dist/esm/lib/data-sources/image-services/arcgis-image-service.js.map +1 -0
- package/dist/esm/lib/data-sources/image-services/image-service.js +72 -0
- package/dist/esm/lib/data-sources/image-services/image-service.js.map +1 -0
- package/dist/esm/lib/data-sources/{wms-service.js → image-services/wms-service.js} +46 -32
- package/dist/esm/lib/data-sources/image-services/wms-service.js.map +1 -0
- package/dist/esm/wip/arcgis-feature-service.js +28 -0
- package/dist/esm/wip/arcgis-feature-service.js.map +1 -0
- package/dist/esm/wip/data-source.js.map +1 -1
- package/dist/esm/wip/gml-loader.js +1 -1
- package/dist/esm/wip/wcs-capabilities-loader.js +1 -1
- package/dist/esm/wip/wfs-capabilities-loader.js +1 -1
- package/dist/esm/wip/wmts-capabilities-loader.js +1 -1
- package/dist/esm/wms-capabilities-loader.js +1 -1
- package/dist/esm/wms-error-loader.js +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -8
- package/dist/lib/data-sources/adhoc-image-service.d.ts +2 -0
- package/dist/lib/data-sources/adhoc-image-service.d.ts.map +1 -1
- package/dist/lib/data-sources/adhoc-image-service.js +2 -0
- package/dist/lib/data-sources/arcgis-image-service.d.ts +79 -0
- package/dist/lib/data-sources/arcgis-image-service.d.ts.map +1 -0
- package/dist/lib/data-sources/arcgis-image-service.js +85 -0
- package/dist/lib/data-sources/create-image-source.d.ts +16 -0
- package/dist/lib/data-sources/create-image-source.d.ts.map +1 -0
- package/dist/lib/data-sources/create-image-source.js +39 -0
- package/dist/lib/data-sources/image-services/arcgis-image-service.d.ts +71 -0
- package/dist/lib/data-sources/image-services/arcgis-image-service.d.ts.map +1 -0
- package/dist/lib/data-sources/image-services/arcgis-image-service.js +85 -0
- package/dist/lib/data-sources/image-services/image-service.d.ts +39 -0
- package/dist/lib/data-sources/image-services/image-service.d.ts.map +1 -0
- package/dist/lib/data-sources/image-services/image-service.js +82 -0
- package/dist/lib/data-sources/{wms-service.d.ts → image-services/wms-service.d.ts} +33 -38
- package/dist/lib/data-sources/image-services/wms-service.d.ts.map +1 -0
- package/dist/lib/data-sources/{wms-service.js → image-services/wms-service.js} +40 -28
- package/dist/wip/arcgis-feature-service.d.ts +56 -0
- package/dist/wip/arcgis-feature-service.d.ts.map +1 -0
- package/dist/wip/arcgis-feature-service.js +28 -0
- package/dist/wip/data-source.d.ts +14 -13
- package/dist/wip/data-source.d.ts.map +1 -1
- package/dist/wip/data-source.js +15 -13
- package/package.json +6 -6
- package/src/index.ts +13 -8
- package/src/lib/data-sources/adhoc-image-service.ts +3 -0
- package/src/lib/data-sources/arcgis-image-service.ts +146 -0
- package/src/lib/data-sources/create-image-source.ts +46 -0
- package/src/lib/data-sources/image-services/arcgis-image-service.ts +136 -0
- package/src/lib/data-sources/image-services/image-service.ts +105 -0
- package/src/lib/data-sources/{wms-service.ts → image-services/wms-service.ts} +51 -47
- package/src/wip/arcgis-feature-service.ts +89 -0
- package/src/wip/data-source.ts +15 -13
- package/dist/es5/lib/data-sources/wms-service.js.map +0 -1
- package/dist/esm/lib/data-sources/wms-service.js.map +0 -1
- package/dist/lib/data-sources/wms-service.d.ts.map +0 -1
|
@@ -9,7 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _parseWcs = require("../lib/wcs/parse-wcs");
|
|
11
11
|
|
|
12
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
12
|
+
var VERSION = typeof "3.3.0-alpha.14" !== 'undefined' ? "3.3.0-alpha.14" : 'latest';
|
|
13
13
|
var WCSCapabilitiesLoader = {
|
|
14
14
|
id: 'wcs-capabilities',
|
|
15
15
|
name: 'WFS Capabilities',
|
|
@@ -9,7 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _parseWfs = require("../lib/wfs/parse-wfs");
|
|
11
11
|
|
|
12
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
12
|
+
var VERSION = typeof "3.3.0-alpha.14" !== 'undefined' ? "3.3.0-alpha.14" : 'latest';
|
|
13
13
|
var WFSCapabilitiesLoader = {
|
|
14
14
|
id: 'wfs-capabilities',
|
|
15
15
|
name: 'WFS Capabilities',
|
|
@@ -9,7 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _parseWmts = require("../lib/wmts/parse-wmts");
|
|
11
11
|
|
|
12
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
12
|
+
var VERSION = typeof "3.3.0-alpha.14" !== 'undefined' ? "3.3.0-alpha.14" : 'latest';
|
|
13
13
|
var WMTSCapabilitiesLoader = {
|
|
14
14
|
id: 'wmts-capabilities',
|
|
15
15
|
name: 'WMTS Capabilities',
|
|
@@ -9,7 +9,7 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
|
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _parseWms = require("./lib/wms/parse-wms");
|
|
11
11
|
|
|
12
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
12
|
+
var VERSION = typeof "3.3.0-alpha.14" !== 'undefined' ? "3.3.0-alpha.14" : 'latest';
|
|
13
13
|
var WMSCapabilitiesLoader = {
|
|
14
14
|
id: 'wms-capabilities',
|
|
15
15
|
name: 'WMS Capabilities',
|
|
@@ -11,7 +11,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
11
11
|
var _parseWms = require("./lib/wms/parse-wms");
|
|
12
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
-
var VERSION = typeof "3.3.0-alpha.
|
|
14
|
+
var VERSION = typeof "3.3.0-alpha.14" !== 'undefined' ? "3.3.0-alpha.14" : 'latest';
|
|
15
15
|
var WMSErrorLoader = {
|
|
16
16
|
id: 'wms-error',
|
|
17
17
|
name: 'WMS Error',
|
package/dist/esm/index.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
export { WMSErrorLoader } from './wms-error-loader';
|
|
4
4
|
export { WMSCapabilitiesLoader } from './wms-capabilities-loader';
|
|
5
|
-
export { WMSService } from './lib/data-sources/wms-service';
|
|
6
5
|
|
|
7
|
-
export { ImageSource
|
|
8
|
-
export {
|
|
6
|
+
export { ImageSource } from './lib/data-sources/image-source';
|
|
7
|
+
export { createImageSource } from './lib/data-sources/create-image-source';
|
|
8
|
+
export { ImageService } from './lib/data-sources/image-services/image-service';
|
|
9
|
+
export { WMSService } from './lib/data-sources/image-services/wms-service';
|
|
10
|
+
export { ArcGISImageService as _ArcGISImageService } from './lib/data-sources/image-services/arcgis-image-service';
|
|
9
11
|
|
|
10
12
|
export { WMSFeatureInfoLoader as _WMSFeatureInfoLoader } from './wip/wms-feature-info-loader';
|
|
11
13
|
export { WMSLayerDescriptionLoader as _WMSLayerDescriptionLoader } from './wip/wms-layer-description-loader';
|
|
@@ -15,6 +17,4 @@ export { WMTSCapabilitiesLoader as _WMTSCapabilitiesLoader } from './wip/wmts-ca
|
|
|
15
17
|
export { WFSCapabilitiesLoader as _WFSCapabilitiesLoader } from './wip/wfs-capabilities-loader';
|
|
16
18
|
|
|
17
19
|
export { GMLLoader as _GMLLoader } from './wip/gml-loader';
|
|
18
|
-
|
|
19
|
-
export { LERCLoader } from './lerc-loader';
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["WMSErrorLoader","WMSCapabilitiesLoader","
|
|
1
|
+
{"version":3,"file":"index.js","names":["WMSErrorLoader","WMSCapabilitiesLoader","ImageSource","createImageSource","ImageService","WMSService","ArcGISImageService","_ArcGISImageService","WMSFeatureInfoLoader","_WMSFeatureInfoLoader","WMSLayerDescriptionLoader","_WMSLayerDescriptionLoader","WMTSCapabilitiesLoader","_WMTSCapabilitiesLoader","WFSCapabilitiesLoader","_WFSCapabilitiesLoader","GMLLoader","_GMLLoader"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// WMS\n\nexport {WMSErrorLoader} from './wms-error-loader';\n\nexport type {WMSLoaderOptions} from './wms-capabilities-loader';\n\nexport type {WMSCapabilities} from './lib/wms/wms-types';\nexport {WMSCapabilitiesLoader} from './wms-capabilities-loader';\n\n// NOTE: Will likely move to tiles module\nexport type {ImageSourceMetadata} from './lib/data-sources/image-source';\nexport type {ImageType} from '@loaders.gl/images';\nexport {ImageSource} from './lib/data-sources/image-source';\n\nexport type {ImageServiceType} from './lib/data-sources/create-image-source';\nexport {createImageSource} from './lib/data-sources/create-image-source';\n\nexport type {ImageServiceProps} from './lib/data-sources/image-services/image-service';\nexport {ImageService} from './lib/data-sources/image-services/image-service';\nexport {WMSService} from './lib/data-sources/image-services/wms-service';\nexport {ArcGISImageService as _ArcGISImageService} from './lib/data-sources/image-services/arcgis-image-service';\n\n// WIP /////////////////////////////////////////////////////////////////\n// Plumbing set up but details of parsing and typing not yet completed\n\n// WMS\n\nexport type {WMSFeatureInfo as _WMSFeatureInfo} from './lib/wms/wms-types';\nexport {WMSFeatureInfoLoader as _WMSFeatureInfoLoader} from './wip/wms-feature-info-loader';\n\nexport type {WMSLayerDescription as _WMSLayerDescription} from './lib/wms/wms-types';\nexport {WMSLayerDescriptionLoader as _WMSLayerDescriptionLoader} from './wip/wms-layer-description-loader';\n\n// WMTS\n\nexport type {WMTSCapabilities as _WMTSCapabilities} from './lib/wmts/wmts-types';\nexport type {WMTSLoaderOptions as _WMTSLoaderOptions} from './wip/wmts-capabilities-loader';\nexport {WMTSCapabilitiesLoader as _WMTSCapabilitiesLoader} from './wip/wmts-capabilities-loader';\n\n// WFS\n\nexport type {WFSCapabilities as _WFSCapabilities} from './lib/wfs/wfs-types';\nexport type {WFSLoaderOptions as _WFSLoaderOptions} from './wip/wfs-capabilities-loader';\nexport {WFSCapabilitiesLoader as _WFSCapabilitiesLoader} from './wip/wfs-capabilities-loader';\n\n// GML\n\nexport type {GeoJSON as _GeoJSON} from '@loaders.gl/schema';\nexport type {GMLLoaderOptions as _GMLLoaderOptions} from './wip/gml-loader';\nexport {GMLLoader as _GMLLoader} from './wip/gml-loader';\n\n// LERC\n\n// TODO - restore once esbuild bundling issues have been resolved\n// export type {LERCData} from './lib/lerc/lerc-types';\n// export {LERCLoader} from './lerc-loader';\n"],"mappings":";;AAIA,SAAQA,cAAc,QAAO,oBAAoB;AAKjD,SAAQC,qBAAqB,QAAO,2BAA2B;;AAK/D,SAAQC,WAAW,QAAO,iCAAiC;AAG3D,SAAQC,iBAAiB,QAAO,wCAAwC;AAGxE,SAAQC,YAAY,QAAO,iDAAiD;AAC5E,SAAQC,UAAU,QAAO,+CAA+C;AACxE,SAAQC,kBAAkB,IAAIC,mBAAmB,QAAO,wDAAwD;;AAQhH,SAAQC,oBAAoB,IAAIC,qBAAqB,QAAO,+BAA+B;AAG3F,SAAQC,yBAAyB,IAAIC,0BAA0B,QAAO,oCAAoC;;AAM1G,SAAQC,sBAAsB,IAAIC,uBAAuB,QAAO,gCAAgC;;AAMhG,SAAQC,qBAAqB,IAAIC,sBAAsB,QAAO,+BAA+B;;AAM7F,SAAQC,SAAS,IAAIC,UAAU,QAAO,kBAAkB"}
|
package/dist/esm/lerc-loader.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Lerc from 'lerc';
|
|
4
4
|
|
|
5
|
-
const VERSION = typeof "3.3.0-alpha.
|
|
5
|
+
const VERSION = typeof "3.3.0-alpha.14" !== 'undefined' ? "3.3.0-alpha.14" : 'latest';
|
|
6
6
|
export const LERCLoader = {
|
|
7
7
|
id: 'lerc',
|
|
8
8
|
name: 'LERC',
|
|
@@ -38,4 +38,6 @@ export class AdHocImageService extends ImageSource {
|
|
|
38
38
|
return url;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
_defineProperty(AdHocImageService, "type", 'template');
|
|
42
|
+
_defineProperty(AdHocImageService, "testURL", url => url.toLowerCase().includes('{'));
|
|
41
43
|
//# sourceMappingURL=adhoc-image-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adhoc-image-service.js","names":["ImageLoader","ImageSource","AdHocImageService","constructor","props","templateUrl","getMetadata","Error","getImage","parameters","granularParameters","getGranularParameters","url","getURLFromTemplate","response","fetch","arrayBuffer","parse","east","north","west","south","bbox","key","value","Object","entries","replace","String"],"sources":["../../../../src/lib/data-sources/adhoc-image-service.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {ImageType} from '@loaders.gl/images';\nimport {ImageLoader} from '@loaders.gl/images';\n\nimport type {ImageSourceMetadata, GetImageParameters} from './image-source';\nimport {ImageSource} from './image-source';\n\nexport type AdHocImageServiceProps = {\n /** Template URL string should contain `${width}` etc which will be substituted. */\n templateUrl: string;\n};\n\n/**\n * Quickly connect to \"ad hoc\" image sources without subclassing ImageSource.\n * ImageSource allows template url strings to be used to ad hoc connect to arbitrary image data sources\n * Accepts a template url string and builds requests URLs\n */\nexport class AdHocImageService extends ImageSource {\n templateUrl: string;\n\n constructor(props: AdHocImageServiceProps) {\n super();\n this.templateUrl = props.templateUrl;\n }\n\n // IMAGE SOURCE API\n\n async getMetadata(): Promise<ImageSourceMetadata> {\n throw new Error('ImageSource.getMetadata not implemented');\n }\n\n async getImage(parameters: GetImageParameters): Promise<ImageType> {\n const granularParameters = this.getGranularParameters(parameters);\n const url = this.getURLFromTemplate(granularParameters);\n const response = await fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n return await ImageLoader.parse(arrayBuffer);\n }\n\n // HELPERS\n\n /** Break up bounding box in east, north, south, west */\n protected getGranularParameters(parameters: GetImageParameters): Record<string, unknown> {\n const [east, north, west, south] = parameters.bbox;\n return {...parameters, east, north, south, west};\n }\n\n protected getURLFromTemplate(parameters: Record<string, unknown>): string {\n let url = this.templateUrl;\n for (const [key, value] of Object.entries(parameters)) {\n // TODO - parameter could be repeated\n // const regex = new RegExp(`\\${${key}}`, 'g');\n url = url.replace(`\\${${key}}`, String(value));\n }\n return url;\n }\n}\n"],"mappings":";;AAGA,SAAQA,WAAW,QAAO,oBAAoB;AAG9C,SAAQC,WAAW,QAAO,gBAAgB;AAY1C,OAAO,MAAMC,iBAAiB,SAASD,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"adhoc-image-service.js","names":["ImageLoader","ImageSource","AdHocImageService","constructor","props","templateUrl","getMetadata","Error","getImage","parameters","granularParameters","getGranularParameters","url","getURLFromTemplate","response","fetch","arrayBuffer","parse","east","north","west","south","bbox","key","value","Object","entries","replace","String","toLowerCase","includes"],"sources":["../../../../src/lib/data-sources/adhoc-image-service.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {ImageType} from '@loaders.gl/images';\nimport {ImageLoader} from '@loaders.gl/images';\n\nimport type {ImageSourceMetadata, GetImageParameters} from './image-source';\nimport {ImageSource} from './image-source';\n\nexport type AdHocImageServiceProps = {\n /** Template URL string should contain `${width}` etc which will be substituted. */\n templateUrl: string;\n};\n\n/**\n * Quickly connect to \"ad hoc\" image sources without subclassing ImageSource.\n * ImageSource allows template url strings to be used to ad hoc connect to arbitrary image data sources\n * Accepts a template url string and builds requests URLs\n */\nexport class AdHocImageService extends ImageSource {\n static type: 'template' = 'template';\n static testURL = (url: string): boolean => url.toLowerCase().includes('{');\n\n templateUrl: string;\n\n constructor(props: AdHocImageServiceProps) {\n super();\n this.templateUrl = props.templateUrl;\n }\n\n // IMAGE SOURCE API\n\n async getMetadata(): Promise<ImageSourceMetadata> {\n throw new Error('ImageSource.getMetadata not implemented');\n }\n\n async getImage(parameters: GetImageParameters): Promise<ImageType> {\n const granularParameters = this.getGranularParameters(parameters);\n const url = this.getURLFromTemplate(granularParameters);\n const response = await fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n return await ImageLoader.parse(arrayBuffer);\n }\n\n // HELPERS\n\n /** Break up bounding box in east, north, south, west */\n protected getGranularParameters(parameters: GetImageParameters): Record<string, unknown> {\n const [east, north, west, south] = parameters.bbox;\n return {...parameters, east, north, south, west};\n }\n\n protected getURLFromTemplate(parameters: Record<string, unknown>): string {\n let url = this.templateUrl;\n for (const [key, value] of Object.entries(parameters)) {\n // TODO - parameter could be repeated\n // const regex = new RegExp(`\\${${key}}`, 'g');\n url = url.replace(`\\${${key}}`, String(value));\n }\n return url;\n }\n}\n"],"mappings":";;AAGA,SAAQA,WAAW,QAAO,oBAAoB;AAG9C,SAAQC,WAAW,QAAO,gBAAgB;AAY1C,OAAO,MAAMC,iBAAiB,SAASD,WAAW,CAAC;EAMjDE,WAAW,CAACC,KAA6B,EAAE;IACzC,KAAK,EAAE;IAAC;IACR,IAAI,CAACC,WA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|
|
3
|
+
import { ImageSource } from './image-source';
|
|
4
|
+
export class ArcGISImageService extends ImageSource {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super();
|
|
7
|
+
_defineProperty(this, "url", void 0);
|
|
8
|
+
_defineProperty(this, "loadOptions", void 0);
|
|
9
|
+
_defineProperty(this, "fetch", void 0);
|
|
10
|
+
this.url = props.url;
|
|
11
|
+
this.loadOptions = props.loadOptions || {};
|
|
12
|
+
this.fetch = props.fetch || fetch;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async getMetadata() {
|
|
16
|
+
return await this.info();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getImage(parameters) {
|
|
20
|
+
throw new Error('not implemented');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async info() {
|
|
24
|
+
throw new Error('not implemented');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exportImage(options) {
|
|
28
|
+
throw new Error('not implemented');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
infoURL(options) {
|
|
32
|
+
return this.url;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
exportImageURL(options) {
|
|
36
|
+
return this.url;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getUrl(options, extra) {
|
|
40
|
+
let url = "".concat(this.url);
|
|
41
|
+
let first = true;
|
|
42
|
+
for (const [key, value] of Object.entries(options)) {
|
|
43
|
+
url += first ? '?' : '&';
|
|
44
|
+
first = false;
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
url += "".concat(key.toUpperCase(), "=").concat(value.join(','));
|
|
47
|
+
} else {
|
|
48
|
+
url += "".concat(key.toUpperCase(), "=").concat(value ? String(value) : '');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return url;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async checkResponse(response) {
|
|
55
|
+
if (!response.ok) {
|
|
56
|
+
throw new Error('error');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
_defineProperty(ArcGISImageService, "type", 'arcgis-image-server');
|
|
61
|
+
_defineProperty(ArcGISImageService, "testURL", url => url.toLowerCase().includes('ImageServer'));
|
|
62
|
+
//# sourceMappingURL=arcgis-image-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arcgis-image-service.js","names":["ImageSource","ArcGISImageService","constructor","props","url","loadOptions","fetch","getMetadata","info","getImage","parameters","Error","exportImage","options","infoURL","exportImageURL","getUrl","extra","first","key","value","Object","entries","Array","isArray","toUpperCase","join","String","checkResponse","response","ok","toLowerCase","includes"],"sources":["../../../../src/lib/data-sources/arcgis-image-service.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {/* ImageLoader, */ ImageType} from '@loaders.gl/images';\nimport type {ImageSourceMetadata, GetImageParameters} from './image-source';\nimport {ImageSource} from './image-source';\n\ntype FetchLike = (url: string, options?: RequestInit) => Promise<Response>;\n\nexport type ArcGISImageServiceProps = {\n url: string;\n loadOptions?: LoaderOptions;\n fetch?: typeof fetch | FetchLike;\n};\n\nexport class ArcGISImageService extends ImageSource {\n static type: 'arcgis-image-server' = 'arcgis-image-server';\n static testURL = (url: string): boolean => url.toLowerCase().includes('ImageServer');\n\n url: string;\n loadOptions: LoaderOptions;\n fetch: typeof fetch | FetchLike;\n\n constructor(props: ArcGISImageServiceProps) {\n super();\n this.url = props.url;\n this.loadOptions = props.loadOptions || {};\n this.fetch = props.fetch || fetch;\n }\n\n // ImageSource (normalized endpoints)\n\n async getMetadata(): Promise<ImageSourceMetadata> {\n return (await this.info()) as ImageSourceMetadata;\n // TODO - normalize metadata\n }\n\n async getImage(parameters: GetImageParameters): Promise<ImageType> {\n throw new Error('not implemented');\n // TODO - Map generic parameters to ArcGIS specific parameters\n // return await this.exportImage(parameters);\n }\n\n // ImageServer endpoints\n\n async info(): Promise<unknown> {\n // We just need a JSON parsing...\n // return this.getUrl({path: '', ...options});\n throw new Error('not implemented');\n }\n\n /** \n * Form a URL to an ESRI ImageServer\n // https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=image`,\n */\n exportImage(options: {\n boundingBox: [number, number, number, number];\n boundingBoxSR?: string;\n width: number;\n height: number;\n imageSR?: string;\n time?: never;\n format?: 'jpgpng';\n pixelType?: 'U8';\n noData?: never;\n noDataInterpretation?: 'esriNoDataMatchAny';\n interpolation?: '+RSP_NearestNeighbor';\n compression?: never;\n compressionQuality?: never;\n bandIds?: never;\n mosaicRule?: never;\n renderingRule?: never;\n f?: 'image';\n }): Promise<ImageType> {\n // See WMSService.getMap()\n throw new Error('not implemented');\n }\n\n // URL creators\n\n infoURL(options: {parameters?: Record<string, unknown>}): string {\n return this.url;\n // return this.getUrl({path: '', ...options});\n }\n\n /** \n * Form a URL to an ESRI ImageServer\n // https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=image`,\n */\n exportImageURL(options: {\n boundingBox: [number, number, number, number];\n boundingBoxSR?: string;\n width: number;\n height: number;\n imageSR?: string;\n time?: never;\n format?: 'jpgpng';\n pixelType?: 'U8';\n noData?: never;\n noDataInterpretation?: 'esriNoDataMatchAny';\n interpolation?: '+RSP_NearestNeighbor';\n compression?: never;\n compressionQuality?: never;\n bandIds?: never;\n mosaicRule?: never;\n renderingRule?: never;\n f?: 'image';\n }): string {\n // const {boundingBox} = options;\n // const bbox = `bbox=${boundingBox[0]},${boundingBox[1]},${boundingBox[2]},${boundingBox[3]}`;\n // const size = `size=${width},${height}`;\n // return this.getUrl({path: 'exportImage'});\n return this.url;\n }\n\n // INTERNAL METHODS\n\n /**\n * @note protected, since perhaps getWMSUrl may need to be overridden to handle certain backends?\n * @note if override is common, maybe add a callback prop?\n * */\n protected getUrl(options: Record<string, unknown>, extra?: Record<string, unknown>): string {\n let url = `${this.url}`;\n let first = true;\n for (const [key, value] of Object.entries(options)) {\n url += first ? '?' : '&';\n first = false;\n if (Array.isArray(value)) {\n url += `${key.toUpperCase()}=${value.join(',')}`;\n } else {\n url += `${key.toUpperCase()}=${value ? String(value) : ''}`;\n }\n }\n return url;\n }\n\n /** Checks for and parses a WMS XML formatted ServiceError and throws an exception */\n protected async checkResponse(response: Response) {\n if (!response.ok) {\n // } || response.headers['content-type'] === WMSErrorLoader.mimeTypes[0]) {\n // const arrayBuffer = await response.arrayBuffer();\n // const error = await WMSErrorLoader.parse(arrayBuffer, this.loadOptions);\n throw new Error('error');\n }\n }\n}\n"],"mappings":";;AAKA,SAAQA,WAAW,QAAO,gBAAgB;AAU1C,OAAO,MAAMC,kBAAkB,SAASD,WAAW,CAAC;EAQlDE,WAAW,CAACC,KAA8B,EAAE;IAC1C,KAAK,EAAE;IAAC;IAAA;IAAA;IACR,IAAI,CAACC,GAAG,GAAGD,KAAK,CAACC,GAAG;IACpB,IAAI,CAACC,WAAW,GAAGF,KAAK,CAACE,WAAW,IAAI,CAAC,CAAC;IAC1C,IAAI,CAACC,KAAK,GAAGH,KAAK,CAACG,KAAK,IAAIA,KAAK;EACnC;;EAIA,MAAMC,WAAW,GAAiC;IAChD,OAAQ,MAAM,IAAI,CAACC,IAAI,EAAE;EAE3B;;EAEA,MAAMC,QAAQ,CAACC,UAA8B,EAAsB;IACjE,MAAM,IAAIC,KAAK,CAA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CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { ImageService } from './image-services/image-service';
|
|
4
|
+
import { WMSService } from './image-services/wms-service';
|
|
5
|
+
import { ArcGISImageService } from './image-services/arcgis-image-service';
|
|
6
|
+
const SERVICES = [WMSService, ArcGISImageService, ImageService];
|
|
7
|
+
export function createImageSource(props) {
|
|
8
|
+
const {
|
|
9
|
+
type = 'auto'
|
|
10
|
+
} = props;
|
|
11
|
+
const serviceType = type === 'auto' ? guessServiceType(props.url) : type;
|
|
12
|
+
switch (serviceType) {
|
|
13
|
+
case 'template':
|
|
14
|
+
return new ImageService(props);
|
|
15
|
+
case 'wms':
|
|
16
|
+
return new WMSService(props);
|
|
17
|
+
default:
|
|
18
|
+
throw new Error('Not a valid image source type');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function guessServiceType(url) {
|
|
23
|
+
for (const Service of SERVICES) {
|
|
24
|
+
if (Service.testURL && Service.testURL(url)) {
|
|
25
|
+
return Service.type;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return 'wms';
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=create-image-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-image-source.js","names":["ImageService","WMSService","ArcGISImageService","SERVICES","createImageSource","props","type","serviceType","guessServiceType","url","Error","Service","testURL"],"sources":["../../../../src/lib/data-sources/create-image-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {ImageSource} from './image-source';\nimport {ImageService, ImageServiceProps} from './image-services/image-service';\nimport {WMSService} from './image-services/wms-service';\nimport {ArcGISImageService} from './image-services/arcgis-image-service';\n\nexport type ImageServiceType = 'wms' | 'arcgis-image-server' | 'template';\n\nconst SERVICES = [WMSService, ArcGISImageService, ImageService];\n\ntype Props = ImageServiceProps & {\n type?: ImageServiceType | 'auto';\n};\n\n/**\n * Creates an image source\n * If type is not supplied, will try to automatically detec the the\n * @param url URL to the image source\n * @param type type of source. if not known, set to 'auto'\n * @returns an ImageSource instance\n */\nexport function createImageSource(props: Props): ImageSource {\n const {type = 'auto'} = props;\n const serviceType = type === 'auto' ? guessServiceType(props.url) : type;\n switch (serviceType) {\n case 'template':\n return new ImageService(props);\n case 'wms':\n return new WMSService(props);\n default:\n // currently only wms service supported\n throw new Error('Not a valid image source type');\n }\n}\n\n/** Guess service type from URL */\nfunction guessServiceType(url: string): ImageServiceType {\n for (const Service of SERVICES) {\n if (Service.testURL && Service.testURL(url)) {\n return Service.type;\n }\n }\n // If all else fails, guess that this is MS service\n return 'wms';\n}\n"],"mappings":";;AAGA,SAAQA,YAAY,QAA0B,gCAAgC;AAC9E,SAAQC,UAAU,QAAO,8BAA8B;AACvD,SAAQC,kBAAkB,QAAO,uCAAuC;AAIxE,MAAMC,QAAQ,GAAG,CAACF,UAAU,EAAEC,kBAAkB,EAAEF,YAAY,CAAC;AAa/D,OAAO,SAASI,iBAAiB,CAACC,KAAY,EAAe;EAC3D,MAAM;IAACC,IAAI,GAAG;EAAM,CAAC,GAAGD,KAAK;EAC7B,MAAME,WAAW,GAAGD,IAAI,KAAK,MAAM,GAAGE,gBAAgB,CAACH,KAAK,CAACI,GAAG,CAAC,GAAGH,IAAI;EACxE,QAAQC,WAAW;IACjB,KAAK,UAAU;MACb,OAAO,IAAIP,YAAY,CAACK,KAAK,CAAC;IAChC,KAAK,KAAK;MACR,OAAO,IAAIJ,UAAU,CAACI,KAAK,CAAC;IAC9B;MAEE,MAAM,IAAIK,KAAK,CAAC,+BAA+B,CAAC;EAAC;AAEvD;;AAGA,SAASF,gBAAgB,CAACC,GAAW,EAAoB;EACvD,KAAK,MAAME,OAAO,IAAIR,QAAQ,EAAE;IAC9B,IAAIQ,OAAO,CAACC,OAAO,IAAID,OAAO,CAACC,OAAO,CAACH,GAAG,CAAC,EAAE;MAC3C,OAAOE,OAAO,CAACL,IAAI;IACrB;EACF;EAEA,OAAO,KAAK;AACd"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
3
|
+
import { ImageSource } from '../image-source';
|
|
4
|
+
import { mergeImageServiceProps, getFetchFunction } from './image-service';
|
|
5
|
+
export class ArcGISImageService extends ImageSource {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super();
|
|
8
|
+
_defineProperty(this, "props", void 0);
|
|
9
|
+
_defineProperty(this, "fetch", void 0);
|
|
10
|
+
this.props = mergeImageServiceProps(props);
|
|
11
|
+
this.fetch = getFetchFunction(this.props);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async getMetadata() {
|
|
15
|
+
return await this.info();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async getImage(parameters) {
|
|
19
|
+
throw new Error('not implemented');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async info() {
|
|
23
|
+
throw new Error('not implemented');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exportImage(options) {
|
|
27
|
+
throw new Error('not implemented');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
infoURL(options) {
|
|
31
|
+
return this.props.url;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exportImageURL(options) {
|
|
35
|
+
return this.props.url;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getUrl(options, extra) {
|
|
39
|
+
let url = "".concat(this.props.url);
|
|
40
|
+
let first = true;
|
|
41
|
+
for (const [key, value] of Object.entries(options)) {
|
|
42
|
+
url += first ? '?' : '&';
|
|
43
|
+
first = false;
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
url += "".concat(key.toUpperCase(), "=").concat(value.join(','));
|
|
46
|
+
} else {
|
|
47
|
+
url += "".concat(key.toUpperCase(), "=").concat(value ? String(value) : '');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return url;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async checkResponse(response) {
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new Error('error');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
_defineProperty(ArcGISImageService, "type", 'arcgis-image-server');
|
|
60
|
+
_defineProperty(ArcGISImageService, "testURL", url => url.toLowerCase().includes('ImageServer'));
|
|
61
|
+
//# sourceMappingURL=arcgis-image-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arcgis-image-service.js","names":["ImageSource","mergeImageServiceProps","getFetchFunction","ArcGISImageService","constructor","props","fetch","getMetadata","info","getImage","parameters","Error","exportImage","options","infoURL","url","exportImageURL","getUrl","extra","first","key","value","Object","entries","Array","isArray","toUpperCase","join","String","checkResponse","response","ok","toLowerCase","includes"],"sources":["../../../../../src/lib/data-sources/image-services/arcgis-image-service.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {ImageType} from '@loaders.gl/images';\nimport type {ImageSourceMetadata, GetImageParameters} from '../image-source';\nimport {ImageSource} from '../image-source';\nimport {ImageServiceProps, mergeImageServiceProps, getFetchFunction} from './image-service';\n\nexport class ArcGISImageService extends ImageSource {\n static type: 'arcgis-image-server' = 'arcgis-image-server';\n static testURL = (url: string): boolean => url.toLowerCase().includes('ImageServer');\n\n props: Required<ImageServiceProps>;\n fetch: (url: string, options?: RequestInit) => Promise<Response>;\n\n constructor(props: ImageServiceProps) {\n super();\n this.props = mergeImageServiceProps(props);\n this.fetch = getFetchFunction(this.props);\n }\n\n // ImageSource (normalized endpoints)\n\n async getMetadata(): Promise<ImageSourceMetadata> {\n return (await this.info()) as ImageSourceMetadata;\n // TODO - normalize metadata\n }\n\n async getImage(parameters: GetImageParameters): Promise<ImageType> {\n throw new Error('not implemented');\n // TODO - Map generic parameters to ArcGIS specific parameters\n // return await this.exportImage(parameters);\n }\n\n // ImageServer endpoints\n\n async info(): Promise<unknown> {\n // We just need a JSON parsing...\n // return this.getUrl({path: '', ...options});\n throw new Error('not implemented');\n }\n\n /** \n * Form a URL to an ESRI ImageServer\n // https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=image`,\n */\n exportImage(options: {\n boundingBox: [number, number, number, number];\n boundingBoxSR?: string;\n width: number;\n height: number;\n imageSR?: string;\n time?: never;\n format?: 'jpgpng';\n pixelType?: 'U8';\n noData?: never;\n noDataInterpretation?: 'esriNoDataMatchAny';\n interpolation?: '+RSP_NearestNeighbor';\n compression?: never;\n compressionQuality?: never;\n bandIds?: never;\n mosaicRule?: never;\n renderingRule?: never;\n f?: 'image';\n }): Promise<ImageType> {\n // See WMSService.getMap()\n throw new Error('not implemented');\n }\n\n // URL creators\n\n infoURL(options: {parameters?: Record<string, unknown>}): string {\n return this.props.url;\n // return this.getUrl({path: '', ...options});\n }\n\n /** \n * Form a URL to an ESRI ImageServer\n // https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=image`,\n */\n exportImageURL(options: {\n boundingBox: [number, number, number, number];\n boundingBoxSR?: string;\n width: number;\n height: number;\n imageSR?: string;\n time?: never;\n format?: 'jpgpng';\n pixelType?: 'U8';\n noData?: never;\n noDataInterpretation?: 'esriNoDataMatchAny';\n interpolation?: '+RSP_NearestNeighbor';\n compression?: never;\n compressionQuality?: never;\n bandIds?: never;\n mosaicRule?: never;\n renderingRule?: never;\n f?: 'image';\n }): string {\n // const {boundingBox} = options;\n // const bbox = `bbox=${boundingBox[0]},${boundingBox[1]},${boundingBox[2]},${boundingBox[3]}`;\n // const size = `size=${width},${height}`;\n // return this.getUrl({path: 'exportImage'});\n return this.props.url;\n }\n\n // INTERNAL METHODS\n\n /**\n * @note protected, since perhaps getWMSUrl may need to be overridden to handle certain backends?\n * @note if override is common, maybe add a callback prop?\n * */\n protected getUrl(options: Record<string, unknown>, extra?: Record<string, unknown>): string {\n let url = `${this.props.url}`;\n let first = true;\n for (const [key, value] of Object.entries(options)) {\n url += first ? '?' : '&';\n first = false;\n if (Array.isArray(value)) {\n url += `${key.toUpperCase()}=${value.join(',')}`;\n } else {\n url += `${key.toUpperCase()}=${value ? String(value) : ''}`;\n }\n }\n return url;\n }\n\n /** Checks for and parses a WMS XML formatted ServiceError and throws an exception */\n protected async checkResponse(response: Response) {\n if (!response.ok) {\n // } || response.headers['content-type'] === WMSErrorLoader.mimeTypes[0]) {\n // const arrayBuffer = await response.arrayBuffer();\n // const error = await WMSErrorLoader.parse(arrayBuffer, this.loadOptions);\n throw new Error('error');\n }\n }\n}\n"],"mappings":";;AAIA,SAAQA,WAAW,QAAO,iBAAiB;AAC3C,SAA2BC,sBAAsB,EAAEC,gBAAgB,QAAO,iBAAiB;AAE3F,OAAO,MAAMC,kBAAkB,SAASH,WAAW,CAAC;EAOlDI,WAAW,CAACC,KAAwB,EAAE;IACpC,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACA,KAAK,GAAGJ,sBAAsB,CAACI,KAAK,CAAC;IAC1C,IAAI,CAACC,KAAK,GAAGJ,gBAAgB,CAAC,IAAI,CAACG,KAAK,CAAC;EAC3C;;EAIA,MAAME,WAAW,GAAiC;IAChD,OAAQ,MAAM,IAAI,CAACC,IAAI,EAAE;EAE3B;;EAEA,MAAMC,QAAQ,CAACC,UAA8B,EAAsB;IACjE,MAAM,IAAIC,KAAK,CAAC,iBAAi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ACC,QAAQ,CAAC,aAAa,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
3
|
+
import { ImageLoader } from '@loaders.gl/images';
|
|
4
|
+
import { ImageSource } from '../image-source';
|
|
5
|
+
|
|
6
|
+
export class ImageService extends ImageSource {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super();
|
|
9
|
+
_defineProperty(this, "props", void 0);
|
|
10
|
+
_defineProperty(this, "fetch", void 0);
|
|
11
|
+
this.props = mergeImageServiceProps(props);
|
|
12
|
+
this.fetch = getFetchFunction(props);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async getMetadata() {
|
|
16
|
+
throw new Error('ImageSource.getMetadata not implemented');
|
|
17
|
+
}
|
|
18
|
+
async getImage(parameters) {
|
|
19
|
+
const granularParameters = this.getGranularParameters(parameters);
|
|
20
|
+
const url = this.getURLFromTemplate(granularParameters);
|
|
21
|
+
const response = await this.fetch(url);
|
|
22
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
23
|
+
return await ImageLoader.parse(arrayBuffer);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getGranularParameters(parameters) {
|
|
27
|
+
const [east, north, west, south] = parameters.bbox;
|
|
28
|
+
return {
|
|
29
|
+
...parameters,
|
|
30
|
+
east,
|
|
31
|
+
north,
|
|
32
|
+
south,
|
|
33
|
+
west
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getURLFromTemplate(parameters) {
|
|
38
|
+
let url = this.props.url;
|
|
39
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
40
|
+
url = url.replace("${".concat(key, "}"), String(value));
|
|
41
|
+
url = url.replace("{".concat(key, "}"), String(value));
|
|
42
|
+
}
|
|
43
|
+
return url;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_defineProperty(ImageService, "type", 'template');
|
|
48
|
+
_defineProperty(ImageService, "testURL", url => url.toLowerCase().includes('{'));
|
|
49
|
+
export function getFetchFunction(options) {
|
|
50
|
+
const fetchFunction = options === null || options === void 0 ? void 0 : options.fetch;
|
|
51
|
+
|
|
52
|
+
if (fetchFunction && typeof fetchFunction === 'function') {
|
|
53
|
+
return (url, fetchOptions) => fetchFunction(url, fetchOptions);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const fetchOptions = options === null || options === void 0 ? void 0 : options.fetch;
|
|
57
|
+
if (fetchOptions && typeof fetchOptions !== 'function') {
|
|
58
|
+
return url => fetch(url, fetchOptions);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return url => fetch(url);
|
|
62
|
+
}
|
|
63
|
+
export function mergeImageServiceProps(props) {
|
|
64
|
+
return {
|
|
65
|
+
...props,
|
|
66
|
+
loadOptions: {
|
|
67
|
+
...props.loadOptions,
|
|
68
|
+
fetch: getFetchFunction(props.loadOptions)
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=image-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-service.js","names":["ImageLoader","ImageSource","ImageService","constructor","props","mergeImageServiceProps","fetch","getFetchFunction","getMetadata","Error","getImage","parameters","granularParameters","getGranularParameters","url","getURLFromTemplate","response","arrayBuffer","parse","east","north","west","south","bbox","key","value","Object","entries","replace","String","toLowerCase","includes","options","fetchFunction","fetchOptions","loadOptions"],"sources":["../../../../../src/lib/data-sources/image-services/image-service.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {ImageType} from '@loaders.gl/images';\nimport {ImageLoader} from '@loaders.gl/images';\n\nimport type {ImageSourceMetadata, GetImageParameters} from '../image-source';\nimport {ImageSource} from '../image-source';\n\n/** Template URL string should contain `${width}` etc which will be substituted. */\nexport type ImageServiceProps = {\n /** Base URL to the service */\n url: string;\n /** Any load options to the loaders.gl Loaders used by the WMSService methods */\n loadOptions?: LoaderOptions;\n};\n\n/**\n * Quickly connect to \"ad hoc\" image sources without subclassing ImageSource.\n * ImageSource allows template url strings to be used to ad hoc connect to arbitrary image data sources\n * Accepts a template url string and builds requests URLs\n */\nexport class ImageService extends ImageSource {\n static type: 'template' = 'template';\n static testURL = (url: string): boolean => url.toLowerCase().includes('{');\n\n props: Required<ImageServiceProps>;\n fetch: (url: string, options?: RequestInit) => Promise<Response>;\n\n constructor(props: ImageServiceProps) {\n super();\n this.props = mergeImageServiceProps(props);\n this.fetch = getFetchFunction(props);\n }\n\n // IMAGE SOURCE API\n\n async getMetadata(): Promise<ImageSourceMetadata> {\n throw new Error('ImageSource.getMetadata not implemented');\n }\n\n async getImage(parameters: GetImageParameters): Promise<ImageType> {\n const granularParameters = this.getGranularParameters(parameters);\n const url = this.getURLFromTemplate(granularParameters);\n const response = await this.fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n return await ImageLoader.parse(arrayBuffer);\n }\n\n // HELPERS\n\n /** Break up bounding box in east, north, south, west */\n protected getGranularParameters(parameters: GetImageParameters): Record<string, unknown> {\n const [east, north, west, south] = parameters.bbox;\n return {...parameters, east, north, south, west};\n }\n\n /** Supports both ${} and {} notations */\n protected getURLFromTemplate(parameters: Record<string, unknown>): string {\n let url = this.props.url;\n for (const [key, value] of Object.entries(parameters)) {\n // TODO - parameter could be repeated\n // const regex = new RegExp(`\\${${key}}`, 'g');\n url = url.replace(`\\${${key}}`, String(value));\n url = url.replace(`{${key}}`, String(value));\n }\n return url;\n }\n}\n\n/**\n * Gets the current fetch function from options\n * @todo - move to loader-utils module\n * @todo - use in core module counterpart\n * @param options\n * @param context\n */\nexport function getFetchFunction(options?: LoaderOptions) {\n const fetchFunction = options?.fetch;\n\n // options.fetch can be a function\n if (fetchFunction && typeof fetchFunction === 'function') {\n return (url: string, fetchOptions?: RequestInit) => fetchFunction(url, fetchOptions);\n }\n\n // options.fetch can be an options object, use global fetch with those options\n const fetchOptions = options?.fetch;\n if (fetchOptions && typeof fetchOptions !== 'function') {\n return (url) => fetch(url, fetchOptions);\n }\n\n // else return the global fetch function\n return (url) => fetch(url);\n}\n\nexport function mergeImageServiceProps(props: ImageServiceProps): Required<ImageServiceProps> {\n return {\n // Default fetch\n ...props,\n loadOptions: {\n ...props.loadOptions,\n fetch: getFetchFunction(props.loadOptions)\n }\n };\n}\n"],"mappings":";;AAIA,SAAQA,WAAW,QAAO,oBAAoB;AAG9C,SAAQC,WAAW,QAAO,iBAAiB;;AAe3C,OAAO,MAAMC,YAAY,SAASD,WAAW,CAAC;EAO5CE,WAAW,CAACC,KAAwB,EAAE;IACpC,KAAK,EAAE;IAAC;IAAA;IACR,IAAI,CAACA,KAAK,GAAGC,sBAAsB,CAACD,KAAK,CAAC;IAC1C,IAAI,CAACE,KAAK,GAAGC,gBAAgB,CAACH,KAAK,CAAC;EACtC;;EAIA,MAAMI,WAAW,GAAiC;IAChD,MAAM,IAAIC,KAAK,CAAC,yCAAyC,CAAC;EAC5D;EAEA,MAAMC,QAAQ,CAACC,UAA8B,EAAsB;IACjE,MAAMC,kBAAkB,GAAG,IAAI,CAACC,qBAAqB,CAACF,UAAU,CAAC;IACjE,MAAMG,GAAG,GAAG,IAAI,CAACC,kBAAkB,CAACH,kBAAkB,CAAC;IACvD,MAAMI,QAAQ,GAAG,MAAM,IAAI,CAACV,KAAK,CAACQ,GAAG,CAAC;IACtC,MAAMG,WAAW,GAAG,MAAMD,QAAQ,CAACC,WAAW,EAAE;IAChD,OAAO,MAAMjB,WAAW,CAACkB,KAAK,CAACD,WAAW,CAAC;EAC7C;;EAKUJ,qBAAqB,CAACF,UAA8B,EAA2B;IACvF,MAAM,CAACQ,IAAI,EAAEC,KAAK,EAAEC,IAAI,EAAEC,KAAK,CAAC,GAAGX,UAAU,CAACY,IAAI;IAClD,OAAO;MAAC,GAAGZ,UAAU;MAAEQ,IAAI;MAAEC,KAAK;MAAEE,KAAK;MAAED;IAAI,CAAC;EACl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B7B,KAAK,EAAEC,gBAAgB,CAACH,KAAK,CAAC+B,WAAW;IAC3C;EACF,CAAC;AACH"}
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
|
|
3
3
|
import { ImageLoader } from '@loaders.gl/images';
|
|
4
|
-
import { ImageSource } from '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { ImageSource } from '../image-source';
|
|
5
|
+
import { getFetchFunction, mergeImageServiceProps } from './image-service';
|
|
6
|
+
import { WMSCapabilitiesLoader } from '../../../wms-capabilities-loader';
|
|
7
|
+
import { WMSFeatureInfoLoader } from '../../../wip/wms-feature-info-loader';
|
|
8
|
+
import { WMSLayerDescriptionLoader } from '../../../wip/wms-layer-description-loader';
|
|
9
|
+
import { WMSErrorLoader } from '../../../wms-error-loader';
|
|
9
10
|
export class WMSService extends ImageSource {
|
|
10
11
|
|
|
11
12
|
constructor(props) {
|
|
13
|
+
var _this$props$loadOptio;
|
|
12
14
|
super();
|
|
13
|
-
_defineProperty(this, "
|
|
14
|
-
_defineProperty(this, "
|
|
15
|
+
_defineProperty(this, "props", void 0);
|
|
16
|
+
_defineProperty(this, "fetch", void 0);
|
|
17
|
+
_defineProperty(this, "capabilities", null);
|
|
18
|
+
_defineProperty(this, "loaders", [ImageLoader, WMSErrorLoader, WMSCapabilitiesLoader, WMSFeatureInfoLoader, WMSLayerDescriptionLoader]);
|
|
19
|
+
this.props = mergeImageServiceProps(props);
|
|
20
|
+
this.fetch = getFetchFunction(this.props);
|
|
21
|
+
this.props.loadOptions = {
|
|
22
|
+
...this.props.loadOptions,
|
|
15
23
|
wms: {
|
|
24
|
+
...((_this$props$loadOptio = this.props.loadOptions) === null || _this$props$loadOptio === void 0 ? void 0 : _this$props$loadOptio.wms),
|
|
16
25
|
throwOnError: true
|
|
17
26
|
}
|
|
18
|
-
}
|
|
19
|
-
_defineProperty(this, "fetch", void 0);
|
|
20
|
-
_defineProperty(this, "loaders", [ImageLoader, WMSErrorLoader, WMSCapabilitiesLoader, WMSFeatureInfoLoader, WMSLayerDescriptionLoader]);
|
|
21
|
-
this.serviceUrl = props.serviceUrl;
|
|
22
|
-
Object.assign(this.loadOptions, props.loadOptions);
|
|
23
|
-
this.fetch = props.fetch || fetch;
|
|
27
|
+
};
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
getMetadata() {
|
|
@@ -32,25 +36,21 @@ export class WMSService extends ImageSource {
|
|
|
32
36
|
|
|
33
37
|
async getCapabilities(wmsParameters, vendorParameters) {
|
|
34
38
|
const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
|
|
35
|
-
const
|
|
36
|
-
fetch
|
|
37
|
-
} = this;
|
|
38
|
-
const response = await fetch(url, this.loadOptions);
|
|
39
|
+
const response = await this.fetch(url);
|
|
39
40
|
const arrayBuffer = await response.arrayBuffer();
|
|
40
41
|
this._checkResponse(response, arrayBuffer);
|
|
41
|
-
|
|
42
|
+
const capabilities = await WMSCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
43
|
+
this.capabilities = capabilities;
|
|
44
|
+
return capabilities;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
async getMap(options, vendorParameters) {
|
|
45
48
|
const url = this.getMapURL(options, vendorParameters);
|
|
46
|
-
const
|
|
47
|
-
fetch
|
|
48
|
-
} = this;
|
|
49
|
-
const response = await fetch(url, this.loadOptions);
|
|
49
|
+
const response = await this.fetch(url);
|
|
50
50
|
const arrayBuffer = await response.arrayBuffer();
|
|
51
51
|
this._checkResponse(response, arrayBuffer);
|
|
52
52
|
try {
|
|
53
|
-
return await ImageLoader.parse(arrayBuffer, this.loadOptions);
|
|
53
|
+
return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
54
54
|
} catch {
|
|
55
55
|
throw this._parseError(arrayBuffer);
|
|
56
56
|
}
|
|
@@ -58,27 +58,39 @@ export class WMSService extends ImageSource {
|
|
|
58
58
|
|
|
59
59
|
async getFeatureInfo(options, vendorParameters) {
|
|
60
60
|
const url = this.getFeatureInfoURL(options, vendorParameters);
|
|
61
|
-
const response = await this.fetch(url
|
|
61
|
+
const response = await this.fetch(url);
|
|
62
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
63
|
+
this._checkResponse(response, arrayBuffer);
|
|
64
|
+
return await WMSFeatureInfoLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async getFeatureInfoText(options, vendorParameters) {
|
|
68
|
+
options = {
|
|
69
|
+
...options,
|
|
70
|
+
info_format: 'text/plain'
|
|
71
|
+
};
|
|
72
|
+
const url = this.getFeatureInfoURL(options, vendorParameters);
|
|
73
|
+
const response = await this.fetch(url);
|
|
62
74
|
const arrayBuffer = await response.arrayBuffer();
|
|
63
75
|
this._checkResponse(response, arrayBuffer);
|
|
64
|
-
return
|
|
76
|
+
return new TextDecoder().decode(arrayBuffer);
|
|
65
77
|
}
|
|
66
78
|
|
|
67
79
|
async describeLayer(options, vendorParameters) {
|
|
68
80
|
const url = this.describeLayerURL(options, vendorParameters);
|
|
69
|
-
const response = await this.fetch(url
|
|
81
|
+
const response = await this.fetch(url);
|
|
70
82
|
const arrayBuffer = await response.arrayBuffer();
|
|
71
83
|
this._checkResponse(response, arrayBuffer);
|
|
72
|
-
return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.loadOptions);
|
|
84
|
+
return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
73
85
|
}
|
|
74
86
|
|
|
75
87
|
async getLegendGraphic(options, vendorParameters) {
|
|
76
88
|
const url = this.getLegendGraphicURL(options, vendorParameters);
|
|
77
|
-
const response = await this.fetch(url
|
|
89
|
+
const response = await this.fetch(url);
|
|
78
90
|
const arrayBuffer = await response.arrayBuffer();
|
|
79
91
|
this._checkResponse(response, arrayBuffer);
|
|
80
92
|
try {
|
|
81
|
-
return await ImageLoader.parse(arrayBuffer, this.loadOptions);
|
|
93
|
+
return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
82
94
|
} catch {
|
|
83
95
|
throw this._parseError(arrayBuffer);
|
|
84
96
|
}
|
|
@@ -146,7 +158,7 @@ export class WMSService extends ImageSource {
|
|
|
146
158
|
}
|
|
147
159
|
|
|
148
160
|
_getWMSUrl(options, vendorParameters) {
|
|
149
|
-
let url =
|
|
161
|
+
let url = this.props.url;
|
|
150
162
|
let first = true;
|
|
151
163
|
for (const [key, value] of Object.entries(options)) {
|
|
152
164
|
url += first ? '?' : '&';
|
|
@@ -163,14 +175,16 @@ export class WMSService extends ImageSource {
|
|
|
163
175
|
_checkResponse(response, arrayBuffer) {
|
|
164
176
|
const contentType = response.headers['content-type'];
|
|
165
177
|
if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
|
|
166
|
-
const error = WMSErrorLoader.parseSync(arrayBuffer, this.loadOptions);
|
|
178
|
+
const error = WMSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);
|
|
167
179
|
throw new Error(error);
|
|
168
180
|
}
|
|
169
181
|
}
|
|
170
182
|
|
|
171
183
|
_parseError(arrayBuffer) {
|
|
172
|
-
const error = WMSErrorLoader.parseSync(arrayBuffer, this.loadOptions);
|
|
184
|
+
const error = WMSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);
|
|
173
185
|
return new Error(error);
|
|
174
186
|
}
|
|
175
187
|
}
|
|
188
|
+
_defineProperty(WMSService, "type", 'wms');
|
|
189
|
+
_defineProperty(WMSService, "testURL", url => url.toLowerCase().includes('wms'));
|
|
176
190
|
//# sourceMappingURL=wms-service.js.map
|