1 |
- import{g as P,gu as G,gv as N,eS as $,aB as C}from"./index.6c049565.js";const J={LineString:"esriGeometryPolyline",MultiLineString:"esriGeometryPolyline",MultiPoint:"esriGeometryMultipoint",Point:"esriGeometryPoint",Polygon:"esriGeometryPolygon",MultiPolygon:"esriGeometryPolygon"};function S(n){return J[n]}function*M(n){switch(n.type){case"Feature":yield n;break;case"FeatureCollection":for(const t of n.features)t&&(yield t)}}function*x(n){if(!n)return null;switch(n.type){case"Point":yield n.coordinates;break;case"LineString":case"MultiPoint":yield*n.coordinates;break;case"MultiLineString":case"Polygon":for(const t of n.coordinates)yield*t;break;case"MultiPolygon":for(const t of n.coordinates)for(const e of t)yield*e}}function*A(n,t={}){var r;const{geometryType:e,objectIdField:o}=t;for(const a of n){const{geometry:c,properties:i,id:l}=a;if(c&&S(c.type)!==e)continue;const s=i||{};let d=(r=s[o])!=null?r:null;o&&l!=null&&!s[o]&&(s[o]=d=l),yield new $(c?Z(new C,c,t):null,s,null,d)}}function D(n){for(const t of n)if(t.length>2)return!0;return!1}function E(n){return!k(n)}function R(n){return k(n)}function k(n){let t=0;for(let e=0;e<n.length;e++){const o=n[e],r=n[(e+1)%n.length];t+=o[0]*r[1]-r[0]*o[1]}return t<=0}function T(n){const t=n[0],e=n[n.length-1];return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]||n.push(t),n}function Z(n,t,e){switch(t.type){case"LineString":return v(n,t,e);case"MultiLineString":return B(n,t,e);case"MultiPoint":return H(n,t,e);case"MultiPolygon":return q(n,t,e);case"Point":return z(n,t,e);case"Polygon":return K(n,t,e)}}function v(n,t,e){return h(n,t.coordinates,e),n}function B(n,t,e){for(const o of t.coordinates)h(n,o,e);return n}function H(n,t,e){return h(n,t.coordinates,e),n}function q(n,t,e){for(const o of t.coordinates){L(n,o[0],e);for(let r=1;r<o.length;r++)O(n,o[r],e)}return n}function z(n,t,e){return b(n,t.coordinates,e),n}function K(n,t,e){const o=t.coordinates;L(n,o[0],e);for(let r=1;r<o.length;r++)O(n,o[r],e);return n}function L(n,t,e){const o=T(t);E(o)?I(n,o,e):h(n,o,e)}function O(n,t,e){const o=T(t);R(o)?I(n,o,e):h(n,o,e)}function h(n,t,e){for(const o of t)b(n,o,e);n.lengths.push(t.length)}function I(n,t,e){for(let o=t.length-1;o>=0;o--)b(n,t[o],e);n.lengths.push(t.length)}function b(n,t,e){const[o,r,a]=t;n.coords.push(o,r),e.hasZ&&n.coords.push(a||0)}function Q(n){switch(typeof n){case"string":return"esriFieldTypeString";case"number":return"esriFieldTypeDouble";default:return"unknown"}}function V(n){if(!n)throw new P("geojson-layer:empty","GeoJSON data is empty");if(n.type!=="Feature"&&n.type!=="FeatureCollection")throw new P("geojson-layer:unsupported-geojson-object","missing or not supported GeoJSON object type",{data:n});const{crs:t}=n;if(!t)return;const e=typeof t=="string"?t:t.type==="name"?t.properties.name:t.type==="EPSG"?t.properties.code:null,o=new RegExp(".*(CRS84H?|4326)$","i");if(!e||!o.test(e))throw new P("geojson-layer:unsupported-crs","unsupported GeoJSON 'crs' member",{crs:t})}function W(n,t={}){const e=[],o=new Set,r=new Set;let a,c=!1,i=null,l=!1,{geometryType:s=null}=t,d=!1;for(const g of M(n)){const{geometry:w,properties:f,id:y}=g;if((!w||(s||(s=S(w.type)),S(w.type)===s))&&(c||(c=D(x(w))),l||(l=y!=null,l&&(a=typeof y,i=Object.keys(f).filter(p=>f[p]===y))),l&&y!=null&&(i.length>1?i=i.filter(p=>f[p]===y):i.length===1&&(i=f[i[0]]===y?i:[])),!d&&f)){let p=!0;for(const u in f){if(o.has(u))continue;const F=f[u];if(F==null){p=!1,r.add(u);continue}const j=Q(F);j!=="unknown"?(r.delete(u),o.add(u),e.push({name:G(u),alias:u,type:j})):r.add(u)}d=p}}const m=G((i==null?void 0:i.length)===1&&i[0]||null);if(m){for(const g of e)if(g.name===m&&N(g)){g.type="esriFieldTypeOID";break}}return{fields:e,geometryType:s,hasZ:c,objectIdFieldName:m,objectIdFieldType:a,unknownFields:Array.from(r)}}function X(n,t){return Array.from(A(M(n),t))}export{X as I,W as L,V as T,S as s};
|