@loaders.gl/wms 3.3.0-alpha.8 → 3.3.0-alpha.9

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 (49) hide show
  1. package/dist/dist.min.js +624 -33
  2. package/dist/es5/bundle.js.map +1 -1
  3. package/dist/es5/index.js +21 -0
  4. package/dist/es5/index.js.map +1 -1
  5. package/dist/es5/lib/data-sources/image-data-source.js +4 -0
  6. package/dist/es5/lib/data-sources/image-data-source.js.map +1 -0
  7. package/dist/es5/lib/data-sources/wms-data-source.js +223 -0
  8. package/dist/es5/lib/data-sources/wms-data-source.js.map +1 -0
  9. package/dist/es5/lib/parse-wms.js +102 -0
  10. package/dist/es5/lib/parse-wms.js.map +1 -0
  11. package/dist/es5/wms-capabilities-loader.js +7 -6
  12. package/dist/es5/wms-capabilities-loader.js.map +1 -1
  13. package/dist/es5/wms-feature-info-loader.js +44 -0
  14. package/dist/es5/wms-feature-info-loader.js.map +1 -0
  15. package/dist/es5/wms-layer-description-loader.js +44 -0
  16. package/dist/es5/wms-layer-description-loader.js.map +1 -0
  17. package/dist/es5/wms-types.js.map +1 -1
  18. package/dist/esm/bundle.js +1 -0
  19. package/dist/esm/bundle.js.map +1 -1
  20. package/dist/esm/index.js +3 -0
  21. package/dist/esm/index.js.map +1 -1
  22. package/dist/esm/lib/data-sources/image-data-source.js +2 -0
  23. package/dist/esm/lib/data-sources/image-data-source.js.map +1 -0
  24. package/dist/esm/lib/data-sources/wms-data-source.js +70 -0
  25. package/dist/esm/lib/data-sources/wms-data-source.js.map +1 -0
  26. package/dist/esm/lib/parse-wms.js +70 -0
  27. package/dist/esm/lib/parse-wms.js.map +1 -0
  28. package/dist/esm/wms-capabilities-loader.js +6 -4
  29. package/dist/esm/wms-capabilities-loader.js.map +1 -1
  30. package/dist/esm/wms-feature-info-loader.js +14 -0
  31. package/dist/esm/wms-feature-info-loader.js.map +1 -0
  32. package/dist/esm/wms-layer-description-loader.js +14 -0
  33. package/dist/esm/wms-layer-description-loader.js.map +1 -0
  34. package/dist/esm/wms-types.js.map +1 -1
  35. package/package.json +4 -4
  36. package/src/bundle.ts +2 -0
  37. package/src/index.ts +8 -1
  38. package/src/lib/data-sources/image-data-source.ts +84 -0
  39. package/src/lib/data-sources/wms-data-source.ts +99 -0
  40. package/src/lib/parse-wms.ts +92 -0
  41. package/src/wms-capabilities-loader.ts +10 -8
  42. package/src/wms-feature-info-loader.ts +21 -0
  43. package/src/wms-layer-description-loader.ts +21 -0
  44. package/src/wms-types.ts +74 -24
  45. package/dist/es5/lib/parse-wms-capabilities.js +0 -19
  46. package/dist/es5/lib/parse-wms-capabilities.js.map +0 -1
  47. package/dist/esm/lib/parse-wms-capabilities.js +0 -14
  48. package/dist/esm/lib/parse-wms-capabilities.js.map +0 -1
  49. package/src/lib/parse-wms-capabilities.ts +0 -14
package/dist/dist.min.js CHANGED
@@ -38,7 +38,7 @@
38
38
  var nameRegexp = "[" + nameStartChar + "][" + nameChar + "]*";
39
39
  var regexName = new RegExp("^" + nameRegexp + "$");
40
40
  var getAllMatches = function(string, regex) {
41
- const matches = [];
41
+ const matches2 = [];
42
42
  let match = regex.exec(string);
43
43
  while (match) {
44
44
  const allmatches = [];
@@ -47,10 +47,10 @@
47
47
  for (let index = 0; index < len; index++) {
48
48
  allmatches.push(match[index]);
49
49
  }
50
- matches.push(allmatches);
50
+ matches2.push(allmatches);
51
51
  match = regex.exec(string);
52
52
  }
53
- return matches;
53
+ return matches2;
54
54
  };
55
55
  var isName = function(string) {
56
56
  const match = regexName.exec(string);
@@ -311,24 +311,24 @@
311
311
  }
312
312
  var validAttrStrRegxp = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
