@loaders.gl/wms 4.0.0-beta.1 → 4.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/dist/{esm/csw-capabilities-loader.js → csw-capabilities-loader.js} +2 -2
  2. package/dist/csw-capabilities-loader.js.map +1 -0
  3. package/dist/{esm/csw-domain-loader.js → csw-domain-loader.js} +2 -2
  4. package/dist/csw-domain-loader.js.map +1 -0
  5. package/dist/{esm/csw-records-loader.js → csw-records-loader.js} +2 -2
  6. package/dist/csw-records-loader.js.map +1 -0
  7. package/dist/{dist.min.js → dist.dev.js} +1151 -1224
  8. package/dist/{esm/gml-loader.js → gml-loader.js} +2 -2
  9. package/dist/gml-loader.js.map +1 -0
  10. package/dist/index.cjs +1641 -0
  11. package/dist/index.js +18 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/{esm/lerc-loader.js → lerc-loader.js} +1 -1
  14. package/dist/lerc-loader.js.map +1 -0
  15. package/dist/{esm/lib → lib}/parsers/csw/parse-csw-capabilities.js +1 -1
  16. package/dist/lib/parsers/csw/parse-csw-capabilities.js.map +1 -0
  17. package/dist/{esm/lib → lib}/parsers/csw/parse-csw-domain.js +1 -1
  18. package/dist/lib/parsers/csw/parse-csw-domain.js.map +1 -0
  19. package/dist/{esm/lib → lib}/parsers/csw/parse-csw-records.js +2 -2
  20. package/dist/lib/parsers/csw/parse-csw-records.js.map +1 -0
  21. package/dist/{esm/lib → lib}/parsers/csw/parse-exception-report.js +1 -1
  22. package/dist/lib/parsers/csw/parse-exception-report.js.map +1 -0
  23. package/dist/lib/parsers/gml/deep-strict-equal.js.map +1 -0
  24. package/dist/{esm/lib → lib}/parsers/gml/parse-gml.js +13 -13
  25. package/dist/lib/parsers/gml/parse-gml.js.map +1 -0
  26. package/dist/lib/parsers/lerc/lerc-types.js.map +1 -0
  27. package/dist/{esm/lib → lib}/parsers/wms/parse-wms-capabilities.js +1 -1
  28. package/dist/lib/parsers/wms/parse-wms-capabilities.js.map +1 -0
  29. package/dist/lib/parsers/wms/parse-wms-error.js.map +1 -0
  30. package/dist/lib/parsers/wms/parse-wms-features.js.map +1 -0
  31. package/dist/lib/parsers/wms/parse-wms-layer-description.js.map +1 -0
  32. package/dist/lib/parsers/xml/parse-xml-helpers.js.map +1 -0
  33. package/dist/lib/services/create-image-service.js.map +1 -0
  34. package/dist/{esm/lib → lib}/services/image-service.js +4 -5
  35. package/dist/lib/services/image-service.js.map +1 -0
  36. package/dist/{esm/services → services}/arcgis/arcgis-image-service.js +7 -7
  37. package/dist/services/arcgis/arcgis-image-service.js.map +1 -0
  38. package/dist/{esm/services → services}/arcgis/arcgis-server.js +5 -5
  39. package/dist/services/arcgis/arcgis-server.js.map +1 -0
  40. package/dist/services/create-image-source.js +8 -0
  41. package/dist/services/create-image-source.js.map +1 -0
  42. package/dist/services/ogc/csw-service.d.ts +1 -1
  43. package/dist/services/ogc/csw-service.d.ts.map +1 -1
  44. package/dist/{esm/services → services}/ogc/csw-service.js +10 -11
  45. package/dist/services/ogc/csw-service.js.map +1 -0
  46. package/dist/services/ogc/wms-service.d.ts.map +1 -1
  47. package/dist/{esm/services → services}/ogc/wms-service.js +12 -12
  48. package/dist/services/ogc/wms-service.js.map +1 -0
  49. package/dist/wip/data-source.js.map +1 -0
  50. package/dist/wip/lib/wcs/parse-wcs-capabilities.js.map +1 -0
  51. package/dist/wip/lib/wfs/parse-wfs-capabilities.js.map +1 -0
  52. package/dist/wip/lib/wfs/parse-wfs.js.map +1 -0
  53. package/dist/wip/lib/wmts/parse-wmts-capabilities.js.map +1 -0
  54. package/dist/wip/lib/wmts/parse-wmts.js.map +1 -0
  55. package/dist/{esm/wip → wip}/services/arcgis-feature-service.js +3 -4
  56. package/dist/wip/services/arcgis-feature-service.js.map +1 -0
  57. package/dist/{esm/wip → wip}/wcs-capabilities-loader.js +2 -2
  58. package/dist/wip/wcs-capabilities-loader.js.map +1 -0
  59. package/dist/{esm/wip → wip}/wfs-capabilities-loader.js +2 -2
  60. package/dist/wip/wfs-capabilities-loader.js.map +1 -0
  61. package/dist/{esm/wip → wip}/wms-feature-info-loader.js +2 -2
  62. package/dist/wip/wms-feature-info-loader.js.map +1 -0
  63. package/dist/{esm/wip → wip}/wms-layer-description-loader.js +2 -2
  64. package/dist/wip/wms-layer-description-loader.js.map +1 -0
  65. package/dist/{esm/wip → wip}/wmts-capabilities-loader.js +2 -2
  66. package/dist/wip/wmts-capabilities-loader.js.map +1 -0
  67. package/dist/{esm/wms-capabilities-loader.js → wms-capabilities-loader.js} +2 -2
  68. package/dist/wms-capabilities-loader.js.map +1 -0
  69. package/dist/{esm/wms-error-loader.js → wms-error-loader.js} +3 -3
  70. package/dist/wms-error-loader.js.map +1 -0
  71. package/package.json +18 -10
  72. package/src/services/ogc/csw-service.ts +1 -1
  73. package/src/services/ogc/wms-service.ts +1 -0
  74. package/dist/bundle.d.ts +0 -2
  75. package/dist/bundle.d.ts.map +0 -1
  76. package/dist/es5/bundle.js +0 -6
  77. package/dist/es5/bundle.js.map +0 -1
  78. package/dist/es5/csw-capabilities-loader.js +0 -49
  79. package/dist/es5/csw-capabilities-loader.js.map +0 -1
  80. package/dist/es5/csw-domain-loader.js +0 -49
  81. package/dist/es5/csw-domain-loader.js.map +0 -1
  82. package/dist/es5/csw-records-loader.js +0 -49
  83. package/dist/es5/csw-records-loader.js.map +0 -1
  84. package/dist/es5/gml-loader.js +0 -49
  85. package/dist/es5/gml-loader.js.map +0 -1
  86. package/dist/es5/index.js +0 -131
  87. package/dist/es5/index.js.map +0 -1
  88. package/dist/es5/lerc-loader.js +0 -67
  89. package/dist/es5/lerc-loader.js.map +0 -1
  90. package/dist/es5/lib/parsers/csw/parse-csw-capabilities.js +0 -25
  91. package/dist/es5/lib/parsers/csw/parse-csw-capabilities.js.map +0 -1
  92. package/dist/es5/lib/parsers/csw/parse-csw-domain.js +0 -43
  93. package/dist/es5/lib/parsers/csw/parse-csw-domain.js.map +0 -1
  94. package/dist/es5/lib/parsers/csw/parse-csw-records.js +0 -76
  95. package/dist/es5/lib/parsers/csw/parse-csw-records.js.map +0 -1
  96. package/dist/es5/lib/parsers/csw/parse-exception-report.js +0 -16
  97. package/dist/es5/lib/parsers/csw/parse-exception-report.js.map +0 -1
  98. package/dist/es5/lib/parsers/gml/deep-strict-equal.js +0 -56
  99. package/dist/es5/lib/parsers/gml/deep-strict-equal.js.map +0 -1
  100. package/dist/es5/lib/parsers/gml/parse-gml.js +0 -405
  101. package/dist/es5/lib/parsers/gml/parse-gml.js.map +0 -1
  102. package/dist/es5/lib/parsers/lerc/lerc-types.js +0 -2
  103. package/dist/es5/lib/parsers/lerc/lerc-types.js.map +0 -1
  104. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js +0 -274
  105. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js.map +0 -1
  106. package/dist/es5/lib/parsers/wms/parse-wms-error.js +0 -15
  107. package/dist/es5/lib/parsers/wms/parse-wms-error.js.map +0 -1
  108. package/dist/es5/lib/parsers/wms/parse-wms-features.js +0 -32
  109. package/dist/es5/lib/parsers/wms/parse-wms-features.js.map +0 -1
  110. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js +0 -13
  111. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js.map +0 -1
  112. package/dist/es5/lib/parsers/xml/parse-xml-helpers.js +0 -67
  113. package/dist/es5/lib/parsers/xml/parse-xml-helpers.js.map +0 -1
  114. package/dist/es5/lib/services/create-image-service.js +0 -53
  115. package/dist/es5/lib/services/create-image-service.js.map +0 -1
  116. package/dist/es5/lib/services/image-service.js +0 -118
  117. package/dist/es5/lib/services/image-service.js.map +0 -1
  118. package/dist/es5/services/arcgis/arcgis-image-service.js +0 -168
  119. package/dist/es5/services/arcgis/arcgis-image-service.js.map +0 -1
  120. package/dist/es5/services/arcgis/arcgis-server.js +0 -111
  121. package/dist/es5/services/arcgis/arcgis-server.js.map +0 -1
  122. package/dist/es5/services/create-image-source.js +0 -14
  123. package/dist/es5/services/create-image-source.js.map +0 -1
  124. package/dist/es5/services/ogc/csw-service.js +0 -359
  125. package/dist/es5/services/ogc/csw-service.js.map +0 -1
  126. package/dist/es5/services/ogc/wms-service.js +0 -539
  127. package/dist/es5/services/ogc/wms-service.js.map +0 -1
  128. package/dist/es5/wip/data-source.js +0 -2
  129. package/dist/es5/wip/data-source.js.map +0 -1
  130. package/dist/es5/wip/lib/wcs/parse-wcs-capabilities.js +0 -22
  131. package/dist/es5/wip/lib/wcs/parse-wcs-capabilities.js.map +0 -1
  132. package/dist/es5/wip/lib/wfs/parse-wfs-capabilities.js +0 -23
  133. package/dist/es5/wip/lib/wfs/parse-wfs-capabilities.js.map +0 -1
  134. package/dist/es5/wip/lib/wfs/parse-wfs.js +0 -41
  135. package/dist/es5/wip/lib/wfs/parse-wfs.js.map +0 -1
  136. package/dist/es5/wip/lib/wmts/parse-wmts-capabilities.js +0 -23
  137. package/dist/es5/wip/lib/wmts/parse-wmts-capabilities.js.map +0 -1
  138. package/dist/es5/wip/lib/wmts/parse-wmts.js +0 -41
  139. package/dist/es5/wip/lib/wmts/parse-wmts.js.map +0 -1
  140. package/dist/es5/wip/services/arcgis-feature-service.js +0 -40
  141. package/dist/es5/wip/services/arcgis-feature-service.js.map +0 -1
  142. package/dist/es5/wip/wcs-capabilities-loader.js +0 -51
  143. package/dist/es5/wip/wcs-capabilities-loader.js.map +0 -1
  144. package/dist/es5/wip/wfs-capabilities-loader.js +0 -51
  145. package/dist/es5/wip/wfs-capabilities-loader.js.map +0 -1
  146. package/dist/es5/wip/wms-feature-info-loader.js +0 -42
  147. package/dist/es5/wip/wms-feature-info-loader.js.map +0 -1
  148. package/dist/es5/wip/wms-layer-description-loader.js +0 -42
  149. package/dist/es5/wip/wms-layer-description-loader.js.map +0 -1
  150. package/dist/es5/wip/wmts-capabilities-loader.js +0 -51
  151. package/dist/es5/wip/wmts-capabilities-loader.js.map +0 -1
  152. package/dist/es5/wms-capabilities-loader.js +0 -49
  153. package/dist/es5/wms-capabilities-loader.js.map +0 -1
  154. package/dist/es5/wms-error-loader.js +0 -66
  155. package/dist/es5/wms-error-loader.js.map +0 -1
  156. package/dist/esm/bundle.js +0 -4
  157. package/dist/esm/bundle.js.map +0 -1
  158. package/dist/esm/csw-capabilities-loader.js.map +0 -1
  159. package/dist/esm/csw-domain-loader.js.map +0 -1
  160. package/dist/esm/csw-records-loader.js.map +0 -1
  161. package/dist/esm/gml-loader.js.map +0 -1
  162. package/dist/esm/index.js +0 -18
  163. package/dist/esm/index.js.map +0 -1
  164. package/dist/esm/lerc-loader.js.map +0 -1
  165. package/dist/esm/lib/parsers/csw/parse-csw-capabilities.js.map +0 -1
  166. package/dist/esm/lib/parsers/csw/parse-csw-domain.js.map +0 -1
  167. package/dist/esm/lib/parsers/csw/parse-csw-records.js.map +0 -1
  168. package/dist/esm/lib/parsers/csw/parse-exception-report.js.map +0 -1
  169. package/dist/esm/lib/parsers/gml/deep-strict-equal.js.map +0 -1
  170. package/dist/esm/lib/parsers/gml/parse-gml.js.map +0 -1
  171. package/dist/esm/lib/parsers/lerc/lerc-types.js.map +0 -1
  172. package/dist/esm/lib/parsers/wms/parse-wms-capabilities.js.map +0 -1
  173. package/dist/esm/lib/parsers/wms/parse-wms-error.js.map +0 -1
  174. package/dist/esm/lib/parsers/wms/parse-wms-features.js.map +0 -1
  175. package/dist/esm/lib/parsers/wms/parse-wms-layer-description.js.map +0 -1
  176. package/dist/esm/lib/parsers/xml/parse-xml-helpers.js.map +0 -1
  177. package/dist/esm/lib/services/create-image-service.js.map +0 -1
  178. package/dist/esm/lib/services/image-service.js.map +0 -1
  179. package/dist/esm/services/arcgis/arcgis-image-service.js.map +0 -1
  180. package/dist/esm/services/arcgis/arcgis-server.js.map +0 -1
  181. package/dist/esm/services/create-image-source.js +0 -8
  182. package/dist/esm/services/create-image-source.js.map +0 -1
  183. package/dist/esm/services/ogc/csw-service.js.map +0 -1
  184. package/dist/esm/services/ogc/wms-service.js.map +0 -1
  185. package/dist/esm/wip/data-source.js.map +0 -1
  186. package/dist/esm/wip/lib/wcs/parse-wcs-capabilities.js.map +0 -1
  187. package/dist/esm/wip/lib/wfs/parse-wfs-capabilities.js.map +0 -1
  188. package/dist/esm/wip/lib/wfs/parse-wfs.js.map +0 -1
  189. package/dist/esm/wip/lib/wmts/parse-wmts-capabilities.js.map +0 -1
  190. package/dist/esm/wip/lib/wmts/parse-wmts.js.map +0 -1
  191. package/dist/esm/wip/services/arcgis-feature-service.js.map +0 -1
  192. package/dist/esm/wip/services/wmts-service.ts.disabled +0 -348
  193. package/dist/esm/wip/wcs-capabilities-loader.js.map +0 -1
  194. package/dist/esm/wip/wfs-capabilities-loader.js.map +0 -1
  195. package/dist/esm/wip/wms-feature-info-loader.js.map +0 -1
  196. package/dist/esm/wip/wms-layer-description-loader.js.map +0 -1
  197. package/dist/esm/wip/wms-layer-description-loader.md.disabled.md +0 -47
  198. package/dist/esm/wip/wmts-capabilities-loader.js.map +0 -1
  199. package/dist/esm/wms-capabilities-loader.js.map +0 -1
  200. package/dist/esm/wms-error-loader.js.map +0 -1
  201. package/src/bundle.ts +0 -6
  202. /package/dist/{esm/lib → lib}/parsers/gml/deep-strict-equal.js +0 -0
  203. /package/dist/{esm/lib → lib}/parsers/lerc/lerc-types.js +0 -0
  204. /package/dist/{esm/lib → lib}/parsers/wms/parse-wms-error.js +0 -0
  205. /package/dist/{esm/lib → lib}/parsers/wms/parse-wms-features.js +0 -0
  206. /package/dist/{esm/lib → lib}/parsers/wms/parse-wms-layer-description.js +0 -0
  207. /package/dist/{esm/lib → lib}/parsers/xml/parse-xml-helpers.js +0 -0
  208. /package/dist/{esm/lib → lib}/services/create-image-service.js +0 -0
  209. /package/dist/{esm/wip → wip}/data-source.js +0 -0
  210. /package/dist/{esm/wip → wip}/lib/wcs/parse-wcs-capabilities.js +0 -0
  211. /package/dist/{esm/wip → wip}/lib/wfs/parse-wfs-capabilities.js +0 -0
  212. /package/dist/{esm/wip → wip}/lib/wfs/parse-wfs.js +0 -0
  213. /package/dist/{esm/wip → wip}/lib/wmts/parse-wmts-capabilities.js +0 -0
  214. /package/dist/{esm/wip → wip}/lib/wmts/parse-wmts.js +0 -0
  215. /package/dist/{es5/wip → wip}/services/wmts-service.ts.disabled +0 -0
  216. /package/dist/{es5/wip → wip}/wms-layer-description-loader.md.disabled.md +0 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,1641 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ CSWCapabilitiesLoader: () => CSWCapabilitiesLoader,
