@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 3.19 kB
JavaScript
import{isSome as t,unwrapOr as e,isNone as n}from"../../../../core/maybe.js";import{p as o}from"../../../../chunks/vec2.js";import{s as r}from"../../../../chunks/vec3.js";import{c as i}from"../../../../chunks/vec3f64.js";import{O as a}from"../../../../chunks/vec4f64.js";import{getReferenceEllipsoid as s}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as u}from"../../../../geometry/projection.js";import{ViewingMode as l}from"../../../ViewingMode.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as p}from"../../webgl-engine/lib/ContentObjectType.js";import{newDoubleArray as f}from"../../webgl-engine/lib/DoubleArray.js";import{newFloatArray as m}from"../../webgl-engine/lib/FloatArray.js";import{Geometry as h}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as T}from"../../webgl-engine/lib/VertexAttribute.js";function b(t,e,n=null){const o=[],r=[],i=e.mapPositions;g(e,r,o);const a=r[0][1].data,s=o[0][1].length,u=new Array(s).fill(0);return E(e,r,o,u),O(e,r,o,u),A(e,r,o,u),I(e,r,o,u),R(e,r,o,u),w(e,r,o,u),j(e,r,o,a),new h(t,r,o,i,p.Line,n)}function g(t,e,n){const{attributeData:{position:o},removeDuplicateStartEnd:r}=t,i=D(o)&&r,a=o.length/3-(i?1:0),s=new Array(2*(a-1)),u=i?o.slice(0,o.length-3):o;let l=0;for(let c=0;c<a-1;c++)s[l++]=c,s[l++]=c+1;e.push([T.POSITION,new c(u,3,i)]),n.push([T.POSITION,s])}function E(n,o,r,i){if(t(n.attributeData.colorFeature))return;const s=n.attributeData.color;o.push([T.COLOR,new c(e(s,a),4)]),r.push([T.COLOR,i])}function A(e,n,o,r){if(!t(e.attributeData.normal))return;const i=e.attributeData.normal;n.push([T.NORMAL,new c(i,3)]),o.push([T.NORMAL,r])}function I(t,e,o,r){const i=t.attributeData.colorFeature;n(i)||(e.push([T.COLORFEATUREATTRIBUTE,new c([i],1,!0)]),o.push([T.COLOR,r]))}function O(n,o,r,i){if(t(n.attributeData.sizeFeature))return;const a=n.attributeData.size;o.push([T.SIZE,new c([e(a,1)],1,!0)]),r.push([T.SIZE,i])}function R(t,e,o,r){const i=t.attributeData.sizeFeature;n(i)||(e.push([T.SIZEFEATUREATTRIBUTE,new c([i],1,!0)]),o.push([T.SIZEFEATUREATTRIBUTE,r]))}function w(t,e,o,r){const i=t.attributeData.opacityFeature;n(i)||(e.push([T.OPACITYFEATUREATTRIBUTE,new c([i],1,!0)]),o.push([T.OPACITYFEATUREATTRIBUTE,r]))}function j(t,e,i,a){if(n(t.overlayInfo)||t.overlayInfo.renderCoordsHelper.viewingMode!==l.Global||!t.overlayInfo.spatialReference.isGeographic)return;const p=f(a.length),h=s(t.overlayInfo.spatialReference);for(let n=0;n<p.length;n+=3)u(a,n,p,n,h);const b=a.length/3,g=m(b+1);let E=y,A=S,I=0,O=0;r(E,p[O++],p[O++],p[O++]),g[0]=0;for(let n=1;n<b+1;++n)n===b&&(O=0),r(A,p[O++],p[O++],p[O++]),I+=o(E,A),g[n]=I,[E,A]=[A,E];e.push([T.DISTANCETOSTART,new c(g,1,!0)]),i.push([T.DISTANCETOSTART,i[0][1]])}function D(t){const e=t.length;return t[0]===t[e-3]&&t[1]===t[e-2]&&t[2]===t[e-1]}const y=i(),S=i();function v(t,e){if(n(t)||0===t.length)return[];const o=[];return t.forEach((t=>{const n=t.length,r=f(3*n);t.forEach(((t,e)=>{r[3*e+0]=t[0],r[3*e+1]=t[1],r[3*e+2]=t[2]}));const i={attributeData:{position:r,normal:e},removeDuplicateStartEnd:!1};o.push(i)})),o}export{b as createGeometry,v as lineStripsToParameters};