@loaders.gl/wms 3.4.0-alpha.2 → 3.4.0-alpha.4

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 (208) hide show
  1. package/dist/dist.min.js +412 -176
  2. package/dist/es5/csw-capabilities-loader.js +7 -11
  3. package/dist/es5/csw-capabilities-loader.js.map +1 -1
  4. package/dist/es5/csw-domain-loader.js +7 -10
  5. package/dist/es5/csw-domain-loader.js.map +1 -1
  6. package/dist/es5/csw-records-loader.js +7 -10
  7. package/dist/es5/csw-records-loader.js.map +1 -1
  8. package/dist/es5/gml-loader.js +7 -10
  9. package/dist/es5/gml-loader.js.map +1 -1
  10. package/dist/es5/index.js +0 -7
  11. package/dist/es5/index.js.map +1 -1
  12. package/dist/es5/lerc-loader.js +17 -22
  13. package/dist/es5/lerc-loader.js.map +1 -1
  14. package/dist/es5/lib/create-image-source.js +1 -2
  15. package/dist/es5/lib/create-image-source.js.map +1 -1
  16. package/dist/es5/lib/parsers/csw/parse-csw-capabilities.js.map +1 -1
  17. package/dist/es5/lib/parsers/csw/parse-csw-domain.js +1 -1
  18. package/dist/es5/lib/parsers/csw/parse-csw-domain.js.map +1 -1
  19. package/dist/es5/lib/parsers/csw/parse-csw-records.js +1 -2
  20. package/dist/es5/lib/parsers/csw/parse-csw-records.js.map +1 -1
  21. package/dist/es5/lib/parsers/csw/parse-exception-report.js +0 -2
  22. package/dist/es5/lib/parsers/csw/parse-exception-report.js.map +1 -1
  23. package/dist/es5/lib/parsers/gml/deep-strict-equal.js +0 -8
  24. package/dist/es5/lib/parsers/gml/deep-strict-equal.js.map +1 -1
  25. package/dist/es5/lib/parsers/gml/parse-gml.js +1 -13
  26. package/dist/es5/lib/parsers/gml/parse-gml.js.map +1 -1
  27. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js +197 -54
  28. package/dist/es5/lib/parsers/wms/parse-wms-capabilities.js.map +1 -1
  29. package/dist/es5/lib/parsers/wms/parse-wms-error.js +0 -1
  30. package/dist/es5/lib/parsers/wms/parse-wms-error.js.map +1 -1
  31. package/dist/es5/lib/parsers/wms/parse-wms-features.js +0 -1
  32. package/dist/es5/lib/parsers/wms/parse-wms-features.js.map +1 -1
  33. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js +0 -1
  34. package/dist/es5/lib/parsers/wms/parse-wms-layer-description.js.map +1 -1
  35. package/dist/es5/lib/parsers/xml/parse-xml-helpers.js +67 -0
  36. package/dist/es5/lib/parsers/xml/parse-xml-helpers.js.map +1 -0
  37. package/dist/es5/lib/services/arcgis/arcgis-image-service.js +36 -60
  38. package/dist/es5/lib/services/arcgis/arcgis-image-service.js.map +1 -1
  39. package/dist/es5/lib/services/arcgis/arcgis-server.js +50 -54
  40. package/dist/es5/lib/services/arcgis/arcgis-server.js.map +1 -1
  41. package/dist/es5/lib/services/generic/image-service.js +28 -42
  42. package/dist/es5/lib/services/generic/image-service.js.map +1 -1
  43. package/dist/es5/lib/services/ogc/csw-service.js +161 -188
  44. package/dist/es5/lib/services/ogc/csw-service.js.map +1 -1
  45. package/dist/es5/lib/services/ogc/wms-service.js +325 -245
  46. package/dist/es5/lib/services/ogc/wms-service.js.map +1 -1
  47. package/dist/es5/lib/sources/data-source.js +36 -13
  48. package/dist/es5/lib/sources/data-source.js.map +1 -1
  49. package/dist/es5/lib/sources/image-source.js.map +1 -1
  50. package/dist/es5/lib/sources/tile-source.js.map +1 -1
  51. package/dist/es5/lib/sources/utils/utils.js +0 -4
  52. package/dist/es5/lib/sources/utils/utils.js.map +1 -1
  53. package/dist/es5/wip/arcgis-feature-service.js +2 -7
  54. package/dist/es5/wip/arcgis-feature-service.js.map +1 -1
  55. package/dist/es5/wip/data-source.js +0 -2
  56. package/dist/es5/wip/lib/wcs/parse-wcs-capabilities.js.map +1 -1
  57. package/dist/es5/wip/lib/wfs/parse-wfs-capabilities.js.map +1 -1
  58. package/dist/es5/wip/lib/wmts/parse-wmts-capabilities.js.map +1 -1
  59. package/dist/es5/wip/wcs-capabilities-loader.js +7 -10
  60. package/dist/es5/wip/wcs-capabilities-loader.js.map +1 -1
  61. package/dist/es5/wip/wfs-capabilities-loader.js +7 -10
  62. package/dist/es5/wip/wfs-capabilities-loader.js.map +1 -1
  63. package/dist/es5/wip/wms-feature-info-loader.js +6 -8
  64. package/dist/es5/wip/wms-feature-info-loader.js.map +1 -1
  65. package/dist/es5/wip/wms-layer-description-loader.js +6 -8
  66. package/dist/es5/wip/wms-layer-description-loader.js.map +1 -1
  67. package/dist/es5/wip/wmts-capabilities-loader.js +7 -16
  68. package/dist/es5/wip/wmts-capabilities-loader.js.map +1 -1
  69. package/dist/es5/wms-capabilities-loader.js +8 -12
  70. package/dist/es5/wms-capabilities-loader.js.map +1 -1
  71. package/dist/es5/wms-error-loader.js +7 -9
  72. package/dist/es5/wms-error-loader.js.map +1 -1
  73. package/dist/esm/bundle.js +0 -2
  74. package/dist/esm/bundle.js.map +1 -1
  75. package/dist/esm/csw-capabilities-loader.js +1 -5
  76. package/dist/esm/csw-capabilities-loader.js.map +1 -1
  77. package/dist/esm/csw-domain-loader.js +1 -4
  78. package/dist/esm/csw-domain-loader.js.map +1 -1
  79. package/dist/esm/csw-records-loader.js +1 -4
  80. package/dist/esm/csw-records-loader.js.map +1 -1
  81. package/dist/esm/gml-loader.js +1 -4
  82. package/dist/esm/gml-loader.js.map +1 -1
  83. package/dist/esm/index.js +0 -11
  84. package/dist/esm/index.js.map +1 -1
  85. package/dist/esm/lerc-loader.js +1 -4
  86. package/dist/esm/lerc-loader.js.map +1 -1
  87. package/dist/esm/lib/create-image-source.js +0 -3
  88. package/dist/esm/lib/create-image-source.js.map +1 -1
  89. package/dist/esm/lib/parsers/csw/parse-csw-capabilities.js +0 -3
  90. package/dist/esm/lib/parsers/csw/parse-csw-capabilities.js.map +1 -1
  91. package/dist/esm/lib/parsers/csw/parse-csw-domain.js +0 -3
  92. package/dist/esm/lib/parsers/csw/parse-csw-domain.js.map +1 -1
  93. package/dist/esm/lib/parsers/csw/parse-csw-records.js +0 -3
  94. package/dist/esm/lib/parsers/csw/parse-csw-records.js.map +1 -1
  95. package/dist/esm/lib/parsers/csw/parse-exception-report.js +0 -3
  96. package/dist/esm/lib/parsers/csw/parse-exception-report.js.map +1 -1
  97. package/dist/esm/lib/parsers/gml/deep-strict-equal.js +0 -9
  98. package/dist/esm/lib/parsers/gml/deep-strict-equal.js.map +1 -1
  99. package/dist/esm/lib/parsers/gml/parse-gml.js +0 -14
  100. package/dist/esm/lib/parsers/gml/parse-gml.js.map +1 -1
  101. package/dist/esm/lib/parsers/wms/parse-wms-capabilities.js +151 -42
  102. package/dist/esm/lib/parsers/wms/parse-wms-capabilities.js.map +1 -1
  103. package/dist/esm/lib/parsers/wms/parse-wms-error.js +0 -3
  104. package/dist/esm/lib/parsers/wms/parse-wms-error.js.map +1 -1
  105. package/dist/esm/lib/parsers/wms/parse-wms-features.js +0 -3
  106. package/dist/esm/lib/parsers/wms/parse-wms-features.js.map +1 -1
  107. package/dist/esm/lib/parsers/wms/parse-wms-layer-description.js +0 -3
  108. package/dist/esm/lib/parsers/wms/parse-wms-layer-description.js.map +1 -1
  109. package/dist/esm/lib/parsers/xml/parse-xml-helpers.js +53 -0
  110. package/dist/esm/lib/parsers/xml/parse-xml-helpers.js.map +1 -0
  111. package/dist/esm/lib/services/arcgis/arcgis-image-service.js +0 -11
  112. package/dist/esm/lib/services/arcgis/arcgis-image-service.js.map +1 -1
  113. package/dist/esm/lib/services/arcgis/arcgis-server.js +0 -2
  114. package/dist/esm/lib/services/arcgis/arcgis-server.js.map +1 -1
  115. package/dist/esm/lib/services/generic/image-service.js +0 -7
  116. package/dist/esm/lib/services/generic/image-service.js.map +1 -1
  117. package/dist/esm/lib/services/ogc/csw-service.js +0 -13
  118. package/dist/esm/lib/services/ogc/csw-service.js.map +1 -1
  119. package/dist/esm/lib/services/ogc/wms-service.js +135 -86
  120. package/dist/esm/lib/services/ogc/wms-service.js.map +1 -1
  121. package/dist/esm/lib/sources/data-source.js +20 -6
  122. package/dist/esm/lib/sources/data-source.js.map +1 -1
  123. package/dist/esm/lib/sources/image-source.js +0 -3
  124. package/dist/esm/lib/sources/image-source.js.map +1 -1
  125. package/dist/esm/lib/sources/tile-source.js +0 -3
  126. package/dist/esm/lib/sources/tile-source.js.map +1 -1
  127. package/dist/esm/lib/sources/utils/utils.js +0 -5
  128. package/dist/esm/lib/sources/utils/utils.js.map +1 -1
  129. package/dist/esm/wip/arcgis-feature-service.js +0 -3
  130. package/dist/esm/wip/arcgis-feature-service.js.map +1 -1
  131. package/dist/esm/wip/lib/wcs/parse-wcs-capabilities.js +0 -3
  132. package/dist/esm/wip/lib/wcs/parse-wcs-capabilities.js.map +1 -1
  133. package/dist/esm/wip/lib/wfs/parse-wfs-capabilities.js +0 -3
  134. package/dist/esm/wip/lib/wfs/parse-wfs-capabilities.js.map +1 -1
  135. package/dist/esm/wip/lib/wmts/parse-wmts-capabilities.js +0 -3
  136. package/dist/esm/wip/lib/wmts/parse-wmts-capabilities.js.map +1 -1
  137. package/dist/esm/wip/wcs-capabilities-loader.js +1 -4
  138. package/dist/esm/wip/wcs-capabilities-loader.js.map +1 -1
  139. package/dist/esm/wip/wfs-capabilities-loader.js +1 -4
  140. package/dist/esm/wip/wfs-capabilities-loader.js.map +1 -1
  141. package/dist/esm/wip/wms-feature-info-loader.js +0 -2
  142. package/dist/esm/wip/wms-feature-info-loader.js.map +1 -1
  143. package/dist/esm/wip/wms-layer-description-loader.js +0 -2
  144. package/dist/esm/wip/wms-layer-description-loader.js.map +1 -1
  145. package/dist/esm/wip/wmts-capabilities-loader.js +1 -6
  146. package/dist/esm/wip/wmts-capabilities-loader.js.map +1 -1
  147. package/dist/esm/wms-capabilities-loader.js +3 -7
  148. package/dist/esm/wms-capabilities-loader.js.map +1 -1
  149. package/dist/esm/wms-error-loader.js +1 -4
  150. package/dist/esm/wms-error-loader.js.map +1 -1
  151. package/dist/index.d.ts +0 -3
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +3 -5
  154. package/dist/lib/create-image-source.d.ts +1 -1
  155. package/dist/lib/create-image-source.d.ts.map +1 -1
  156. package/dist/lib/parsers/wms/parse-wms-capabilities.d.ts +78 -62
  157. package/dist/lib/parsers/wms/parse-wms-capabilities.d.ts.map +1 -1
  158. package/dist/lib/parsers/wms/parse-wms-capabilities.js +166 -1935
  159. package/dist/lib/parsers/xml/parse-xml-helpers.d.ts +11 -0
  160. package/dist/lib/parsers/xml/parse-xml-helpers.d.ts.map +1 -0
  161. package/dist/lib/parsers/xml/parse-xml-helpers.js +68 -0
  162. package/dist/lib/services/arcgis/arcgis-image-service.d.ts +1 -2
  163. package/dist/lib/services/arcgis/arcgis-image-service.d.ts.map +1 -1
  164. package/dist/lib/services/arcgis/arcgis-image-service.js +1 -2
  165. package/dist/lib/services/generic/image-service.d.ts +2 -3
  166. package/dist/lib/services/generic/image-service.d.ts.map +1 -1
  167. package/dist/lib/services/generic/image-service.js +1 -2
  168. package/dist/lib/services/ogc/csw-service.d.ts +2 -3
  169. package/dist/lib/services/ogc/csw-service.d.ts.map +1 -1
  170. package/dist/lib/services/ogc/csw-service.js +1 -2
  171. package/dist/lib/services/ogc/wms-service.d.ts +128 -72
  172. package/dist/lib/services/ogc/wms-service.d.ts.map +1 -1
  173. package/dist/lib/services/ogc/wms-service.js +154 -73
  174. package/dist/lib/sources/data-source.d.ts +12 -2
  175. package/dist/lib/sources/data-source.d.ts.map +1 -1
  176. package/dist/lib/sources/data-source.js +22 -0
  177. package/dist/lib/sources/image-source.d.ts +9 -15
  178. package/dist/lib/sources/image-source.d.ts.map +1 -1
  179. package/dist/lib/sources/tile-source.d.ts +4 -2
  180. package/dist/lib/sources/tile-source.d.ts.map +1 -1
  181. package/dist/wip/wmts-capabilities-loader.d.ts +3 -4
  182. package/dist/wip/wmts-capabilities-loader.d.ts.map +1 -1
  183. package/dist/wip/wmts-capabilities-loader.js +1 -0
  184. package/dist/wms-capabilities-loader.d.ts +6 -1
  185. package/dist/wms-capabilities-loader.d.ts.map +1 -1
  186. package/dist/wms-capabilities-loader.js +2 -2
  187. package/package.json +6 -6
  188. package/src/index.ts +3 -4
  189. package/src/lib/create-image-source.ts +1 -1
  190. package/src/lib/parsers/wms/parse-wms-capabilities.ts +294 -2004
  191. package/src/lib/parsers/xml/parse-xml-helpers.ts +65 -0
  192. package/src/lib/services/arcgis/arcgis-image-service.ts +1 -4
  193. package/src/lib/services/generic/image-service.ts +2 -5
  194. package/src/lib/services/ogc/csw-service.ts +2 -4
  195. package/src/lib/services/ogc/wms-service.ts +290 -125
  196. package/src/lib/sources/data-source.ts +29 -2
  197. package/src/lib/sources/image-source.ts +9 -15
  198. package/src/lib/sources/tile-source.ts +4 -2
  199. package/src/wip/wmts-capabilities-loader.ts +2 -2
  200. package/src/wms-capabilities-loader.ts +9 -3
  201. package/dist/es5/lib/services/generic/tile-service.js +0 -2
  202. package/dist/es5/lib/services/generic/tile-service.js.map +0 -1
  203. package/dist/esm/lib/services/generic/tile-service.js +0 -2
  204. package/dist/esm/lib/services/generic/tile-service.js.map +0 -1
  205. package/dist/lib/services/generic/tile-service.d.ts +0 -1
  206. package/dist/lib/services/generic/tile-service.d.ts.map +0 -1
  207. package/dist/lib/services/generic/tile-service.js +0 -1
  208. package/src/lib/services/generic/tile-service.ts +0 -0
