chunk-YVTH4OGO.js 5.5 KB

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