34
+ CSWDomainLoader: () => CSWDomainLoader,
35
+ CSWRecordsLoader: () => CSWRecordsLoader,
36
+ CSWService: () => CSWService,
37
+ ImageService: () => ImageService,
38
+ ImageSource: () => import_loader_utils5.ImageSource,
39
+ WMSCapabilitiesLoader: () => WMSCapabilitiesLoader,
40
+ WMSErrorLoader: () => WMSErrorLoader,
41
+ WMSService: () => WMSService,
42
+ WMSSource: () => WMSSource,
43
+ _ArcGISImageService: () => ArcGISImageService,
44
+ _GMLLoader: () => GMLLoader,
45
+ _WFSCapabilitiesLoader: () => WFSCapabilitiesLoader,
46
+ _WMSFeatureInfoLoader: () => WMSFeatureInfoLoader,
47
+ _WMSLayerDescriptionLoader: () => WMSLayerDescriptionLoader,
48
+ _getArcGISServices: () => getArcGISServices,
49
+ createImageService: () => createImageService,
50
+ createImageSource: () => createImageSource
51
+ });
52
+ module.exports = __toCommonJS(src_exports);
53
+
54
+ // src/lib/parsers/csw/parse-csw-capabilities.ts
55
+ var import_xml = require("@loaders.gl/xml");
56
+
57
+ // src/lib/parsers/csw/parse-exception-report.ts
58
+ function parseExceptionReport(parsedXML) {
59
+ var _a, _b, _c;
60
+ const exceptionReport = parsedXML.exceptionReport;
61
+ if (!exceptionReport) {
62
+ return;
63
+ }
64
+ const errorMessage = ((_a = exceptionReport.exception) == null ? void 0 : _a.exceptionText) || ((_b = exceptionReport.exception) == null ? void 0 : _b.exceptionCode) || ((_c = exceptionReport.exception) == null ? void 0 : _c.locator) || "server error";
65
+ throw new Error(`Catalog Server: ${errorMessage}`);
66
+ }
67
+
68
+ // src/lib/parsers/csw/parse-csw-capabilities.ts
69
+ function parseCSWCapabilities(text, options) {
70
+ var _a, _b;
71
+ const parsedXML = (_b = (_a = import_xml.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, {
72
+ ...options,
73
+ xml: {
74
+ ...options == null ? void 0 : options.xml,
75
+ removeNSPrefix: true,
76
+ uncapitalizeKeys: true
77
+ }
78
+ });
79
+ parseExceptionReport(parsedXML);
80
+ const xmlCapabilities = parsedXML.capabilities || parsedXML;
81
+ return xmlCapabilities;
82
+ }
83
+
84
+ // src/csw-capabilities-loader.ts
85
+ var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
86
+ var CSWCapabilitiesLoader = {
87
+ id: "csw-capabilities",
88
+ name: "CSW Capabilities",
89
+ module: "wms",
90
+ version: VERSION,
91
+ worker: false,
92
+ extensions: ["xml"],
93
+ mimeTypes: ["application/vnd.ogc.csw_xml", "application/xml", "text/xml"],
94
+ testText: testXMLFile,
95
+ options: {
96
+ csw: {}
97
+ },
98
+ parse: async (arrayBuffer, options) => parseCSWCapabilities(new TextDecoder().decode(arrayBuffer), options),
99
+ parseTextSync: (text, options) => parseCSWCapabilities(text, options)
100
+ };
101
+ function testXMLFile(text) {
102
+ return text.startsWith("<?xml");
103
+ }
104
+
105
+ // src/lib/parsers/csw/parse-csw-domain.ts
106
+ var import_xml2 = require("@loaders.gl/xml");
107
+ function parseCSWDomain(text, options) {
108
+ var _a, _b, _c;
109
+ const parsedXML = (_b = (_a = import_xml2.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, {
110
+ ...options,
111
+ xml: {
112
+ ...options == null ? void 0 : options.xml,
113
+ removeNSPrefix: true,
114
+ uncapitalizeKeys: true,
115
+ arrayPaths: [
116
+ "GetDomainResponse.DomainValues",
117
+ "GetDomainResponse.DomainValues.ListOfValues.value"
118
+ ]
119
+ }
120
+ });
121
+ parseExceptionReport(parsedXML);
122
+ const xmlDomain = parsedXML.getDomainResponse;
123
+ for (const domainValue of xmlDomain.domainValues) {
124
+ domainValue.values = (_c = domainValue.listOfValues) == null ? void 0 : _c.value;
125
+ delete domainValue.listOfValues;
126
+ }
127
+ return xmlDomain;
128
+ }
129
+
130
+ // src/csw-domain-loader.ts
131
+ var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
132
+ var CSWDomainLoader = {
133
+ id: "csw-domain",
134
+ name: "CSW Domain",
135
+ module: "wms",
136
+ version: VERSION2,
137
+ worker: false,
138
+ extensions: ["xml"],
139
+ mimeTypes: ["application/vnd.ogc.csw_xml", "application/xml", "text/xml"],
140
+ testText: testXMLFile2,
141
+ options: {
142
+ csw: {}
143
+ },
144
+ parse: async (arrayBuffer, options) => parseCSWDomain(new TextDecoder().decode(arrayBuffer), options),
145
+ parseTextSync: (text, options) => parseCSWDomain(text, options)
146
+ };
147
+ function testXMLFile2(text) {
148
+ return text.startsWith("<?xml");
149
+ }
150
+
151
+ // src/lib/parsers/csw/parse-csw-records.ts
152
+ var import_xml3 = require("@loaders.gl/xml");
153
+ var import_xml4 = require("@loaders.gl/xml");
154
+ function parseCSWRecords(text, options) {
155
+ var _a, _b, _c;
156
+ const parsedXML = (_c = (_b = import_xml4.XMLLoader).parseTextSync) == null ? void 0 : _c.call(_b, text, {
157
+ ...options,
158
+ xml: {
159
+ ...options == null ? void 0 : options.xml,
160
+ removeNSPrefix: true,
161
+ uncapitalizeKeys: true,
162
+ arrayPaths: [],
163
+ _fastXML: {
164
+ ...(_a = options == null ? void 0 : options.xml) == null ? void 0 : _a._fastXML,
165
+ parseAttributeValue: true
166
+ }
167
+ }
168
+ });
169
+ parseExceptionReport(parsedXML);
170
+ const xmlRecords = parsedXML.getRecordsResponse;
171
+ const elementSet = xmlRecords.searchResults.elementSet;
172
+ const recordsFieldName = `${elementSet}Record`;
173
+ xmlRecords.records = xmlRecords.searchResults[recordsFieldName];
174
+ delete xmlRecords.searchResults[recordsFieldName];
175
+ (0, import_xml3.convertXMLFieldToArrayInPlace)(xmlRecords, "records");
176
+ for (const record of xmlRecords.records) {
177
+ record.boundingBoxes = record.boundingBox;
178
+ delete record.boundingBox;
179
+ (0, import_xml3.convertXMLFieldToArrayInPlace)(record, "boundingBoxes");
180
+ for (const boundingBox of record.boundingBoxes) {
181
+ boundingBox.value = [
182
+ boundingBox.upperCorner[0],
183
+ boundingBox.upperCorner[1],
184
+ boundingBox.lowerCorner[0],
185
+ boundingBox.lowerCorner[1]
186
+ ];
187
+ delete boundingBox.upperCorner;
188
+ delete boundingBox.lowerCorner;
189
+ }
190
+ }
191
+ return xmlRecords;
192
+ }
193
+
194
+ // src/csw-records-loader.ts
195
+ var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
196
+ var CSWRecordsLoader = {
197
+ id: "csw-records",
198
+ name: "CSW Records",
199
+ module: "wms",
200
+ version: VERSION3,
201
+ worker: false,
202
+ extensions: ["xml"],
203
+ mimeTypes: ["application/vnd.ogc.csw_xml", "application/xml", "text/xml"],
204
+ testText: testXMLFile3,
205
+ options: {
206
+ csw: {}
207
+ },
208
+ parse: async (arrayBuffer, options) => parseCSWRecords(new TextDecoder().decode(arrayBuffer), options),
209
+ parseTextSync: (text, options) => parseCSWRecords(text, options)
210
+ };
211
+ function testXMLFile3(text) {
212
+ return text.startsWith("<?xml");
213
+ }
214
+
215
+ // src/lib/parsers/wms/parse-wms-error.ts
216
+ var import_xml5 = require("@loaders.gl/xml");
217
+ function parseWMSError(text, options) {
218
+ var _a, _b, _c, _d;
219
+ const parsedXML = (_b = (_a = import_xml5.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, options);
220
+ const serviceExceptionXML = ((_c = parsedXML == null ? void 0 : parsedXML.ServiceExceptionReport) == null ? void 0 : _c.ServiceException) || ((_d = parsedXML == null ? void 0 : parsedXML["ogc:ServiceExceptionReport"]) == null ? void 0 : _d["ogc:ServiceException"]);
221
+ const message = typeof serviceExceptionXML === "string" ? serviceExceptionXML : serviceExceptionXML.value || serviceExceptionXML.code || "Unknown error";
222
+ return message;
223
+ }
224
+
225
+ // src/wms-error-loader.ts
226
+ var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
227
+ var WMSErrorLoader = {
228
+ id: "wms-error",
229
+ name: "WMS Error",
230
+ module: "wms",
231
+ version: VERSION4,
232
+ worker: false,
233
+ extensions: ["xml"],
234
+ mimeTypes: ["application/vnd.ogc.se_xml", "application/xml", "text/xml"],
235
+ testText: testXMLFile4,
236
+ options: {
237
+ wms: {
238
+ throwOnError: false
239
+ }
240
+ },
241
+ parse: async (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
242
+ parseSync: (arrayBuffer, options) => parseTextSync(new TextDecoder().decode(arrayBuffer), options),
243
+ parseTextSync: (text, options) => parseTextSync(text, options)
244
+ };
245
+ function testXMLFile4(text) {
246
+ return text.startsWith("<?xml");
247
+ }
248
+ function parseTextSync(text, options) {
249
+ const wmsOptions = { ...WMSErrorLoader.options.wms, ...options == null ? void 0 : options.wms };
250
+ const error = parseWMSError(text, wmsOptions);
251
+ const message = wmsOptions.minimalErrors ? error : `WMS Service error: ${error}`;
252
+ if (wmsOptions.throwOnError) {
253
+ throw new Error(message);
254
+ }
255
+ return message;
256
+ }
257
+
258
+ // src/lib/parsers/wms/parse-wms-capabilities.ts
259
+ var import_xml6 = require("@loaders.gl/xml");
260
+
261
+ // src/lib/parsers/xml/parse-xml-helpers.ts
262
+ function getXMLArray(xmlValue) {
263
+ if (Array.isArray(xmlValue)) {
264
+ return xmlValue;
265
+ }
266
+ if (xmlValue) {
267
+ return [xmlValue];
268
+ }
269
+ return [];
270
+ }
271
+ function getXMLStringArray(xmlValue) {
272
+ const xmlArray = getXMLArray(xmlValue);
273
+ if (xmlArray.length > 0 && xmlArray.every((_) => typeof _ === "string")) {
274
+ return xmlArray;
275
+ }
276
+ return [];
277
+ }
278
+ function getXMLFloat(xmlValue, defaultValue = void 0) {
279
+ switch (typeof xmlValue) {
280
+ case "number":
281
+ return xmlValue;
282
+ case "string":
283
+ return parseFloat(xmlValue);
284
+ default:
285
+ return void 0;
286
+ }
287
+ }
288
+ function getXMLInteger(xmlValue, defaultValue = void 0) {
289
+ switch (typeof xmlValue) {
290
+ case "number":
291
+ return xmlValue;
292
+ case "string":
293
+ return parseInt(xmlValue, 10);
294
+ default:
295
+ return void 0;
296
+ }
297
+ }
298
+ function getXMLBoolean(xmlValue) {
299
+ switch (xmlValue) {
300
+ case "true":
301
+ return true;
302
+ case "false":
303
+ return false;
304
+ case "1":
305
+ return true;
306
+ case "0":
307
+ return false;
308
+ default:
309
+ return false;
310
+ }
311
+ }
312
+
313
+ // src/lib/parsers/wms/parse-wms-capabilities.ts
314
+ function parseWMSCapabilities(xmlText, options) {
315
+ var _a, _b;
316
+ const parsedXML = (_b = (_a = import_xml6.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, xmlText, options);
317
+ const xmlCapabilities = parsedXML.WMT_MS_Capabilities || parsedXML.WMS_Capabilities || parsedXML;
318
+ const capabilities = extractCapabilities(xmlCapabilities);
319
+ if (options == null ? void 0 : options.inheritedLayerProps) {
320
+ for (const layer of capabilities.layers) {
321
+ addInheritedLayerProps(layer, null);
322
+ }
323
+ }
324
+ if ((options == null ? void 0 : options.includeRawData) || (options == null ? void 0 : options.raw)) {
325
+ capabilities.raw = xmlCapabilities;
326
+ }
327
+ if (options == null ? void 0 : options.includeXMLText) {
328
+ capabilities.xml = xmlText;
329
+ }
330
+ return capabilities;
331
+ }
332
+ function extractCapabilities(xml) {
333
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
334
+ const capabilities = {
335
+ version: String(xml.version || ""),
336
+ name: String(((_a = xml.Service) == null ? void 0 : _a.Name) || "unnamed"),
337
+ title: ((_b = xml.Service) == null ? void 0 : _b.Title) ? String((_c = xml.Service) == null ? void 0 : _c.Title) : void 0,
338
+ abstract: ((_d = xml.Service) == null ? void 0 : _d.Abstract) ? String((_e = xml.Service) == null ? void 0 : _e.Abstract) : void 0,
339
+ keywords: getXMLStringArray((_g = (_f = xml.Service) == null ? void 0 : _f.KeywordList) == null ? void 0 : _g.Keyword),
340
+ fees: ((_h = xml.Service) == null ? void 0 : _h.Fees) ? JSON.stringify((_i = xml.Service) == null ? void 0 : _i.Fees) : void 0,
341
+ accessConstraints: ((_j = xml.Service) == null ? void 0 : _j.AccessConstraints) ? JSON.stringify((_k = xml.Service) == null ? void 0 : _k.AccessConstraints) : void 0,
342
+ layerLimit: getXMLInteger((_l = xml.Service) == null ? void 0 : _l.LayerLimit),
343
+ maxWidth: getXMLInteger((_m = xml.Service) == null ? void 0 : _m.maxWidth),
344
+ maxHeight: getXMLInteger((_n = xml.Service) == null ? void 0 : _n.maxHeight),
345
+ layers: [],
346
+ requests: extractRequests((_o = xml.Capability) == null ? void 0 : _o.Request),
347
+ exceptions: extractExceptions(xml.Exception)
348
+ // contact field is a mess of largely irrelevant information, put it last
349
+ // contact: xml.Service?.Contact ? JSON.stringify(xml.Service?.Contact) : undefined,
350
+ };
351
+ const xmlLayers = getXMLArray((_p = xml.Capability) == null ? void 0 : _p.Layer);
352
+ for (const xmlSubLayer of xmlLayers) {
353
+ capabilities.layers.push(extractLayer(xmlSubLayer));
354
+ }
355
+ for (const [key, value] of Object.entries(capabilities)) {
356
+ if (value === void 0) {
357
+ delete capabilities[key];
358
+ }
359
+ }
360
+ return capabilities;
361
+ }
362
+ function extractRequests(xmlRequests) {
363
+ const requests = {};
364
+ for (const [name, xmlRequest] of Object.entries(xmlRequests || {})) {
365
+ const mimeTypes = getXMLStringArray(xmlRequest == null ? void 0 : xmlRequest.Format);
366
+ requests[name] = { mimeTypes };
367
+ }
368
+ return requests;
369
+ }
370
+ function extractExceptions(xmlException) {
371
+ const xmlExceptionFormats = getXMLArray(xmlException == null ? void 0 : xmlException.Format);
372
+ if (xmlExceptionFormats.length > 0) {
373
+ return {
374
+ mimeTypes: getXMLStringArray(xmlException)
375
+ };
376
+ }
377
+ return void 0;
378
+ }
379
+ function extractLayer(xmlLayer) {
380
+ var _a;
381
+ const layer = {
382
+ // All layers must have a title
383
+ title: String((xmlLayer == null ? void 0 : xmlLayer.Title) || ""),
384
+ // Name is required only if renderable
385
+ name: (xmlLayer == null ? void 0 : xmlLayer.Name) && String(xmlLayer == null ? void 0 : xmlLayer.Name),
386
+ abstract: (xmlLayer == null ? void 0 : xmlLayer.Name) && String(xmlLayer == null ? void 0 : xmlLayer.Abstract),
387
+ keywords: getXMLStringArray((_a = xmlLayer.KeywordList) == null ? void 0 : _a.Keyword)
388
+ };
389
+ const crs = (xmlLayer == null ? void 0 : xmlLayer.CRS) || (xmlLayer == null ? void 0 : xmlLayer.SRS);
390
+ if (crs && Array.isArray(crs) && crs.every((_) => typeof _ === "string")) {
391
+ layer.crs = crs;
392
+ }
393
+ let geographicBoundingBox = (xmlLayer == null ? void 0 : xmlLayer.EX_GeographicBoundingBox) && extractEXBoundingBox(xmlLayer == null ? void 0 : xmlLayer.EX_GeographicBoundingBox);
394
+ if (geographicBoundingBox) {
395
+ layer.geographicBoundingBox = geographicBoundingBox;
396
+ }
397
+ geographicBoundingBox = (xmlLayer == null ? void 0 : xmlLayer.LatLonBoundingBox) && extractLatLonBoundingBox(xmlLayer == null ? void 0 : xmlLayer.LatLonBoundingBox);
398
+ if (geographicBoundingBox) {
399
+ layer.geographicBoundingBox = geographicBoundingBox;
400
+ }
401
+ const boundingBoxes = (xmlLayer == null ? void 0 : xmlLayer.BoundingBox) && extractWMSBoundingBoxes(xmlLayer == null ? void 0 : xmlLayer.BoundingBox);
402
+ if (boundingBoxes && boundingBoxes.length > 0) {
403
+ layer.boundingBoxes = boundingBoxes;
404
+ }
405
+ const xmlDimensions = getXMLArray(xmlLayer == null ? void 0 : xmlLayer.Dimension);
406
+ const dimensions = xmlDimensions.map((xml) => extractDimension(xml));
407
+ if (dimensions.length) {
408
+ layer.dimensions = dimensions;
409
+ }
410
+ if (xmlLayer == null ? void 0 : xmlLayer.opaque) {
411
+ layer.opaque = getXMLBoolean(xmlLayer == null ? void 0 : xmlLayer.opaque);
412
+ }
413
+ if (xmlLayer == null ? void 0 : xmlLayer.cascaded) {
414
+ layer.cascaded = getXMLBoolean(xmlLayer == null ? void 0 : xmlLayer.cascaded);
415
+ }
416
+ if (xmlLayer == null ? void 0 : xmlLayer.queryable) {
417
+ layer.queryable = getXMLBoolean(xmlLayer == null ? void 0 : xmlLayer.queryable);
418
+ }
419
+ const xmlLayers = getXMLArray(xmlLayer == null ? void 0 : xmlLayer.Layer);
420
+ const layers = [];
421
+ for (const xmlSubLayer of xmlLayers) {
422
+ layers.push(extractLayer(xmlSubLayer));
423
+ }
424
+ if (layers.length > 0) {
425
+ layer.layers = layers;
426
+ }
427
+ for (const [key, value] of Object.entries(layer)) {
428
+ if (value === void 0) {
429
+ delete layer[key];
430
+ }
431
+ }
432
+ return layer;
433
+ }
434
+ function extractEXBoundingBox(xmlBoundingBox) {
435
+ const {
436
+ westBoundLongitude: w,
437
+ northBoundLatitude: n,
438
+ eastBoundLongitude: e,
439
+ southBoundLatitude: s
440
+ } = xmlBoundingBox;
441
+ return [
442
+ [w, s],
443
+ [e, n]
444
+ ];
445
+ }
446
+ function extractLatLonBoundingBox(xmlBoundingBox) {
447
+ const { minx, miny, maxx, maxy } = xmlBoundingBox;
448
+ return [
449
+ [minx, miny],
450
+ [maxx, maxy]
451
+ ];
452
+ }
453
+ function extractWMSBoundingBoxes(xmlBoundingBoxes) {
454
+ const xmlBoxes = getXMLArray(xmlBoundingBoxes);
455
+ return xmlBoxes.map((xmlBox) => extractWMSBoundingBox(xmlBox));
456
+ }
457
+ function extractWMSBoundingBox(xmlBoundingBox) {
458
+ const { CRS, SRS, minx, miny, maxx, maxy, resx, resy } = xmlBoundingBox;
459
+ const boundingBox = {
460
+ // CRS in 1.3.0, SRS in 1.1.1
461
+ crs: CRS || SRS,
462
+ boundingBox: [
463
+ [getXMLFloat(minx), getXMLFloat(miny)],
464
+ [getXMLFloat(maxx), getXMLFloat(maxy)]
465
+ ]
466
+ };
467
+ if (resx) {
468
+ boundingBox.xResolution = resx;
469
+ }
470
+ if (resy) {
471
+ boundingBox.yResolution = resy;
472
+ }
473
+ return boundingBox;
474
+ }
475
+ function extractDimension(xmlDimension) {
476
+ const { name, units, value: extent } = xmlDimension;
477
+ const dimension = { name, units, extent };
478
+ if (xmlDimension.unitSymbol) {
479
+ dimension.unitSymbol = xmlDimension.unitSymbol;
480
+ }
481
+ if (xmlDimension.default) {
482
+ dimension.defaultValue = xmlDimension.default;
483
+ }
484
+ if (xmlDimension.multipleValues) {
485
+ dimension.multipleValues = getXMLBoolean(xmlDimension.multipleValues);
486
+ }
487
+ if (xmlDimension.nearestValue) {
488
+ dimension.nearestValue = getXMLBoolean(xmlDimension.nearestValue);
489
+ }
490
+ if (xmlDimension.current) {
491
+ dimension.current = getXMLBoolean(xmlDimension.current);
492
+ }
493
+ return dimension;
494
+ }
495
+ function addInheritedLayerProps(layer, parent) {
496
+ if ((parent == null ? void 0 : parent.geographicBoundingBox) && !layer.geographicBoundingBox) {
497
+ layer.geographicBoundingBox = [...parent.geographicBoundingBox];
498
+ }
499
+ if ((parent == null ? void 0 : parent.crs) && !layer.crs) {
500
+ layer.crs = [...parent.crs];
501
+ }
502
+ if ((parent == null ? void 0 : parent.boundingBoxes) && !layer.boundingBoxes) {
503
+ layer.boundingBoxes = [...parent.boundingBoxes];
504
+ }
505
+ if ((parent == null ? void 0 : parent.dimensions) && !layer.dimensions) {
506
+ layer.dimensions = [...parent.dimensions];
507
+ }
508
+ for (const subLayer of layer.layers || []) {
509
+ addInheritedLayerProps(subLayer, layer);
510
+ }
511
+ }
512
+
513
+ // src/wms-capabilities-loader.ts
514
+ var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
515
+ var WMSCapabilitiesLoader = {
516
+ id: "wms-capabilities",
517
+ name: "WMS Capabilities",
518
+ module: "wms",
519
+ version: VERSION5,
520
+ worker: false,
521
+ extensions: ["xml"],
522
+ mimeTypes: ["application/vnd.ogc.wms_xml", "application/xml", "text/xml"],
523
+ testText: testXMLFile5,
524
+ options: {
525
+ wms: {}
526
+ },
527
+ parse: async (arrayBuffer, options) => (
528
+ // TODO pass in XML options
529
+ parseWMSCapabilities(new TextDecoder().decode(arrayBuffer), options == null ? void 0 : options.wms)
530
+ ),
531
+ parseTextSync: (text, options) => (
532
+ // TODO pass in XML options
533
+ parseWMSCapabilities(text, options == null ? void 0 : options.wms)
534
+ )
535
+ };
536
+ function testXMLFile5(text) {
537
+ return text.startsWith("<?xml");
538
+ }
539
+
540
+ // src/lib/parsers/wms/parse-wms-features.ts
541
+ var import_xml7 = require("@loaders.gl/xml");
542
+ function parseWMSFeatureInfo(text, options) {
543
+ var _a, _b, _c;
544
+ const parsedXML = (_b = (_a = import_xml7.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, options);
545
+ const xmlFeatureInfo = ((_c = parsedXML.FeatureInfoResponse) == null ? void 0 : _c.FIELDS) || [];
546
+ const xmlFeatures = Array.isArray(xmlFeatureInfo) ? xmlFeatureInfo : [xmlFeatureInfo];
547
+ return {
548
+ features: xmlFeatures.map((xmlFeature) => extractFeature(xmlFeature))
549
+ };
550
+ }
551
+ function extractFeature(xmlFeature) {
552
+ const xmlFields = xmlFeature || {};
553
+ return {
554
+ attributes: xmlFields,
555
+ type: "",
556
+ bounds: { bottom: 0, top: 0, left: 0, right: 0 }
557
+ };
558
+ }
559
+
560
+ // src/wip/wms-feature-info-loader.ts
561
+ var WMSFeatureInfoLoader = {
562
+ ...WMSCapabilitiesLoader,
563
+ id: "wms-feature-info",
564
+ name: "WMS FeatureInfo",
565
+ parse: async (arrayBuffer, options) => parseWMSFeatureInfo(new TextDecoder().decode(arrayBuffer), options),
566
+ parseTextSync: (text, options) => parseWMSFeatureInfo(text, options)
567
+ };
568
+
569
+ // src/lib/parsers/wms/parse-wms-layer-description.ts
570
+ var import_xml8 = require("@loaders.gl/xml");
571
+ function parseWMSLayerDescription(text, options) {
572
+ var _a, _b;
573
+ const parsedXML = (_b = (_a = import_xml8.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, options);
574
+ return parsedXML;
575
+ }
576
+
577
+ // src/wip/wms-layer-description-loader.ts
578
+ var WMSLayerDescriptionLoader = {
579
+ ...WMSCapabilitiesLoader,
580
+ id: "wms-layer-description",
581
+ name: "WMS DescribeLayer",
582
+ parse: async (arrayBuffer, options) => parseWMSLayerDescription(new TextDecoder().decode(arrayBuffer), options),
583
+ parseTextSync: (text, options) => parseWMSLayerDescription(text, options)
584
+ };
585
+
586
+ // src/wip/lib/wfs/parse-wfs-capabilities.ts
587
+ var import_xml9 = require("@loaders.gl/xml");
588
+ function parseWFSCapabilities(text, options) {
589
+ var _a, _b;
590
+ const parsedXML = (_b = (_a = import_xml9.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, { ...options, xml: {
591
+ ...options == null ? void 0 : options.xml,
592
+ removeNSPrefix: true,
593
+ uncapitalizeKeys: true
594
+ } });
595
+ const xmlCapabilities = parsedXML.Capabilities || parsedXML;
596
+ return xmlCapabilities;
597
+ }
598
+
599
+ // src/wip/wfs-capabilities-loader.ts
600
+ var VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
601
+ var WFSCapabilitiesLoader = {
602
+ id: "wfs-capabilities",
603
+ name: "WFS Capabilities",
604
+ module: "wms",
605
+ version: VERSION6,
606
+ worker: false,
607
+ extensions: ["xml"],
608
+ mimeTypes: ["application/vnd.ogc.wfs_xml", "application/xml", "text/xml"],
609
+ testText: testXMLFile6,
610
+ options: {
611
+ wfs: {}
612
+ },
613
+ parse: async (arrayBuffer, options) => parseWFSCapabilities(new TextDecoder().decode(arrayBuffer), options),
614
+ parseTextSync: (text, options) => parseWFSCapabilities(text, options)
615
+ };
616
+ function testXMLFile6(text) {
617
+ return text.startsWith("<?xml");
618
+ }
619
+
620
+ // src/lib/parsers/gml/parse-gml.ts
621
+ var import_xml10 = require("@loaders.gl/xml");
622
+
623
+ // src/lib/parsers/gml/deep-strict-equal.ts
624
+ function deepStrictEqual(actual, expected, strict) {
625
+ if (actual === expected) {
626
+ return true;
627
+ } else if (actual instanceof Date && expected instanceof Date) {
628
+ return actual.getTime() === expected.getTime();
629
+ } else if (actual instanceof RegExp && expected instanceof RegExp) {
630
+ return actual.source === expected.source && actual.global === expected.global && actual.multiline === expected.multiline && actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase;
631
+ } else if ((actual === null || typeof actual !== "object") && (expected === null || typeof expected !== "object")) {
632
+ return strict ? actual === expected : actual == expected;
633
+ }
634
+ return objEquiv(actual, expected, strict);
635
+ }
636
+ var pSlice = Array.prototype.slice;
637
+ function isPrimitive(arg) {
638
+ return arg === null || typeof arg !== "object" && typeof arg !== "function";
639
+ }
640
+ function isArguments(object) {
641
+ return Object.prototype.toString.call(object) == "[object Arguments]";
642
+ }
643
+ function objEquiv(a, b, strict) {
644
+ if (a === null || a === void 0 || b === null || b === void 0)
645
+ return false;
646
+ if (isPrimitive(a) || isPrimitive(b))
647
+ return a === b;
648
+ if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
649
+ return false;
650
+ const aIsArgs = isArguments(a);
651
+ const bIsArgs = isArguments(b);
652
+ if (aIsArgs && !bIsArgs || !aIsArgs && bIsArgs)
653
+ return false;
654
+ if (aIsArgs) {
655
+ a = pSlice.call(a);
656
+ b = pSlice.call(b);
657
+ return deepStrictEqual(a, b, strict);
658
+ }
659
+ const ka = Object.keys(a);
660
+ const kb = Object.keys(b);
661
+ let key;
662
+ let i;
663
+ if (ka.length !== kb.length)
664
+ return false;
665
+ ka.sort();
666
+ kb.sort();
667
+ for (i = ka.length - 1; i >= 0; i--) {
668
+ if (ka[i] !== kb[i])
669
+ return false;
670
+ }
671
+ for (i = ka.length - 1; i >= 0; i--) {
672
+ key = ka[i];
673
+ if (!deepStrictEqual(a[key], b[key], strict))
674
+ return false;
675
+ }
676
+ return true;
677
+ }
678
+
679
+ // src/lib/parsers/gml/parse-gml.ts
680
+ var import_rewind = __toESM(require("@turf/rewind"), 1);
681
+ function noTransform(...coords) {
682
+ return coords;
683
+ }
684
+ function parseGML(text, options) {
685
+ var _a, _b;
686
+ const parsedXML = (_b = (_a = import_xml10.XMLLoader).parseTextSync) == null ? void 0 : _b.call(_a, text, options);
687
+ options = { transformCoords: noTransform, stride: 2, ...options };
688
+ const context = createChildContext(parsedXML, options, {});
689
+ return parseGMLToGeometry(parsedXML, options, context);
690
+ }
691
+ function parseGMLToGeometry(inputXML, options, context) {
692
+ const childContext = createChildContext(inputXML, options, context);
693
+ let geometry = null;
694
+ const [name, xml] = getFirstKeyValue(inputXML);
695
+ switch (name) {
696
+ case "gml:LineString":
697
+ geometry = {
698
+ type: "LineString",
699
+ coordinates: parseLinearRingOrLineString(xml, options, childContext)
700
+ };
701
+ break;
702
+ case "gml:Polygon":
703
+ case "gml:Rectangle":
704
+ geometry = {
705
+ type: "Polygon",
706
+ coordinates: parsePolygonOrRectangle(xml, options, childContext)
707
+ };
708
+ break;
709
+ case "gml:Surface":
710
+ geometry = {
711
+ type: "MultiPolygon",
712
+ coordinates: parseSurface(xml, options, childContext)
713
+ };
714
+ break;
715
+ case "gml:MultiSurface":
716
+ geometry = {
717
+ type: "MultiPolygon",
718
+ coordinates: parseMultiSurface(xml, options, childContext)
719
+ };
720
+ break;
721
+ default:
722
+ return null;
723
+ }
724
+ return (0, import_rewind.default)(geometry, { mutate: true });
725
+ }
726
+ function parseCoords(s, options, context) {
727
+ var _a;
728
+ const stride = context.srsDimension || options.stride || 2;
729
+ const coords = s.replace(/\s+/g, " ").trim().split(" ");
730
+ if (coords.length === 0 || coords.length % stride !== 0) {
731
+ throw new Error(`invalid coordinates list (stride ${stride})`);
732
+ }
733
+ const points = [];
734
+ for (let i = 0; i < coords.length - 1; i += stride) {
735
+ const point = coords.slice(i, i + stride).map(parseFloat);
736
+ points.push(((_a = options.transformCoords) == null ? void 0 : _a.call(options, ...point)) || point);
737
+ }
738
+ return points;
739
+ }
740
+ function parsePosList(xml, options, context) {
741
+ const childContext = createChildContext(xml, options, context);
742
+ const coords = textOf(xml);
743
+ if (!coords) {
744
+ throw new Error("invalid gml:posList element");
745
+ }
746
+ return parseCoords(coords, options, childContext);
747
+ }
748
+ function parsePos(xml, options, context) {
749
+ const childContext = createChildContext(xml, options, context);
750
+ const coords = textOf(xml);
751
+ if (!coords) {
752
+ throw new Error("invalid gml:pos element");
753
+ }
754
+ const points = parseCoords(coords, options, childContext);
755
+ if (points.length !== 1) {
756
+ throw new Error("gml:pos must have 1 point");
757
+ }
758
+ return points[0];
759
+ }
760
+ function parsePoint(xml, options, context) {
761
+ const childContext = createChildContext(xml, options, context);
762
+ const pos = findIn(xml, "gml:pos");
763
+ if (!pos) {
764
+ throw new Error("invalid gml:Point element, expected a gml:pos subelement");
765
+ }
766
+ return parsePos(pos, options, childContext);
767
+ }
768
+ function parseLinearRingOrLineString(xml, options, context) {
769
+ const childContext = createChildContext(xml, options, context);
770
+ let points = [];
771
+ const posList = findIn(xml, "gml:posList");
772
+ if (posList) {
773
+ points = parsePosList(posList, options, childContext);
774
+ } else {
775
+ for (const [childName, childXML] of Object.entries(xml)) {
776
+ switch (childName) {
777
+ case "gml:Point":
778
+ points.push(parsePoint(childXML, options, childContext));
779
+ break;
780
+ case "gml:pos":
781
+ points.push(parsePos(childXML, options, childContext));
782
+ break;
783
+ default:
784
+ continue;
785
+ }
786
+ }
787
+ }
788
+ if (points.length === 0) {
789
+ throw new Error(`${xml.name} must have > 0 points`);
790
+ }
791
+ return points;
792
+ }
793
+ function parseCurveSegments(xml, options, context) {
794
+ const points = [];
795
+ for (const [childName, childXML] of Object.entries(xml)) {
796
+ switch (childName) {
797
+ case "gml:LineStringSegment":
798
+ const points2 = parseLinearRingOrLineString(childXML, options, context);
799
+ const end = points[points.length - 1];
800
+ const start = points2[0];
801
+ if (end && start && deepStrictEqual(end, start)) {
802
+ points2.shift();
803
+ }
804
+ points.push(...points2);
805
+ break;
806
+ default:
807
+ continue;
808
+ }
809
+ }
810
+ if (points.length === 0) {
811
+ throw new Error("gml:Curve > gml:segments must have > 0 points");
812
+ }
813
+ return points;
814
+ }
815
+ function parseRing(xml, options, context) {
816
+ const childContext = createChildContext(xml, options, context);
817
+ const points = [];
818
+ for (const [childName, childXML] of Object.entries(xml)) {
819
+ switch (childName) {
820
+ case "gml:curveMember":
821
+ let points2;
822
+ const lineString = findIn(childXML, "gml:LineString");
823
+ if (lineString) {
824
+ points2 = parseLinearRingOrLineString(lineString, options, childContext);
825
+ } else {
826
+ const segments = findIn(childXML, "gml:Curve", "gml:segments");
827
+ if (!segments) {
828
+ throw new Error(`invalid ${childName} element`);
829
+ }
830
+ points2 = parseCurveSegments(segments, options, childContext);
831
+ }
832
+ const end = points[points.length - 1];
833
+ const start = points2[0];
834
+ if (end && start && deepStrictEqual(end, start)) {
835
+ points2.shift();
836
+ }
837
+ points.push(...points2);
838
+ break;
839
+ }
840
+ }
841
+ if (points.length < 4) {
842
+ throw new Error(`${xml.name} must have >= 4 points`);
843
+ }
844
+ return points;
845
+ }
846
+ function parseExteriorOrInterior(xml, options, context) {
847
+ const linearRing = findIn(xml, "gml:LinearRing");
848
+ if (linearRing) {
849
+ return parseLinearRingOrLineString(linearRing, options, context);
850
+ }
851
+ const ring = findIn(xml, "gml:Ring");
852
+ if (!ring) {
853
+ throw new Error(`invalid ${xml.name} element`);
854
+ }
855
+ return parseRing(ring, options, context);
856
+ }
857
+ function parsePolygonOrRectangle(xml, options, context) {
858
+ const childContext = createChildContext(xml, options, context);
859
+ const exterior = findIn(xml, "gml:exterior");
860
+ if (!exterior) {
861
+ throw new Error(`invalid ${xml.name} element`);
862
+ }
863
+ const pointLists = [parseExteriorOrInterior(exterior, options, childContext)];
864
+ for (const [childName, childXML] of Object.entries(xml)) {
865
+ switch (childName) {
866
+ case "gml:interior":
867
+ pointLists.push(parseExteriorOrInterior(childXML, options, childContext));
868
+ break;
869
+ }
870
+ }
871
+ return pointLists;
872
+ }
873
+ function parseSurface(xml, options, context) {
874
+ const childContext = createChildContext(xml, options, context);
875
+ const patches = findIn(xml, "gml:patches");
876
+ if (!patches) {
877
+ throw new Error(`invalid ${xml.name} element`);
878
+ }
879
+ const polygons = [];
880
+ for (const [childName, childXML] of Object.entries(xml)) {
881
+ switch (childName) {
882
+ case "gml:PolygonPatch":
883
+ case "gml:Rectangle":
884
+ polygons.push(parsePolygonOrRectangle(childXML, options, childContext));
885
+ break;
886
+ default:
887
+ continue;
888
+ }
889
+ }
890
+ if (polygons.length === 0) {
891
+ throw new Error(`${xml.name} must have > 0 polygons`);
892
+ }
893
+ return polygons;
894
+ }
895
+ function parseCompositeSurface(xml, options, context) {
896
+ const childContext = createChildContext(xml, options, context);
897
+ const polygons = [];
898
+ for (const [childName, childXML] of Object.entries(xml)) {
899
+ switch (childName) {
900
+ case "gml:surfaceMember":
901
+ case "gml:surfaceMembers":
902
+ const [c2Name, c2Xml] = getFirstKeyValue(childXML);
903
+ switch (c2Name) {
904
+ case "gml:Surface":
905
+ polygons.push(...parseSurface(c2Xml, options, childContext));
906
+ break;
907
+ case "gml:Polygon":
908
+ polygons.push(parsePolygonOrRectangle(c2Xml, options, childContext));
909
+ break;
910
+ }
911
+ break;
912
+ }
913
+ }
914
+ if (polygons.length === 0) {
915
+ throw new Error(`${xml.name} must have > 0 polygons`);
916
+ }
917
+ return polygons;
918
+ }
919
+ function parseMultiSurface(xml, options, context) {
920
+ let el = xml;
921
+ const surfaceMembers = findIn(xml, "gml:LinearRing");
922
+ if (surfaceMembers) {
923
+ el = surfaceMembers;
924
+ }
925
+ const polygons = [];
926
+ for (const [childName, childXML] of Object.entries(el)) {
927
+ switch (childName) {
928
+ case "gml:Surface":
929
+ const polygons2 = parseSurface(childXML, options, context);
930
+ polygons.push(...polygons2);
931
+ break;
932
+ case "gml:surfaceMember":
933
+ const polygons3 = parseSurfaceMember(childXML, options, context);
934
+ polygons.push(...polygons3);
935
+ break;
936
+ case "gml:surfaceMembers":
937
+ const polygonXML = findIn(childXML, "gml:Polygon");
938
+ for (const surfaceMemberXML of polygonXML) {
939
+ const polygons32 = parseSurfaceMember(surfaceMemberXML, options, context);
940
+ polygons.push(...polygons32);
941
+ }
942
+ break;
943
+ }
944
+ }
945
+ if (polygons.length === 0) {
946
+ throw new Error(`${xml.name} must have > 0 polygons`);
947
+ }
948
+ return polygons;
949
+ }
950
+ function parseSurfaceMember(xml, options, context) {
951
+ const [childName, childXml] = getFirstKeyValue(xml);
952
+ switch (childName) {
953
+ case "gml:CompositeSurface":
954
+ return parseCompositeSurface(childXml, options, context);
955
+ case "gml:Surface":
956
+ return parseSurface(childXml, options, context);
957
+ case "gml:Polygon":
958
+ return [parsePolygonOrRectangle(childXml, options, context)];
959
+ }
960
+ throw new Error(`${childName} must have polygons`);
961
+ }
962
+ function textOf(el) {
963
+ if (typeof el !== "string") {
964
+ throw new Error("expected string");
965
+ }
966
+ return el;
967
+ }
968
+ function findIn(root, ...tags) {
969
+ let el = root;
970
+ for (const tag of tags) {
971
+ const child = el[tag];
972
+ if (!child) {
973
+ return null;
974
+ }
975
+ el = child;
976
+ }
977
+ return el;
978
+ }
979
+ function getFirstKeyValue(object) {
980
+ if (object && typeof object === "object") {
981
+ for (const [key, value] of Object.entries(object)) {
982
+ return [key, value];
983
+ }
984
+ }
985
+ return ["", null];
986
+ }
987
+ function createChildContext(xml, options, context) {
988
+ const srsDimensionAttribute = xml.attributes && xml.attributes.srsDimension;
989
+ if (srsDimensionAttribute) {
990
+ const srsDimension = parseInt(srsDimensionAttribute);
991
+ if (Number.isNaN(srsDimension) || srsDimension <= 0) {
992
+ throw new Error(
993
+ `invalid srsDimension attribute value "${srsDimensionAttribute}", expected a positive integer`
994
+ );
995
+ }
996
+ const childContext = Object.create(context);
997
+ childContext.srsDimension = srsDimension;
998
+ return childContext;
999
+ }
1000
+ return context;
1001
+ }
1002
+
1003
+ // src/gml-loader.ts
1004
+ var VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1005
+ var GMLLoader = {
1006
+ name: "GML",
1007
+ id: "gml",
1008
+ module: "wms",
1009
+ version: VERSION7,
1010
+ worker: false,
1011
+ extensions: ["xml"],
1012
+ mimeTypes: ["application/vnd.ogc.gml", "application/xml", "text/xml"],
1013
+ testText: testXMLFile7,
1014
+ options: {
1015
+ gml: {}
1016
+ },
1017
+ parse: async (arrayBuffer, options) => parseGML(new TextDecoder().decode(arrayBuffer), options),
1018
+ parseTextSync: (text, options) => parseGML(text, options)
1019
+ };
1020
+ function testXMLFile7(text) {
1021
+ return text.startsWith("<?xml");
1022
+ }
1023
+
1024
+ // src/lib/services/create-image-service.ts
1025
+ function createImageService(props, services) {
1026
+ const { type = "auto" } = props;
1027
+ const service = type === "auto" ? guessServiceType(props.url, services) : getServiceOfType(type, services);
1028
+ if (!service) {
1029
+ throw new Error("Not a valid image source type");
1030
+ }
1031
+ return service.create(props);
1032
+ }
1033
+ function getServiceOfType(type, services) {
1034
+ for (const service of services) {
1035
+ if (service.type === type) {
1036
+ return service;
1037
+ }
1038
+ }
1039
+ return null;
1040
+ }
1041
+ function guessServiceType(url, services) {
1042
+ for (const service of services) {
1043
+ if (service.testURL && service.testURL(url)) {
1044
+ return service;
1045
+ }
1046
+ }
1047
+ return null;
1048
+ }
1049
+
1050
+ // src/services/ogc/wms-service.ts
1051
+ var import_images = require("@loaders.gl/images");
1052
+ var import_loader_utils = require("@loaders.gl/loader-utils");
1053
+ var import_loader_utils2 = require("@loaders.gl/loader-utils");
1054
+ var WMSService = {
1055
+ type: "wms",
1056
+ testURL: (url) => url.toLowerCase().includes("wms"),
1057
+ create: (props) => new WMSSource(props)
1058
+ };
1059
+ var WMSSource = class extends import_loader_utils2.ImageSource {
1060
+ /** Create a WMSSource */
1061
+ constructor(props) {
1062
+ super(props);
1063
+ this.capabilities = null;
1064
+ this.url = props.url;
1065
+ this.substituteCRS84 = props.substituteCRS84 ?? false;
1066
+ this.flipCRS = ["EPSG:4326"];
1067
+ this.wmsParameters = {
1068
+ layers: void 0,
1069
+ query_layers: void 0,
1070
+ styles: void 0,
1071
+ version: "1.3.0",
1072
+ crs: "EPSG:4326",
1073
+ format: "image/png",
1074
+ info_format: "text/plain",
1075
+ transparent: void 0,
1076
+ time: void 0,
1077
+ elevation: void 0,
1078
+ ...props.wmsParameters
1079
+ };
1080
+ this.vendorParameters = props.vendorParameters || {};
1081
+ }
1082
+ // ImageService implementation
1083
+ async getMetadata() {
1084
+ const capabilities = await this.getCapabilities();
1085
+ return this.normalizeMetadata(capabilities);
1086
+ }
1087
+ async getImage(parameters) {
1088
+ return await this.getMap(parameters);
1089
+ }
1090
+ normalizeMetadata(capabilities) {
1091
+ return capabilities;
1092
+ }
1093
+ // WMS Service API Stubs
1094
+ /** Get Capabilities */
1095
+ async getCapabilities(wmsParameters, vendorParameters) {
1096
+ const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
1097
+ const response = await this.fetch(url);
1098
+ const arrayBuffer = await response.arrayBuffer();
1099
+ this._checkResponse(response, arrayBuffer);
1100
+ const capabilities = await WMSCapabilitiesLoader.parse(arrayBuffer, this.loadOptions);
1101
+ this.capabilities = capabilities;
1102
+ return capabilities;
1103
+ }
1104
+ /** Get a map image */
1105
+ async getMap(wmsParameters, vendorParameters) {
1106
+ const url = this.getMapURL(wmsParameters, vendorParameters);
1107
+ const response = await this.fetch(url);
1108
+ const arrayBuffer = await response.arrayBuffer();
1109
+ this._checkResponse(response, arrayBuffer);
1110
+ try {
1111
+ return await import_images.ImageLoader.parse(arrayBuffer, this.loadOptions);
1112
+ } catch {
1113
+ throw this._parseError(arrayBuffer);
1114
+ }
1115
+ }
1116
+ /** Get Feature Info for a coordinate */
1117
+ async getFeatureInfo(wmsParameters, vendorParameters) {
1118
+ const url = this.getFeatureInfoURL(wmsParameters, vendorParameters);
1119
+ const response = await this.fetch(url);
1120
+ const arrayBuffer = await response.arrayBuffer();
1121
+ this._checkResponse(response, arrayBuffer);
1122
+ return await WMSFeatureInfoLoader.parse(arrayBuffer, this.loadOptions);
1123
+ }
1124
+ /** Get Feature Info for a coordinate */
1125
+ async getFeatureInfoText(wmsParameters, vendorParameters) {
1126
+ const url = this.getFeatureInfoURL(wmsParameters, vendorParameters);
1127
+ const response = await this.fetch(url);
1128
+ const arrayBuffer = await response.arrayBuffer();
1129
+ this._checkResponse(response, arrayBuffer);
1130
+ return new TextDecoder().decode(arrayBuffer);
1131
+ }
1132
+ /** Get more information about a layer */
1133
+ async describeLayer(wmsParameters, vendorParameters) {
1134
+ const url = this.describeLayerURL(wmsParameters, vendorParameters);
1135
+ const response = await this.fetch(url);
1136
+ const arrayBuffer = await response.arrayBuffer();
1137
+ this._checkResponse(response, arrayBuffer);
1138
+ return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.loadOptions);
1139
+ }
1140
+ /** Get an image with a semantic legend */
1141
+ async getLegendGraphic(wmsParameters, vendorParameters) {
1142
+ const url = this.getLegendGraphicURL(wmsParameters, vendorParameters);
1143
+ const response = await this.fetch(url);
1144
+ const arrayBuffer = await response.arrayBuffer();
1145
+ this._checkResponse(response, arrayBuffer);
1146
+ try {
1147
+ return await import_images.ImageLoader.parse(arrayBuffer, this.loadOptions);
1148
+ } catch {
1149
+ throw this._parseError(arrayBuffer);
1150
+ }
1151
+ }
1152
+ // Typed URL creators
1153
+ // For applications that want full control of fetching and parsing
1154
+ /** Generate a URL for the GetCapabilities request */
1155
+ getCapabilitiesURL(wmsParameters, vendorParameters) {
1156
+ const options = {
1157
+ version: this.wmsParameters.version,
1158
+ ...wmsParameters
1159
+ };
1160
+ return this._getWMSUrl("GetCapabilities", options, vendorParameters);
1161
+ }
1162
+ /** Generate a URL for the GetMap request */
1163
+ getMapURL(wmsParameters, vendorParameters) {
1164
+ wmsParameters = this._getWMS130Parameters(wmsParameters);
1165
+ const options = {
1166
+ version: this.wmsParameters.version,
1167
+ format: this.wmsParameters.format,
1168
+ transparent: this.wmsParameters.transparent,
1169
+ time: this.wmsParameters.time,
1170
+ elevation: this.wmsParameters.elevation,
1171
+ layers: this.wmsParameters.layers,
1172
+ styles: this.wmsParameters.styles,
1173
+ crs: this.wmsParameters.crs,
1174
+ // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
1175
+ // width: 1200,
1176
+ // height: 900,
1177
+ ...wmsParameters
1178
+ };
1179
+ return this._getWMSUrl("GetMap", options, vendorParameters);
1180
+ }
1181
+ /** Generate a URL for the GetFeatureInfo request */
1182
+ getFeatureInfoURL(wmsParameters, vendorParameters) {
1183
+ wmsParameters = this._getWMS130Parameters(wmsParameters);
1184
+ const options = {
1185
+ version: this.wmsParameters.version,
1186
+ // query_layers: [],
1187
+ // format: this.wmsParameters.format,
1188
+ info_format: this.wmsParameters.info_format,
1189
+ layers: this.wmsParameters.layers,
1190
+ query_layers: this.wmsParameters.query_layers,
1191
+ styles: this.wmsParameters.styles,
1192
+ crs: this.wmsParameters.crs,
1193
+ // bbox: [-77.87304, 40.78975, -77.85828, 40.80228],
1194
+ // width: 1200,
1195
+ // height: 900,
1196
+ // x: undefined!,
1197
+ // y: undefined!,
1198
+ ...wmsParameters
1199
+ };
1200
+ return this._getWMSUrl("GetFeatureInfo", options, vendorParameters);
1201
+ }
1202
+ /** Generate a URL for the GetFeatureInfo request */
1203
+ describeLayerURL(wmsParameters, vendorParameters) {
1204
+ const options = {
1205
+ version: this.wmsParameters.version,
1206
+ ...wmsParameters
1207
+ };
1208
+ return this._getWMSUrl("DescribeLayer", options, vendorParameters);
1209
+ }
1210
+ getLegendGraphicURL(wmsParameters, vendorParameters) {
1211
+ const options = {
1212
+ version: this.wmsParameters.version,
1213
+ // format?
1214
+ ...wmsParameters
1215
+ };
1216
+ return this._getWMSUrl("GetLegendGraphic", options, vendorParameters);
1217
+ }
1218
+ // INTERNAL METHODS
1219
+ _parseWMSUrl(url) {
1220
+ const [baseUrl, search] = url.split("?");
1221
+ const searchParams = search.split("&");
1222
+ const parameters = {};
1223
+ for (const parameter of searchParams) {
1224
+ const [key, value] = parameter.split("=");
1225
+ parameters[key] = value;
1226
+ }
1227
+ return { url: baseUrl, parameters };
1228
+ }
1229
+ /**
1230
+ * Generate a URL with parameters
1231
+ * @note case _getWMSUrl may need to be overridden to handle certain backends?
1232
+ * @note at the moment, only URLs with parameters are supported (no XML payloads)
1233
+ * */
1234
+ _getWMSUrl(request, wmsParameters, vendorParameters) {
1235
+ let url = this.url;
1236
+ let first = true;
1237
+ const allParameters = {
1238
+ service: "WMS",
1239
+ version: wmsParameters.version,
1240
+ request,
1241
+ ...wmsParameters,
1242
+ ...this.vendorParameters,
1243
+ ...vendorParameters
1244
+ };
1245
+ const IGNORE_EMPTY_KEYS = ["transparent", "time", "elevation"];
1246
+ for (const [key, value] of Object.entries(allParameters)) {
1247
+ if (!IGNORE_EMPTY_KEYS.includes(key) || value) {
1248
+ url += first ? "?" : "&";
1249
+ first = false;
1250
+ url += this._getURLParameter(key, value, wmsParameters);
1251
+ }
1252
+ }
1253
+ return encodeURI(url);
1254
+ }
1255
+ _getWMS130Parameters(wmsParameters) {
1256
+ const newParameters = { ...wmsParameters };
1257
+ if (newParameters.srs) {
1258
+ newParameters.crs = newParameters.crs || newParameters.srs;
1259
+ delete newParameters.srs;
1260
+ }
1261
+ return newParameters;
1262
+ }
1263
+ // eslint-disable-complexity
1264
+ _getURLParameter(key, value, wmsParameters) {
1265
+ switch (key) {
1266
+ case "crs":
1267
+ if (wmsParameters.version !== "1.3.0") {
1268
+ key = "srs";
1269
+ } else if (this.substituteCRS84 && value === "EPSG:4326") {
1270
+ value = "CRS:84";
1271
+ }
1272
+ break;
1273
+ case "srs":
1274
+ if (wmsParameters.version === "1.3.0") {
1275
+ key = "crs";
1276
+ }
1277
+ break;
1278
+ case "bbox":
1279
+ const bbox = this._flipBoundingBox(value, wmsParameters);
1280
+ if (bbox) {
1281
+ value = bbox;
1282
+ }
1283
+ break;
1284
+ default:
1285
+ }
1286
+ key = key.toUpperCase();
1287
+ return Array.isArray(value) ? `${key}=${value.join(",")}` : `${key}=${value ? String(value) : ""}`;
1288
+ }
1289
+ /** Coordinate order is flipped for certain CRS in WMS 1.3.0 */
1290
+ _flipBoundingBox(bboxValue, wmsParameters) {
1291
+ if (!Array.isArray(bboxValue) || bboxValue.length !== 4) {
1292
+ return null;
1293
+ }
1294
+ const flipCoordinates = (
1295
+ // Only affects WMS 1.3.0
1296
+ wmsParameters.version === "1.3.0" && // Flip if we are dealing with a CRS that was flipped in 1.3.0
1297
+ this.flipCRS.includes(wmsParameters.crs || "") && // Don't flip if we are subsituting EPSG:4326 with CRS:84
1298
+ !(this.substituteCRS84 && wmsParameters.crs === "EPSG:4326")
1299
+ );
1300
+ const bbox = bboxValue;
1301
+ return flipCoordinates ? [bbox[1], bbox[0], bbox[3], bbox[2]] : bbox;
1302
+ }
1303
+ /** Fetches an array buffer and checks the response (boilerplate reduction) */
1304
+ async _fetchArrayBuffer(url) {
1305
+ const response = await this.fetch(url);
1306
+ const arrayBuffer = await response.arrayBuffer();
1307
+ this._checkResponse(response, arrayBuffer);
1308
+ return arrayBuffer;
1309
+ }
1310
+ /** Checks for and parses a WMS XML formatted ServiceError and throws an exception */
1311
+ _checkResponse(response, arrayBuffer) {
1312
+ var _a, _b;
1313
+ const contentType = response.headers["content-type"];
1314
+ if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
1315
+ const loadOptions = (0, import_loader_utils.mergeLoaderOptions)(this.loadOptions, {
1316
+ wms: { throwOnError: true }
1317
+ });
1318
+ const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, loadOptions);
1319
+ throw new Error(error);
1320
+ }
1321
+ }
1322
+ /** Error situation detected */
1323
+ _parseError(arrayBuffer) {
1324
+ var _a, _b;
1325
+ const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, this.loadOptions);
1326
+ return new Error(error);
1327
+ }
1328
+ };
1329
+
1330
+ // src/lib/services/image-service.ts
1331
+ var import_images2 = require("@loaders.gl/images");
1332
+ var import_loader_utils3 = require("@loaders.gl/loader-utils");
1333
+ var ImageService = class extends import_loader_utils3.ImageSource {
1334
+ constructor(props) {
1335
+ super(props);
1336
+ }
1337
+ // IMAGE SOURCE API
1338
+ async getMetadata() {
1339
+ throw new Error("ImageSource.getMetadata not implemented");
1340
+ }
1341
+ async getImage(parameters) {
1342
+ const granularParameters = this.getGranularParameters(parameters);
1343
+ const url = this.getURLFromTemplate(granularParameters);
1344
+ const response = await this.fetch(url);
1345
+ const arrayBuffer = await response.arrayBuffer();
1346
+ return await import_images2.ImageLoader.parse(arrayBuffer);
1347
+ }
1348
+ // HELPERS
1349
+ /** Break up bounding box in east, north, south, west */
1350
+ getGranularParameters(parameters) {
1351
+ const [east, north, west, south] = parameters.bbox;
1352
+ return { ...parameters, east, north, south, west };
1353
+ }
1354
+ /** Supports both ${} and {} notations */
1355
+ getURLFromTemplate(parameters) {
1356
+ let url = this.props.url;
1357
+ for (const [key, value] of Object.entries(parameters)) {
1358
+ url = url.replace(`\${${key}}`, String(value));
1359
+ url = url.replace(`{${key}}`, String(value));
1360
+ }
1361
+ return url;
1362
+ }
1363
+ };
1364
+ ImageService.type = "template";
1365
+ ImageService.testURL = (url) => url.toLowerCase().includes("{");
1366
+
1367
+ // src/services/arcgis/arcgis-image-service.ts
1368
+ var ArcGISImageSource = class extends ImageService {
1369
+ constructor(props) {
1370
+ super(props);
1371
+ }
1372
+ // ImageSource (normalized endpoints)
1373
+ async getMetadata() {
1374
+ return await this.metadata();
1375
+ }
1376
+ async getImage(parameters) {
1377
+ throw new Error("not implemented");
1378
+ }
1379
+ // ImageServer endpoints
1380
+ async metadata() {
1381
+ throw new Error("not implemented");
1382
+ }
1383
+ /**
1384
+ * Form a URL to an ESRI ImageServer
1385
+ // 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`,
1386
+ */
1387
+ exportImage(options) {
1388
+ throw new Error("not implemented");
1389
+ }
1390
+ // URL creators
1391
+ metadataURL(options) {
1392
+ return `${this.props.url}?f=pjson`;
1393
+ }
1394
+ /**
1395
+ * Form a URL to an ESRI ImageServer
1396
+ // https://sampleserver6.arcgisonline.com/arcgis/rest/services/NLCDLandCover2001/ImageServer/exportImage?
1397
+ // bbox=${bounds[0]},${bounds[1]},${bounds[2]},${bounds[3]}&bboxSR=4326&
1398
+ // size=${width},${height}&imageSR=102100&time=&format=jpgpng&pixelType=U8&
1399
+ // noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_NearestNeighbor&compression=&
1400
+ // compressionQuality=&bandIds=&mosaicRule=&renderingRule=&
1401
+ // f=image
1402
+ */
1403
+ exportImageURL(options) {
1404
+ const bbox = `bbox=${options.bbox[0]},${options.bbox[1]},${options.bbox[2]},${options.bbox[3]}`;
1405
+ const size = `size=${options.width},${options.height}`;
1406
+ const arcgisOptions = { ...options, bbox, size };
1407
+ delete arcgisOptions.width;
1408
+ delete arcgisOptions.height;
1409
+ return this.getUrl("exportImage", arcgisOptions);
1410
+ }
1411
+ // INTERNAL METHODS
1412
+ /**
1413
+ * @note protected, since perhaps getWMSUrl may need to be overridden to handle certain backends?
1414
+ * @note if override is common, maybe add a callback prop?
1415
+ * */
1416
+ getUrl(path, options, extra) {
1417
+ let url = `${this.props.url}/${path}`;
1418
+ let first = true;
1419
+ for (const [key, value] of Object.entries(options)) {
1420
+ url += first ? "?" : "&";
1421
+ first = false;
1422
+ if (Array.isArray(value)) {
1423
+ url += `${key.toUpperCase()}=${value.join(",")}`;
1424
+ } else {
1425
+ url += `${key.toUpperCase()}=${value ? String(value) : ""}`;
1426
+ }
1427
+ }
1428
+ return url;
1429
+ }
1430
+ /** Checks for and parses a WMS XML formatted ServiceError and throws an exception */
1431
+ async checkResponse(response) {
1432
+ if (!response.ok) {
1433
+ throw new Error("error");
1434
+ }
1435
+ }
1436
+ };
1437
+ var ArcGISImageService = {
1438
+ type: "arcgis-image-server",
1439
+ testURL: (url) => url.toLowerCase().includes("ImageServer"),
1440
+ create: (props) => new ArcGISImageSource(props)
1441
+ };
1442
+
1443
+ // src/services/create-image-source.ts
1444
+ var SERVICES = [WMSService, ArcGISImageService];
1445
+ function createImageSource(props) {
1446
+ return createImageService(props, SERVICES);
1447
+ }
1448
+
1449
+ // src/services/ogc/csw-service.ts
1450
+ var import_loader_utils4 = require("@loaders.gl/loader-utils");
1451
+ var CSWService = class extends import_loader_utils4.DataSource {
1452
+ /** Create a CSWService */
1453
+ constructor(props) {
1454
+ super(props);
1455
+ this.capabilities = null;
1456
+ /** A list of loaders used by the CSWService methods */
1457
+ this.loaders = [WMSErrorLoader, CSWCapabilitiesLoader];
1458
+ }
1459
+ async getMetadata() {
1460
+ const capabilities = await this.getCapabilities();
1461
+ return this.normalizeMetadata(capabilities);
1462
+ }
1463
+ normalizeMetadata(capabilities) {
1464
+ return capabilities;
1465
+ }
1466
+ async getServiceDirectory(options) {
1467
+ const services = [];
1468
+ const unknownServices = [];
1469
+ const records = await this.getRecords();
1470
+ for (const record of records.records) {
1471
+ for (const reference of record.references) {
1472
+ const url = reference.value;
1473
+ switch (reference.scheme) {
1474
+ case "OGC:WMS":
1475
+ services.push({ name: record.title, type: "ogc-wms-service", ...this._parseOGCUrl(url) });
1476
+ break;
1477
+ case "OGC:WMTS":
1478
+ services.push({
1479
+ name: record.title,
1480
+ type: "ogc-wmts-service",
1481
+ ...this._parseOGCUrl(url)
1482
+ });
1483
+ break;
1484
+ case "OGC:WFS":
1485
+ services.push({ name: record.title, type: "ogc-wfs-service", ...this._parseOGCUrl(url) });
1486
+ break;
1487
+ default:
1488
+ unknownServices.push({
1489
+ name: record.title,
1490
+ type: "unknown",
1491
+ url: reference.value,
1492
+ scheme: reference.scheme
1493
+ });
1494
+ }
1495
+ }
1496
+ }
1497
+ return (options == null ? void 0 : options.includeUnknown) ? services.concat(unknownServices) : services;
1498
+ }
1499
+ _parseOGCUrl(url) {
1500
+ const parts = url.split("?");
1501
+ return {
1502
+ url: parts[0],
1503
+ params: parts[1] || ""
1504
+ };
1505
+ }
1506
+ // CSW Service API Stubs
1507
+ /** Get Capabilities */
1508
+ async getCapabilities(wmsParameters, vendorParameters) {
1509
+ const url = this.getCapabilitiesURL(wmsParameters, vendorParameters);
1510
+ const response = await this.fetch(url);
1511
+ const arrayBuffer = await response.arrayBuffer();
1512
+ this._checkResponse(response, arrayBuffer);
1513
+ const capabilities = await CSWCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);
1514
+ return capabilities;
1515
+ }
1516
+ /** Get Records */
1517
+ async getRecords(wmsParameters, vendorParameters) {
1518
+ const url = this.getRecordsURL(wmsParameters, vendorParameters);
1519
+ const response = await this.fetch(url);
1520
+ const arrayBuffer = await response.arrayBuffer();
1521
+ this._checkResponse(response, arrayBuffer);
1522
+ return await CSWRecordsLoader.parse(arrayBuffer, this.props.loadOptions);
1523
+ }
1524
+ /** Get Domain */
1525
+ async getDomain(wmsParameters, vendorParameters) {
1526
+ const url = this.getDomainURL(wmsParameters, vendorParameters);
1527
+ const response = await this.fetch(url);
1528
+ const arrayBuffer = await response.arrayBuffer();
1529
+ this._checkResponse(response, arrayBuffer);
1530
+ return await CSWDomainLoader.parse(arrayBuffer, this.props.loadOptions);
1531
+ }
1532
+ // Typed URL creators
1533
+ // For applications that want full control of fetching and parsing
1534
+ /** Generate a URL for the GetCapabilities request */
1535
+ getCapabilitiesURL(wmsParameters, vendorParameters) {
1536
+ const options = {
1537
+ version: "3.0.0",
1538
+ ...wmsParameters,
1539
+ ...vendorParameters,
1540
+ service: "CSW",
1541
+ request: "GetCapabilities"
1542
+ };
1543
+ return this._getCSWUrl(options, vendorParameters);
1544
+ }
1545
+ /** Generate a URL for the GetCapabilities request */
1546
+ getRecordsURL(wmsParameters, vendorParameters) {
1547
+ const options = {
1548
+ version: "3.0.0",
1549
+ typenames: "csw:Record",
1550
+ ...wmsParameters,
1551
+ ...vendorParameters,
1552
+ service: "CSW",
1553
+ request: "GetRecords"
1554
+ };
1555
+ return this._getCSWUrl(options, vendorParameters);
1556
+ }
1557
+ /** Generate a URL for the GetCapabilities request */
1558
+ getDomainURL(wmsParameters, vendorParameters) {
1559
+ const options = {
1560
+ version: "3.0.0",
1561
+ ...wmsParameters,
1562
+ ...vendorParameters,
1563
+ service: "CSW",
1564
+ request: "GetDomain"
1565
+ };
1566
+ return this._getCSWUrl(options, vendorParameters);
1567
+ }
1568
+ // INTERNAL METHODS
1569
+ /**
1570
+ * @note case _getCSWUrl may need to be overridden to handle certain backends?
1571
+ * */
1572
+ _getCSWUrl(options, vendorParameters) {
1573
+ let url = this.props.url;
1574
+ let first = true;
1575
+ for (const [key, value] of Object.entries(options)) {
1576
+ url += first ? "?" : "&";
1577
+ first = false;
1578
+ if (Array.isArray(value)) {
1579
+ url += `${key.toUpperCase()}=${value.join(",")}`;
1580
+ } else {
1581
+ url += `${key.toUpperCase()}=${value ? String(value) : ""}`;
1582
+ }
1583
+ }
1584
+ return encodeURI(url);
1585
+ }
1586
+ /** Checks for and parses a CSW XML formatted ServiceError and throws an exception */
1587
+ _checkResponse(response, arrayBuffer) {
1588
+ var _a, _b;
1589
+ const contentType = response.headers["content-type"];
1590
+ if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
1591
+ const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, this.props.loadOptions);
1592
+ throw new Error(error);
1593
+ }
1594
+ }
1595
+ /** Error situation detected */
1596
+ _parseError(arrayBuffer) {
1597
+ var _a, _b;
1598
+ const error = (_b = (_a = WMSErrorLoader).parseSync) == null ? void 0 : _b.call(_a, arrayBuffer, this.props.loadOptions);
1599
+ return new Error(error);
1600
+ }
1601
+ };
1602
+ CSWService.type = "csw";
1603
+ CSWService.testURL = (url) => url.toLowerCase().includes("csw");
1604
+
1605
+ // src/services/arcgis/arcgis-server.ts
1606
+ async function getArcGISServices(url, fetchFile = fetch) {
1607
+ if (url.includes("rest/services")) {
1608
+ const serverUrl = url.replace(/rest\/services.*$/i, "rest/services");
1609
+ return loadServiceDirectory(serverUrl, fetchFile, []);
1610
+ }
1611
+ return null;
1612
+ }
1613
+ async function loadServiceDirectory(serverUrl, fetch2, path) {
1614
+ const serviceUrl = `${serverUrl}/${path.join("/")}`;
1615
+ const response = await fetch2(`${serviceUrl}?f=pjson`);
1616
+ const directory = await response.json();
1617
+ const services = extractServices(directory, serviceUrl);
1618
+ const folders = directory.folders || [];
1619
+ const promises = folders.map(
1620
+ (folder) => loadServiceDirectory(`${serverUrl}`, fetch2, [...path, folder])
1621
+ );
1622
+ for (const folderServices of await Promise.all(promises)) {
1623
+ services.push(...folderServices);
1624
+ }
1625
+ return services;
1626
+ }
1627
+ function extractServices(directory, url) {
1628
+ const arcgisServices = directory.services || [];
1629
+ const services = [];
1630
+ for (const service of arcgisServices) {
1631
+ services.push({
1632
+ name: service.name,
1633
+ type: `arcgis-${service.type.toLocaleLowerCase().replace("server", "-server")}`,
1634
+ url: `${url}${service.name}/${service.type}`
1635
+ });
1636
+ }
1637
+ return services;
1638
+ }
1639
+
1640
+ // src/index.ts
1641
+ var import_loader_utils5 = require("@loaders.gl/loader-utils");