package/dist/dist.min.js CHANGED
@@ -430,7 +430,10 @@
430
430
  ignoreDeclaration: false,
431
431
  ignorePiTags: false,
432
432
  transformTagName: false,
433
- transformAttributeName: false
433
+ transformAttributeName: false,
434
+ updateTag: function(tagName, jPath, attrs) {
435
+ return tagName;
436
+ }
434
437
  };
435
438
  var buildOptions = function(options) {
436
439
  return Object.assign({}, defaultOptions, options);
@@ -708,6 +711,7 @@
708
711
  this.replaceEntitiesValue = replaceEntitiesValue;
709
712
  this.readStopNodeData = readStopNodeData;
710
713
  this.saveTextToParentTag = saveTextToParentTag;
714
+ this.addChild = addChild;
711
715
  }
712
716
  };
713
717
  function addExternalEntities(externalEntities) {
@@ -760,7 +764,7 @@
760
764
  return tagname;
761
765
  }
762
766
  var attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
763
- function buildAttributesMap(attrStr, jPath) {
767
+ function buildAttributesMap(attrStr, jPath, tagName) {
764
768
  if (!this.options.ignoreAttributes && typeof attrStr === "string") {
765
769
  const matches2 = util.getAllMatches(attrStr, attrsRegx);
766
770
  const len = matches2.length;
@@ -828,7 +832,18 @@
828
832
  if (currentNode) {
829
833
  textData = this.saveTextToParentTag(textData, currentNode, jPath);
830
834
  }
831
- jPath = jPath.substr(0, jPath.lastIndexOf("."));
835
+ const lastTagName = jPath.substring(jPath.lastIndexOf(".") + 1);
836
+ if (tagName && this.options.unpairedTags.indexOf(tagName) !== -1) {
837
+ throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);
838
+ }
839
+ let propIndex = 0;
840
+ if (lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1) {
841
+ propIndex = jPath.lastIndexOf(".", jPath.lastIndexOf(".") - 1);
842
+ this.tagsNodeStack.pop();
843
+ } else {
844
+ propIndex = jPath.lastIndexOf(".");
845
+ }
846
+ jPath = jPath.substring(0, propIndex);
832
847
  currentNode = this.tagsNodeStack.pop();
833
848
  textData = "";
834
849
  i = closeIndex;
@@ -842,9 +857,9 @@
842
857
  const childNode = new xmlNode(tagData.tagName);
843
858
  childNode.add(this.options.textNodeName, "");
844
859
  if (tagData.tagName !== tagData.tagExp && tagData.attrExpPresent) {
845
- childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath);
860
+ childNode[":@"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);
846
861
  }
847
- currentNode.addChild(childNode);
862
+ this.addChild(currentNode, childNode, jPath);
848
863
  }
