/* COPYRIGHT Esri - https://js.arcgis.com/5.0.18/LICENSE.txt */
import t from"../../../core/Error.js";import e from"../../../geometry/Multipoint.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/Polygon.js";import r from"../../../geometry/Polyline.js";function n(t,o){const s={spatialReference:o},r=p(t,s),n=t.lengths,a=t.coords,h=n[0];s.points=[];let l=0;for(let e=0;e<h;e++){const t=[];for(let e=0;e<r;e++)t[e]=a[l],l++;s.points.push(t)}return new e(s)}function a(t,e){const s={spatialReference:e};let r=2;p(t,s);const n=t.coords;return s.x=n[0],s.y=n[1],t.has_z&&(s.z=n[r],r++),t.has_m&&(s.m=n[r]),new o(s)}function h(t,e){const{paths:o,hasM:s,hasZ:n}=i(t,3);return new r({paths:o,hasM:s,hasZ:n,spatialReference:e})}function l(t,e){const{paths:o,hasM:r,hasZ:n}=i(t,4);return new s({rings:o,hasM:r,hasZ:n,spatialReference:e})}function i(e,o){const s={paths:[],hasM:!1,hasZ:!1},r=p(e,s),{coords:n,geometry_type:a,lengths:h}=e;if(a.value!==o)throw new t("KnowledgeGraph:illegal-geometry-type","Illegal Geometry type for multipath conversion");let l=0;return h.forEach(t=>{const e=[];for(let o=0;o<t;o++){const t=[];for(let e=0;e<r;e++)t[e]=n[l],l++;e.push(t)}s.paths.push(e)}),s}function p(t,e){let o=2;return t.has_z?(e.hasZ=t.has_z,o++):e.hasZ=!1,t.has_m?(e.hasM=t.has_m,o++):e.hasM=!1,o}export{n as wasmToMultipointGeometry,a as wasmToPointGeometry,l as wasmToPolygonGeometry,h as wasmToPolylineGeometry};
