UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.23 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{projectBuffer as o}from"../../../../geometry/projection/projectBuffer.js";import{newDoubleArray as t,doubleSubArray as n}from"../../../../geometry/support/DoubleArray.js";import{ringsToTriangulationInfo as s,CounterClockwiseMode as i}from"../../../../geometry/support/triangulationUtils.js";import{applyPerVertexElevationAlignment as e}from"../../layers/graphics/elevationAlignmentUtils.js";import{drapedZ as r}from"../../terrain/OverlayRenderer.js";function p(o,n,r,p){const c=s(o.rings,!!o.hasZ&&"on-the-ground"!==p.mode,i.CCW_IS_HOLE,o.spatialReference),a=t(c.position.length),h=e(c.position,o.spatialReference,0,a,0,c.position,0,c.position.length/3,n,r,p),m=null!=h;return new g(c.position,a,u(c.polygons,c.position,a),l(c.outlines,c.position,a),m,h)}function c(t,n){const e=s(t.rings,!1,i.CCW_IS_HOLE),p=o(e.position,t.spatialReference,0,e.position,n,0);for(let o=2;o<e.position.length;o+=3)e.position[o]=r;return{position:e.position,polygons:u(e.polygons,e.position),outlines:l(e.outlines,e.position),projectionSuccess:p}}function l(o,t,s=null){return o.filter((({count:o})=>o>1)).map((({index:o,count:i})=>{const e=3*o,r=3*i;return null!=s?new h(o,i,n(t,e,r),n(s,e,r)):new a(o,i,n(t,e,r))}))}function u(o,t,s=null){const i=new Array;for(const{index:e,count:r,holeIndices:p,pathLengths:c}of o){if(r<=1)continue;const o=3*e,l=3*r,u=p.map((o=>o-e)),a=null!=s?new m(e,r,n(t,3*e,3*r),n(s,o,l),u,c):new f(e,r,n(t,3*e,3*r),u,c);i.push(a)}return i}class a{constructor(o,t,n){this.index=o,this.count=t,this.position=n}}class h extends a{constructor(o,t,n,s){super(o,t,n),this.mapPositions=s}}class m extends h{constructor(o,t,n,s,i,e){super(o,t,n,s),this.holeIndices=i,this.pathLengths=e}}class f extends a{constructor(o,t,n,s,i){super(o,t,n),this.holeIndices=s,this.pathLengths=i}}class g{constructor(o,t,n,s,i,e){this.position=o,this.mapPositions=t,this.polygons=n,this.outlines=s,this.projectionSuccess=i,this.sampledElevation=e}}export{g as PolygonRenderInfo,m as PolygonVertexData,f as PolygonVertexDataDraped,p as geometryToRenderInfo,c as geometryToRenderInfoDraped};