849
864
  i = tagData.closeIndex + 1;
850
865
  } else if (xmlData.substr(i + 1, 3) === "!--") {
@@ -886,12 +901,13 @@
886
901
  textData = this.saveTextToParentTag(textData, currentNode, jPath, false);
887
902
  }
888
903
  }
889
- if (tagName !== xmlObj.tagname) {
890
- jPath += jPath ? "." + tagName : tagName;
891
- }
892
904
  const lastTag = currentNode;
893
905
  if (lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1) {
894
906
  currentNode = this.tagsNodeStack.pop();
907
+ jPath = jPath.substring(0, jPath.lastIndexOf("."));
908
+ }
909
+ if (tagName !== xmlObj.tagname) {
910
+ jPath += jPath ? "." + tagName : tagName;
895
911
  }
896
912
  if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {
897
913
  let tagContent = "";
@@ -908,14 +924,14 @@
908
924
  }
909
925
  const childNode = new xmlNode(tagName);
910
926
  if (tagName !== tagExp && attrExpPresent) {
911
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
927
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
912
928
  }
913
929
  if (tagContent) {
914
930
  tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);
915
931
  }
916
932
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
917
933
  childNode.add(this.options.textNodeName, tagContent);
918
- currentNode.addChild(childNode);
934
+ this.addChild(currentNode, childNode, jPath);
919
935
  } else {
920
936
  if (tagExp.length > 0 && tagExp.lastIndexOf("/") === tagExp.length - 1) {
921
937
  if (tagName[tagName.length - 1] === "/") {
@@ -929,17 +945,17 @@
929
945
  }
930
946
  const childNode = new xmlNode(tagName);
931
947
  if (tagName !== tagExp && attrExpPresent) {
932
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
948
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
933
949
  }
950
+ this.addChild(currentNode, childNode, jPath);
934
951
  jPath = jPath.substr(0, jPath.lastIndexOf("."));
935
- currentNode.addChild(childNode);
936
952
  } else {
937
953
  const childNode = new xmlNode(tagName);
938
954
  this.tagsNodeStack.push(currentNode);
939
955
  if (tagName !== tagExp && attrExpPresent) {
940
- childNode[":@"] = this.buildAttributesMap(tagExp, jPath);
956
+ childNode[":@"] = this.buildAttributesMap(tagExp, jPath, tagName);
941
957
  }
942
- currentNode.addChild(childNode);
958
+ this.addChild(currentNode, childNode, jPath);
943
959
  currentNode = childNode;
944
960
  }
945
961
  textData = "";
@@ -952,6 +968,16 @@
952
968
  }
953
969
  return xmlObj.child;
954
970
  };
