@loaders.gl/wms 3.3.0-alpha.8 → 3.3.0
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +6 -0
- package/dist/dist.min.js +4141 -1479
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/index.js +77 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lerc-loader.js +74 -0
- package/dist/es5/lerc-loader.js.map +1 -0
- package/dist/es5/lib/data-sources/adhoc-image-service.js +129 -0
- package/dist/es5/lib/data-sources/adhoc-image-service.js.map +1 -0
- 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/image-services/wms-service.js +400 -0
- package/dist/es5/lib/data-sources/image-services/wms-service.js.map +1 -0
- package/dist/es5/lib/data-sources/image-source.js +14 -0
- package/dist/es5/lib/data-sources/image-source.js.map +1 -0
- package/dist/es5/lib/gml/deep-strict-equal.js +64 -0
- package/dist/es5/lib/gml/deep-strict-equal.js.map +1 -0
- package/dist/es5/lib/gml/parse-gml.js +416 -0
- package/dist/es5/lib/gml/parse-gml.js.map +1 -0
- package/dist/es5/lib/lerc/lerc-types.js +2 -0
- package/dist/es5/lib/lerc/lerc-types.js.map +1 -0
- package/dist/es5/lib/wcs/parse-wcs.js +43 -0
- package/dist/es5/lib/wcs/parse-wcs.js.map +1 -0
- package/dist/es5/lib/wcs/wcs-types.js +2 -0
- package/dist/es5/lib/wcs/wcs-types.js.map +1 -0
- package/dist/es5/lib/wfs/parse-wfs.js +43 -0
- package/dist/es5/lib/wfs/parse-wfs.js.map +1 -0
- package/dist/es5/lib/wfs/wfs-types.js +2 -0
- package/dist/es5/lib/wfs/wfs-types.js.map +1 -0
- package/dist/es5/lib/wms/parse-wms.js +135 -0
- package/dist/es5/lib/wms/parse-wms.js.map +1 -0
- package/dist/es5/{wms-types.js → lib/wms/wms-types.js} +0 -0
- package/dist/{esm → es5/lib/wms}/wms-types.js.map +1 -1
- package/dist/es5/lib/wmts/parse-wmts.js +43 -0
- package/dist/es5/lib/wmts/parse-wmts.js.map +1 -0
- package/dist/es5/lib/wmts/wmts-types.js +2 -0
- package/dist/es5/lib/wmts/wmts-types.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 +4 -0
- package/dist/es5/wip/data-source.js.map +1 -0
- package/dist/es5/wip/gml-loader.js +54 -0
- package/dist/es5/wip/gml-loader.js.map +1 -0
- package/dist/es5/wip/wcs-capabilities-loader.js +54 -0
- package/dist/es5/wip/wcs-capabilities-loader.js.map +1 -0
- package/dist/es5/wip/wfs-capabilities-loader.js +54 -0
- package/dist/es5/wip/wfs-capabilities-loader.js.map +1 -0
- package/dist/es5/wip/wms-feature-info-loader.js +44 -0
- package/dist/es5/wip/wms-feature-info-loader.js.map +1 -0
- package/dist/es5/wip/wms-layer-description-loader.js +44 -0
- package/dist/es5/wip/wms-layer-description-loader.js.map +1 -0
- package/dist/es5/wip/wms-layer-description-loader.md.disabled.md +47 -0
- package/dist/es5/wip/wmts-capabilities-loader.js +54 -0
- package/dist/es5/wip/wmts-capabilities-loader.js.map +1 -0
- package/dist/es5/wms-capabilities-loader.js +7 -6
- package/dist/es5/wms-capabilities-loader.js.map +1 -1
- package/dist/es5/wms-error-loader.js +70 -0
- package/dist/es5/wms-error-loader.js.map +1 -0
- package/dist/esm/bundle.js +1 -0
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lerc-loader.js +25 -0
- package/dist/esm/lerc-loader.js.map +1 -0
- package/dist/esm/lib/data-sources/adhoc-image-service.js +43 -0
- package/dist/esm/lib/data-sources/adhoc-image-service.js.map +1 -0
- 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/image-services/wms-service.js +190 -0
- package/dist/esm/lib/data-sources/image-services/wms-service.js.map +1 -0
- package/dist/esm/lib/data-sources/image-source.js +4 -0
- package/dist/esm/lib/data-sources/image-source.js.map +1 -0
- package/dist/esm/lib/gml/deep-strict-equal.js +57 -0
- package/dist/esm/lib/gml/deep-strict-equal.js.map +1 -0
- package/dist/esm/lib/gml/parse-gml.js +348 -0
- package/dist/esm/lib/gml/parse-gml.js.map +1 -0
- package/dist/esm/lib/lerc/lerc-types.js +2 -0
- package/dist/esm/lib/lerc/lerc-types.js.map +1 -0
- package/dist/esm/lib/wcs/parse-wcs.js +32 -0
- package/dist/esm/lib/wcs/parse-wcs.js.map +1 -0
- package/dist/esm/lib/wcs/wcs-types.js +2 -0
- package/dist/esm/lib/wcs/wcs-types.js.map +1 -0
- package/dist/esm/lib/wfs/parse-wfs.js +32 -0
- package/dist/esm/lib/wfs/parse-wfs.js.map +1 -0
- package/dist/esm/lib/wfs/wfs-types.js +2 -0
- package/dist/esm/lib/wfs/wfs-types.js.map +1 -0
- package/dist/esm/lib/wms/parse-wms.js +101 -0
- package/dist/esm/lib/wms/parse-wms.js.map +1 -0
- package/dist/esm/{wms-types.js → lib/wms/wms-types.js} +0 -0
- package/dist/{es5 → esm/lib/wms}/wms-types.js.map +1 -1
- package/dist/esm/lib/wmts/parse-wmts.js +32 -0
- package/dist/esm/lib/wmts/parse-wmts.js.map +1 -0
- package/dist/esm/lib/wmts/wmts-types.js +2 -0
- package/dist/esm/lib/wmts/wmts-types.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 +2 -0
- package/dist/esm/wip/data-source.js.map +1 -0
- package/dist/esm/wip/gml-loader.js +25 -0
- package/dist/esm/wip/gml-loader.js.map +1 -0
- package/dist/esm/wip/wcs-capabilities-loader.js +25 -0
- package/dist/esm/wip/wcs-capabilities-loader.js.map +1 -0
- package/dist/esm/wip/wfs-capabilities-loader.js +25 -0
- package/dist/esm/wip/wfs-capabilities-loader.js.map +1 -0
- package/dist/esm/wip/wms-feature-info-loader.js +14 -0
- package/dist/esm/wip/wms-feature-info-loader.js.map +1 -0
- package/dist/esm/wip/wms-layer-description-loader.js +14 -0
- package/dist/esm/wip/wms-layer-description-loader.js.map +1 -0
- package/dist/esm/wip/wms-layer-description-loader.md.disabled.md +47 -0
- package/dist/esm/wip/wmts-capabilities-loader.js +25 -0
- package/dist/esm/wip/wmts-capabilities-loader.js.map +1 -0
- package/dist/esm/wms-capabilities-loader.js +6 -4
- package/dist/esm/wms-capabilities-loader.js.map +1 -1
- package/dist/esm/wms-error-loader.js +40 -0
- package/dist/esm/wms-error-loader.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/lerc-loader.d.ts +30 -0
- package/dist/lerc-loader.d.ts.map +1 -0
- package/dist/lerc-loader.js +56 -0
- package/dist/lib/data-sources/adhoc-image-service.d.ts +24 -0
- package/dist/lib/data-sources/adhoc-image-service.d.ts.map +1 -0
- package/dist/lib/data-sources/adhoc-image-service.js +46 -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/image-services/wms-service.d.ts +188 -0
- package/dist/lib/data-sources/image-services/wms-service.d.ts.map +1 -0
- package/dist/lib/data-sources/image-services/wms-service.js +218 -0
- package/dist/lib/data-sources/image-source.d.ts +73 -0
- package/dist/lib/data-sources/image-source.d.ts.map +1 -0
- package/dist/lib/data-sources/image-source.js +12 -0
- package/dist/lib/gml/deep-strict-equal.d.ts +3 -0
- package/dist/lib/gml/deep-strict-equal.d.ts.map +1 -0
- package/dist/lib/gml/deep-strict-equal.js +119 -0
- package/dist/lib/gml/parse-gml.d.ts +28 -0
- package/dist/lib/gml/parse-gml.d.ts.map +1 -0
- package/dist/lib/gml/parse-gml.js +371 -0
- package/dist/lib/lerc/lerc-types.d.ts +30 -0
- package/dist/lib/lerc/lerc-types.d.ts.map +1 -0
- package/dist/lib/lerc/lerc-types.js +3 -0
- package/dist/lib/wcs/parse-wcs.d.ts +7 -0
- package/dist/lib/wcs/parse-wcs.d.ts.map +1 -0
- package/dist/lib/wcs/parse-wcs.js +36 -0
- package/dist/lib/wcs/wcs-types.d.ts +73 -0
- package/dist/lib/wcs/wcs-types.d.ts.map +1 -0
- package/dist/lib/wcs/wcs-types.js +3 -0
- package/dist/lib/wfs/parse-wfs.d.ts +7 -0
- package/dist/lib/wfs/parse-wfs.d.ts.map +1 -0
- package/dist/lib/wfs/parse-wfs.js +36 -0
- package/dist/lib/wfs/wfs-types.d.ts +73 -0
- package/dist/lib/wfs/wfs-types.d.ts.map +1 -0
- package/dist/lib/wfs/wfs-types.js +3 -0
- package/dist/lib/wms/parse-wms.d.ts +24 -0
- package/dist/lib/wms/parse-wms.d.ts.map +1 -0
- package/dist/lib/wms/parse-wms.js +115 -0
- package/dist/lib/wms/wms-types.d.ts +100 -0
- package/dist/lib/wms/wms-types.d.ts.map +1 -0
- package/dist/lib/wms/wms-types.js +1908 -0
- package/dist/lib/wmts/parse-wmts.d.ts +7 -0
- package/dist/lib/wmts/parse-wmts.d.ts.map +1 -0
- package/dist/lib/wmts/parse-wmts.js +36 -0
- package/dist/lib/wmts/wmts-types.d.ts +73 -0
- package/dist/lib/wmts/wmts-types.d.ts.map +1 -0
- package/dist/lib/wmts/wmts-types.js +3 -0
- 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 +54 -0
- package/dist/wip/data-source.d.ts.map +1 -0
- package/dist/wip/data-source.js +59 -0
- package/dist/wip/gml-loader.d.ts +26 -0
- package/dist/wip/gml-loader.d.ts.map +1 -0
- package/dist/wip/gml-loader.js +31 -0
- package/dist/wip/wcs-capabilities-loader.d.ts +26 -0
- package/dist/wip/wcs-capabilities-loader.d.ts.map +1 -0
- package/dist/wip/wcs-capabilities-loader.js +31 -0
- package/dist/wip/wfs-capabilities-loader.d.ts +26 -0
- package/dist/wip/wfs-capabilities-loader.d.ts.map +1 -0
- package/dist/wip/wfs-capabilities-loader.js +31 -0
- package/dist/wip/wms-feature-info-loader.d.ts +22 -0
- package/dist/wip/wms-feature-info-loader.d.ts.map +1 -0
- package/dist/wip/wms-feature-info-loader.js +17 -0
- package/dist/wip/wms-layer-description-loader.d.ts +22 -0
- package/dist/wip/wms-layer-description-loader.d.ts.map +1 -0
- package/dist/wip/wms-layer-description-loader.js +17 -0
- package/dist/wip/wmts-capabilities-loader.d.ts +26 -0
- package/dist/wip/wmts-capabilities-loader.d.ts.map +1 -0
- package/dist/wip/wmts-capabilities-loader.js +31 -0
- package/dist/wms-capabilities-loader.d.ts +26 -0
- package/dist/wms-capabilities-loader.d.ts.map +1 -0
- package/dist/wms-capabilities-loader.js +31 -0
- package/dist/wms-error-loader.d.ts +34 -0
- package/dist/wms-error-loader.d.ts.map +1 -0
- package/dist/wms-error-loader.js +43 -0
- package/package.json +17 -6
- package/src/bundle.ts +2 -0
- package/src/index.ts +54 -2
- package/src/lerc-loader.ts +50 -0
- package/src/lib/data-sources/adhoc-image-service.ts +61 -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/image-services/wms-service.ts +351 -0
- package/src/lib/data-sources/image-source.ts +82 -0
- package/src/lib/gml/deep-strict-equal.ts +119 -0
- package/src/lib/gml/parse-gml.ts +500 -0
- package/src/lib/lerc/lerc-types.ts +43 -0
- package/src/lib/wcs/parse-wcs.ts +39 -0
- package/src/lib/wcs/wcs-types.ts +77 -0
- package/src/lib/wfs/parse-wfs.ts +39 -0
- package/src/lib/wfs/wfs-types.ts +78 -0
- package/src/lib/wms/parse-wms.ts +142 -0
- package/src/{wms-types.ts → lib/wms/wms-types.ts} +76 -24
- package/src/lib/wmts/parse-wmts.ts +39 -0
- package/src/lib/wmts/wmts-types.ts +77 -0
- package/src/wip/arcgis-feature-service.ts +89 -0
- package/src/wip/data-source.ts +62 -0
- package/src/wip/gml-loader.ts +40 -0
- package/src/wip/wcs-capabilities-loader.ts +40 -0
- package/src/wip/wfs-capabilities-loader.ts +40 -0
- package/src/wip/wms-feature-info-loader.ts +21 -0
- package/src/wip/wms-layer-description-loader.md.disabled.md +47 -0
- package/src/wip/wms-layer-description-loader.ts +21 -0
- package/src/wip/wmts-capabilities-loader.ts +40 -0
- package/src/wms-capabilities-loader.ts +10 -8
- package/src/wms-error-loader.ts +59 -0
- package/dist/es5/lib/parse-wms-capabilities.js +0 -19
- package/dist/es5/lib/parse-wms-capabilities.js.map +0 -1
- package/dist/esm/lib/parse-wms-capabilities.js +0 -14
- package/dist/esm/lib/parse-wms-capabilities.js.map +0 -1
- package/src/lib/parse-wms-capabilities.ts +0 -14
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
3
|
+
import { ImageLoader } from '@loaders.gl/images';
|
|
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';
|
|
10
|
+
export class WMSService extends ImageSource {
|
|
11
|
+
|
|
12
|
+
constructor(props) {
|
|
13
|
+
var _this$props$loadOptio;
|
|
14
|
+
super();
|
|
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,
|
|
23
|
+
wms: {
|
|
24
|
+
...((_this$props$loadOptio = this.props.loadOptions) === null || _this$props$loadOptio === void 0 ? void 0 : _this$props$loadOptio.wms),
|
|
25
|
+
throwOnError: true
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getMetadata() {
|
|
31
|
+
return this.getCapabilities();
|
|
32
|
+
}
|
|
33
|
+
getImage(parameters) {
|
|
34
|
+
return this.getMap(parameters);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getCapabilities(wmsParameters, vendorParameters) {
|
|
38
|
+
const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
|
|
39
|
+
const response = await this.fetch(url);
|
|
40
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
41
|
+
this._checkResponse(response, arrayBuffer);
|
|
42
|
+
const capabilities = await WMSCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
43
|
+
this.capabilities = capabilities;
|
|
44
|
+
return capabilities;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async getMap(options, vendorParameters) {
|
|
48
|
+
const url = this.getMapURL(options, vendorParameters);
|
|
49
|
+
const response = await this.fetch(url);
|
|
50
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
51
|
+
this._checkResponse(response, arrayBuffer);
|
|
52
|
+
try {
|
|
53
|
+
return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
54
|
+
} catch {
|
|
55
|
+
throw this._parseError(arrayBuffer);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async getFeatureInfo(options, vendorParameters) {
|
|
60
|
+
const url = this.getFeatureInfoURL(options, vendorParameters);
|
|
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);
|
|
74
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
75
|
+
this._checkResponse(response, arrayBuffer);
|
|
76
|
+
return new TextDecoder().decode(arrayBuffer);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async describeLayer(options, vendorParameters) {
|
|
80
|
+
const url = this.describeLayerURL(options, vendorParameters);
|
|
81
|
+
const response = await this.fetch(url);
|
|
82
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
83
|
+
this._checkResponse(response, arrayBuffer);
|
|
84
|
+
return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async getLegendGraphic(options, vendorParameters) {
|
|
88
|
+
const url = this.getLegendGraphicURL(options, vendorParameters);
|
|
89
|
+
const response = await this.fetch(url);
|
|
90
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
91
|
+
this._checkResponse(response, arrayBuffer);
|
|
92
|
+
try {
|
|
93
|
+
return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
|
|
94
|
+
} catch {
|
|
95
|
+
throw this._parseError(arrayBuffer);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getCapabilitiesURL(wmsParameters, vendorParameters) {
|
|
100
|
+
const options = {
|
|
101
|
+
service: 'WMS',
|
|
102
|
+
version: '1.1.1',
|
|
103
|
+
request: 'GetCapabilities',
|
|
104
|
+
...wmsParameters,
|
|
105
|
+
...vendorParameters
|
|
106
|
+
};
|
|
107
|
+
return this._getWMSUrl(options, vendorParameters);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
getMapURL(wmsParameters, vendorParameters) {
|
|
111
|
+
const options = {
|
|
112
|
+
service: 'WMS',
|
|
113
|
+
version: '1.1.1',
|
|
114
|
+
request: 'GetMap',
|
|
115
|
+
styles: undefined,
|
|
116
|
+
srs: 'EPSG:4326',
|
|
117
|
+
format: 'image/png',
|
|
118
|
+
...wmsParameters,
|
|
119
|
+
...vendorParameters
|
|
120
|
+
};
|
|
121
|
+
return this._getWMSUrl(options, vendorParameters);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
getFeatureInfoURL(wmsParameters, vendorParameters) {
|
|
125
|
+
const options = {
|
|
126
|
+
service: 'WMS',
|
|
127
|
+
version: '1.1.1',
|
|
128
|
+
request: 'GetFeatureInfo',
|
|
129
|
+
srs: 'EPSG:4326',
|
|
130
|
+
format: 'image/png',
|
|
131
|
+
info_format: 'text/plain',
|
|
132
|
+
styles: undefined,
|
|
133
|
+
...wmsParameters,
|
|
134
|
+
...vendorParameters
|
|
135
|
+
};
|
|
136
|
+
return this._getWMSUrl(options, vendorParameters);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
describeLayerURL(wmsParameters, vendorParameters) {
|
|
140
|
+
const options = {
|
|
141
|
+
service: 'WMS',
|
|
142
|
+
version: '1.1.1',
|
|
143
|
+
request: 'DescribeLayer',
|
|
144
|
+
...wmsParameters,
|
|
145
|
+
...vendorParameters
|
|
146
|
+
};
|
|
147
|
+
return this._getWMSUrl(options, vendorParameters);
|
|
148
|
+
}
|
|
149
|
+
getLegendGraphicURL(wmsParameters, vendorParameters) {
|
|
150
|
+
const options = {
|
|
151
|
+
service: 'WMS',
|
|
152
|
+
version: '1.1.1',
|
|
153
|
+
request: 'GetLegendGraphic',
|
|
154
|
+
...wmsParameters,
|
|
155
|
+
...vendorParameters
|
|
156
|
+
};
|
|
157
|
+
return this._getWMSUrl(options, vendorParameters);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
_getWMSUrl(options, vendorParameters) {
|
|
161
|
+
let url = this.props.url;
|
|
162
|
+
let first = true;
|
|
163
|
+
for (const [key, value] of Object.entries(options)) {
|
|
164
|
+
url += first ? '?' : '&';
|
|
165
|
+
first = false;
|
|
166
|
+
if (Array.isArray(value)) {
|
|
167
|
+
url += "".concat(key.toUpperCase(), "=").concat(value.join(','));
|
|
168
|
+
} else {
|
|
169
|
+
url += "".concat(key.toUpperCase(), "=").concat(value ? String(value) : '');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return encodeURI(url);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
_checkResponse(response, arrayBuffer) {
|
|
176
|
+
const contentType = response.headers['content-type'];
|
|
177
|
+
if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
|
|
178
|
+
const error = WMSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);
|
|
179
|
+
throw new Error(error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
_parseError(arrayBuffer) {
|
|
184
|
+
const error = WMSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);
|
|
185
|
+
return new Error(error);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
_defineProperty(WMSService, "type", 'wms');
|
|
189
|
+
_defineProperty(WMSService, "testURL", url => url.toLowerCase().includes('wms'));
|
|
190
|
+
//# sourceMappingURL=wms-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wms-service.js","names":["ImageLoader","ImageSource","getFetchFunction","mergeImageServiceProps","WMSCapabilitiesLoader","WMSFeatureInfoLoader","WMSLayerDescriptionLoader","WMSErrorLoader","WMSService","constructor","props","fetch","loadOptions","wms","throwOnError","getMetadata","getCapabilities","getImage","parameters","getMap","wmsParameters","vendorParameters","url","getCapabilitiesURL","response","arrayBuffer","_checkResponse","capabilities","parse","options","getMapURL","_parseError","getFeatureInfo","getFeatureInfoURL","getFeatureInfoText","info_format","TextDecoder","decode","describeLayer","describeLayerURL","getLegendGraphic","getLegendGraphicURL","service","version","request","_getWMSUrl","styles","undefined","srs","format","first","key","value","Object","entries","Array","isArray","toUpperCase","join","String","encodeURI","contentType","headers","ok","mimeTypes","includes","error","parseSync","Error","toLowerCase"],"sources":["../../../../../src/lib/data-sources/image-services/wms-service.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/* eslint-disable camelcase */\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';\nimport {ImageServiceProps, getFetchFunction, mergeImageServiceProps} from './image-service';\n\nimport type {WMSCapabilities, WMSFeatureInfo, WMSLayerDescription} from '../../wms/wms-types';\nimport {WMSCapabilitiesLoader} from '../../../wms-capabilities-loader';\nimport {WMSFeatureInfoLoader} from '../../../wip/wms-feature-info-loader';\nimport {WMSLayerDescriptionLoader} from '../../../wip/wms-layer-description-loader';\nimport {WMSErrorLoader} from '../../../wms-error-loader';\n\ntype WMSCommonParameters = {\n /** In case the endpoint supports multiple services */\n service?: 'WMS';\n /** In case the endpoint supports multiple WMS versions */\n version?: '1.1.1' | '1.3.0';\n};\n\nexport type WMSGetCapabilitiesParameters = WMSCommonParameters & {\n /** Request type */\n request?: 'GetCapabilities';\n};\n\nexport type WMSGetMapParameters = WMSCommonParameters & {\n /** Request type */\n request?: 'GetMap';\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n bbox: [number, number, number, number];\n /** pixel width of returned image */\n width: number;\n /** pixels */\n height: number;\n /** srs for the image (not the bounding box) */\n srs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\n// https://imagery.pasda.psu.edu/arcgis/services/pasda/UrbanTreeCanopy_Landcover/MapServer/WmsServer?SERVICE=WMS&\nexport type WMSGetFeatureInfoParameters = WMSCommonParameters & {\n /** Request type */\n request?: 'GetFeatureInfo';\n\n /** x coordinate for the feature info request */\n x: number;\n /** y coordinate for the feature info request */\n y: number;\n /** list of layers to query (could be different from rendered layers) */\n query_layers: string[];\n /** MIME type of returned feature info */\n info_format?: 'text/plain' | 'application/vnd.ogc.gml';\n\n /** Layers to render */\n layers: string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n bbox: [number, number, number, number];\n /** pixel width of returned image */\n width: number;\n /** pixels */\n height: number;\n /** srs for the image (not the bounding box) */\n srs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\nexport type WMSDescribeLayerParameters = WMSCommonParameters & {\n /** Request type */\n request?: 'DescribeLayer';\n};\n\nexport type WMSGetLegendGraphicParameters = WMSCommonParameters & {\n /** Request type */\n request?: 'GetLegendGraphic';\n};\n\n/**\n * The WMSService class provides\n * - provides type safe methods to form URLs to a WMS service\n * - provides type safe methods to query and parse results (and errors) from a WMS service\n * - implements the ImageService interface\n * @note Only the URL parameter conversion is supported. XML posts are not supported.\n */\nexport class WMSService extends ImageSource {\n static type: 'wms' = 'wms';\n static testURL = (url: string): boolean => url.toLowerCase().includes('wms');\n\n props: Required<ImageServiceProps>;\n fetch: (url: string, options?: RequestInit) => Promise<Response>;\n capabilities: WMSCapabilities | null = null;\n\n /** A list of loaders used by the WMSService methods */\n readonly loaders = [\n ImageLoader,\n WMSErrorLoader,\n WMSCapabilitiesLoader,\n WMSFeatureInfoLoader,\n WMSLayerDescriptionLoader\n ];\n\n /** Create a WMSService */\n constructor(props: ImageServiceProps) {\n super();\n this.props = mergeImageServiceProps(props);\n this.fetch = getFetchFunction(this.props);\n this.props.loadOptions = {\n ...this.props.loadOptions,\n // We want error responses to throw exceptions, the WMSErrorLoader can do this\n wms: {...this.props.loadOptions?.wms, throwOnError: true}\n };\n }\n\n // ImageSource implementation\n getMetadata(): Promise<ImageSourceMetadata> {\n return this.getCapabilities();\n }\n\n getImage(parameters: GetImageParameters): Promise<ImageType> {\n return this.getMap(parameters);\n }\n\n // WMS Service API Stubs\n\n /** Get Capabilities */\n async getCapabilities(\n wmsParameters?: WMSGetCapabilitiesParameters,\n vendorParameters?: Record<string, unknown>\n ): Promise<WMSCapabilities> {\n const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);\n const response = await this.fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n this._checkResponse(response, arrayBuffer);\n const capabilities = await WMSCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);\n this.capabilities = capabilities;\n return capabilities;\n }\n\n /** Get a map image */\n async getMap(\n options: WMSGetMapParameters,\n vendorParameters?: Record<string, unknown>\n ): Promise<ImageType> {\n const url = this.getMapURL(options, vendorParameters);\n const response = await this.fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n this._checkResponse(response, arrayBuffer);\n try {\n return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);\n } catch {\n throw this._parseError(arrayBuffer);\n }\n }\n\n /** Get Feature Info for a coordinate */\n async getFeatureInfo(\n options: WMSGetFeatureInfoParameters,\n vendorParameters?: Record<string, unknown>\n ): Promise<WMSFeatureInfo> {\n const url = this.getFeatureInfoURL(options, vendorParameters);\n const response = await this.fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n this._checkResponse(response, arrayBuffer);\n return await WMSFeatureInfoLoader.parse(arrayBuffer, this.props.loadOptions);\n }\n\n /** Get Feature Info for a coordinate */\n async getFeatureInfoText(\n options: WMSGetFeatureInfoParameters,\n vendorParameters?: Record<string, unknown>\n ): Promise<string> {\n options = {...options, info_format: 'text/plain'};\n const url = this.getFeatureInfoURL(options, vendorParameters);\n const response = await this.fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n this._checkResponse(response, arrayBuffer);\n return new TextDecoder().decode(arrayBuffer);\n }\n\n /** Get more information about a layer */\n async describeLayer(\n options: WMSDescribeLayerParameters,\n vendorParameters?: Record<string, unknown>\n ): Promise<WMSLayerDescription> {\n const url = this.describeLayerURL(options, vendorParameters);\n const response = await this.fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n this._checkResponse(response, arrayBuffer);\n return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.props.loadOptions);\n }\n\n /** Get an image with a semantic legend */\n async getLegendGraphic(\n options: WMSGetLegendGraphicParameters,\n vendorParameters?: Record<string, unknown>\n ): Promise<ImageType> {\n const url = this.getLegendGraphicURL(options, vendorParameters);\n const response = await this.fetch(url);\n const arrayBuffer = await response.arrayBuffer();\n this._checkResponse(response, arrayBuffer);\n try {\n return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);\n } catch {\n throw this._parseError(arrayBuffer);\n }\n }\n\n // Typed URL creators\n // For applications that want full control of fetching and parsing\n\n /** Generate a URL for the GetCapabilities request */\n getCapabilitiesURL(\n wmsParameters?: WMSGetCapabilitiesParameters,\n vendorParameters?: Record<string, unknown>\n ): string {\n const options: Required<WMSGetCapabilitiesParameters> = {\n service: 'WMS',\n version: '1.1.1',\n request: 'GetCapabilities',\n ...wmsParameters,\n ...vendorParameters\n };\n return this._getWMSUrl(options, vendorParameters);\n }\n\n /** Generate a URL for the GetMap request */\n getMapURL(\n wmsParameters: WMSGetMapParameters,\n vendorParameters?: Record<string, unknown>\n ): string {\n const options: Required<WMSGetMapParameters> = {\n service: 'WMS',\n version: '1.1.1',\n request: 'GetMap',\n // layers: [],\n // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],\n // width: 1200,\n // height: 900,\n styles: undefined,\n srs: 'EPSG:4326',\n format: 'image/png',\n ...wmsParameters,\n ...vendorParameters\n };\n return this._getWMSUrl(options, vendorParameters);\n }\n\n /** Generate a URL for the GetFeatureInfo request */\n getFeatureInfoURL(\n wmsParameters: WMSGetFeatureInfoParameters,\n vendorParameters?: Record<string, unknown>\n ): string {\n const options: Required<WMSGetFeatureInfoParameters> = {\n service: 'WMS',\n version: '1.1.1',\n request: 'GetFeatureInfo',\n // layers: [],\n // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],\n // width: 1200,\n // height: 900,\n // x: undefined!,\n // y: undefined!,\n // query_layers: [],\n srs: 'EPSG:4326',\n format: 'image/png',\n info_format: 'text/plain',\n styles: undefined,\n ...wmsParameters,\n ...vendorParameters\n };\n return this._getWMSUrl(options, vendorParameters);\n }\n\n /** Generate a URL for the GetFeatureInfo request */\n describeLayerURL(\n wmsParameters: WMSDescribeLayerParameters,\n vendorParameters?: Record<string, unknown>\n ): string {\n const options: Required<WMSDescribeLayerParameters> = {\n service: 'WMS',\n version: '1.1.1',\n request: 'DescribeLayer',\n ...wmsParameters,\n ...vendorParameters\n };\n return this._getWMSUrl(options, vendorParameters);\n }\n\n getLegendGraphicURL(\n wmsParameters: WMSGetLegendGraphicParameters,\n vendorParameters?: Record<string, unknown>\n ): string {\n const options: Required<WMSGetLegendGraphicParameters> = {\n service: 'WMS',\n version: '1.1.1',\n request: 'GetLegendGraphic',\n ...wmsParameters,\n ...vendorParameters\n };\n return this._getWMSUrl(options, vendorParameters);\n }\n\n // INTERNAL METHODS\n\n /**\n * @note case _getWMSUrl may need to be overridden to handle certain backends?\n * */\n protected _getWMSUrl(\n options: Record<string, unknown>,\n vendorParameters?: Record<string, unknown>\n ): 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 encodeURI(url);\n }\n\n /** Checks for and parses a WMS XML formatted ServiceError and throws an exception */\n protected _checkResponse(response: Response, arrayBuffer: ArrayBuffer): void {\n const contentType = response.headers['content-type'];\n if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {\n const error = WMSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);\n throw new Error(error);\n }\n }\n\n /** Error situation detected */\n protected _parseError(arrayBuffer: ArrayBuffer): Error {\n const error = WMSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);\n return new Error(error);\n }\n}\n"],"mappings":";;AAKA,SAAQA,WAAW,QAAO,oBAAoB;AAG9C,SAAQC,WAAW,QAAO,iBAAiB;AA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,CAAC,EAAE;MAClE,MAAMK,KAAK,GAAG3D,cAAc,CAAC4D,SAAS,CAAC1C,WAAW,EAAE,IAAI,CAACf,KAAK,CAACE,WAAW,CAAC;MAC3E,MAAM,IAAIwD,KAAK,CAACF,KAAK,CAAC;IACxB;EACF;;EAGUnC,WAAW,CAACN,WAAwB,EAAS;IACrD,MAAMyC,KAAK,GAAG3D,cAAc,CAAC4D,SAAS,CAAC1C,WAAW,EAAE,IAAI,CAACf,KAAK,CAACE,WAAW,CAAC;IAC3E,OAAO,IAAIwD,KAAK,CAACF,KAAK,CAAC;EACzB;AACF;AAAC,gBA/PY1D,UAAU,UACA,KAAK;AAAA,gBADfA,UAAU,aAEHc,GAAW,IAAcA,GAAG,CAAC+C,WAAW,EAAE,CAACJ,QAAQ,CAAC,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-source.js","names":["ImageSource"],"sources":["../../../../src/lib/data-sources/image-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {ImageType} from '@loaders.gl/images';\n\n/**\n * Normalized capabilities of an Image service\n * @example\n * The WMSService will normalize the response to the WMS `GetCapabilities` data structure extracted from WMS XML response\n * into an ImageSourceMetadata.\n */\nexport type ImageSourceMetadata = {\n name: string;\n title?: string;\n abstract?: string;\n keywords: string[];\n layer: {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: ImageSourceLayer[];\n };\n};\n\nexport type ImageSourceLayer = {\n name: string;\n title?: string;\n srs?: string[];\n boundingBox?: [number, number, number, number];\n layers: ImageSourceLayer[];\n};\n\nexport type GetImageParameters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n /** bounding box of the requested map image */\n bbox: [number, number, number, number];\n /** pixel width of returned image */\n width: number;\n /** pixels */\n height: number;\n /** srs for the image (not the bounding box) */\n srs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\n// Attempt to break down GetImageParameters\nexport type ImageFilters = {\n /** Layers to render */\n layers: string | string[];\n /** Styling */\n styles?: unknown;\n};\n\nexport type ImageRegion = {\n /** bounding box of the requested map image */\n bbox: [number, number, number, number];\n};\n\nexport type ImageFormat = {\n /** pixel width of returned image */\n width: number;\n /** pixels */\n height: number;\n /** srs for the image (not the bounding box) */\n srs?: string;\n /** requested format for the return image */\n format?: 'image/png';\n};\n\n/**\n * MapImageSource - data sources that allow data to be queried by (geospatial) extents\n * @note\n * - If geospatial, bounding box is expected to be in web mercator coordinates\n */\nexport abstract class ImageSource {\n abstract getMetadata(): Promise<ImageSourceMetadata>;\n abstract getImage(parameters: GetImageParameters): Promise<ImageType>;\n}\n"],"mappings":";;AA8EA,OAAO,MAAeA,WAAW,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export function deepStrictEqual(actual, expected, strict) {
|
|
4
|
+
if (actual === expected) {
|
|
5
|
+
return true;
|
|
6
|
+
|
|
7
|
+
} else if (actual instanceof Date && expected instanceof Date) {
|
|
8
|
+
return actual.getTime() === expected.getTime();
|
|
9
|
+
|
|
10
|
+
} else if (actual instanceof RegExp && expected instanceof RegExp) {
|
|
11
|
+
return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase;
|
|
12
|
+
|
|
13
|
+
} else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) {
|
|
14
|
+
return strict ? actual === expected : actual == expected;
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return objEquiv(actual, expected, strict);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const pSlice = Array.prototype.slice;
|
|
22
|
+
function isPrimitive(arg) {
|
|
23
|
+
return arg === null || typeof arg !== 'object' && typeof arg !== 'function';
|
|
24
|
+
}
|
|
25
|
+
function isArguments(object) {
|
|
26
|
+
return Object.prototype.toString.call(object) == '[object Arguments]';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function objEquiv(a, b, strict) {
|
|
30
|
+
if (a === null || a === undefined || b === null || b === undefined) return false;
|
|
31
|
+
if (isPrimitive(a) || isPrimitive(b)) return a === b;
|
|
32
|
+
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
|
|
33
|
+
const aIsArgs = isArguments(a);
|
|
34
|
+
const bIsArgs = isArguments(b);
|
|
35
|
+
if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs) return false;
|
|
36
|
+
if (aIsArgs) {
|
|
37
|
+
a = pSlice.call(a);
|
|
38
|
+
b = pSlice.call(b);
|
|
39
|
+
return deepStrictEqual(a, b, strict);
|
|
40
|
+
}
|
|
41
|
+
const ka = Object.keys(a);
|
|
42
|
+
const kb = Object.keys(b);
|
|
43
|
+
let key;
|
|
44
|
+
let i;
|
|
45
|
+
if (ka.length !== kb.length) return false;
|
|
46
|
+
ka.sort();
|
|
47
|
+
kb.sort();
|
|
48
|
+
for (i = ka.length - 1; i >= 0; i--) {
|
|
49
|
+
if (ka[i] !== kb[i]) return false;
|
|
50
|
+
}
|
|
51
|
+
for (i = ka.length - 1; i >= 0; i--) {
|
|
52
|
+
key = ka[i];
|
|
53
|
+
if (!deepStrictEqual(a[key], b[key], strict)) return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=deep-strict-equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-strict-equal.js","names":["deepStrictEqual","actual","expected","strict","Date","getTime","RegExp","source","global","multiline","lastIndex","ignoreCase","objEquiv","pSlice","Array","prototype","slice","isPrimitive","arg","isArguments","object","Object","toString","call","a","b","undefined","getPrototypeOf","aIsArgs","bIsArgs","ka","keys","kb","key","i","length","sort"],"sources":["../../../../src/lib/gml/deep-strict-equal.ts"],"sourcesContent":["// https://github.com/nodejs/node/commit/c1d82ac2ff15594840e2a1b9531b506ae067ed27;\n\n// http://wiki.commonjs.org/wiki/Unit_Testing/1.0\n//\n// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!\n//\n// Originally from narwhal.js (http://narwhaljs.org)\n// Copyright (c) 2009 Thomas Robinson <280north.com>\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the 'Software'), to\n// deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n// sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n/** @todo replace this ridiculous choice of deepStrictEqual */\n// eslint-disable-next-line complexity\nexport function deepStrictEqual(actual: unknown, expected: unknown, strict?: boolean) {\n // 7.1. All identical values are equivalent, as determined by ===.\n if (actual === expected) {\n return true;\n // } else if (actual instanceof Buffer && expected instanceof Buffer) {\n // return compare(actual, expected) === 0;\n\n // // 7.2. If the expected value is a Date object, the actual value is\n // // equivalent if it is also a Date object that refers to the same time.\n } else if (actual instanceof Date && expected instanceof Date) {\n return actual.getTime() === expected.getTime();\n\n // 7.3 If the expected value is a RegExp object, the actual value is\n // equivalent if it is also a RegExp object with the same source and\n // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).\n } else if (actual instanceof RegExp && expected instanceof RegExp) {\n return (\n actual.source === expected.source &&\n actual.global === expected.global &&\n actual.multiline === expected.multiline &&\n actual.lastIndex === expected.lastIndex &&\n actual.ignoreCase === expected.ignoreCase\n );\n\n // 7.4. Other pairs that do not both pass typeof value == 'object',\n // equivalence is determined by ==.\n } else if (\n (actual === null || typeof actual !== 'object') &&\n (expected === null || typeof expected !== 'object')\n ) {\n // eslint-disable-next-line eqeqeq\n return strict ? actual === expected : actual == expected;\n\n // 7.5 For all other Object pairs, including Array objects, equivalence is\n // determined by having the same number of owned properties (as verified\n // with Object.prototype.hasOwnProperty.call), the same set of keys\n // (although not necessarily the same order), equivalent values for every\n // corresponding key, and an identical 'prototype' property. Note: this\n // accounts for both named and indexed properties on Arrays.\n }\n return objEquiv(actual, expected, strict);\n}\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst pSlice = Array.prototype.slice;\n\nfunction isPrimitive(arg) {\n return arg === null || (typeof arg !== 'object' && typeof arg !== 'function');\n}\n\nfunction isArguments(object) {\n // eslint-disable-next-line eqeqeq\n return Object.prototype.toString.call(object) == '[object Arguments]';\n}\n\n// eslint-disable-next-line complexity\nfunction objEquiv(a: unknown, b: unknown, strict) {\n if (a === null || a === undefined || b === null || b === undefined) return false;\n // if one is a primitive, the other must be same\n if (isPrimitive(a) || isPrimitive(b)) return a === b;\n if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;\n const aIsArgs = isArguments(a);\n const bIsArgs = isArguments(b);\n if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) return false;\n if (aIsArgs) {\n a = pSlice.call(a);\n b = pSlice.call(b);\n return deepStrictEqual(a, b, strict);\n }\n const ka = Object.keys(a);\n const kb = Object.keys(b);\n let key;\n let i;\n // having the same number of owned properties (keys incorporates\n // hasOwnProperty)\n if (ka.length !== kb.length) return false;\n // the same set of keys (although not necessarily the same order),\n ka.sort();\n kb.sort();\n // ~~~cheap key test\n for (i = ka.length - 1; i >= 0; i--) {\n if (ka[i] !== kb[i]) return false;\n }\n // equivalent values for every corresponding key, and\n // ~~~possibly expensive deep test\n for (i = ka.length - 1; i >= 0; i--) {\n key = ka[i];\n if (!deepStrictEqual(a[key], b[key], strict)) return false;\n }\n return true;\n}\n"],"mappings":";;AA4BA,OAAO,SAASA,eAAe,CAACC,MAAe,EAAEC,QAAiB,EAAEC,MAAgB,EAAE;EAEpF,IAAIF,MAAM,KAAKC,QAAQ,EAAE;IACvB,OAAO,IAAI;;EAMb,CAAC,MAAM,IAAID,MAAM,YAAYG,IAAI,IAAIF,QAAQ,YAAYE,IAAI,EAAE;IAC7D,OAAOH,MAAM,CAACI,OAAO,EAAE,KAAKH,QAAQ,CAACG,OAAO,EAAE;;EAKhD,CAAC,MAAM,IAAIJ,MAAM,YAAYK,MAAM,IAAIJ,QAAQ,YAAYI,MAAM,EAAE;IACjE,OACEL,MAAM,CAACM,MAAM,KAAKL,QAAQ,CAACK,MAAM,IACjCN,MAAM,CAACO,MAAM,KAAKN,QAAQ,CAACM,MAAM,IACjCP,MAAM,CAACQ,SAAS,KAAKP,QAAQ,CAACO,SAAS,IACvCR,MAAM,CAACS,SAAS,KAAKR,QAAQ,CAACQ,SAAS,IACvCT,MAAM,CAACU,UAAU,KAAKT,QAAQ,CAACS,UAAU;;EAK7C,CAAC,MAAM,IACL,CAACV,MAAM,KAAK,IAAI,IAAI,OAAOA,MAAM,KAAK,QAAQ,MAC7CC,QAAQ,KAAK,IAAI,IAAI,OAAOA,QAAQ,KAAK,QAAQ,CAAC,EACnD;IAEA,OAAOC,MAAM,GAAGF,MAAM,KAAKC,QAAQ,GAAGD,MAAM,IAAIC,QAAQ;;EAQ1D;;EACA,OAAOU,QAAQ,CAACX,MAAM,EAAEC,QAAQ,EAAEC,MAAM,CAAC;AAC3C;;AAGA,MAAMU,MAAM,GAAGC,KAAK,CAACC,SAAS,CAACC,KAAK;AAEpC,SAASC,WAAW,CAACC,GAAG,EAAE;EACxB,OAAOA,GAAG,KAAK,IAAI,IAAK,OAAOA,GAAG,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EAAE,OAAO,KAAK;EAEzCL,EAAE,CAACM,IAAI,EAAE;EACTJ,EAAE,CAACI,IAAI,EAAE;EAET,KAAKF,CAAC,GAAGJ,EAAE,CAACK,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IACnC,IAAIJ,EAAE,CAACI,CAAC,CAAC,KAAKF,EAAE,CAACE,CAAC,CAAC,EAAE,OAAO,KAAK;EACnC;EAGA,KAAKA,CAAC,GAAGJ,EAAE,CAACK,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IACnCD,GAAG,GAAGH,EAAE,CAACI,CAAC,CAAC;IACX,IAAI,CAAClC,eAAe,CAACwB,CAAC,CAACS,GAAG,CAAC,EAAER,CAAC,CAACQ,GAAG,CAAC,EAAE9B,MAAM,CAAC,EAAE,OAAO,KAAK;EAC5D;EACA,OAAO,IAAI;AACb"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import { XMLLoader } from '@loaders.gl/xml';
|
|
4
|
+
import { deepStrictEqual } from './deep-strict-equal';
|
|
5
|
+
import rewind from '@turf/rewind';
|
|
6
|
+
function noTransform() {
|
|
7
|
+
for (var _len = arguments.length, coords = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
8
|
+
coords[_key] = arguments[_key];
|
|
9
|
+
}
|
|
10
|
+
return coords;
|
|
11
|
+
}
|
|
12
|
+
export function parseGML(text, options) {
|
|
13
|
+
const parsedXML = XMLLoader.parseTextSync(text, options);
|
|
14
|
+
options = {
|
|
15
|
+
transformCoords: noTransform,
|
|
16
|
+
stride: 2,
|
|
17
|
+
...options
|
|
18
|
+
};
|
|
19
|
+
const context = createChildContext(parsedXML, options, {});
|
|
20
|
+
return parseGMLToGeometry(parsedXML, options, context);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function parseGMLToGeometry(inputXML, options, context) {
|
|
24
|
+
const childContext = createChildContext(inputXML, options, context);
|
|
25
|
+
let geometry = null;
|
|
26
|
+
const [name, xml] = getFirstKeyValue(inputXML);
|
|
27
|
+
switch (name) {
|
|
28
|
+
|
|
29
|
+
case 'gml:LineString':
|
|
30
|
+
geometry = {
|
|
31
|
+
type: 'LineString',
|
|
32
|
+
coordinates: parseLinearRingOrLineString(xml, options, childContext)
|
|
33
|
+
};
|
|
34
|
+
break;
|
|
35
|
+
|
|
36
|
+
case 'gml:Polygon':
|
|
37
|
+
case 'gml:Rectangle':
|
|
38
|
+
geometry = {
|
|
39
|
+
type: 'Polygon',
|
|
40
|
+
coordinates: parsePolygonOrRectangle(xml, options, childContext)
|
|
41
|
+
};
|
|
42
|
+
break;
|
|
43
|
+
case 'gml:Surface':
|
|
44
|
+
geometry = {
|
|
45
|
+
type: 'MultiPolygon',
|
|
46
|
+
coordinates: parseSurface(xml, options, childContext)
|
|
47
|
+
};
|
|
48
|
+
break;
|
|
49
|
+
case 'gml:MultiSurface':
|
|
50
|
+
geometry = {
|
|
51
|
+
type: 'MultiPolygon',
|
|
52
|
+
coordinates: parseMultiSurface(xml, options, childContext)
|
|
53
|
+
};
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return rewind(geometry, {
|
|
60
|
+
mutate: true
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function parseCoords(s, options, context) {
|
|
65
|
+
const stride = context.srsDimension || options.stride || 2;
|
|
66
|
+
|
|
67
|
+
const coords = s.replace(/\s+/g, ' ').trim().split(' ');
|
|
68
|
+
if (coords.length === 0 || coords.length % stride !== 0) {
|
|
69
|
+
throw new Error("invalid coordinates list (stride ".concat(stride, ")"));
|
|
70
|
+
}
|
|
71
|
+
const points = [];
|
|
72
|
+
for (let i = 0; i < coords.length - 1; i += stride) {
|
|
73
|
+
var _options$transformCoo;
|
|
74
|
+
const point = coords.slice(i, i + stride).map(parseFloat);
|
|
75
|
+
points.push(((_options$transformCoo = options.transformCoords) === null || _options$transformCoo === void 0 ? void 0 : _options$transformCoo.call(options, ...point)) || point);
|
|
76
|
+
}
|
|
77
|
+
return points;
|
|
78
|
+
}
|
|
79
|
+
export function parsePosList(xml, options, context) {
|
|
80
|
+
const childContext = createChildContext(xml, options, context);
|
|
81
|
+
const coords = textOf(xml);
|
|
82
|
+
if (!coords) {
|
|
83
|
+
throw new Error('invalid gml:posList element');
|
|
84
|
+
}
|
|
85
|
+
return parseCoords(coords, options, childContext);
|
|
86
|
+
}
|
|
87
|
+
export function parsePos(xml, options, context) {
|
|
88
|
+
const childContext = createChildContext(xml, options, context);
|
|
89
|
+
const coords = textOf(xml);
|
|
90
|
+
if (!coords) {
|
|
91
|
+
throw new Error('invalid gml:pos element');
|
|
92
|
+
}
|
|
93
|
+
const points = parseCoords(coords, options, childContext);
|
|
94
|
+
if (points.length !== 1) {
|
|
95
|
+
throw new Error('gml:pos must have 1 point');
|
|
96
|
+
}
|
|
97
|
+
return points[0];
|
|
98
|
+
}
|
|
99
|
+
export function parsePoint(xml, options, context) {
|
|
100
|
+
const childContext = createChildContext(xml, options, context);
|
|
101
|
+
|
|
102
|
+
const pos = findIn(xml, 'gml:pos');
|
|
103
|
+
if (!pos) {
|
|
104
|
+
throw new Error('invalid gml:Point element, expected a gml:pos subelement');
|
|
105
|
+
}
|
|
106
|
+
return parsePos(pos, options, childContext);
|
|
107
|
+
}
|
|
108
|
+
export function parseLinearRingOrLineString(xml, options, context) {
|
|
109
|
+
const childContext = createChildContext(xml, options, context);
|
|
110
|
+
let points = [];
|
|
111
|
+
const posList = findIn(xml, 'gml:posList');
|
|
112
|
+
if (posList) {
|
|
113
|
+
points = parsePosList(posList, options, childContext);
|
|
114
|
+
} else {
|
|
115
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
116
|
+
switch (childName) {
|
|
117
|
+
case 'gml:Point':
|
|
118
|
+
points.push(parsePoint(childXML, options, childContext));
|
|
119
|
+
break;
|
|
120
|
+
case 'gml:pos':
|
|
121
|
+
points.push(parsePos(childXML, options, childContext));
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (points.length === 0) {
|
|
129
|
+
throw new Error("".concat(xml.name, " must have > 0 points"));
|
|
130
|
+
}
|
|
131
|
+
return points;
|
|
132
|
+
}
|
|
133
|
+
export function parseCurveSegments(xml, options, context) {
|
|
134
|
+
const points = [];
|
|
135
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
136
|
+
switch (childName) {
|
|
137
|
+
case 'gml:LineStringSegment':
|
|
138
|
+
const points2 = parseLinearRingOrLineString(childXML, options, context);
|
|
139
|
+
|
|
140
|
+
const end = points[points.length - 1];
|
|
141
|
+
const start = points2[0];
|
|
142
|
+
if (end && start && deepStrictEqual(end, start)) {
|
|
143
|
+
points2.shift();
|
|
144
|
+
}
|
|
145
|
+
points.push(...points2);
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (points.length === 0) {
|
|
152
|
+
throw new Error('gml:Curve > gml:segments must have > 0 points');
|
|
153
|
+
}
|
|
154
|
+
return points;
|
|
155
|
+
}
|
|
156
|
+
export function parseRing(xml, options, context) {
|
|
157
|
+
const childContext = createChildContext(xml, options, context);
|
|
158
|
+
const points = [];
|
|
159
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
160
|
+
switch (childName) {
|
|
161
|
+
case 'gml:curveMember':
|
|
162
|
+
let points2;
|
|
163
|
+
const lineString = findIn(childXML, 'gml:LineString');
|
|
164
|
+
if (lineString) {
|
|
165
|
+
points2 = parseLinearRingOrLineString(lineString, options, childContext);
|
|
166
|
+
} else {
|
|
167
|
+
const segments = findIn(childXML, 'gml:Curve', 'gml:segments');
|
|
168
|
+
if (!segments) {
|
|
169
|
+
throw new Error("invalid ".concat(childName, " element"));
|
|
170
|
+
}
|
|
171
|
+
points2 = parseCurveSegments(segments, options, childContext);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const end = points[points.length - 1];
|
|
175
|
+
const start = points2[0];
|
|
176
|
+
if (end && start && deepStrictEqual(end, start)) {
|
|
177
|
+
points2.shift();
|
|
178
|
+
}
|
|
179
|
+
points.push(...points2);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (points.length < 4) {
|
|
184
|
+
throw new Error("".concat(xml.name, " must have >= 4 points"));
|
|
185
|
+
}
|
|
186
|
+
return points;
|
|
187
|
+
}
|
|
188
|
+
export function parseExteriorOrInterior(xml, options, context) {
|
|
189
|
+
const linearRing = findIn(xml, 'gml:LinearRing');
|
|
190
|
+
if (linearRing) {
|
|
191
|
+
return parseLinearRingOrLineString(linearRing, options, context);
|
|
192
|
+
}
|
|
193
|
+
const ring = findIn(xml, 'gml:Ring');
|
|
194
|
+
if (!ring) {
|
|
195
|
+
throw new Error("invalid ".concat(xml.name, " element"));
|
|
196
|
+
}
|
|
197
|
+
return parseRing(ring, options, context);
|
|
198
|
+
}
|
|
199
|
+
export function parsePolygonOrRectangle(xml, options, context) {
|
|
200
|
+
const childContext = createChildContext(xml, options, context);
|
|
201
|
+
const exterior = findIn(xml, 'gml:exterior');
|
|
202
|
+
if (!exterior) {
|
|
203
|
+
throw new Error("invalid ".concat(xml.name, " element"));
|
|
204
|
+
}
|
|
205
|
+
const pointLists = [parseExteriorOrInterior(exterior, options, childContext)];
|
|
206
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
207
|
+
switch (childName) {
|
|
208
|
+
case 'gml:interior':
|
|
209
|
+
pointLists.push(parseExteriorOrInterior(childXML, options, childContext));
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return pointLists;
|
|
214
|
+
}
|
|
215
|
+
export function parseSurface(xml, options, context) {
|
|
216
|
+
const childContext = createChildContext(xml, options, context);
|
|
217
|
+
const patches = findIn(xml, 'gml:patches');
|
|
218
|
+
if (!patches) {
|
|
219
|
+
throw new Error("invalid ".concat(xml.name, " element"));
|
|
220
|
+
}
|
|
221
|
+
const polygons = [];
|
|
222
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
223
|
+
switch (childName) {
|
|
224
|
+
case 'gml:PolygonPatch':
|
|
225
|
+
case 'gml:Rectangle':
|
|
226
|
+
polygons.push(parsePolygonOrRectangle(childXML, options, childContext));
|
|
227
|
+
break;
|
|
228
|
+
default:
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (polygons.length === 0) {
|
|
233
|
+
throw new Error("".concat(xml.name, " must have > 0 polygons"));
|
|
234
|
+
}
|
|
235
|
+
return polygons;
|
|
236
|
+
}
|
|
237
|
+
export function parseCompositeSurface(xml, options, context) {
|
|
238
|
+
const childContext = createChildContext(xml, options, context);
|
|
239
|
+
const polygons = [];
|
|
240
|
+
for (const [childName, childXML] of Object.entries(xml)) {
|
|
241
|
+
switch (childName) {
|
|
242
|
+
case 'gml:surfaceMember':
|
|
243
|
+
case 'gml:surfaceMembers':
|
|
244
|
+
const [c2Name, c2Xml] = getFirstKeyValue(childXML);
|
|
245
|
+
switch (c2Name) {
|
|
246
|
+
case 'gml:Surface':
|
|
247
|
+
polygons.push(...parseSurface(c2Xml, options, childContext));
|
|
248
|
+
break;
|
|
249
|
+
case 'gml:Polygon':
|
|
250
|
+
polygons.push(parsePolygonOrRectangle(c2Xml, options, childContext));
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (polygons.length === 0) {
|
|
257
|
+
throw new Error("".concat(xml.name, " must have > 0 polygons"));
|
|
258
|
+
}
|
|
259
|
+
return polygons;
|
|
260
|
+
}
|
|
261
|
+
export function parseMultiSurface(xml, options, context) {
|
|
262
|
+
let el = xml;
|
|
263
|
+
const surfaceMembers = findIn(xml, 'gml:LinearRing');
|
|
264
|
+
if (surfaceMembers) {
|
|
265
|
+
el = surfaceMembers;
|
|
266
|
+
}
|
|
267
|
+
const polygons = [];
|
|
268
|
+
for (const [childName, childXML] of Object.entries(el)) {
|
|
269
|
+
switch (childName) {
|
|
270
|
+
case 'gml:Surface':
|
|
271
|
+
const polygons2 = parseSurface(childXML, options, context);
|
|
272
|
+
polygons.push(...polygons2);
|
|
273
|
+
break;
|
|
274
|
+
case 'gml:surfaceMember':
|
|
275
|
+
const polygons3 = parseSurfaceMember(childXML, options, context);
|
|
276
|
+
polygons.push(...polygons3);
|
|
277
|
+
break;
|
|
278
|
+
case 'gml:surfaceMembers':
|
|
279
|
+
const polygonXML = findIn(childXML, 'gml:Polygon');
|
|
280
|
+
for (const surfaceMemberXML of polygonXML) {
|
|
281
|
+
const polygons3 = parseSurfaceMember(surfaceMemberXML, options, context);
|
|
282
|
+
polygons.push(...polygons3);
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (polygons.length === 0) {
|
|
288
|
+
throw new Error("".concat(xml.name, " must have > 0 polygons"));
|
|
289
|
+
}
|
|
290
|
+
return polygons;
|
|
291
|
+
}
|
|
292
|
+
function parseSurfaceMember(xml, options, context) {
|
|
293
|
+
const [childName, childXml] = getFirstKeyValue(xml);
|
|
294
|
+
switch (childName) {
|
|
295
|
+
case 'gml:CompositeSurface':
|
|
296
|
+
return parseCompositeSurface(childXml, options, context);
|
|
297
|
+
case 'gml:Surface':
|
|
298
|
+
return parseSurface(childXml, options, context);
|
|
299
|
+
case 'gml:Polygon':
|
|
300
|
+
return [parsePolygonOrRectangle(childXml, options, context)];
|
|
301
|
+
}
|
|
302
|
+
throw new Error("".concat(childName, " must have polygons"));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function textOf(el) {
|
|
306
|
+
if (typeof el !== 'string') {
|
|
307
|
+
throw new Error('expected string');
|
|
308
|
+
}
|
|
309
|
+
return el;
|
|
310
|
+
}
|
|
311
|
+
function findIn(root) {
|
|
312
|
+
let el = root;
|
|
313
|
+
for (var _len2 = arguments.length, tags = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
314
|
+
tags[_key2 - 1] = arguments[_key2];
|
|
315
|
+
}
|
|
316
|
+
for (const tag of tags) {
|
|
317
|
+
const child = el[tag];
|
|
318
|
+
if (!child) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
el = child;
|
|
322
|
+
}
|
|
323
|
+
return el;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function getFirstKeyValue(object) {
|
|
327
|
+
if (object && typeof object === 'object') {
|
|
328
|
+
for (const [key, value] of Object.entries(object)) {
|
|
329
|
+
return [key, value];
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return ['', null];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function createChildContext(xml, options, context) {
|
|
336
|
+
const srsDimensionAttribute = xml.attributes && xml.attributes.srsDimension;
|
|
337
|
+
if (srsDimensionAttribute) {
|
|
338
|
+
const srsDimension = parseInt(srsDimensionAttribute);
|
|
339
|
+
if (Number.isNaN(srsDimension) || srsDimension <= 0) {
|
|
340
|
+
throw new Error("invalid srsDimension attribute value \"".concat(srsDimensionAttribute, "\", expected a positive integer"));
|
|
341
|
+
}
|
|
342
|
+
const childContext = Object.create(context);
|
|
343
|
+
childContext.srsDimension = srsDimension;
|
|
344
|
+
return childContext;
|
|
345
|
+
}
|
|
346
|
+
return context;
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=parse-gml.js.map
|