@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.21 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{getHeightUnitCorrectionFactor as t,makeFeatureFromGroupPart as n}from"./builderUtils.js";import{getSegmentLength3d as e,getSegmentLength as s,pointAlongLineWithZAndOffset as i,pointAlongLineAndOffset as o,pointFromPolylineVertex as a,offsetPointFromSegment as h,computedTotalLength as r}from"./shapeUtils.js";import{maxDigitizingDisplayEdits as p}from"../../support/executorUtils.js";import{e as l}from"../../../../../chunks/offsetOperator.js";import{isPolyline as g}from"../../../../../geometry/support/jsonUtils.js";var f,c;function m({templatePart:r,edits:l,relationships:c,shape:m,distance:d,isProportional:B,offsetDistance:A,vertexBeforeOffset:P,vertexPlacement:j,mode:x}){const N=P||0===A?m:u(m,A);if(null===N||!g(N))return;const v=t(N);A=P?A:0;let E=0,V=null,Z=0;for(let t=0;t<N.paths.length;t++){if(l.length>p&&"digitizing"===x)return;const g=N.paths[t].length,m=t===N.paths.length-1;for(let u=0;u<g;u++){if(l.length>p&&"digitizing"===x)return;if(u>0&&0!==d&&(E+=N.hasZ?e(N.paths[t][u-1],N.paths[t][u],v):s(N.paths[t][u-1],N.paths[t][u])),(0!==u||j!==f.NotBeginning)&&!(u===g-1&&j===f.NotEnd&&m||(0===u||u===g-1&&m)&&j===f.Interior||0===u&&d<0&&B||u===g-1&&d>0&&B)){if(0!==d){let n=1;if(B){const i=d<0?u-1:u+1;if(i>=g||i<0)continue;n=N.hasZ?e(N.paths[t][u],N.paths[t][i],v):s(N.paths[t][u],N.paths[t][i])}const a=E+n*d;V=N.hasZ?i(N,a,A,v):o(N,a,0)}else V=a(N,t,u),0!==A&&(V=h(V,u===g-1?[N.paths[t][u-1],N.paths[t][u]]:[N.paths[t][u],N.paths[t][u+1]],A));V&&n({templatePart:r,shape:V,edits:l,relationships:c,mode:x},`V${(Z+u).toString()}`)}}Z+=g}}function u(t,n){return l(t,n,{unit:"meters",joins:"miter",miterLimit:2})}function d(t){let n=0;for(const e of t.paths)n+=e.length;return n}function B({templatePart:p,edits:l,relationships:f,shape:m,distance:B,isProportional:A,offsetDistance:P,vertexBeforeOffset:j,vertexPlacement:x,mode:N}){const v=j||0===P?m:u(m,P);if(null===v||!g(v))return;const E=t(v);P=j?P:0;let V=null,Z="";if(0!==B){const t=x===c.AtBeginning?0:v.paths.length-1,n=x===c.AtBeginning?0:v.paths[v.paths.length-1].length-1,a=x===c.AtBeginning?0:r(v),h=x===c.AtBeginning?v.paths[0].length:v.paths[v.paths.length-1].length;let p=1;if(A){const i=B<0?n-1:n+1;if(i>=h||i<0)return;p=v.hasZ?e(v.paths[t][n],v.paths[t][i],E):s(v.paths[t][n],v.paths[t][i])}const l=a+p*B;V=v.hasZ?i(v,l,P,E):o(v,l,P),Z=x===c.AtBeginning?"V0":`V${(d(v)-1).toString()}`}else{if(V=x===c.AtBeginning?a(v,0,0):a(v,v.paths.length-1,v.paths[v.paths.length-1].length-1),0!==P)if(x===c.AtBeginning)V=h(V,[v.paths[0][0],v.paths[0][1]],P);else{const t=v.paths[v.paths.length-1];V=h(V,[t[t.length-2],t[t.length-1]],P)}Z=x===c.AtBeginning?"V0":`V${(d(v)-1).toString()}`}V&&n({templatePart:p,shape:V,edits:l,relationships:f,mode:N},Z)}!function(t){t[t.All=0]="All",t[t.NotBeginning=1]="NotBeginning",t[t.NotEnd=2]="NotEnd",t[t.Interior=3]="Interior"}(f||(f={})),function(t){t[t.AtBeginning=4]="AtBeginning",t[t.AtEnd=5]="AtEnd"}(c||(c={}));export{c as VertexEndPlacement,f as VertexPlacement,m as lineVerticesOffset,u as offset,B as vertexOffsetFromStartOrEndOfLine};