971
+ function addChild(currentNode, childNode, jPath) {
972
+ const result = this.options.updateTag(childNode.tagname, jPath, childNode[":@"]);
973
+ if (result === false) {
974
+ } else if (typeof result === "string") {
975
+ childNode.tagname = result;
976
+ currentNode.addChild(childNode);
977
+ } else {
978
+ currentNode.addChild(childNode);
979
+ }
980
+ }
955
981
  var replaceEntitiesValue = function(val2) {
956
982
  if (this.options.processEntities) {
957
983
  for (let entityName2 in this.docTypeEntities) {
@@ -1200,9 +1226,14 @@
1200
1226
  }
1201
1227
  }
1202
1228
  function isLeafTag(obj, options) {
1229
+ const { textNodeName } = options;
1203
1230
  const propCount = Object.keys(obj).length;
1204
- if (propCount === 0 || propCount === 1 && obj[options.textNodeName])
1231
+ if (propCount === 0) {
1232
+ return true;
1233
+ }
1234
+ if (propCount === 1 && (obj[textNodeName] || typeof obj[textNodeName] === "boolean" || obj[textNodeName] === 0)) {
1205
1235
  return true;
1236
+ }
1206
1237
  return false;
1207
1238
  }
1208
1239
  exports.prettify = prettify;
@@ -1421,7 +1452,8 @@
1421
1452
  { regex: new RegExp('"', "g"), val: "&quot;" }
1422
1453
  ],
1423
1454
  processEntities: true,
1424
- stopNodes: []
1455
+ stopNodes: [],
1456
+ oneListGroup: false
1425
1457
  };
1426
1458
  function Builder(options) {
1427
1459
  this.options = Object.assign({}, defaultOptions, options);
@@ -1484,6 +1516,7 @@
1484
1516
  }
1485
1517
  } else if (Array.isArray(jObj[key])) {
1486
1518
  const arrLen = jObj[key].length;
1519
+ let listTagVal = "";
1487
1520
  for (let j = 0; j < arrLen; j++) {
1488
1521
  const item = jObj[key][j];
1489
1522
  if (typeof item === "undefined") {
@@ -1493,11 +1526,19 @@
1493
1526
  else
1494
1527
  val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
1495
1528
  } else if (typeof item === "object") {
1496
- val2 += this.processTextOrObjNode(item, key, level);
1529
+ if (this.options.oneListGroup) {
1530
+ listTagVal += this.j2x(item, level + 1).val;
1531
+ } else {
1532
+ listTagVal += this.processTextOrObjNode(item, key, level);
1533
+ }
1497
1534
  } else {
1498
- val2 += this.buildTextValNode(item, key, "", level);
1535
+ listTagVal += this.buildTextValNode(item, key, "", level);
1499
1536
  }
1500
1537
  }
1538
+ if (this.options.oneListGroup) {
1539
+ listTagVal = this.buildObjectNode(listTagVal, key, "", level);
1540
+ }
1541
+ val2 += listTagVal;
1501
1542
  } else {
1502
1543
  if (this.options.attributesGroupName && key === this.options.attributesGroupName) {
1503
1544
  const Ks = Object.keys(jObj[key]);
@@ -2042,59 +2083,229 @@
2042
2083
  }
2043
2084
  });
2044
2085
 
2086
+ // src/lib/parsers/xml/parse-xml-helpers.ts
2087
+ function getXMLArray(xmlValue) {
2088
+ if (Array.isArray(xmlValue)) {
2089
+ return xmlValue;
2090
+ }
2091
+ if (xmlValue) {
2092
+ return [xmlValue];
2093
+ }
2094
+ return [];
2095
+ }
2096
+ function getXMLStringArray(xmlValue) {
2097
+ const xmlArray = getXMLArray(xmlValue);
2098
+ if (xmlArray.length > 0 && xmlArray.every((_) => typeof _ === "string")) {
2099
+ return xmlArray;
2100
+ }
2101
+ return [];
2102
+ }
2103
+ function getXMLFloat(xmlValue, defaultValue = void 0) {
2104
+ switch (typeof xmlValue) {
2105
+ case "number":
2106
+ return xmlValue;
2107
+ case "string":
2108
+ return parseFloat(xmlValue);
2109
+ default:
2110
+ return void 0;
2111
+ }
2112
+ }
2113
+ function getXMLInteger(xmlValue, defaultValue = void 0) {
2114
+ switch (typeof xmlValue) {
2115
+ case "number":
2116
+ return xmlValue;
2117
+ case "string":
2118
+ return parseInt(xmlValue, 10);
2119
+ default:
2120
+ return void 0;
2121
+ }
2122
+ }
2123
+ function getXMLBoolean(xmlValue) {
2124
+ switch (xmlValue) {
2125
+ case "true":
2126
+ return true;
2127
+ case "false":
2128
+ return false;
2129
+ case "1":
2130
+ return true;
2131
+ case "0":
2132
+ return false;
2133
+ default:
2134
+ return false;
2135
+ }
2136
+ }
2137
+ var init_parse_xml_helpers = __esm({
2138
+ "src/lib/parsers/xml/parse-xml-helpers.ts"() {
2139
+ }
2140
+ });
2141
+
2045
2142
  // src/lib/parsers/wms/parse-wms-capabilities.ts
