chunk-C4RSV5VB.js 9.5 KB

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