chunk-2H3JYQ2D.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import {
  2. s as s2,
  3. t
  4. } from "./chunk-3IRT3YKJ.js";
  5. import {
  6. ie,
  7. p
  8. } from "./chunk-47NSA4T4.js";
  9. import {
  10. s3 as s
  11. } from "./chunk-E5O6P5I2.js";
  12. // node_modules/@arcgis/core/layers/graphics/sources/geojson/geojson.js
  13. var i = { LineString: "esriGeometryPolyline", MultiLineString: "esriGeometryPolyline", MultiPoint: "esriGeometryMultipoint", Point: "esriGeometryPoint", Polygon: "esriGeometryPolygon", MultiPolygon: "esriGeometryPolygon" };
  14. function s3(e) {
  15. return i[e];
  16. }
  17. function* c(e) {
  18. switch (e.type) {
  19. case "Feature":
  20. yield e;
  21. break;
  22. case "FeatureCollection":
  23. for (const t2 of e.features)
  24. t2 && (yield t2);
  25. }
  26. }
  27. function* u(e) {
  28. if (!e)
  29. return null;
  30. switch (e.type) {
  31. case "Point":
  32. yield e.coordinates;
  33. break;
  34. case "LineString":
  35. case "MultiPoint":
  36. yield* e.coordinates;
  37. break;
  38. case "MultiLineString":
  39. case "Polygon":
  40. for (const t2 of e.coordinates)
  41. yield* t2;
  42. break;
  43. case "MultiPolygon":
  44. for (const t2 of e.coordinates)
  45. for (const e2 of t2)
  46. yield* e2;
  47. }
  48. }
  49. function* l(e, o = {}) {
  50. var _a;
  51. const { geometryType: r, objectIdField: i2 } = o;
  52. for (const c2 of e) {
  53. const { geometry: e2, properties: u2, id: l2 } = c2;
  54. if (e2 && s3(e2.type) !== r)
  55. continue;
  56. const f2 = u2 || {};
  57. let a2 = (_a = f2[i2]) != null ? _a : null;
  58. i2 && null != l2 && !f2[i2] && (f2[i2] = a2 = l2);
  59. const y2 = new s2(e2 ? g(new t(), e2, o) : null, f2, null, a2);
  60. yield y2;
  61. }
  62. }
  63. function f(e) {
  64. for (const t2 of e)
  65. if (t2.length > 2)
  66. return true;
  67. return false;
  68. }
  69. function a(e) {
  70. return !p2(e);
  71. }
  72. function y(e) {
  73. return p2(e);
  74. }
  75. function p2(e) {
  76. let t2 = 0;
  77. for (let n = 0; n < e.length; n++) {
  78. const o = e[n], r = e[(n + 1) % e.length];
  79. t2 += o[0] * r[1] - r[0] * o[1];
  80. }
  81. return t2 <= 0;
  82. }
  83. function d(e) {
  84. const t2 = e[0], n = e[e.length - 1];
  85. return t2[0] === n[0] && t2[1] === n[1] && t2[2] === n[2] || e.push(t2), e;
  86. }
  87. function g(e, t2, n) {
  88. switch (t2.type) {
  89. case "LineString":
  90. return m(e, t2, n);
  91. case "MultiLineString":
  92. return h(e, t2, n);
  93. case "MultiPoint":
  94. return w(e, t2, n);
  95. case "MultiPolygon":
  96. return P(e, t2, n);
  97. case "Point":
  98. return b(e, t2, n);
  99. case "Polygon":
  100. return j(e, t2, n);
  101. }
  102. }
  103. function m(e, t2, n) {
  104. return G(e, t2.coordinates, n), e;
  105. }
  106. function h(e, t2, n) {
  107. for (const o of t2.coordinates)
  108. G(e, o, n);
  109. return e;
  110. }
  111. function w(e, t2, n) {
  112. return G(e, t2.coordinates, n), e;
  113. }
  114. function P(e, t2, n) {
  115. for (const o of t2.coordinates) {
  116. S(e, o[0], n);
  117. for (let t3 = 1; t3 < o.length; t3++)
  118. F(e, o[t3], n);
  119. }
  120. return e;
  121. }
  122. function b(e, t2, n) {
  123. return k(e, t2.coordinates, n), e;
  124. }
  125. function j(e, t2, n) {
  126. const o = t2.coordinates;
  127. S(e, o[0], n);
  128. for (let r = 1; r < o.length; r++)
  129. F(e, o[r], n);
  130. return e;
  131. }
  132. function S(e, t2, n) {
  133. const o = d(t2);
  134. a(o) ? M(e, o, n) : G(e, o, n);
  135. }
  136. function F(e, t2, n) {
  137. const o = d(t2);
  138. y(o) ? M(e, o, n) : G(e, o, n);
  139. }
  140. function G(e, t2, n) {
  141. for (const o of t2)
  142. k(e, o, n);
  143. e.lengths.push(t2.length);
  144. }
  145. function M(e, t2, n) {
  146. for (let o = t2.length - 1; o >= 0; o--)
  147. k(e, t2[o], n);
  148. e.lengths.push(t2.length);
  149. }
  150. function k(e, t2, n) {
  151. const [o, r, i2] = t2;
  152. e.coords.push(o, r), n.hasZ && e.coords.push(i2 || 0);
  153. }
  154. function O(e) {
  155. switch (typeof e) {
  156. case "string":
  157. return "esriFieldTypeString";
  158. case "number":
  159. return "esriFieldTypeDouble";
  160. default:
  161. return "unknown";
  162. }
  163. }
  164. function T(t2) {
  165. if (!t2)
  166. throw new s("geojson-layer:empty", "GeoJSON data is empty");
  167. if ("Feature" !== t2.type && "FeatureCollection" !== t2.type)
  168. throw new s("geojson-layer:unsupported-geojson-object", "missing or not supported GeoJSON object type", { data: t2 });
  169. const { crs: n } = t2;
  170. if (!n)
  171. return;
  172. const o = "string" == typeof n ? n : "name" === n.type ? n.properties.name : "EPSG" === n.type ? n.properties.code : null, r = new RegExp(".*(CRS84H?|4326)$", "i");
  173. if (!o || !r.test(o))
  174. throw new s("geojson-layer:unsupported-crs", "unsupported GeoJSON 'crs' member", { crs: n });
  175. }
  176. function L(e, t2 = {}) {
  177. const n = [], i2 = /* @__PURE__ */ new Set(), l2 = /* @__PURE__ */ new Set();
  178. let a2, y2 = false, p3 = null, d2 = false, { geometryType: g2 = null } = t2, m2 = false;
  179. for (const r of c(e)) {
  180. const { geometry: e2, properties: t3, id: c2 } = r;
  181. if (!e2 || (g2 || (g2 = s3(e2.type)), s3(e2.type) === g2)) {
  182. if (!y2) {
  183. y2 = f(u(e2));
  184. }
  185. if (d2 || (d2 = null != c2, d2 && (a2 = typeof c2, p3 = Object.keys(t3).filter((e3) => t3[e3] === c2))), d2 && null != c2 && (p3.length > 1 ? p3 = p3.filter((e3) => t3[e3] === c2) : 1 === p3.length && (p3 = t3[p3[0]] === c2 ? p3 : [])), !m2 && t3) {
  186. let e3 = true;
  187. for (const r2 in t3) {
  188. if (i2.has(r2))
  189. continue;
  190. const s4 = t3[r2];
  191. if (null == s4) {
  192. e3 = false, l2.add(r2);
  193. continue;
  194. }
  195. const c3 = O(s4);
  196. "unknown" !== c3 ? (l2.delete(r2), i2.add(r2), n.push({ name: p(r2), alias: r2, type: c3 })) : l2.add(r2);
  197. }
  198. m2 = e3;
  199. }
  200. }
  201. }
  202. const h2 = p(1 === (p3 == null ? void 0 : p3.length) && p3[0] || null);
  203. if (h2) {
  204. for (const o of n)
  205. if (o.name === h2 && ie(o)) {
  206. o.type = "esriFieldTypeOID";
  207. break;
  208. }
  209. }
  210. return { fields: n, geometryType: g2, hasZ: y2, objectIdFieldName: h2, objectIdFieldType: a2, unknownFields: Array.from(l2) };
  211. }
  212. function I(e, t2) {
  213. return Array.from(l(c(e), t2));
  214. }
  215. export {
  216. s3 as s,
  217. T,
  218. L,
  219. I
  220. };
  221. //# sourceMappingURL=chunk-2H3JYQ2D.js.map