2046
- function parseWMSCapabilities(text, options) {
2047
- const parsedXML = XMLLoader.parseTextSync(text, options);
2143
+ function parseWMSCapabilities(xmlText, options) {
2144
+ const parsedXML = XMLLoader.parseTextSync(xmlText, options);
2048
2145
  const xmlCapabilities = parsedXML.WMT_MS_Capabilities || parsedXML.WMS_Capabilities || parsedXML;
2049
- return extractCapabilities(xmlCapabilities);
2146
+ const capabilities = extractCapabilities(xmlCapabilities);
2147
+ if (options?.inheritedLayerProps) {
2148
+ for (const layer of capabilities.layers) {
2149
+ addInheritedLayerProps(layer, null);
2150
+ }
2151
+ }
2152
+ if (options?.includeRawData || options?.raw) {
2153
+ capabilities.raw = xmlCapabilities;
2154
+ }
2155
+ if (options?.includeXMLText) {
2156
+ capabilities.xml = xmlText;
2157
+ }
2158
+ return capabilities;
2050
2159
  }
2051
2160
  function extractCapabilities(xml) {
2052
2161
  const capabilities = {
2053
- name: xml.Service?.Name || "unnamed",
2054
- title: xml.Service?.Title,
2055
- keywords: [],
2056
- requests: {},
2057
- layer: extractLayer(xml.Capability?.Layer),
2058
- raw: xml
2162
+ version: String(xml.version || ""),
2163
+ name: String(xml.Service?.Name || "unnamed"),
2164
+ title: xml.Service?.Title ? String(xml.Service?.Title) : void 0,
2165
+ abstract: xml.Service?.Abstract ? String(xml.Service?.Abstract) : void 0,
2166
+ keywords: getXMLStringArray(xml.Service?.KeywordList?.Keyword),
2167
+ fees: xml.Service?.Fees ? JSON.stringify(xml.Service?.Fees) : void 0,
2168
+ accessConstraints: xml.Service?.AccessConstraints ? JSON.stringify(xml.Service?.AccessConstraints) : void 0,
2169
+ layerLimit: getXMLInteger(xml.Service?.LayerLimit),
2170
+ maxWidth: getXMLInteger(xml.Service?.maxWidth),
2171
+ maxHeight: getXMLInteger(xml.Service?.maxHeight),
2172
+ layers: [],
2173
+ requests: extractRequests(xml.Capability?.Request),
2174
+ exceptions: extractExceptions(xml.Exception)
2059
2175
  };
2060
- for (const keyword of xml.Service?.KeywordList?.Keyword || []) {
2061
- capabilities.keywords.push(keyword);
2176
+ const xmlLayers = getXMLArray(xml.Capability?.Layer);
2177
+ for (const xmlSubLayer of xmlLayers) {
2178
+ capabilities.layers.push(extractLayer(xmlSubLayer));
2062
2179
  }
2063
- for (const [name, xmlRequest] of Object.entries(xml.Capability?.Request || {})) {
2064
- capabilities.requests[name] = extractRequest(name, xmlRequest);
2180
+ for (const [key, value] of Object.entries(capabilities)) {
2181
+ if (value === void 0) {
2182
+ delete capabilities[key];
2183
+ }
2065
2184
  }
2066
2185
  return capabilities;
2067
2186
  }
2068
- function extractRequest(name, xmlRequest) {
2069
- const format = xmlRequest?.Format;
2070
- const mimeTypes = Array.isArray(format) ? format : [format];
2071
- return { name, mimeTypes };
2187
+ function extractRequests(xmlRequests) {
2188
+ const requests = {};
2189
+ for (const [name, xmlRequest] of Object.entries(xmlRequests || {})) {
2190
+ const mimeTypes = getXMLStringArray(xmlRequest?.Format);
2191
+ requests[name] = { mimeTypes };
2192
+ }
2193
+ return requests;
2194
+ }
2195
+ function extractExceptions(xmlException) {
2196
+ const xmlExceptionFormats = getXMLArray(xmlException?.Format);
2197
+ if (xmlExceptionFormats.length > 0) {
2198
+ return {
2199
+ mimeTypes: getXMLStringArray(xmlException)
2200
+ };
2201
+ }
2202
+ return void 0;
2072
2203
  }
2073
2204
  function extractLayer(xmlLayer) {
2074
2205
  const layer = {
2075
- name: xmlLayer?.Name,
2076
- title: xmlLayer?.Title,
2077
- srs: xmlLayer?.SRS || [],
2078
- layers: []
2206
+ title: String(xmlLayer?.Title || ""),
2207
+ name: String(xmlLayer?.Name),
2208
+ abstract: String(xmlLayer?.Abstract),
2209
+ keywords: getXMLStringArray(xmlLayer.KeywordList?.Keyword)
2079
2210
  };
2211
+ const crs = xmlLayer?.CRS || xmlLayer?.SRS;
2212
+ if (crs && Array.isArray(crs) && crs.every((_) => typeof _ === "string")) {
2213
+ layer.crs = crs;
2214
+ }
2215
+ let geographicBoundingBox = xmlLayer?.EX_GeographicBoundingBox && extractEXBoundingBox(xmlLayer?.EX_GeographicBoundingBox);
2216
+ if (geographicBoundingBox) {
2217
+ layer.geographicBoundingBox = geographicBoundingBox;
2218
+ }
2219
+ geographicBoundingBox = xmlLayer?.LatLonBoundingBox && extractLatLonBoundingBox(xmlLayer?.LatLonBoundingBox);
2220
+ if (geographicBoundingBox) {
2221
+ layer.geographicBoundingBox = geographicBoundingBox;
2222
+ }
2223
+ const boundingBoxes = xmlLayer?.BoundingBox && extractWMSBoundingBoxes(xmlLayer?.BoundingBox);
2224
+ if (boundingBoxes && boundingBoxes.length > 0) {
2225
+ layer.boundingBoxes = boundingBoxes;
2226
+ }
2227
+ if (xmlLayer?.opaque) {
2228
+ layer.opaque = getXMLBoolean(xmlLayer?.opaque);
2229
+ }
2230
+ if (xmlLayer?.cascaded) {
2231
+ layer.cascaded = getXMLBoolean(xmlLayer?.cascaded);
2232
+ }
2233
+ if (xmlLayer?.queryable) {
2234
+ layer.queryable = getXMLBoolean(xmlLayer?.queryable);
2235
+ }
2080
2236
  const xmlLayers = getXMLArray(xmlLayer?.Layer);
2237
+ const layers = [];
2081
2238
  for (const xmlSubLayer of xmlLayers) {
2082
- layer.layers?.push(extractLayer(xmlSubLayer));
2239
+ layers.push(extractLayer(xmlSubLayer));
2240
+ }
2241
+ if (layers.length > 0) {
2242
+ layer.layers = layers;
2243
+ }
2244
+ for (const [key, value] of Object.entries(layer)) {
2245
+ if (value === void 0) {
2246
+ delete layer[key];
2247
+ }
2083
2248
  }
2084
2249
  return layer;
2085
2250
  }
2086
- function getXMLArray(xmlValue) {
2087
- if (Array.isArray(xmlValue)) {
2088
- return xmlValue;
2251
+ function extractEXBoundingBox(xmlBoundingBox) {
2252
+ const {
2253
+ westBoundLongitude: w,
2254
+ northBoundLatitude: n,
2255
+ eastBoundLongitude: e,
2256
+ southBoundLatitude: s
2257
+ } = xmlBoundingBox;
2258
+ return [
2259
+ [w, s],
2260
+ [e, n]
2261
+ ];
2262
+ }
2263
+ function extractLatLonBoundingBox(xmlBoundingBox) {
2264
+ const { minx, miny, maxx, maxy } = xmlBoundingBox;
2265
+ return [
2266
+ [minx, miny],
2267
+ [maxx, maxy]
2268
+ ];
2269
+ }
2270
+ function extractWMSBoundingBoxes(xmlBoundingBoxes) {
2271
+ const xmlBoxes = getXMLArray(xmlBoundingBoxes);
2272
+ return xmlBoxes.map((xmlBox) => extractWMSBoundingBox(xmlBox));
2273
+ }
2274
+ function extractWMSBoundingBox(xmlBoundingBox) {
2275
+ const { CRS, SRS, minx, miny, maxx, maxy, resx, resy } = xmlBoundingBox;
2276
+ const boundingBox = {
2277
+ crs: CRS || SRS,
2278
+ boundingBox: [
2279
+ [getXMLFloat(minx), getXMLFloat(miny)],
2280
+ [getXMLFloat(maxx), getXMLFloat(maxy)]
2281
+ ]
2282
+ };
2283
+ if (resx) {
2284
+ boundingBox.xResolution = resx;
2089
2285
  }
2090
- if (xmlValue) {
2091
- return [xmlValue];
2286
+ if (resy) {
2287
+ boundingBox.yResolution = resy;
2288
+ }
2289
+ return boundingBox;
2290
+ }
2291
+ function addInheritedLayerProps(layer, parent) {
2292
+ if (parent && parent.geographicBoundingBox && !layer.geographicBoundingBox) {
2293
+ layer.geographicBoundingBox = [...parent.geographicBoundingBox];
2294
+ }
2295
+ if (parent && parent.crs && !layer.crs) {
2296
+ layer.crs = [...parent.crs];
2297
+ }
2298
+ if (parent && parent.boundingBoxes && !layer.boundingBoxes) {
2299
+ layer.boundingBoxes = [...parent.boundingBoxes];
2300
+ }
2301
+ for (const subLayer of layer.layers || []) {
2302
+ addInheritedLayerProps(subLayer, layer);
2092
2303
  }
2093
- return [];
2094
2304
  }
2095
2305
  var init_parse_wms_capabilities = __esm({
2096
2306
  "src/lib/parsers/wms/parse-wms-capabilities.ts"() {
2097
2307
  init_src2();
2308
+ init_parse_xml_helpers();
2098
2309
  }
2099
2310
  });
2100
2311
 
@@ -2119,8 +2330,8 @@
2119
2330
  options: {
2120
2331
  wms: {}
2121
2332
  },
2122
- parse: async (arrayBuffer, options) => parseWMSCapabilities(new TextDecoder().decode(arrayBuffer), options),
2123
- parseTextSync: (text, options) => parseWMSCapabilities(text, options)
2333
+ parse: async (arrayBuffer, options) => parseWMSCapabilities(new TextDecoder().decode(arrayBuffer), options?.wms),
2334
+ parseTextSync: (text, options) => parseWMSCapabilities(text, options?.wms)
2124
2335
  };
2125
2336
  }
2126
2337
  });
@@ -2191,49 +2402,6 @@
2191
2402
  }
2192
2403
  });