313
313
  function validateAttributeString(attrStr, options) {
314
- const matches = util.getAllMatches(attrStr, validAttrStrRegxp);
314
+ const matches2 = util.getAllMatches(attrStr, validAttrStrRegxp);
315
315
  const attrNames = {};
316
- for (let i = 0; i < matches.length; i++) {
317
- if (matches[i][1].length === 0) {
318
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' has no space in starting.", getPositionFromMatch(matches[i]));
319
- } else if (matches[i][3] !== void 0 && matches[i][4] === void 0) {
320
- return getErrorObject("InvalidAttr", "Attribute '" + matches[i][2] + "' is without value.", getPositionFromMatch(matches[i]));
321
- } else if (matches[i][3] === void 0 && !options.allowBooleanAttributes) {
322
- return getErrorObject("InvalidAttr", "boolean attribute '" + matches[i][2] + "' is not allowed.", getPositionFromMatch(matches[i]));
316
+ for (let i = 0; i < matches2.length; i++) {
317
+ if (matches2[i][1].length === 0) {
318
+ return getErrorObject("InvalidAttr", "Attribute '" + matches2[i][2] + "' has no space in starting.", getPositionFromMatch(matches2[i]));
319
+ } else if (matches2[i][3] !== void 0 && matches2[i][4] === void 0) {
320
+ return getErrorObject("InvalidAttr", "Attribute '" + matches2[i][2] + "' is without value.", getPositionFromMatch(matches2[i]));
321
+ } else if (matches2[i][3] === void 0 && !options.allowBooleanAttributes) {
322
+ return getErrorObject("InvalidAttr", "boolean attribute '" + matches2[i][2] + "' is not allowed.", getPositionFromMatch(matches2[i]));
323
323
  }
324
- const attrName = matches[i][2];
324
+ const attrName = matches2[i][2];
325
325
  if (!validateAttrName(attrName)) {
326
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches[i]));
326
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is an invalid name.", getPositionFromMatch(matches2[i]));
327
327
  }
328
328
  if (!attrNames.hasOwnProperty(attrName)) {
329
329
  attrNames[attrName] = 1;
330
330
  } else {
331
- return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches[i]));
331
+ return getErrorObject("InvalidAttr", "Attribute '" + attrName + "' is repeated.", getPositionFromMatch(matches2[i]));
332
332
  }
333
333
  }
334
334
  return true;
@@ -725,12 +725,12 @@
725
725
  var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
