@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 5.76 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import"../../core/has.js";import{baseObjectMemory as e,estimateNumberArrayMemory as t,estimateNestedObjectMemory as s,estimateAttributesMemory as n}from"../../core/memoryEstimations.js";import{generateUID as r}from"../../core/uid.js";import i from"../../geometry/SpatialReference.js";import{empty as o,expandWithNestedArray as a}from"../../geometry/support/aaBoundingBox.js";import{empty as l,expandWithNestedArray as u}from"../../geometry/support/aaBoundingRect.js";import{unquantizePolyline as c,unquantizePolygon as p,unquantizeMultipoint as m,unquantizePoint as h}from"../../geometry/support/quantizationUtils.js";import{featureGeometryTypeKebabDictionary as f}from"../../geometry/support/typeUtils.js";import y from"../support/Field.js";import{getApproximateMaxDensificationSegments as g}from"../../views/2d/layers/graphics/densificationConstants.js";export{equals}from"./dehydratedFeatureComparison.js";class d{constructor(e,t,s){this.uid=e,this.geometry=t,this.attributes=s,this.visible=!0,this.objectId=null,this.centroid=null}}function b(e){return null!=e.geometry}class x{constructor(){this.exceededTransferLimit=!1,this.features=[],this.fields=[],this.hasM=!1,this.hasZ=!1,this.geometryType=null,this.objectIdFieldName=null,this.globalIdFieldName=null,this.geometryProperties=null,this.geohashFieldName=null,this.spatialReference=null,this.transform=null}}function j(e,t){const s=f.fromJSON(e.geometryType),n=i.fromJSON(e.spatialReference),r=e.transform,o=e.objectIdFieldName,a=t?.maxStringAttributeLength,l=t?.maxStringAttributeFields;let u;const g=e.features.map((t=>{const i=N(t,s,n,e.objectIdFieldName),f=i.geometry;if(w(i.attributes,l,a,(e=>{u??=[];const t=R(i,o);null!=t&&u.push({objectId:t,attribute:e})})),null!=f&&r)switch(f.type){case"point":i.geometry=h(r,f,f);break;case"multipoint":i.geometry=m(r,f,f);break;case"polygon":i.geometry=p(r,f,f);break;case"polyline":i.geometry=c(r,f,f);break;case"extent":case"mesh":i.geometry=f}return i}));return{geometryType:s,features:g,spatialReference:n,fields:e.fields?.map((e=>y.fromJSON(e)))??[],objectIdFieldName:e.objectIdFieldName,globalIdFieldName:e.globalIdFieldName,geohashFieldName:e.geohashFieldName,geometryProperties:e.geometryProperties,hasZ:e.hasZ,hasM:e.hasM,exceededTransferLimit:e.exceededTransferLimit,transform:null,missingAttributes:u}}function N(e,t,s,n){return{uid:r(),objectId:n&&e.attributes?e.attributes[n]:null,attributes:e.attributes,geometry:Z(e.geometry,t,s),visible:!0}}function Z(e,t,s){if(null==e)return null;switch(t){case"point":{const t=e;return{x:t.x,y:t.y,z:t.z,m:t.m,hasZ:null!=t.z,hasM:null!=t.m,type:"point",spatialReference:s}}case"polyline":{const t=e;return{paths:t.paths,hasZ:!!t.hasZ,hasM:!!t.hasM,type:"polyline",spatialReference:s}}case"polygon":{const t=e;return{rings:t.rings,hasZ:!!t.hasZ,hasM:!!t.hasM,type:"polygon",spatialReference:s}}case"multipoint":{const t=e;return{points:t.points,hasZ:!!t.hasZ,hasM:!!t.hasM,type:"multipoint",spatialReference:s}}}}function F(n){if(null==n)return 0;switch(n.type){case"point":return e+10+8+24;case"polyline":case"polygon":{let t=0;const r=2+(n.hasZ?1:0)+(n.hasM?1:0),i="polyline"===n.type?n.paths:n.rings,o="polyline"===n.type?n.curvePaths:n.curveRings;if(o?.length){const e=3*g()*128;t=8*e*r+128*e+32*(i.length+1)}else t=s(i);return e+64+t+34}case"multipoint":{const t=s(n.points);return e+t+64+34+32}case"extent":return e+10+64+34;case"mesh":{const s=n.vertexAttributes;return e+t(s.position,s.normal,s.uv,s.tangent)}default:return e}}function I(e){let t=32;return t+=n(e.attributes),t+=3,t+=8+F(e.geometry),t}function k(e){if(null==e)return 0;switch(e.type){case"point":return 1;case"polyline":{let t=0;for(const s of e.paths)t+=s.length;return t}case"polygon":{let t=0;for(const s of e.rings)t+=s.length;return t}case"multipoint":return e.points.length;case"extent":return 2;case"mesh":{const t=e.vertexAttributes&&e.vertexAttributes.position;return t?t.length/3:0}default:return}}function M(e){if(null==e)return!1;switch(e.type){case"extent":case"point":return!0;case"polyline":for(const t of e.paths)if(t.length>0)return!0;return!1;case"polygon":for(const t of e.rings)if(t.length>0)return!0;return!1;case"multipoint":return e.points.length>0;case"mesh":return!e.loaded||e.vertexAttributes.position.length>0}}function v(e,t){switch(o(t),"mesh"===e.type&&(e=e.extent),e.type){case"point":t[0]=t[3]=e.x,t[1]=t[4]=e.y,e.hasZ&&(t[2]=t[5]=e.z);break;case"polyline":for(let s=0;s<e.paths.length;s++)a(t,e.paths[s],!!e.hasZ);break;case"polygon":for(let s=0;s<e.rings.length;s++)a(t,e.rings[s],!!e.hasZ);break;case"multipoint":a(t,e.points,!!e.hasZ);break;case"extent":t[0]=e.xmin,t[1]=e.ymin,t[3]=e.xmax,t[4]=e.ymax,null!=e.zmin&&(t[2]=e.zmin),null!=e.zmax&&(t[5]=e.zmax)}return t}function z(e,t){switch(l(t),"mesh"===e.type&&(e=e.extent),e.type){case"point":t[0]=t[2]=e.x,t[1]=t[3]=e.y;break;case"polyline":for(let s=0;s<e.paths.length;s++)u(t,e.paths[s]);break;case"polygon":for(let s=0;s<e.rings.length;s++)u(t,e.rings[s]);break;case"multipoint":u(t,e.points);break;case"extent":t[0]=e.xmin,t[1]=e.ymin,t[2]=e.xmax,t[3]=e.ymax}}function R(e,t){return null!=e.objectId?e.objectId:e.attributes&&t?e.attributes[t]:null}function w(e,t,s,n){if(t?.size&&null!=s&&e)for(const r in e){if(!t.has(r))continue;const i=e[r];"string"==typeof i&&i.length>s&&(n(r),e[r]="")}}export{d as DehydratedFeatureClass,x as DehydratedFeatureSetClass,v as computeAABB,z as computeAABR,F as estimateGeometryMemory,I as estimateSize,j as fromFeatureSetJSON,Z as fromJSONGeometry,R as getObjectId,b as hasGeometry,M as hasVertices,k as numVertices,w as removeLargeStringAttributes};