2193
2404
 
2194
- // src/wip/lib/wmts/parse-wmts-capabilities.ts
2195
- function parseWMTSCapabilities(text, options) {
2196
- const parsedXML = XMLLoader.parseTextSync(text, { ...options, xml: {
2197
- ...options?.xml,
2198
- removeNSPrefix: true,
2199
- uncapitalizeKeys: true
2200
- } });
2201
- const xmlCapabilities = parsedXML.Capabilities || parsedXML;
2202
- return xmlCapabilities;
2203
- }
2204
- var init_parse_wmts_capabilities = __esm({
2205
- "src/wip/lib/wmts/parse-wmts-capabilities.ts"() {
2206
- init_src2();
2207
- }
2208
- });
2209
-
2210
- // src/wip/wmts-capabilities-loader.ts
2211
- function testXMLFile7(text) {
2212
- return text.startsWith("<?xml");
2213
- }
2214
- var VERSION7, WMTSCapabilitiesLoader;
2215
- var init_wmts_capabilities_loader = __esm({
2216
- "src/wip/wmts-capabilities-loader.ts"() {
2217
- init_parse_wmts_capabilities();
2218
- VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2219
- WMTSCapabilitiesLoader = {
2220
- id: "wmts-capabilities",
2221
- name: "WMTS Capabilities",
2222
- module: "wms",
2223
- version: VERSION7,
2224
- worker: false,
2225
- extensions: ["xml"],
2226
- mimeTypes: ["application/vnd.ogc.wmts_xml", "application/xml", "text/xml"],
2227
- testText: testXMLFile7,
2228
- options: {
2229
- wms: {}
2230
- },
2231
- parse: async (arrayBuffer, options) => parseWMTSCapabilities(new TextDecoder().decode(arrayBuffer), options),
2232
- parseTextSync: (text, options) => parseWMTSCapabilities(text, options)
2233
- };
2234
- }
2235
- });
2236
-
2237
2405
  // src/wip/lib/wfs/parse-wfs-capabilities.ts