726
726
  function buildAttributesMap(attrStr, jPath) {
727
727
  if (!this.options.ignoreAttributes && typeof attrStr === "string") {
728
- const matches = util.getAllMatches(attrStr, attrsRegx);
729
- const len = matches.length;
728
+ const matches2 = util.getAllMatches(attrStr, attrsRegx);
729
+ const len = matches2.length;
730
730
  const attrs = {};
731
731
  for (let i = 0; i < len; i++) {
732
- const attrName = this.resolveNameSpace(matches[i][1]);
733
- let oldVal = matches[i][4];
732
+ const attrName = this.resolveNameSpace(matches2[i][1]);
733
+ let oldVal = matches2[i][4];
734
734
  const aName = this.options.attributeNamePrefix + attrName;
735
735
  if (attrName.length) {
736
736
  if (oldVal !== void 0) {
@@ -1574,7 +1574,11 @@
1574
1574
 
1575
1575
  // ../xml/src/lib/parse-xml.ts
1576
1576
  function parseXML(text, options) {
1577
- const parser = new import_fast_xml_parser.XMLParser({ ...options });
1577
+ const parser = new import_fast_xml_parser.XMLParser({
1578
+ ignoreAttributes: false,
1579
+ attributeNamePrefix: "",
1580
+ ...options
1581
+ });
1578
1582
  const parsedXML = parser.parse(text);
1579
1583
  return parsedXML;
1580
1584
  }
@@ -1619,19 +1623,60 @@
1619
1623
  }
1620
1624
  });
1621
1625
 
1622
- // src/lib/parse-wms-capabilities.ts
1626
+ // src/lib/parse-wms.ts
1623
1627
  function parseWMSCapabilities(text, options) {
1624
1628
  const parsedXML = XMLLoader.parseTextSync(text, options);
1625
- if (parsedXML.WMT_MS_Capabilities) {
1626
- return parsedXML.WMT_MS_Capabilities;
1629
+ const xmlCapabilities = parsedXML.WMT_MS_Capabilities || parsedXML.WMS_Capabilities || parsedXML;
1630
+ return extractCapabilities(xmlCapabilities);
1631
+ }
1632
+ function extractCapabilities(xml) {
1633
+ const capabilities = {
1634
+ name: xml.Service?.Name || "unnamed",
1635
+ title: xml.Service?.Title,
1636
+ keywords: [],
1637
+ requests: {},
1638
+ layer: extractLayer(xml.Capability?.Layer),
1639
+ raw: xml
1640
+ };
1641
+ for (const keyword of xml.Service?.KeywordList?.Keyword || []) {
1642
+ capabilities.keywords.push(keyword);
1627
1643
  }
1628
- if (parsedXML.WMS_Capabilities) {
1629
- return parsedXML.WMS_Capabilities;
1644
+ for (const [name, xmlRequest] of Object.entries(xml.Capability?.Request || {})) {
1645
+ capabilities.requests[name] = extractRequest(name, xmlRequest);
1630
1646
  }
1631
- return parsedXML;
1647
+ return capabilities;
1648
+ }
1649
+ function extractRequest(name, xmlRequest) {
1650
+ const format = xmlRequest?.Format;
1651
+ const mimeTypes = Array.isArray(format) ? format : [format];
1652
+ return { name, mimeTypes };
1653
+ }
1654
+ function extractLayer(xmlLayer) {
1655
+ const layer = {
1656
+ name: xmlLayer?.Name,
1657
+ title: xmlLayer?.Title,
1658
+ srs: xmlLayer?.SRS || [],
1659
+ layers: []
1660
+ };
1661
+ for (const xmlSubLayer of xmlLayer?.Layer || []) {
1662
+ layer.layers?.push(extractLayer(xmlSubLayer));
1663
+ }
1664
+ return layer;
1632
1665
  }
1633
- var init_parse_wms_capabilities = __esm({
1634
- "src/lib/parse-wms-capabilities.ts"() {
1666
+ function parseWMSFeatureInfo(text, options) {
1667
+ const parsedXML = XMLLoader.parseTextSync(text, options);
1668
+ const xmlFeatureInfo = parsedXML.FeatureInfoResponse?.FIELDS || [];
1669
+ const xmlFeatures = Array.isArray(xmlFeatureInfo) ? xmlFeatureInfo : [xmlFeatureInfo];
1670
+ return {
1671
+ features: xmlFeatures.map((xmlFeature) => extractFeature(xmlFeature))
1672
+ };
1673
+ }
1674
+ function extractFeature(xmlFeature) {
1675
+ const xmlFields = xmlFeature || {};
1676
+ return { attributes: xmlFields };
1677
+ }
1678
+ var init_parse_wms = __esm({
1679
+ "src/lib/parse-wms.ts"() {
1635
1680
  init_src();
1636
1681
  }
1637
1682
  });
@@ -1643,11 +1688,11 @@
1643
1688
  var VERSION2, WMSCapabilitiesLoader;
1644
1689
  var init_wms_capabilities_loader = __esm({
1645
1690
  "src/wms-capabilities-loader.ts"() {
1646
- init_parse_wms_capabilities();
1691
+ init_parse_wms();
1647
1692
  VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1648
1693
  WMSCapabilitiesLoader = {
1649
1694
  name: "WMS Capabilities",
1650
- id: "wms",
1695
+ id: "wms-capabilities",
1651
1696
  module: "wms",
1652
1697
  version: VERSION2,
1653
1698
  worker: false,
@@ -1655,7 +1700,7 @@
1655
1700
  mimeTypes: ["application/vnd.ogc.wms_xml", "application/xml", "text/xml"],
1656
1701
  testText: testXMLFile2,
1657
1702
  options: {
1658
- obj: {}
1703
+ wms: {}
1659
1704
  },
1660
1705
  parse: async (arrayBuffer, options) => parseWMSCapabilities(new TextDecoder().decode(arrayBuffer), options),
1661
1706
  parseTextSync: (text, options) => parseWMSCapabilities(text, options)
@@ -1663,21 +1708,567 @@
1663
1708
  }
1664
1709
  });
1665
1710
 
1711
+ // src/wms-feature-info-loader.ts
1712
+ var WMSFeatureInfoLoader;
1713
+ var init_wms_feature_info_loader = __esm({
1714
+ "src/wms-feature-info-loader.ts"() {
1715
+ init_wms_capabilities_loader();
1716
+ init_parse_wms();
1717
+ WMSFeatureInfoLoader = {
1718
+ ...WMSCapabilitiesLoader,
1719
+ name: "WMS FeatureInfo",
1720
+ id: "wms-feature-info",
1721
+ parse: async (arrayBuffer, options) => parseWMSFeatureInfo(new TextDecoder().decode(arrayBuffer), options),
1722
+ parseTextSync: (text, options) => parseWMSFeatureInfo(text, options)
1723
+ };
1724
+ }
1725
+ });
1726
+
1727
+ // src/wms-layer-description-loader.ts
1728
+ var WMSLayerDescriptionLoader;
1729
+ var init_wms_layer_description_loader = __esm({
1730
+ "src/wms-layer-description-loader.ts"() {
1731
+ init_wms_capabilities_loader();
1732
+ init_parse_wms();
1733
+ WMSLayerDescriptionLoader = {
1734
+ ...WMSCapabilitiesLoader,
1735
+ name: "WMS DescribeLayer",
1736
+ id: "wms-layer-description",
1737
+ parse: async (arrayBuffer, options) => parseWMSFeatureInfo(new TextDecoder().decode(arrayBuffer), options),
1738
+ parseTextSync: (text, options) => parseWMSFeatureInfo(text, options)
1739
+ };
1740
+ }
1741
+ });
1742
+
1743
+ // ../images/src/lib/utils/version.ts
1744
+ var VERSION3;
1745
+ var init_version = __esm({
1746
+ "../images/src/lib/utils/version.ts"() {
1747
+ VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
1748
+ }
1749
+ });
1750
+
1751
+ // ../loader-utils/src/lib/env-utils/assert.ts
1752
+ function assert(condition, message) {
1753
+ if (!condition) {
1754
+ throw new Error(message || "loader assertion failed.");
1755
+ }
1756
+ }
1757
+ var init_assert = __esm({
1758
+ "../loader-utils/src/lib/env-utils/assert.ts"() {
1759
+ }
1760
+ });
1761
+
1762
+ // ../loader-utils/src/lib/env-utils/globals.ts
1763
+ var globals, self_, window_, global_, document_, isBrowser, matches, nodeVersion;
1764
+ var init_globals = __esm({
1765
+ "../loader-utils/src/lib/env-utils/globals.ts"() {
1766
+ globals = {
1767
+ self: typeof self !== "undefined" && self,
1768
+ window: typeof window !== "undefined" && window,
1769
+ global: typeof global !== "undefined" && global,
1770
+ document: typeof document !== "undefined" && document
1771
+ };
1772
+ self_ = globals.self || globals.window || globals.global || {};
1773
+ window_ = globals.window || globals.self || globals.global || {};
1774
+ global_ = globals.global || globals.self || globals.window || {};
1775
+ document_ = globals.document || {};
1776
+ isBrowser = Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser);
1777
+ matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
1778
+ nodeVersion = matches && parseFloat(matches[1]) || 0;
1779
+ }
1780
+ });
1781
+
1782
+ // ../loader-utils/src/index.ts
1783
+ var init_src2 = __esm({
1784
+ "../loader-utils/src/index.ts"() {
1785
+ init_assert();
1786
+ init_globals();
1787
+ }
1788
+ });
1789
+
1790
+ // ../images/src/lib/category-api/image-type.ts
1791
+ function isImageTypeSupported(type) {
1792
+ switch (type) {
1793
+ case "auto":
1794
+ return IMAGE_BITMAP_SUPPORTED || IMAGE_SUPPORTED || DATA_SUPPORTED;
1795
+ case "imagebitmap":
1796
+ return IMAGE_BITMAP_SUPPORTED;
1797
+ case "image":
1798
+ return IMAGE_SUPPORTED;
1799
+ case "data":
1800
+ return DATA_SUPPORTED;
1801
+ default:
1802
+ throw new Error(`@loaders.gl/images: image ${type} not supported in this environment`);
1803
+ }
1804
+ }
1805
+ function getDefaultImageType() {
1806
+ if (IMAGE_BITMAP_SUPPORTED) {
1807
+ return "imagebitmap";
1808
+ }
1809
+ if (IMAGE_SUPPORTED) {
1810
+ return "image";
1811
+ }
1812
+ if (DATA_SUPPORTED) {
1813
+ return "data";
1814
+ }
1815
+ throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");
1816
+ }
1817
+ var _parseImageNode, IMAGE_SUPPORTED, IMAGE_BITMAP_SUPPORTED, NODE_IMAGE_SUPPORTED, DATA_SUPPORTED;
1818
+ var init_image_type = __esm({
1819
+ "../images/src/lib/category-api/image-type.ts"() {
1820
+ init_src2();
1821
+ ({ _parseImageNode } = globalThis);
1822
+ IMAGE_SUPPORTED = typeof Image !== "undefined";
1823
+ IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
1824
+ NODE_IMAGE_SUPPORTED = Boolean(_parseImageNode);
1825
+ DATA_SUPPORTED = isBrowser ? true : NODE_IMAGE_SUPPORTED;
1826
+ }
1827
+ });
1828
+
1829
+ // ../images/src/lib/category-api/parsed-image-api.ts
1830
+ function getImageType(image) {
1831
+ const format = getImageTypeOrNull(image);
1832
+ if (!format) {
1833
+ throw new Error("Not an image");
1834
+ }
1835
+ return format;
1836
+ }
1837
+ function getImageData(image) {
1838
+ switch (getImageType(image)) {
1839
+ case "data":
1840
+ return image;
1841
+ case "image":
1842
+ case "imagebitmap":
1843
+ const canvas = document.createElement("canvas");
1844
+ const context = canvas.getContext("2d");
1845
+ if (!context) {
1846
+ throw new Error("getImageData");
1847
+ }
1848
+ canvas.width = image.width;
1849
+ canvas.height = image.height;
1850
+ context.drawImage(image, 0, 0);
1851
+ return context.getImageData(0, 0, image.width, image.height);
1852
+ default:
1853
+ throw new Error("getImageData");
1854
+ }
1855
+ }
1856
+ function getImageTypeOrNull(image) {
1857
+ if (typeof ImageBitmap !== "undefined" && image instanceof ImageBitmap) {
1858
+ return "imagebitmap";
1859
+ }
1860
+ if (typeof Image !== "undefined" && image instanceof Image) {
1861
+ return "image";
1862
+ }
1863
+ if (image && typeof image === "object" && image.data && image.width && image.height) {
1864
+ return "data";
1865
+ }
1866
+ return null;
1867
+ }
1868
+ var init_parsed_image_api = __esm({
1869
+ "../images/src/lib/category-api/parsed-image-api.ts"() {
1870
+ }
1871
+ });
1872
+
1873
+ // ../images/src/lib/parsers/svg-utils.ts
1874
+ function isSVG(url) {
1875
+ return url && (SVG_DATA_URL_PATTERN.test(url) || SVG_URL_PATTERN.test(url));
1876
+ }
1877
+ function getBlobOrSVGDataUrl(arrayBuffer, url) {
1878
+ if (isSVG(url)) {
1879
+ const textDecoder = new TextDecoder();
1880
+ let xmlText = textDecoder.decode(arrayBuffer);
1881
+ try {
1882
+ if (typeof unescape === "function" && typeof encodeURIComponent === "function") {
1883
+ xmlText = unescape(encodeURIComponent(xmlText));
1884
+ }
1885
+ } catch (error) {
1886
+ throw new Error(error.message);
1887
+ }
1888
+ const src = `data:image/svg+xml;base64,${btoa(xmlText)}`;
1889
+ return src;
1890
+ }
1891
+ return getBlob(arrayBuffer, url);
1892
+ }
1893
+ function getBlob(arrayBuffer, url) {
1894
+ if (isSVG(url)) {
1895
+ throw new Error("SVG cannot be parsed directly to imagebitmap");
1896
+ }
1897
+ return new Blob([new Uint8Array(arrayBuffer)]);
1898
+ }
1899
+ var SVG_DATA_URL_PATTERN, SVG_URL_PATTERN;
1900
+ var init_svg_utils = __esm({
1901
+ "../images/src/lib/parsers/svg-utils.ts"() {
1902
+ SVG_DATA_URL_PATTERN = /^data:image\/svg\+xml/;
1903
+ SVG_URL_PATTERN = /\.svg((\?|#).*)?$/;
1904
+ }
1905
+ });
1906
+
1907
+ // ../images/src/lib/parsers/parse-to-image.ts
1908
+ async function parseToImage(arrayBuffer, options, url) {
1909
+ const blobOrDataUrl = getBlobOrSVGDataUrl(arrayBuffer, url);
1910
+ const URL = self.URL || self.webkitURL;
1911
+ const objectUrl = typeof blobOrDataUrl !== "string" && URL.createObjectURL(blobOrDataUrl);
1912
+ try {
1913
+ return await loadToImage(objectUrl || blobOrDataUrl, options);
1914
+ } finally {
1915
+ if (objectUrl) {
1916
+ URL.revokeObjectURL(objectUrl);
1917
+ }
1918
+ }
1919
+ }
1920
+ async function loadToImage(url, options) {
1921
+ const image = new Image();
1922
+ image.src = url;
1923
+ if (options.image && options.image.decode && image.decode) {
1924
+ await image.decode();
1925
+ return image;
1926
+ }
1927
+ return await new Promise((resolve, reject) => {
1928
+ try {
1929
+ image.onload = () => resolve(image);
1930
+ image.onerror = (err) => reject(new Error(`Could not load image ${url}: ${err}`));
1931
+ } catch (error) {
1932
+ reject(error);
1933
+ }
1934
+ });
1935
+ }
1936
+ var init_parse_to_image = __esm({
1937
+ "../images/src/lib/parsers/parse-to-image.ts"() {
1938
+ init_svg_utils();
1939
+ }
1940
+ });
1941
+
1942
+ // ../images/src/lib/parsers/parse-to-image-bitmap.ts
1943
+ async function parseToImageBitmap(arrayBuffer, options, url) {
1944
+ let blob;
1945
+ if (isSVG(url)) {
1946
+ const image = await parseToImage(arrayBuffer, options, url);
1947
+ blob = image;
1948
+ } else {
1949
+ blob = getBlob(arrayBuffer, url);
1950
+ }
1951
+ const imagebitmapOptions = options && options.imagebitmap;
1952
+ return await safeCreateImageBitmap(blob, imagebitmapOptions);
1953
+ }
1954
+ async function safeCreateImageBitmap(blob, imagebitmapOptions = null) {
1955
+ if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
1956
+ imagebitmapOptions = null;
1957
+ }
1958
+ if (imagebitmapOptions) {
1959
+ try {
1960
+ return await createImageBitmap(blob, imagebitmapOptions);
1961
+ } catch (error) {
1962
+ console.warn(error);
1963
+ imagebitmapOptionsSupported = false;
1964
+ }
1965
+ }
1966
+ return await createImageBitmap(blob);
1967
+ }
1968
+ function isEmptyObject(object) {
1969
+ for (const key in object || EMPTY_OBJECT) {
1970
+ return false;
1971
+ }
1972
+ return true;
1973
+ }
1974
+ var EMPTY_OBJECT, imagebitmapOptionsSupported;
1975
+ var init_parse_to_image_bitmap = __esm({
1976
+ "../images/src/lib/parsers/parse-to-image-bitmap.ts"() {
1977
+ init_svg_utils();
1978
+ init_parse_to_image();
1979
+ EMPTY_OBJECT = {};
1980
+ imagebitmapOptionsSupported = true;
1981
+ }
1982
+ });
1983
+
1984
+ // ../images/src/lib/category-api/binary-image-api.ts
1985
+ function getBinaryImageMetadata(binaryData) {
1986
+ const dataView = toDataView(binaryData);
1987
+ return getPngMetadata(dataView) || getJpegMetadata(dataView) || getGifMetadata(dataView) || getBmpMetadata(dataView);
1988
+ }
1989
+ function getPngMetadata(binaryData) {
1990
+ const dataView = toDataView(binaryData);
1991
+ const isPng = dataView.byteLength >= 24 && dataView.getUint32(0, BIG_ENDIAN) === 2303741511;
1992
+ if (!isPng) {
1993
+ return null;
1994
+ }
1995
+ return {
1996
+ mimeType: "image/png",
1997
+ width: dataView.getUint32(16, BIG_ENDIAN),
1998
+ height: dataView.getUint32(20, BIG_ENDIAN)
1999
+ };
2000
+ }
2001
+ function getGifMetadata(binaryData) {
2002
+ const dataView = toDataView(binaryData);
2003
+ const isGif = dataView.byteLength >= 10 && dataView.getUint32(0, BIG_ENDIAN) === 1195984440;
2004
+ if (!isGif) {
2005
+ return null;
2006
+ }
2007
+ return {
2008
+ mimeType: "image/gif",
2009
+ width: dataView.getUint16(6, LITTLE_ENDIAN),
2010
+ height: dataView.getUint16(8, LITTLE_ENDIAN)
2011
+ };
2012
+ }
2013
+ function getBmpMetadata(binaryData) {
2014
+ const dataView = toDataView(binaryData);
2015
+ const isBmp = dataView.byteLength >= 14 && dataView.getUint16(0, BIG_ENDIAN) === 16973 && dataView.getUint32(2, LITTLE_ENDIAN) === dataView.byteLength;
2016
+ if (!isBmp) {
2017
+ return null;
2018
+ }
2019
+ return {
2020
+ mimeType: "image/bmp",
2021
+ width: dataView.getUint32(18, LITTLE_ENDIAN),
2022
+ height: dataView.getUint32(22, LITTLE_ENDIAN)
2023
+ };
2024
+ }
2025
+ function getJpegMetadata(binaryData) {
2026
+ const dataView = toDataView(binaryData);
2027
+ const isJpeg = dataView.byteLength >= 3 && dataView.getUint16(0, BIG_ENDIAN) === 65496 && dataView.getUint8(2) === 255;
2028
+ if (!isJpeg) {
2029
+ return null;
2030
+ }
2031
+ const { tableMarkers, sofMarkers } = getJpegMarkers();
2032
+ let i = 2;
2033
+ while (i + 9 < dataView.byteLength) {
2034
+ const marker = dataView.getUint16(i, BIG_ENDIAN);
2035
+ if (sofMarkers.has(marker)) {
2036
+ return {
2037
+ mimeType: "image/jpeg",
2038
+ height: dataView.getUint16(i + 5, BIG_ENDIAN),
2039
+ width: dataView.getUint16(i + 7, BIG_ENDIAN)
2040
+ };
2041
+ }
2042
+ if (!tableMarkers.has(marker)) {
2043
+ return null;
2044
+ }
2045
+ i += 2;
2046
+ i += dataView.getUint16(i, BIG_ENDIAN);
2047
+ }
2048
+ return null;
2049
+ }
2050
+ function getJpegMarkers() {
2051
+ const tableMarkers = new Set([65499, 65476, 65484, 65501, 65534]);
2052
+ for (let i = 65504; i < 65520; ++i) {
2053
+ tableMarkers.add(i);
2054
+ }
2055
+ const sofMarkers = new Set([
2056
+ 65472,
2057
+ 65473,
2058
+ 65474,
2059
+ 65475,
2060
+ 65477,
2061
+ 65478,
2062
+ 65479,
2063
+ 65481,
2064
+ 65482,
2065
+ 65483,
2066
+ 65485,
2067
+ 65486,
2068
+ 65487,
2069
+ 65502
2070
+ ]);
2071
+ return { tableMarkers, sofMarkers };
2072
+ }
2073
+ function toDataView(data) {
2074
+ if (data instanceof DataView) {
2075
+ return data;
2076
+ }
2077
+ if (ArrayBuffer.isView(data)) {
2078
+ return new DataView(data.buffer);
2079
+ }
2080
+ if (data instanceof ArrayBuffer) {
2081
+ return new DataView(data);
2082
+ }
2083
+ throw new Error("toDataView");
2084
+ }
2085
+ var BIG_ENDIAN, LITTLE_ENDIAN;
2086
+ var init_binary_image_api = __esm({
2087
+ "../images/src/lib/category-api/binary-image-api.ts"() {
2088
+ BIG_ENDIAN = false;
2089
+ LITTLE_ENDIAN = true;
2090
+ }
2091
+ });
2092
+
2093
+ // ../images/src/lib/parsers/parse-to-node-image.ts
2094
+ async function parseToNodeImage(arrayBuffer, options) {
2095
+ const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
2096
+ const _parseImageNode2 = globalThis._parseImageNode;
2097
+ assert(_parseImageNode2);
2098
+ return await _parseImageNode2(arrayBuffer, mimeType);
2099
+ }
2100
+ var init_parse_to_node_image = __esm({
2101
+ "../images/src/lib/parsers/parse-to-node-image.ts"() {
2102
+ init_src2();
2103
+ init_binary_image_api();
2104
+ }
2105
+ });
2106
+
2107
+ // ../images/src/lib/parsers/parse-image.ts
2108
+ async function parseImage(arrayBuffer, options, context) {
2109
+ options = options || {};
2110
+ const imageOptions = options.image || {};
2111
+ const imageType = imageOptions.type || "auto";
2112
+ const { url } = context || {};
2113
+ const loadType = getLoadableImageType(imageType);
2114
+ let image;
2115
+ switch (loadType) {
2116
+ case "imagebitmap":
2117
+ image = await parseToImageBitmap(arrayBuffer, options, url);
2118
+ break;
2119
+ case "image":
2120
+ image = await parseToImage(arrayBuffer, options, url);
2121
+ break;
2122
+ case "data":
2123
+ image = await parseToNodeImage(arrayBuffer, options);
2124
+ break;
2125
+ default:
2126
+ assert(false);
2127
+ }
2128
+ if (imageType === "data") {
2129
+ image = getImageData(image);
2130
+ }
2131
+ return image;
2132
+ }
2133
+ function getLoadableImageType(type) {
2134
+ switch (type) {
2135
+ case "auto":
2136
+ case "data":
2137
+ return getDefaultImageType();
2138
+ default:
2139
+ isImageTypeSupported(type);
2140
+ return type;
2141
+ }
2142
+ }
2143
+ var init_parse_image = __esm({
2144
+ "../images/src/lib/parsers/parse-image.ts"() {
2145
+ init_src2();
2146
+ init_image_type();
2147
+ init_parsed_image_api();
2148
+ init_parse_to_image();
2149
+ init_parse_to_image_bitmap();
2150
+ init_parse_to_node_image();
2151
+ }
2152
+ });
2153
+
2154
+ // ../images/src/image-loader.ts
2155
+ var EXTENSIONS, MIME_TYPES, DEFAULT_IMAGE_LOADER_OPTIONS, ImageLoader;
2156
+ var init_image_loader = __esm({
2157
+ "../images/src/image-loader.ts"() {
2158
+ init_version();
2159
+ init_parse_image();
2160
+ init_binary_image_api();
2161
+ EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg"];
2162
+ MIME_TYPES = [
2163
+ "image/png",
2164
+ "image/jpeg",
2165
+ "image/gif",
2166
+ "image/webp",
2167
+ "image/bmp",
2168
+ "image/vnd.microsoft.icon",
2169
+ "image/svg+xml"
2170
+ ];
2171
+ DEFAULT_IMAGE_LOADER_OPTIONS = {
2172
+ image: {
2173
+ type: "auto",
2174
+ decode: true
2175
+ }
2176
+ };
2177
+ ImageLoader = {
2178
+ id: "image",
2179
+ module: "images",
2180
+ name: "Images",
2181
+ version: VERSION3,
2182
+ mimeTypes: MIME_TYPES,
2183
+ extensions: EXTENSIONS,
2184
+ parse: parseImage,
2185
+ tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
2186
+ options: DEFAULT_IMAGE_LOADER_OPTIONS
2187
+ };
2188
+ }
2189
+ });
2190
+
2191
+ // ../images/src/index.ts
2192
+ var init_src3 = __esm({
2193
+ "../images/src/index.ts"() {
2194
+ init_image_loader();
2195
+ }
2196
+ });
2197
+
2198
+ // src/lib/data-sources/wms-data-source.ts
2199
+ var WMSDataSource;
2200
+ var init_wms_data_source = __esm({
2201
+ "src/lib/data-sources/wms-data-source.ts"() {
2202
+ init_src4();
2203
+ init_src3();
2204
+ WMSDataSource = class {
2205
+ constructor(props) {
2206
+ this.url = props.url;
2207
+ this.loadOptions = props.loadOptions || {};
2208
+ this.fetch = props.fetch || fetch;
2209
+ }
2210
+ async getCapabilities(options) {
2211
+ const url = this.getUrl({ request: "GetCapabilities", ...options });
2212
+ const response = await this.fetch(url, this.loadOptions);
2213
+ const arrayBuffer = await response.arrayBuffer();
2214
+ return await WMSCapabilitiesLoader.parse(arrayBuffer, this.loadOptions);
2215
+ }
2216
+ async getImage(options) {
2217
+ const url = this.getUrl({ request: "GetMap", ...options });
2218
+ const response = await this.fetch(url, this.loadOptions);
2219
+ const arrayBuffer = await response.arrayBuffer();
2220
+ return await ImageLoader.parse(arrayBuffer, this.loadOptions);
2221
+ }
2222
+ async getFeatureInfo(options) {
2223
+ const url = this.getUrl({ request: "GetFeatureInfo", ...options });
2224
+ const response = await this.fetch(url, this.loadOptions);
2225
+ const arrayBuffer = await response.arrayBuffer();
2226
+ return await WMSFeatureInfoLoader.parse(arrayBuffer, this.loadOptions);
2227
+ }
2228
+ async getLayerInfo(options) {
2229
+ const url = this.getUrl({ request: "GetLayerInfo", ...options });
2230
+ const response = await this.fetch(url, this.loadOptions);
2231
+ const arrayBuffer = await response.arrayBuffer();
2232
+ return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.loadOptions);
2233
+ }
2234
+ async getLegendImage(options) {
2235
+ const url = this.getUrl({ request: "GetLegendImage", ...options });
2236
+ const response = await this.fetch(url, this.loadOptions);
2237
+ const arrayBuffer = await response.arrayBuffer();
2238
+ return await ImageLoader.parse(arrayBuffer, this.loadOptions);
2239
+ }
2240
+ getUrl(options) {
2241
+ let url = `${this.url}?REQUEST=${options.request}`;
2242
+ if (options.layers?.length) {
2243
+ url += `&LAYERS=[${options.layers.join(",")}]`;
2244
+ }
2245
+ return url;
2246
+ }
2247
+ };
2248
+ }
2249
+ });
2250
+
1666
2251
  // src/index.ts
1667
2252
  var src_exports = {};
1668
2253
  __export(src_exports, {
1669
- WMSCapabilitiesLoader: () => WMSCapabilitiesLoader
2254
+ WMSCapabilitiesLoader: () => WMSCapabilitiesLoader,
2255
+ WMSFeatureInfoLoader: () => WMSFeatureInfoLoader,
2256
+ WMSLayerDescriptionLoader: () => WMSLayerDescriptionLoader,
2257
+ _WMSDataSource: () => WMSDataSource
1670
2258
  });
1671
- var init_src2 = __esm({
2259
+ var init_src4 = __esm({
1672
2260
  "src/index.ts"() {
1673
2261
  init_wms_capabilities_loader();
2262
+ init_wms_feature_info_loader();
2263
+ init_wms_layer_description_loader();
2264
+ init_wms_data_source();
1674
2265
  }
1675
2266
  });
1676
2267
 
1677
2268
  // src/bundle.ts
1678
2269
  var require_bundle = __commonJS({
1679
2270
  "src/bundle.ts"(exports, module) {
1680
- var moduleExports = (init_src2(), src_exports);
2271
+ var moduleExports = (init_src4(), src_exports);
1681
2272
  globalThis.loaders = globalThis.loaders || {};
1682
2273
  module.exports = Object.assign(globalThis.loaders, moduleExports);
1683
2274
  }