chunk-Z32FUDOP.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. import {
  2. n as n2,
  3. o as o2
  4. } from "./chunk-FEH5F4VW.js";
  5. import {
  6. i as i2
  7. } from "./chunk-YVTH4OGO.js";
  8. import {
  9. fn,
  10. rn
  11. } from "./chunk-DH2OBAUC.js";
  12. import {
  13. y
  14. } from "./chunk-BJHM4JNS.js";
  15. import {
  16. i
  17. } from "./chunk-ZOEK6QHJ.js";
  18. import {
  19. U
  20. } from "./chunk-VNFRAYHO.js";
  21. import {
  22. ht,
  23. mt,
  24. z
  25. } from "./chunk-VBRY5KJM.js";
  26. import {
  27. M2 as M
  28. } from "./chunk-ECW2QABR.js";
  29. import {
  30. E as E2,
  31. c,
  32. k2 as k
  33. } from "./chunk-MRJEICT6.js";
  34. import {
  35. n3 as n,
  36. o
  37. } from "./chunk-Y3WMVFTW.js";
  38. import {
  39. E
  40. } from "./chunk-ULGDPLM2.js";
  41. import {
  42. s3 as s
  43. } from "./chunk-EMJ4ZSM2.js";
  44. import {
  45. r,
  46. t
  47. } from "./chunk-GZT4BVFP.js";
  48. // node_modules/@arcgis/core/layers/ogc/dateUtils.js
  49. function e(e2) {
  50. return t2(e2) ?? n3(e2);
  51. }
  52. function n3(e2) {
  53. const n4 = new Date(e2).getTime();
  54. return Number.isNaN(n4) ? null : n4;
  55. }
  56. function t2(e2) {
  57. const n4 = s2.exec(e2);
  58. if (!n4)
  59. return null;
  60. const t3 = n4.groups, u = +t3.year, o3 = +t3.month - 1, r2 = +t3.day, f = +(t3.hours ?? "0"), i3 = +(t3.minutes ?? "0"), d = +(t3.seconds ?? "0");
  61. if (f > 23)
  62. return null;
  63. if (i3 > 59)
  64. return null;
  65. if (d > 59)
  66. return null;
  67. const l = t3.ms ?? "0", c2 = l ? +l.padEnd(3, "0").substring(0, 3) : 0;
  68. let a;
  69. if (t3.isUTC)
  70. a = Date.UTC(u, o3, r2, f, i3, d, c2);
  71. else if (t3.offsetSign) {
  72. const e3 = +t3.offsetHours, n5 = +t3.offsetMinutes;
  73. a = 6e4 * (t3.offsetSign === "+" ? -1 : 1) * (60 * e3 + n5) + Date.UTC(u, o3, r2, f, i3, d, c2);
  74. } else
  75. a = new Date(u, o3, r2, f, i3, d, c2).getTime();
  76. return Number.isNaN(a) ? null : a;
  77. }
  78. var s2 = /^(?:(?<year>-?\d{4,})-(?<month>\d{2})-(?<day>\d{2}))(?:T(?<hours>\d{2}):(?<minutes>\d{2}):(?<seconds>\d{2})(?:\.(?<ms>\d+))?)?(?:(?<isUTC>Z)|(?:(?<offsetSign>\+|-)(?<offsetHours>\d{2}):(?<offsetMinutes>\d{2})))?$/;
  79. // node_modules/@arcgis/core/layers/ogc/wfsUtils.js
  80. var S = "xlink:href";
  81. var x = "2.0.0";
  82. var C = "__esri_wfs_id__";
  83. var E3 = "wfs-layer:getWFSLayerTypeInfo-error";
  84. var N = "wfs-layer:empty-service";
  85. var P = "wfs-layer:feature-type-not-found";
  86. var R = "wfs-layer:geojson-not-supported";
  87. var j = "wfs-layer:kvp-encoding-not-supported";
  88. var A = "wfs-layer:malformed-json";
  89. var G = "wfs-layer:unknown-geometry-type";
  90. var k2 = "wfs-layer:unknown-field-type";
  91. var v = "wfs-layer:unsupported-spatial-reference";
  92. var U2 = "wfs-layer:unsupported-wfs-version";
  93. async function D(t3, r2) {
  94. const n4 = I((await U(t3, { responseType: "text", query: { SERVICE: "WFS", REQUEST: "GetCapabilities", VERSION: x, ...r2?.customParameters }, signal: r2?.signal })).data);
  95. return $(t3, n4), n4;
  96. }
  97. function I(e2) {
  98. const t3 = te(e2);
  99. ne(t3), ae(t3);
  100. const r2 = t3.firstElementChild, a = n(M2(r2));
  101. return { operations: L(r2), get featureTypes() {
  102. return Array.from(a());
  103. }, readFeatureTypes: a };
  104. }
  105. var O = new Set(["json", "application/json", "geojson", "application/json; subtype=geojson"]);
  106. function L(e2) {
  107. let r2 = false;
  108. const n4 = { GetCapabilities: { url: "" }, DescribeFeatureType: { url: "" }, GetFeature: { url: "", outputFormat: null, supportsPagination: false } };
  109. if (o2(e2, { OperationsMetadata: { Operation: (e3) => {
  110. switch (e3.getAttribute("name")) {
  111. case "GetCapabilities":
  112. return { DCP: { HTTP: { Get: (e4) => {
  113. n4.GetCapabilities.url = e4.getAttribute(S);
  114. } } } };
  115. case "DescribeFeatureType":
  116. return { DCP: { HTTP: { Get: (e4) => {
  117. n4.DescribeFeatureType.url = e4.getAttribute(S);
  118. } } } };
  119. case "GetFeature":
  120. return { DCP: { HTTP: { Get: (e4) => {
  121. n4.GetFeature.url = e4.getAttribute(S);
  122. } } }, Parameter: (e4) => {
  123. if (e4.getAttribute("name") === "outputFormat")
  124. return { AllowedValues: { Value: (e5) => {
  125. const t3 = e5.textContent;
  126. O.has(t3.toLowerCase()) && (n4.GetFeature.outputFormat = t3);
  127. } } };
  128. } };
  129. }
  130. }, Constraint: (e3) => {
  131. switch (e3.getAttribute("name")) {
  132. case "KVPEncoding":
  133. return { DefaultValue: (e4) => {
  134. r2 = e4.textContent.toLowerCase() === "true";
  135. } };
  136. case "ImplementsResultPaging":
  137. return { DefaultValue: (e4) => {
  138. n4.GetFeature.supportsPagination = e4.textContent.toLowerCase() === "true";
  139. } };
  140. }
  141. } } }), !r2)
  142. throw new s(j, "WFS service doesn't support key/value pair (KVP) encoding");
  143. if (t(n4.GetFeature.outputFormat))
  144. throw new s(R, "WFS service doesn't support GeoJSON output format");
  145. return n4;
  146. }
  147. function $(e2, t3) {
  148. ht(e2) && (z(e2, t3.operations.DescribeFeatureType.url, true) && (t3.operations.DescribeFeatureType.url = mt(t3.operations.DescribeFeatureType.url)), z(e2, t3.operations.GetFeature.url, true) && (t3.operations.GetFeature.url = mt(t3.operations.GetFeature.url)));
  149. }
  150. function M2(e2) {
  151. return n2(e2, { FeatureTypeList: { FeatureType: (e3) => {
  152. const t3 = { typeName: "undefined:undefined", name: "", title: "", description: "", extent: null, namespacePrefix: "", namespaceUri: "", supportedSpatialReferences: [] }, r2 = new Set([4326]), n4 = (e4) => {
  153. const t4 = parseInt(e4.textContent.match(/(?<wkid>\d+$)/i)?.groups?.wkid, 10);
  154. Number.isNaN(t4) || r2.add(t4);
  155. };
  156. return o2(e3, { Name: (e4) => {
  157. const { name: r3, prefix: n5 } = re(e4.textContent);
  158. t3.typeName = `${n5}:${r3}`, t3.name = r3, t3.namespacePrefix = n5, t3.namespaceUri = e4.lookupNamespaceURI(n5);
  159. }, Abstract: (e4) => {
  160. t3.description = e4.textContent;
  161. }, Title: (e4) => {
  162. t3.title = e4.textContent;
  163. }, WGS84BoundingBox: (e4) => {
  164. t3.extent = V(e4);
  165. }, DefaultSRS: n4, DefaultCRS: n4, OtherSRS: n4, OtherCRS: n4 }), t3.title || (t3.title = t3.name), t3.supportedSpatialReferences.push(...r2), t3;
  166. } } });
  167. }
  168. function V(e2) {
  169. let t3, r2, n4, a;
  170. for (const o3 of e2.children)
  171. switch (o3.localName) {
  172. case "LowerCorner":
  173. [t3, r2] = o3.textContent.split(" ").map((e3) => Number.parseFloat(e3));
  174. break;
  175. case "UpperCorner":
  176. [n4, a] = o3.textContent.split(" ").map((e3) => Number.parseFloat(e3));
  177. }
  178. return { xmin: t3, ymin: r2, xmax: n4, ymax: a, spatialReference: c };
  179. }
  180. function W(e2, t3, n4) {
  181. return o(e2, (e3) => n4 ? e3.name === t3 && e3.namespaceUri === n4 : e3.typeName === t3 || e3.name === t3);
  182. }
  183. async function X(e2, t3, r2, n4 = {}) {
  184. const { featureType: a, extent: o3 } = await Y(e2, t3, r2, n4), { fields: s3, geometryType: i3, swapXY: p, objectIdField: u, geometryField: c2 } = await q(e2, a.typeName, n4);
  185. return { url: e2.operations.GetCapabilities.url, name: a.name, namespaceUri: a.namespaceUri, fields: s3, geometryField: c2, geometryType: i3, objectIdField: u, spatialReference: n4.spatialReference ?? k.WGS84, extent: o3, swapXY: p, wfsCapabilities: e2, customParameters: n4.customParameters };
  186. }
  187. async function Y(e2, r2, n4, o3 = {}) {
  188. const { spatialReference: s3 = k.WGS84 } = o3, i3 = e2.readFeatureTypes(), p = r2 ? W(i3, r2, n4) : i3.next().value;
  189. if (t(p))
  190. throw r2 ? new s(P, `The type '${r2}' could not be found in the service`) : new s(N, "The service is empty");
  191. let u = new M({ ...p.extent, spatialReference: s3 });
  192. if (!E2(s3, c))
  193. try {
  194. await fn(c, s3, void 0, o3), u = rn(u, c);
  195. } catch {
  196. throw new s(v, "Projection not supported");
  197. }
  198. return { extent: u, spatialReference: s3, featureType: p };
  199. }
  200. async function q(e2, r2, n4 = {}) {
  201. const [o3, i3] = await E([J(e2.operations.DescribeFeatureType.url, r2, n4), _(e2, r2, n4)]);
  202. if (o3.error || i3.error)
  203. throw new s(E3, `An error occurred while getting info about the feature type '${r2}'`, { error: o3.error || i3.error });
  204. const { fields: p, errors: u } = o3.value, c2 = o3.value.geometryType || i3.value.geometryType, l = i3.value.swapXY;
  205. if (t(c2))
  206. throw new s(G, `The geometry type could not be determined for type '${r2}`, { typeName: r2, geometryType: c2, fields: p, errors: u });
  207. return { ...z2(p), geometryType: c2, swapXY: l };
  208. }
  209. function z2(e2) {
  210. const t3 = e2.find((e3) => e3.type === "geometry");
  211. let r2 = e2.find((e3) => e3.type === "oid");
  212. return e2 = e2.filter((e3) => e3.type !== "geometry"), r2 || (r2 = new y({ name: C, type: "oid", alias: C }), e2.unshift(r2)), { geometryField: t3?.name ?? null, objectIdField: r2.name, fields: e2 };
  213. }
  214. async function _(t3, r2, n4 = {}) {
  215. let a, o3 = false;
  216. const [s3, i3] = await Promise.all([K(t3.operations.GetFeature.url, r2, t3.operations.GetFeature.outputFormat, { ...n4, count: 1 }), U(t3.operations.GetFeature.url, { responseType: "text", query: Z(r2, void 0, { ...n4, count: 1 }), signal: n4?.signal })]), p = s3.type === "FeatureCollection" && s3.features[0]?.geometry;
  217. if (p) {
  218. let e2;
  219. switch (a = i.fromJSON(i2(p.type)), p.type) {
  220. case "Point":
  221. e2 = p.coordinates;
  222. break;
  223. case "LineString":
  224. case "MultiPoint":
  225. e2 = p.coordinates[0];
  226. break;
  227. case "MultiLineString":
  228. case "Polygon":
  229. e2 = p.coordinates[0][0];
  230. break;
  231. case "MultiPolygon":
  232. e2 = p.coordinates[0][0][0];
  233. }
  234. const t4 = /<[^>]*pos[^>]*> *(-?\d+(?:\.\d+)?) (-?\d+(?:\.\d+)?)/.exec(i3.data);
  235. if (t4) {
  236. const r3 = e2[0].toFixed(3), n5 = e2[1].toFixed(3), a2 = parseFloat(t4[1]).toFixed(3);
  237. r3 === parseFloat(t4[2]).toFixed(3) && n5 === a2 && (o3 = true);
  238. }
  239. }
  240. return { geometryType: a, swapXY: o3 };
  241. }
  242. async function J(t3, r2, n4) {
  243. return Q(r2, (await U(t3, { responseType: "text", query: { SERVICE: "WFS", REQUEST: "DescribeFeatureType", VERSION: x, TYPENAME: r2, ...n4?.customParameters }, signal: n4?.signal })).data);
  244. }
  245. function Q(e2, n4) {
  246. const { name: a } = re(e2), s3 = te(n4);
  247. ae(s3);
  248. const i3 = o(n2(s3.firstElementChild, { element: (e3) => ({ name: e3.getAttribute("name"), typeName: re(e3.getAttribute("type")).name }) }), ({ name: e3 }) => e3 === a);
  249. if (r(i3)) {
  250. const e3 = o(n2(s3.firstElementChild, { complexType: (e4) => e4 }), (e4) => e4.getAttribute("name") === i3.typeName);
  251. if (r(e3))
  252. return B(e3);
  253. }
  254. throw new s(P, `Type '${e2}' not found in document`, { document: new XMLSerializer().serializeToString(s3) });
  255. }
  256. var H = new Set(["objectid", "fid"]);
  257. function B(e2) {
  258. const r2 = [], n4 = [];
  259. let a;
  260. const o3 = n2(e2, { complexContent: { extension: { sequence: { element: (e3) => e3 } } } });
  261. for (const s3 of o3) {
  262. const o4 = s3.getAttribute("name");
  263. if (!o4)
  264. continue;
  265. let i3, p;
  266. if (s3.hasAttribute("type") ? i3 = re(s3.getAttribute("type")).name : o2(s3, { simpleType: { restriction: (e3) => (i3 = re(e3.getAttribute("base")).name, { maxLength: (e4) => {
  267. p = +e4.getAttribute("value");
  268. } }) } }), !i3)
  269. continue;
  270. const u = s3.getAttribute("nillable") === "true";
  271. let c2 = false;
  272. switch (i3.toLowerCase()) {
  273. case "integer":
  274. case "nonpositiveinteger":
  275. case "negativeinteger":
  276. case "long":
  277. case "int":
  278. case "short":
  279. case "byte":
  280. case "nonnegativeinteger":
  281. case "unsignedlong":
  282. case "unsignedint":
  283. case "unsignedshort":
  284. case "unsignedbyte":
  285. case "positiveinteger":
  286. n4.push(new y({ name: o4, alias: o4, type: "integer", nullable: u }));
  287. break;
  288. case "float":
  289. case "double":
  290. case "decimal":
  291. n4.push(new y({ name: o4, alias: o4, type: "double", nullable: u }));
  292. break;
  293. case "boolean":
  294. case "string":
  295. case "gyearmonth":
  296. case "gyear":
  297. case "gmonthday":
  298. case "gday":
  299. case "gmonth":
  300. case "anyuri":
  301. case "qname":
  302. case "notation":
  303. case "normalizedstring":
  304. case "token":
  305. case "language":
  306. case "idrefs":
  307. case "entities":
  308. case "nmtoken":
  309. case "nmtokens":
  310. case "name":
  311. case "ncname":
  312. case "id":
  313. case "idref":
  314. case "entity":
  315. case "duration":
  316. case "time":
  317. n4.push(new y({ name: o4, alias: o4, type: "string", nullable: u, length: p ?? 255 }));
  318. break;
  319. case "datetime":
  320. case "date":
  321. n4.push(new y({ name: o4, alias: o4, type: "date", nullable: u, length: p ?? 36 }));
  322. break;
  323. case "pointpropertytype":
  324. a = "point", c2 = true;
  325. break;
  326. case "multipointpropertytype":
  327. a = "multipoint", c2 = true;
  328. break;
  329. case "curvepropertytype":
  330. case "multicurvepropertytype":
  331. case "multilinestringpropertytype":
  332. a = "polyline", c2 = true;
  333. break;
  334. case "surfacepropertytype":
  335. case "multisurfacepropertytype":
  336. case "multipolygonpropertytype":
  337. a = "polygon", c2 = true;
  338. break;
  339. case "geometrypropertytype":
  340. case "multigeometrypropertytype":
  341. c2 = true, r2.push(new s(G, `geometry type '${i3}' is not supported`, { type: new XMLSerializer().serializeToString(e2) }));
  342. break;
  343. default:
  344. r2.push(new s(k2, `Unknown field type '${i3}'`, { type: new XMLSerializer().serializeToString(e2) }));
  345. }
  346. c2 && n4.push(new y({ name: o4, alias: o4, type: "geometry", nullable: u }));
  347. }
  348. for (const t3 of n4)
  349. if (t3.type === "integer" && !t3.nullable && H.has(t3.name.toLowerCase())) {
  350. t3.type = "oid";
  351. break;
  352. }
  353. return { geometryType: a, fields: n4, errors: r2 };
  354. }
  355. async function K(r2, n4, a, o3) {
  356. let { data: s3 } = await U(r2, { responseType: "text", query: Z(n4, a, o3), signal: o3?.signal });
  357. s3 = s3.replace(/": +(-?\d+),(\d+)(,)?/g, '": $1.$2$3');
  358. try {
  359. if (o3?.dateFields?.length) {
  360. const e2 = new Set(o3.dateFields);
  361. return JSON.parse(s3, (t3, r3) => e2.has(t3) ? e(r3) : r3);
  362. }
  363. return JSON.parse(s3);
  364. } catch (i3) {
  365. throw new s(A, "Error while parsing the\xA0response", { response: s3, error: i3 });
  366. }
  367. }
  368. function Z(e2, t3, r2) {
  369. return { SERVICE: "WFS", REQUEST: "GetFeature", VERSION: x, TYPENAMES: e2, OUTPUTFORMAT: t3, SRSNAME: "EPSG:4326", STARTINDEX: r2?.startIndex, COUNT: r2?.count, ...r2?.customParameters };
  370. }
  371. function te(e2) {
  372. return new DOMParser().parseFromString(e2.trim(), "text/xml");
  373. }
  374. function re(e2) {
  375. const [t3, r2] = e2.split(":");
  376. return { prefix: r2 ? t3 : "", name: r2 ?? t3 };
  377. }
  378. function ne(e2) {
  379. const r2 = e2.firstElementChild.getAttribute("version");
  380. if (r2 && r2 !== x)
  381. throw new s(U2, `Unsupported WFS version ${r2}. Supported version: ${x}`);
  382. }
  383. function ae(e2) {
  384. let r2, n4;
  385. if (o2(e2.firstElementChild, { Exception: (e3) => (r2 = e3.getAttribute("exceptionCode"), { ExceptionText: (e4) => {
  386. n4 = e4.textContent;
  387. } }) }), r2)
  388. throw new s(`wfs-layer:${r2}`, n4);
  389. }
  390. export {
  391. C,
  392. D,
  393. W,
  394. X,
  395. z2 as z,
  396. K
  397. };
  398. //# sourceMappingURL=chunk-Z32FUDOP.js.map