@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.08 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import e from"../../../../../core/Error.js";import{isLoadedSharedTemplate as t,isSharedPresetTemplate as o,isSharedFeatureTemplate as r}from"../../../../templateUtils.js";import{createFeatureServiceEdit as s}from"../../support/createFeatureServiceEdit.js";import{createPresetServiceEdit as n}from"../../support/createPresetServiceEdit.js";import a from"../../../../../geometry/Polygon.js";import{isPoint as i,isPolygon as u}from"../../../../../geometry/support/jsonTypeUtils.js";import{getPaths as l,getEndpoint as c,isCurvedGeometry as p,cloneCurve as f}from"../../../../../geometry/support/curves/curveUtils.js";function m({edits:a,mode:u,relationships:l,shape:c,templatePart:p,associationFeaturesByTemplate:f},m=""){if(null===p)return;const{template:h}=p;if(!t(h))throw new e("shared-template:template-not-loaded","A template part's template must be loaded before use");if(o(h)){if(!i(c))throw new e("shared-template:invalid-geometry","Preset templates must have a point geometry");n({geometry:c,template:h,edits:a,relationships:l,rotation:0,mode:u,tag:m,associationFeaturesByTemplate:f})}else r(h)&&s({geometry:c,template:h,edits:a,relationships:l,tag:m})}function h(e,t){if(!e||!u(e))return null;if(!t.hasZ&&!t.hasM)return e;let o=null,r=null;const s=t.hasZ&&t.hasM?3:2;switch(t.type){case"point":o=t.hasZ?t.z:null,r=t.hasM?t.m:null;break;case"polygon":case"polyline":{const e=l(t);for(const n of e)for(const e of n){const n=c(e);t.hasZ&&(null===o||n[2]>o)&&(o=n[2]),t.hasM&&(null===r||n[s]>r)&&(r=n[s])}}break;case"multipoint":for(const e of t.points)t.hasZ&&(null===o||e[2]>o)&&(o=e[2]),t.hasM&&(null===r||e[s]>r)&&(r=e[s]);break;default:return e}return p(e)?new a({curveRings:R(e.curveRings,t.hasZ,t.hasM,o,r),spatialReference:e.spatialReference,hasZ:t.hasZ,hasM:t.hasM}):new a({rings:j(e.rings,t.hasZ,t.hasM,o,r),spatialReference:e.spatialReference,hasZ:t.hasZ,hasM:t.hasM})}function d(e){let t=!1;return void 0!==e.byNumber&&(t=!0===e.byNumber),t}function y(e){let t=0;return void 0!==e.count&&(t=e.count),t}function g(e,t){let o=0;return t?void 0!==e.proportional&&(o=e.proportional):void 0!==e.distanceValue&&(o=e.distanceValue),t&&(o/=100),o}function v(e){return!0===e.isProportional}function M(e){return!1!==e.createUnique}function Z(e){let t=0;return void 0!==e.offsetDistance&&(t=e.offsetDistance),void 0!==e.side&&1===e.side&&(t*=-1),t}function b(e){return 0!==e.vertexBeforeOffset}function j(e,t,o,r,s){const n=[];for(const a of e)n.push(w(a,t,o,r,s));return n}function w(e,t,o,r,s){const n=[];for(const a of e){const e=[a[0],a[1]];t&&(e[2]=r),o&&(e[t?3:2]=s),n.push(e)}return n}function R(e,t,o,r,s){const n=[];for(const a of e)n.push(P(a,t,o,r,s));return n}function P(e,t,o,r,s){const n=[];for(const a of e){const e=f(a),i=c(e);t&&(i[2]=r),o&&(i[t?3:2]=s),n.push(e)}return n}export{h as correctZandMFollowingBuffer,m as makeFeatureFromGroupPart,d as readByNumber,y as readCount,g as readDistance,v as readIsProportional,M as readIsUnique,Z as readOffsetDistance,b as readVertexBeforeOffset};