2238
2406
  function parseWFSCapabilities(text, options) {
2239
2407
  const parsedXML = XMLLoader.parseTextSync(text, { ...options, xml: {
@@ -2251,23 +2419,23 @@
2251
2419
  });
2252
2420
 
2253
2421
  // src/wip/wfs-capabilities-loader.ts
2254
- function testXMLFile8(text) {
2422
+ function testXMLFile7(text) {
2255
2423
  return text.startsWith("<?xml");
2256
2424
  }
2257
- var VERSION8, WFSCapabilitiesLoader;
2425
+ var VERSION7, WFSCapabilitiesLoader;
2258
2426
  var init_wfs_capabilities_loader = __esm({
2259
2427
  "src/wip/wfs-capabilities-loader.ts"() {
2260
2428
  init_parse_wfs_capabilities();
2261
- VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2429
+ VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
2262
2430
  WFSCapabilitiesLoader = {
2263
2431
  id: "wfs-capabilities",
2264
2432
  name: "WFS Capabilities",
2265
2433
  module: "wms",
2266
- version: VERSION8,
2434
+ version: VERSION7,
2267
2435
  worker: false,
2268
2436
  extensions: ["xml"],
2269
2437
  mimeTypes: ["application/vnd.ogc.wfs_xml", "application/xml", "text/xml"],
2270
- testText: testXMLFile8,
2438
+ testText: testXMLFile7,
2271
2439
  options: {
2272
2440
  wms: {}
2273
2441
  },
@@ -3045,23 +3213,23 @@
3045
3213
  });
3046
3214
 
3047
3215
  // src/gml-loader.ts
3048
- function testXMLFile9(text) {
3216
+ function testXMLFile8(text) {
3049
3217
  return text.startsWith("<?xml");
3050
3218
  }
3051
- var VERSION9, GMLLoader;
3219
+ var VERSION8, GMLLoader;
3052
3220
  var init_gml_loader = __esm({
3053
3221
  "src/gml-loader.ts"() {
3054
3222
  init_parse_gml();
3055
- VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3223
+ VERSION8 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3056
3224
  GMLLoader = {
3057
3225
  name: "GML",
3058
3226
  id: "gml",
3059
3227
  module: "wms",
3060
- version: VERSION9,
3228
+ version: VERSION8,
3061
3229
  worker: false,
3062
3230
  extensions: ["xml"],
3063
3231
  mimeTypes: ["application/vnd.ogc.gml", "application/xml", "text/xml"],
3064
- testText: testXMLFile9,
3232
+ testText: testXMLFile8,
3065
3233
  options: {
3066
3234
  gml: {}
3067
3235
  },
@@ -3088,9 +3256,25 @@
3088
3256
  "src/lib/sources/data-source.ts"() {
3089
3257
  DataSource = class {
3090
3258
  constructor(props) {
3259
+ this._needsRefresh = true;
3260
+ this.props = { ...props };
3091
3261
  this.loadOptions = { ...props.loadOptions };
3092
3262
  this.fetch = getFetchFunction(this.loadOptions);
3093
3263
  }
3264
+ setProps(props) {
3265
+ this.props = Object.assign(this.props, props);
3266
+ this.setNeedsRefresh();
3267
+ }
3268
+ setNeedsRefresh() {
3269
+ this._needsRefresh = true;
3270
+ }
3271
+ getNeedsRefresh(clear = true) {
3272
+ const needsRefresh = this._needsRefresh;
3273
+ if (clear) {
3274
+ this._needsRefresh = false;
3275
+ }
3276
+ return needsRefresh;
3277
+ }
3094
3278
  };
3095
3279
  }
3096
3280
  });
@@ -3106,10 +3290,10 @@
3106
3290
  });
3107
3291
 
3108
3292
  // ../images/src/lib/utils/version.ts
3109
- var VERSION10;
3293
+ var VERSION9;
3110
3294
  var init_version = __esm({
3111
3295
  "../images/src/lib/utils/version.ts"() {
3112
- VERSION10 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3296
+ VERSION9 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
3113
3297
  }
3114
3298
  });
3115
3299
 
@@ -3558,7 +3742,7 @@
3558
3742
  id: "image",
3559
3743
  module: "images",
3560
3744
  name: "Images",
3561
- version: VERSION10,
3745
+ version: VERSION9,
3562
3746
  mimeTypes: MIME_TYPES,
3563
3747
  extensions: EXTENSIONS,
3564
3748
  parse: parseImage,
@@ -3584,7 +3768,6 @@
3584
3768
  ImageService = class extends ImageSource {
3585
3769
  constructor(props) {
3586
3770
  super(props);
3587
- this.props = props;
3588
3771
  }
3589
3772
  async getMetadata() {
3590
3773
  throw new Error("ImageSource.getMetadata not implemented");
@@ -3636,16 +3819,21 @@
3636
3819
  WMSFeatureInfoLoader,
3637
3820
  WMSLayerDescriptionLoader
3638
3821
  ];
3639
- this.props = {
3640
- loadOptions: void 0,
3822
+ this.url = props.url;
3823
+ this.substituteCRS84 = props.substituteCRS84 ?? false;
3824
+ this.flipCRS = ["EPSG:4326"];
3825
+ this.wmsParameters = {
3641
3826
  layers: void 0,
3827
+ query_layers: void 0,
3642
3828
  styles: void 0,
3643
- version: "1.1.1",
3644
- srs: "EPSG:4326",
3829
+ version: "1.3.0",
3830
+ crs: "EPSG:4326",
3645
3831
  format: "image/png",
3646
3832
  info_format: "text/plain",
3647
- ...props
3833
+ transparent: void 0,
3834
+ ...props.wmsParameters
3648
3835
  };
3836
+ this.vendorParameters = props.vendorParameters || {};
3649
3837
  }
3650
3838
  async getMetadata() {
3651
3839
  const capabilities = await this.getCapabilities();
@@ -3662,128 +3850,180 @@
3662
3850
  const response = await this.fetch(url);
3663
3851
  const arrayBuffer = await response.arrayBuffer();
3664
3852
  this._checkResponse(response, arrayBuffer);
3665
- const capabilities = await WMSCapabilitiesLoader.parse(arrayBuffer, this.props.loadOptions);
3853
+ const capabilities = await WMSCapabilitiesLoader.parse(arrayBuffer, this.loadOptions);
3666
3854
  this.capabilities = capabilities;
3667
3855
  return capabilities;
3668
3856
  }
3669
- async getMap(options, vendorParameters) {
3670
- const url = this.getMapURL(options, vendorParameters);
3857
+ async getMap(wmsParameters, vendorParameters) {
3858
+ const url = this.getMapURL(wmsParameters, vendorParameters);
3671
3859
  const response = await this.fetch(url);
3672
3860
  const arrayBuffer = await response.arrayBuffer();
3673
3861
  this._checkResponse(response, arrayBuffer);
3674
3862
  try {
3675
- return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
3863
+ return await ImageLoader.parse(arrayBuffer, this.loadOptions);
3676
3864
  } catch {
3677
3865
  throw this._parseError(arrayBuffer);
3678
3866
  }
3679
3867
  }
3680
- async getFeatureInfo(options, vendorParameters) {
3681
- const url = this.getFeatureInfoURL(options, vendorParameters);
3868
+ async getFeatureInfo(wmsParameters, vendorParameters) {
3869
+ const url = this.getFeatureInfoURL(wmsParameters, vendorParameters);
3682
3870
  const response = await this.fetch(url);
3683
3871
  const arrayBuffer = await response.arrayBuffer();
3684
3872
  this._checkResponse(response, arrayBuffer);
3685
- return await WMSFeatureInfoLoader.parse(arrayBuffer, this.props.loadOptions);
3873
+ return await WMSFeatureInfoLoader.parse(arrayBuffer, this.loadOptions);
3686
3874
  }
3687
- async getFeatureInfoText(options, vendorParameters) {
3688
- const url = this.getFeatureInfoURL(options, vendorParameters);
3875
+ async getFeatureInfoText(wmsParameters, vendorParameters) {
3876
+ const url = this.getFeatureInfoURL(wmsParameters, vendorParameters);
3689
3877
  const response = await this.fetch(url);
3690
3878
  const arrayBuffer = await response.arrayBuffer();
3691
3879
  this._checkResponse(response, arrayBuffer);
3692
3880
  return new TextDecoder().decode(arrayBuffer);
3693
3881
  }
3694
- async describeLayer(options, vendorParameters) {
3695
- const url = this.describeLayerURL(options, vendorParameters);
3882
+ async describeLayer(wmsParameters, vendorParameters) {
3883
+ const url = this.describeLayerURL(wmsParameters, vendorParameters);
3696
3884
  const response = await this.fetch(url);
3697
3885
  const arrayBuffer = await response.arrayBuffer();
3698
3886
  this._checkResponse(response, arrayBuffer);
3699
- return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.props.loadOptions);
3887
+ return await WMSLayerDescriptionLoader.parse(arrayBuffer, this.loadOptions);
3700
3888
  }
3701
- async getLegendGraphic(options, vendorParameters) {
3702
- const url = this.getLegendGraphicURL(options, vendorParameters);
3889
+ async getLegendGraphic(wmsParameters, vendorParameters) {
3890
+ const url = this.getLegendGraphicURL(wmsParameters, vendorParameters);
3703
3891
  const response = await this.fetch(url);
3704
3892
  const arrayBuffer = await response.arrayBuffer();
3705
3893
  this._checkResponse(response, arrayBuffer);
3706
3894
  try {
3707
- return await ImageLoader.parse(arrayBuffer, this.props.loadOptions);
3895
+ return await ImageLoader.parse(arrayBuffer, this.loadOptions);
3708
3896
  } catch {
3709
3897
  throw this._parseError(arrayBuffer);
3710
3898
  }
3711
3899
  }
3712
3900
  getCapabilitiesURL(wmsParameters, vendorParameters) {
3713
3901
  const options = {
3714
- service: "WMS",
3715
- version: this.props.version,
3716
- request: "GetCapabilities",
3717
- ...wmsParameters,
3718
- ...vendorParameters
3902
+ version: this.wmsParameters.version,
3903
+ ...wmsParameters
3719
3904
  };
3720
- return this._getWMSUrl(options, vendorParameters);
3905
+ return this._getWMSUrl("GetCapabilities", options, vendorParameters);
3721
3906
  }
3722
3907
  getMapURL(wmsParameters, vendorParameters) {
3908
+ wmsParameters = this._getWMS130Parameters(wmsParameters);
3723
3909
  const options = {
3724
- service: "WMS",
3725
- version: this.props.version,
3726
- request: "GetMap",
3727
- styles: this.props.styles,
3728
- srs: this.props.srs,
3729
- format: this.props.format,
3730
- ...wmsParameters,
3731
- ...vendorParameters
3910
+ version: this.wmsParameters.version,
3911
+ format: this.wmsParameters.format,
3912
+ transparent: this.wmsParameters.transparent,
3913
+ layers: this.wmsParameters.layers,
3914
+ styles: this.wmsParameters.styles,
3915
+ crs: this.wmsParameters.crs,
3916
+ ...wmsParameters
3732
3917
  };
3733
- return this._getWMSUrl(options, vendorParameters);
3918
+ return this._getWMSUrl("GetMap", options, vendorParameters);
3734
3919
  }
3735
3920
  getFeatureInfoURL(wmsParameters, vendorParameters) {
3736
3921
  const options = {
3737
- service: "WMS",
3738
- version: this.props.version,
3739
- request: "GetFeatureInfo",
3740
- srs: this.props.srs,
3741
- format: this.props.format,
3742
- info_format: this.props.info_format,
3743
- styles: this.props.styles,
3744
- ...wmsParameters,
3745
- ...vendorParameters
3922
+ version: this.wmsParameters.version,
3923
+ info_format: this.wmsParameters.info_format,
3924
+ layers: this.wmsParameters.layers,
3925
+ query_layers: this.wmsParameters.query_layers,
3926
+ styles: this.wmsParameters.styles,
3927
+ crs: this.wmsParameters.crs,
3928
+ ...wmsParameters
3746
3929
  };
3747
- return this._getWMSUrl(options, vendorParameters);
3930
+ return this._getWMSUrl("GetFeatureInfo", options, vendorParameters);
3748
3931
  }
3749
3932
  describeLayerURL(wmsParameters, vendorParameters) {
3750
3933
  const options = {
3751
- service: "WMS",
3752
- version: this.props.version,
3753
- request: "DescribeLayer",
3754
- ...wmsParameters,
3755
- ...vendorParameters
3934
+ version: this.wmsParameters.version,
3935
+ ...wmsParameters
3756
3936
  };
3757
- return this._getWMSUrl(options, vendorParameters);
3937
+ return this._getWMSUrl("DescribeLayer", options, vendorParameters);
3758
3938
  }
3759
3939
  getLegendGraphicURL(wmsParameters, vendorParameters) {
3760
3940
  const options = {
3941
+ version: this.wmsParameters.version,
3942
+ ...wmsParameters
3943
+ };
3944
+ return this._getWMSUrl("GetLegendGraphic", options, vendorParameters);
3945
+ }
3946
+ _parseWMSUrl(url) {
3947
+ const [baseUrl, search] = url.split("?");
3948
+ const searchParams = search.split("&");
3949
+ const parameters = {};
3950
+ for (const parameter of searchParams) {
3951
+ const [key, value] = parameter.split("=");
3952
+ parameters[key] = value;
3953
+ }
3954
+ return { url: baseUrl, parameters };
3955
+ }
3956
+ _getWMSUrl(request, wmsParameters, vendorParameters) {
3957
+ let url = this.url;
3958
+ let first = true;
3959
+ const allParameters = {
3761
3960
  service: "WMS",
3762
- version: this.props.version,
3763
- request: "GetLegendGraphic",
3961
+ version: wmsParameters.version,
3962
+ request,
3764
3963
  ...wmsParameters,
3964
+ ...this.vendorParameters,
3765
3965
  ...vendorParameters
3766
3966
  };
3767
- return this._getWMSUrl(options, vendorParameters);
3768
- }
3769
- _getWMSUrl(options, vendorParameters) {
3770
- let url = this.props.url;
3771
- let first = true;
3772
- for (const [key, value] of Object.entries(options)) {
3773
- url += first ? "?" : "&";
3774
- first = false;
3775
- if (Array.isArray(value)) {
3776
- url += `${key.toUpperCase()}=${value.join(",")}`;
3777
- } else {
3778
- url += `${key.toUpperCase()}=${value ? String(value) : ""}`;
3967
+ for (const [key, value] of Object.entries(allParameters)) {
3968
+ if (key !== "transparent" || value) {
3969
+ url += first ? "?" : "&";
3970
+ first = false;
3971
+ url += this._getURLParameter(key, value, wmsParameters);
3779
3972
  }
3780
3973
  }
3781
3974
  return encodeURI(url);
3782
3975
  }
3976
+ _getWMS130Parameters(wmsParameters) {
3977
+ const newParameters = { ...wmsParameters };
3978
+ if (newParameters.srs) {
3979
+ newParameters.crs = newParameters.crs || newParameters.srs;
3980
+ delete newParameters.srs;
3981
+ }
3982
+ return newParameters;
3983
+ }
3984
+ _getURLParameter(key, value, wmsParameters) {
3985
+ switch (key) {
3986
+ case "crs":
3987
+ if (wmsParameters.version !== "1.3.0") {
3988
+ key = "srs";
3989
+ } else if (this.substituteCRS84 && value === "EPSG:4326") {
3990
+ value = "CRS:84";
3991
+ }
3992
+ break;
3993
+ case "srs":
3994
+ if (wmsParameters.version === "1.3.0") {
3995
+ key = "crs";
3996
+ }
3997
+ break;
3998
+ case "bbox":
3999
+ const bbox = this._flipBoundingBox(value, wmsParameters);
4000
+ if (bbox) {
4001
+ value = bbox;
4002
+ }
4003
+ break;
4004
+ default:
4005
+ }
4006
+ key = key.toUpperCase();
4007
+ return Array.isArray(value) ? `${key}=${value.join(",")}` : `${key}=${value ? String(value) : ""}`;
4008
+ }
4009
+ _flipBoundingBox(bboxValue, wmsParameters) {
4010
+ if (!Array.isArray(bboxValue) || bboxValue.length !== 4) {
4011
+ return null;
4012
+ }
4013
+ const flipCoordinates = wmsParameters.version === "1.3.0" && this.flipCRS.includes(wmsParameters.crs || "") && !(this.substituteCRS84 && wmsParameters.crs === "EPSG:4326");
4014
+ const bbox = bboxValue;
4015
+ return flipCoordinates ? [bbox[1], bbox[0], bbox[3], bbox[2]] : bbox;
4016
+ }
4017
+ async _fetchArrayBuffer(url) {
4018
+ const response = await this.fetch(url);
4019
+ const arrayBuffer = await response.arrayBuffer();
4020
+ this._checkResponse(response, arrayBuffer);
4021
+ return arrayBuffer;
4022
+ }
3783
4023
  _checkResponse(response, arrayBuffer) {
3784
4024
  const contentType = response.headers["content-type"];
3785
4025
  if (!response.ok || WMSErrorLoader.mimeTypes.includes(contentType)) {
3786
- const loadOptions = mergeLoaderOptions(this.props.loadOptions, {
4026
+ const loadOptions = mergeLoaderOptions(this.loadOptions, {
3787
4027
  wms: { throwOnError: true }
3788
4028
  });
3789
4029
  const error = WMSErrorLoader.parseSync(arrayBuffer, loadOptions);
@@ -3791,7 +4031,7 @@
3791
4031
  }
3792
4032
  }
3793
4033
  _parseError(arrayBuffer) {
3794
- const error = WMSErrorLoader.parseSync(arrayBuffer, this.props.loadOptions);
4034
+ const error = WMSErrorLoader.parseSync(arrayBuffer, this.loadOptions);
3795
4035
  return new Error(error);
3796
4036
  }
3797
4037
  };
@@ -3808,7 +4048,6 @@
3808
4048
  ArcGISImageServer = class extends ImageSource {
3809
4049
  constructor(props) {
3810
4050
  super(props);
3811
- this.props = props;
3812
4051
  }
3813
4052
  async getMetadata() {
3814
4053
  return await this.metadata();
@@ -3903,7 +4142,6 @@
3903
4142
  super(props);
3904
4143
  this.capabilities = null;
3905
4144
  this.loaders = [WMSErrorLoader, CSWCapabilitiesLoader];
3906
- this.props = props;
3907
4145
  }
3908
4146
  async getMetadata() {
3909
4147
  const capabilities = await this.getCapabilities();
@@ -4090,7 +4328,6 @@
4090
4328
  _WFSCapabilitiesLoader: () => WFSCapabilitiesLoader,
4091
4329
  _WMSFeatureInfoLoader: () => WMSFeatureInfoLoader,
4092
4330
  _WMSLayerDescriptionLoader: () => WMSLayerDescriptionLoader,
4093
- _WMTSCapabilitiesLoader: () => WMTSCapabilitiesLoader,
4094
4331
  _getArcGISServices: () => getArcGISServices,
4095
4332
  createImageSource: () => createImageSource
4096
4333
  });
@@ -4103,7 +4340,6 @@
4103
4340
  init_wms_capabilities_loader();
4104
4341
  init_wms_feature_info_loader();
4105
4342
  init_wms_layer_description_loader();
4106
- init_wmts_capabilities_loader();
4107
4343
  init_wfs_capabilities_loader();
4108
4344
  init_gml_loader();
4109
4345
  init_image_source();