chunk-T6STWTVU.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import {
  2. L,
  3. O,
  4. T
  5. } from "./chunk-YVTH4OGO.js";
  6. import {
  7. u
  8. } from "./chunk-4D6PVVFX.js";
  9. import {
  10. ne,
  11. se,
  12. te
  13. } from "./chunk-FYNVVMWY.js";
  14. import {
  15. e
  16. } from "./chunk-Q52DVFYK.js";
  17. import {
  18. d
  19. } from "./chunk-KMAHKQ2G.js";
  20. import {
  21. i
  22. } from "./chunk-F6A2QQ26.js";
  23. import {
  24. U
  25. } from "./chunk-VNFRAYHO.js";
  26. import {
  27. M
  28. } from "./chunk-ECW2QABR.js";
  29. import {
  30. c as c2,
  31. k2 as k
  32. } from "./chunk-MRJEICT6.js";
  33. import {
  34. s,
  35. s3 as s2
  36. } from "./chunk-EMJ4ZSM2.js";
  37. import {
  38. c,
  39. r,
  40. t
  41. } from "./chunk-GZT4BVFP.js";
  42. // node_modules/@arcgis/core/layers/ogc/ogcFeatureUtils.js
  43. var b = s.getLogger("esri.layers.graphics.sources.ogcfeature");
  44. var j = "http://www.opengis.net/def/crs/";
  45. var F = `${j}OGC/1.3/CRS84`;
  46. async function I(i2, r2, a = {}, s3 = 5) {
  47. const { links: o } = i2, l = G(o, "items", "application/geo+json") || G(o, "http://www.opengis.net/def/rel/ogc/1.0/items", "application/geo+json");
  48. if (t(l))
  49. throw new s2("ogc-feature-layer:missing-items-page", "Missing items url");
  50. const { data: c3 } = await U(l.href, { signal: a.signal, query: { limit: s3, ...a.customParameters, token: a.apiKey }, headers: { accept: "application/geo+json" } });
  51. await O(c3);
  52. const d2 = T(c3, { geometryType: r2.geometryType }), u2 = r2.fields || d2.fields || [], f = r2.hasZ != null ? r2.hasZ : d2.hasZ, h = d2.geometryType, j2 = r2.objectIdField || d2.objectIdFieldName || "OBJECTID";
  53. let F2 = r2.timeInfo;
  54. const I2 = u2.find((e2) => e2.name === j2);
  55. if (!I2) {
  56. if (!d2.objectIdFieldType)
  57. throw new s2("ogc-feature-layer:missing-feature-id", "Collection geojson require a feature id as a unique identifier");
  58. u2.unshift({ name: j2, alias: j2, type: "esriFieldTypeOID", editable: false, nullable: false });
  59. } else
  60. I2.type = "esriFieldTypeOID", I2.editable = false, I2.nullable = false;
  61. if (j2 !== d2.objectIdFieldName) {
  62. const e2 = u2.find((e3) => e3.name === d2.objectIdFieldName);
  63. e2 && (e2.type = "esriFieldTypeInteger");
  64. }
  65. u2 === d2.fields && d2.unknownFields.length > 0 && b.warn({ name: "ogc-feature-layer:unknown-field-types", message: "Some fields types couldn't be inferred from the features and were dropped", details: { unknownFields: d2.unknownFields } });
  66. for (const e2 of u2) {
  67. if (e2.name == null && (e2.name = e2.alias), e2.alias == null && (e2.alias = e2.name), e2.type !== "esriFieldTypeOID" && e2.type !== "esriFieldTypeGlobalID" && (e2.editable = e2.editable == null || !!e2.editable, e2.nullable = e2.nullable == null || !!e2.nullable), !e2.name)
  68. throw new s2("ogc-feature-layer:invalid-field-name", "field name is missing", { field: e2 });
  69. if (!i.jsonValues.includes(e2.type))
  70. throw new s2("ogc-feature-layer:invalid-field-type", `invalid type for field "${e2.name}"`, { field: e2 });
  71. }
  72. if (F2) {
  73. const e2 = new d(u2);
  74. if (F2.startTimeField) {
  75. const t2 = e2.get(F2.startTimeField);
  76. t2 ? (F2.startTimeField = t2.name, t2.type = "esriFieldTypeDate") : F2.startTimeField = null;
  77. }
  78. if (F2.endTimeField) {
  79. const t2 = e2.get(F2.endTimeField);
  80. t2 ? (F2.endTimeField = t2.name, t2.type = "esriFieldTypeDate") : F2.endTimeField = null;
  81. }
  82. if (F2.trackIdField) {
  83. const t2 = e2.get(F2.trackIdField);
  84. t2 ? F2.trackIdField = t2.name : (F2.trackIdField = null, b.warn({ name: "ogc-feature-layer:invalid-timeInfo-trackIdField", message: "trackIdField is missing", details: { timeInfo: F2 } }));
  85. }
  86. F2.startTimeField || F2.endTimeField || (b.warn({ name: "ogc-feature-layer:invalid-timeInfo", message: "startTimeField and endTimeField are missing", details: { timeInfo: F2 } }), F2 = null);
  87. }
  88. return { drawingInfo: h ? u(h) : null, geometryType: h, fields: u2, hasZ: !!f, objectIdField: j2, timeInfo: F2 };
  89. }
  90. async function T2(i2, r2 = {}) {
  91. const { links: a } = i2, s3 = G(a, "data", "application/json") || G(a, "http://www.opengis.net/def/rel/ogc/1.0/data", "application/json");
  92. if (t(s3))
  93. throw new s2("ogc-feature-layer:missing-collections-page", "Missing collections url");
  94. const { apiKey: o, customParameters: l, signal: c3 } = r2, { data: d2 } = await U(s3.href, { signal: c3, headers: { accept: "application/json" }, query: { ...l, token: o } });
  95. return d2;
  96. }
  97. async function k2(i2, r2 = {}) {
  98. const { links: a } = i2, s3 = G(a, "conformance", "application/json") || G(a, "http://www.opengis.net/def/rel/ogc/1.0/conformance", "application/json");
  99. if (t(s3))
  100. throw new s2("ogc-feature-layer:missing-conformance-page", "Missing conformance url");
  101. const { apiKey: o, customParameters: l, signal: c3 } = r2, { data: d2 } = await U(s3.href, { signal: c3, headers: { accept: "application/json" }, query: { ...l, token: o } });
  102. return d2;
  103. }
  104. async function S(t2, i2 = {}) {
  105. const { apiKey: n, customParameters: r2, signal: a } = i2, { data: s3 } = await U(t2, { signal: a, headers: { accept: "application/json" }, query: { ...r2, token: n } });
  106. return s3;
  107. }
  108. async function x(t2, i2 = {}) {
  109. const r2 = "application/vnd.oai.openapi+json;version=3.0", a = G(t2.links, "service-desc", r2);
  110. if (t(a))
  111. return b.warn("ogc-feature-layer:missing-openapi-page", "The OGC API-Features server does not have an OpenAPI page."), null;
  112. const { apiKey: s3, customParameters: o, signal: l } = i2, { data: c3 } = await U(a.href, { signal: l, headers: { accept: r2 }, query: { ...o, token: s3 } });
  113. return c3;
  114. }
  115. function N(e2) {
  116. const t2 = /^http:\/\/www\.opengis.net\/def\/crs\/(?<authority>.*)\/(?<version>.*)\/(?<code>.*)$/i.exec(e2)?.groups;
  117. if (!t2)
  118. return null;
  119. const { authority: i2, code: n } = t2;
  120. switch (i2.toLowerCase()) {
  121. case "ogc":
  122. switch (n.toLowerCase()) {
  123. case "crs27":
  124. return k.GCS_NAD_1927.wkid;
  125. case "crs83":
  126. return 4269;
  127. case "crs84":
  128. case "crs84h":
  129. return k.WGS84.wkid;
  130. default:
  131. return null;
  132. }
  133. case "esri":
  134. case "epsg": {
  135. const e3 = Number.parseInt(n, 10);
  136. return Number.isNaN(e3) ? null : e3;
  137. }
  138. default:
  139. return null;
  140. }
  141. }
  142. async function q(e2, t2, i2) {
  143. const n = await v(e2, t2, i2);
  144. return se(n);
  145. }
  146. async function v(i2, l, p) {
  147. const { capabilities: { query: { maxRecordCount: m } }, collection: g, layerDefinition: y, queryParameters: { apiKey: w, customParameters: b2 }, spatialReference: j2, supportedCrs: F2 } = i2, { links: I2 } = g, T3 = G(I2, "items", "application/geo+json") || G(I2, "http://www.opengis.net/def/rel/ogc/1.0/items", "application/geo+json");
  148. if (t(T3))
  149. throw new s2("ogc-feature-layer:missing-items-page", "Missing items url");
  150. const { geometry: k3, num: S2, start: x2, timeExtent: N2, where: q2 } = l;
  151. if (l.objectIds)
  152. throw new s2("ogc-feature-layer:query-by-objectids-not-supported", "Queries with objectids are not supported");
  153. const v2 = k.fromJSON(j2), M3 = c(l.outSpatialReference, v2), C2 = M3.isWGS84 ? null : O2(M3, F2), P = D(k3, F2), W = R(N2), Z = $(q2), K = S2 ?? (x2 != null && x2 !== void 0 ? 10 : m), { data: L2 } = await U(T3.href, { ...p, query: { ...b2, ...P, crs: C2, datetime: W, query: Z, limit: K, startindex: x2, token: w }, headers: { accept: "application/geo+json" } });
  154. let A = false;
  155. if (L2.links) {
  156. const e2 = L2.links.find((e3) => e3.rel === "next");
  157. A = !!e2;
  158. }
  159. !A && Number.isInteger(L2.numberMatched) && Number.isInteger(L2.numberReturned) && (A = L2.numberReturned < L2.numberMatched);
  160. const { fields: E, globalIdField: J, hasM: U2, hasZ: _, objectIdField: z } = y, B = y.geometryType, Q = L(L2, { geometryType: B, hasZ: _, objectIdField: z });
  161. if (!C2 && M3.isWebMercator) {
  162. for (const e2 of Q)
  163. if (r(e2.geometry)) {
  164. const t2 = ne(e2.geometry, B, _, false);
  165. t2.spatialReference = k.WGS84, e2.geometry = te(M(t2, M3));
  166. }
  167. }
  168. for (const e2 of Q)
  169. e2.objectId = e2.attributes[z];
  170. const V = C2 || !C2 && M3.isWebMercator ? M3.toJSON() : c2, H = new e();
  171. return H.exceededTransferLimit = A, H.features = Q, H.fields = E, H.geometryType = B, H.globalIdFieldName = J, H.hasM = U2, H.hasZ = _, H.objectIdFieldName = z, H.spatialReference = V, H;
  172. }
  173. function M2(e2) {
  174. return r(e2) && e2.type === "extent";
  175. }
  176. function O2(e2, t2) {
  177. const { isWebMercator: i2, wkid: n } = e2;
  178. if (!n)
  179. return null;
  180. const r2 = i2 ? t2[3857] ?? t2[102100] ?? t2[102113] ?? t2[900913] : t2[e2.wkid];
  181. return r2 ? `${j}${r2}` : null;
  182. }
  183. function C(e2) {
  184. if (t(e2))
  185. return "";
  186. const { xmin: t2, ymin: i2, xmax: r2, ymax: a } = e2;
  187. return `${t2},${i2},${r2},${a}`;
  188. }
  189. function R(e2) {
  190. if (t(e2))
  191. return null;
  192. const { start: t2, end: i2 } = e2;
  193. return `${r(t2) ? t2.toISOString() : ".."}/${r(i2) ? i2.toISOString() : ".."}`;
  194. }
  195. function $(e2) {
  196. return t(e2) || !e2 || e2 === "1=1" ? null : e2;
  197. }
  198. function D(e2, t2) {
  199. if (!M2(e2))
  200. return null;
  201. const { spatialReference: i2 } = e2;
  202. if (!i2 || i2.isWGS84)
  203. return { bbox: C(e2) };
  204. const n = O2(i2, t2);
  205. return r(n) ? { bbox: C(e2), "bbox-crs": n } : i2.isWebMercator ? { bbox: C(M(e2, k.WGS84)) } : null;
  206. }
  207. function G(e2, t2, i2) {
  208. return e2.find((e3) => e3.rel === t2 && e3.type === i2) || e2.find((e3) => e3.rel === t2 && !e3.type);
  209. }
  210. export {
  211. j,
  212. F,
  213. I,
  214. T2 as T,
  215. k2 as k,
  216. S,
  217. x,
  218. N,
  219. q,
  220. v
  221. };
  222. //# sourceMappingURL=chunk-T6STWTVU.js.map