@arcgis/core 5.1.0-next.59 → 5.1.0-next.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/Components/arcadeFeatureUtils.js +1 -1
- package/applications/Components/featureUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{9321f5ec514805307219.js → 05c8d2c0362af4511d86.js} +1 -1
- package/assets/esri/core/workers/chunks/{ad1946c084219bb678a0.js → 06868e4f52de9d918255.js} +1 -1
- package/assets/esri/core/workers/chunks/{8df0c154bb0d79a905c0.js → 06c0b93e276cfc1fb7ac.js} +1 -1
- package/assets/esri/core/workers/chunks/{05d25a98c54679233902.js → 0888baa99c9007ad63bc.js} +1 -1
- package/assets/esri/core/workers/chunks/{1613123918e9b0f7cfdb.js → 0f597c690e5c60fe944b.js} +1 -1
- package/assets/esri/core/workers/chunks/{e2e3c39876bbe019c57a.js → 0f8736242544f9e9a57a.js} +1 -1
- package/assets/esri/core/workers/chunks/{c9c5e6996f36ec4b1558.js → 11a8541f3909f9ffb000.js} +1 -1
- package/assets/esri/core/workers/chunks/{3de17e89973160b42923.js → 16806f5044a9da553b66.js} +1 -1
- package/assets/esri/core/workers/chunks/{3e0752a81a7247c567ab.js → 185f59f90070d5d6ac94.js} +1 -1
- package/assets/esri/core/workers/chunks/1984c0f037065acd21d3.js +1 -0
- package/assets/esri/core/workers/chunks/1af247c86d1c4ae8fef3.js +1 -0
- package/assets/esri/core/workers/chunks/{1f91280032aa42b1585b.js → 2a7e7a497823e9f05aa3.js} +1 -1
- package/assets/esri/core/workers/chunks/2d92ba11781a3cfc3a78.js +1 -0
- package/assets/esri/core/workers/chunks/{9d580b5bcd59857a5702.js → 2f74147597805828cb38.js} +23 -7
- package/assets/esri/core/workers/chunks/{d9444dd0d40aa8332b28.js → 31e0bfc2cab055aebf9a.js} +1 -1
- package/assets/esri/core/workers/chunks/{93d1118f7a909d123b40.js → 32360a55d1836b2a737e.js} +1 -1
- package/assets/esri/core/workers/chunks/{a9eb90b901e64e67b7a3.js → 368b4c0a5eecbb06feac.js} +1 -1
- package/assets/esri/core/workers/chunks/{7b6e3cc086d13da770fa.js → 37729578a7c4cf15eded.js} +1 -1
- package/assets/esri/core/workers/chunks/{4b3622fc355fd2fd8678.js → 3af1e2f0b3d30c58d0c2.js} +1 -1
- package/assets/esri/core/workers/chunks/{83113a9e284701d053b5.js → 3c155efd5768003a91eb.js} +1 -1
- package/assets/esri/core/workers/chunks/{7ed2aa1092c0a2c839c0.js → 3f0d9fdd8c37605dd85d.js} +1 -1
- package/assets/esri/core/workers/chunks/{86a6dd19903fa5023cc7.js → 58614f12796dbba013f4.js} +1 -1
- package/assets/esri/core/workers/chunks/{26cafd20c8d03c274389.js → 5c1abb46b9937a050c32.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f8e22df08c2f5fbb8c8.js → 6172715b2b2853819d8a.js} +1 -1
- package/assets/esri/core/workers/chunks/{87077f4cbca13e030411.js → 62c2757f5dc4aaca2df8.js} +1 -1
- package/assets/esri/core/workers/chunks/{23f6d24bf850bc3280ec.js → 6355de3ee89916b74dae.js} +1 -1
- package/assets/esri/core/workers/chunks/64ad6130de549083caba.js +1 -0
- package/assets/esri/core/workers/chunks/{9b53aa2429573f1b977f.js → 68475eba323b4aa892a3.js} +1 -1
- package/assets/esri/core/workers/chunks/{a7a553e245ba011d259f.js → 78c7eace6ec3fa5c7413.js} +1 -1
- package/assets/esri/core/workers/chunks/7cee28575fd57430cf02.js +1 -0
- package/assets/esri/core/workers/chunks/{b20f4c82d0b44fdb4670.js → 7e1ef2a55f8d123f31e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{5a9f5a49dc68b42762bb.js → 8083dface1ca2dbd12b2.js} +1 -1
- package/assets/esri/core/workers/chunks/{85c72d9fa533552a6e8a.js → 82e0691995d821137d5f.js} +1 -1
- package/assets/esri/core/workers/chunks/{ec1b2eb05410848081c9.js → 8432ffc33843e898bab7.js} +1 -1
- package/assets/esri/core/workers/chunks/{bacc343a79828e456de7.js → 8435b6bf356959009b76.js} +1 -1
- package/assets/esri/core/workers/chunks/{56bce3a6701f8549606b.js → 8878ab87ef7961fafae8.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ef740d25dc17bef11b2.js → 8a893f23827769d42092.js} +1 -1
- package/assets/esri/core/workers/chunks/{e8a23ae30d586e3a973c.js → 8e68b4628e9616356c34.js} +1 -1
- package/assets/esri/core/workers/chunks/{e7e565e7c0ce1464c6b0.js → 8ea67b502f9355dab7e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{66fc3c4d6c54eee231b9.js → 8edae79554843dd77ada.js} +1 -1
- package/assets/esri/core/workers/chunks/{0e88e61d89f89994c4bf.js → 909ef35fa33be2b6da41.js} +1 -1
- package/assets/esri/core/workers/chunks/{c91d39e8e14be3d8bdf5.js → 90b7acc70adba193b215.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1a0a7cdaf50f98adb3e.js → 97f10efb0fe05bedcebd.js} +1 -1
- package/assets/esri/core/workers/chunks/98f5bf1b91f3696b2fce.js +1 -0
- package/assets/esri/core/workers/chunks/{4fb718174c6e07d752e0.js → 9c52d4b54dfdb69dee29.js} +1 -1
- package/assets/esri/core/workers/chunks/{5143f74f1fe7533a6069.js → 9c72127de7afcbaafbaf.js} +1 -1
- package/assets/esri/core/workers/chunks/{155c741a9839d24f04a2.js → 9def5d17b94e5db71883.js} +1 -1
- package/assets/esri/core/workers/chunks/{a41fabf8b2cf15b7d0c9.js → a10be7eb05a007fff1ed.js} +1 -1
- package/assets/esri/core/workers/chunks/{ab3183f2327ff26e2b45.js → a226ba96d9a3ecc14e3e.js} +1 -1
- package/assets/esri/core/workers/chunks/{2bc6edeb3156d241677b.js → a32c87b89567a9fd1efc.js} +1 -1
- package/assets/esri/core/workers/chunks/{e26894655823849947f4.js → a446dff865332268625a.js} +1 -1
- package/assets/esri/core/workers/chunks/a520f83ae0c3c3e78858.js +1 -0
- package/assets/esri/core/workers/chunks/{bb047157f09471ecea53.js → a6d166058e3025bb280e.js} +1 -1
- package/assets/esri/core/workers/chunks/{691d0a60354b6458b9de.js → a80eb704e75d13732878.js} +1 -1
- package/assets/esri/core/workers/chunks/{75e28458e08b0738b35a.js → ab223c508f3dd562e7d3.js} +2 -2
- package/assets/esri/core/workers/chunks/{3cb0f020f9bfc6653c5d.js → b42487c6a989e11a2559.js} +1 -1
- package/assets/esri/core/workers/chunks/b6d94cbd1c5adad2f247.js +1 -0
- package/assets/esri/core/workers/chunks/{cd391415b8b8320e12e4.js → b75165880704efccc47c.js} +1 -1
- package/assets/esri/core/workers/chunks/{45eddf3918973fa8d751.js → ba72989749543122a6fe.js} +1 -1
- package/assets/esri/core/workers/chunks/{0b4a2361b9f9a6c0b8a7.js → ba9e107edc2027238be3.js} +1 -1
- package/assets/esri/core/workers/chunks/be1d2c3a61e6447fbbc7.js +1 -0
- package/assets/esri/core/workers/chunks/{e9dd60d0220036545ebb.js → bf4bad2c9a541cd425f5.js} +1 -1
- package/assets/esri/core/workers/chunks/{78cb6b9ab32abdd1d530.js → c08e9914deb1dc62bc0f.js} +1 -1
- package/assets/esri/core/workers/chunks/{52dbfd7519555028a8af.js → c0bb53d8d58ad18334d3.js} +1 -1
- package/assets/esri/core/workers/chunks/{c6149e0ac1c103e03baf.js → c0d453f93af2d4a6ce64.js} +1 -1
- package/assets/esri/core/workers/chunks/c72e90a952543d06d84b.js +1 -0
- package/assets/esri/core/workers/chunks/{005fe95c3329cfe74219.js → cf7acf5acb6d322fd996.js} +1 -1
- package/assets/esri/core/workers/chunks/{457bbf27e9bc18132464.js → d23dd7da45a7aa341540.js} +1 -1
- package/assets/esri/core/workers/chunks/{929b26999321519824b9.js → d2801df3fa44dee15ec8.js} +1 -1
- package/assets/esri/core/workers/chunks/{932a0b39d85a76377d52.js → d626e08d23330d84413b.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d11e7972bc298cb94ce.js → db6e03fe8dd316f5005f.js} +1 -1
- package/assets/esri/core/workers/chunks/{a37697ef360e2425768a.js → dca595fdd5e1a571e441.js} +1 -1
- package/assets/esri/core/workers/chunks/{da2a10e72a315c3c1f82.js → e2779965db231fb666a5.js} +1 -1
- package/assets/esri/core/workers/chunks/{f7af90c5f9d371eb7009.js → e4144ccc85ad4c76a9b7.js} +1 -1
- package/assets/esri/core/workers/chunks/{9066f095f16448c0a04e.js → e4e2f059c52674dcae5b.js} +1 -1
- package/assets/esri/core/workers/chunks/edc2e87968c958bc852b.js +1 -0
- package/assets/esri/core/workers/chunks/{a256edc8337e462f80f0.js → efdd75896ca53eb6242f.js} +1 -1
- package/assets/esri/core/workers/chunks/{c250799c131aa4ed2c35.js → f1c348cf2a1e35da9b20.js} +1 -1
- package/assets/esri/core/workers/chunks/{861a7d0e665add901e11.js → f4d577ff61da7964e08a.js} +1 -1
- package/assets/esri/core/workers/chunks/{5aff2d6ae0d2a2d92ecc.js → f7da652f8dab57677cc3.js} +1 -1
- package/chunks/GlobalIllumination.glsl.js +24 -8
- package/chunks/OITBlend.glsl.js +4 -3
- package/config.js +1 -1
- package/interfaces.d.ts +7 -0
- package/kernel.js +1 -1
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/mixins/RasterJobHandlerMixin.js +1 -1
- package/layers/raster/functions/vectorFieldUtils.js +1 -1
- package/layers/support/RasterJobHandler.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/TitleCreator.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/networks/support/NamedTraceConfiguration.d.ts +2 -1
- package/networks/support/NamedTraceConfiguration.js +1 -1
- package/networks/support/TraceConfiguration.d.ts +4 -2
- package/networks/support/TraceConfiguration.js +1 -1
- package/package.json +2 -2
- package/popup/Feature.d.ts +250 -0
- package/popup/Feature.js +2 -0
- package/popup/support/arcadeFeatureUtils.js +2 -0
- package/popup/support/featureUtils.js +2 -0
- package/popup/support/relatedFeatureUtils.js +2 -0
- package/popup/types.d.ts +17 -3
- package/support/revision.js +1 -1
- package/tables/AttributeTableTemplate.d.ts +2 -2
- package/tables/elements/AttributeTableGroupElement.d.ts +3 -16
- package/tables/support/tablesUtils.d.ts +6 -5
- package/tables/types.d.ts +18 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/fill/AFillMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
- package/views/2d/layers/imagery/ImageryVFStrategy.js +1 -1
- package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
- package/views/3d/support/GaussianSplatSortWorker.js +1 -1
- package/views/3d/support/GaussianSplatWorkerHandle.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
- package/views/3d/webgl-engine/shaders/GlobalIllumination.glsl.js +1 -1
- package/widgets/Attachments/AttachmentsViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/support/EditorEditingCapabilities.js +1 -1
- package/widgets/Feature/FeatureContent/FeatureContentViewModel.js +1 -1
- package/widgets/Feature/FeatureContent.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/Feature/FeatureFields/FeatureFieldsViewModel.js +1 -1
- package/widgets/Feature/FeatureMedia/FeatureMediaViewModel.js +1 -1
- package/widgets/Feature/FeatureMedia.js +1 -1
- package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/RelationshipInput.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Popup/actionUtils.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0f2ab57e4eb722b3b0c0.js +0 -1
- package/assets/esri/core/workers/chunks/522bc1d79dbe957301e4.js +0 -1
- package/assets/esri/core/workers/chunks/60ad54e5707d4414d8b9.js +0 -1
- package/assets/esri/core/workers/chunks/76064c2c801da55cd844.js +0 -1
- package/assets/esri/core/workers/chunks/ad4f0a4e2dde44cd43d4.js +0 -1
- package/assets/esri/core/workers/chunks/b3e5dcb530cef678c8f8.js +0 -1
- package/assets/esri/core/workers/chunks/d01a98c13501c89205b6.js +0 -1
- package/assets/esri/core/workers/chunks/d3b3e8c6d7096bc59489.js +0 -1
- package/assets/esri/core/workers/chunks/d53c6fc10425adc2c0cf.js +0 -1
- package/assets/esri/core/workers/chunks/e543bb228f3f9d937d43.js +0 -1
- package/assets/esri/core/workers/chunks/f8ee1a99580a7da42cde.js +0 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +0 -2
- package/widgets/Feature/support/featureUtils.js +0 -2
- package/widgets/Feature/support/relatedFeatureUtils.js +0 -2
- /package/assets/esri/core/workers/chunks/{75e28458e08b0738b35a.js.LICENSE.txt → ab223c508f3dd562e7d3.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{insertSortedStableTopN as e}from"../../../core/arrayUtils.js";import{clone as t}from"../../../core/lang.js";import{polygonCentroid as s,extentCentroid as i}from"../../../geometry/support/centroid.js";import{getPolygonExtent as a,getGeometryExtent as n}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as r}from"../../../geometry/support/quantizationUtils.js";import{isValid as o,equals as l}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as u}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as c,isCoordinate as m,cloneCurve as d}from"../../../geometry/support/curves/curveUtils.js";import p from"./AttributesBuilder.js";import{cleanFromGeometryEngine as f,getGeometry as h,transformCentroid as y}from"./geometryUtils.js";import{project as g}from"./projectionSupport.js";import{getDateInNumber as x}from"./queryUtils.js";import{SnappingCandidateEdge as F,SnappingCandidateVertex as T}from"./SnappingCandidate.js";import{isDateField as I,isDateOnlyField as _,isTimestampOffsetField as v,isStringField as V,isTimeOnlyField as S}from"../../support/fieldUtils.js";import b from"../../../rest/support/AutoIntervalBinParameters.js";import R from"../../../rest/support/DateBinParameters.js";import{unitsDict as z}from"../../../rest/support/DateBinUtils.js";import B from"../../../rest/support/FixedBoundariesBinParameters.js";import M from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as A,calculateStatistics as w,processSummaryStatisticsResult as N,calculateUniqueValuesCount as D,createUVResult as P,calculateClassBreaks as q,resolveCBResult as O,calculateHistogram as j,calculatePercentile as C,binIndex as Z,getBinParams as G,isNullCountSupported as E,getAttributeComparator as H}from"../../../statistics/utils.js";import{utc as U}from"../../../time/constants.js";import{DateTime as k}from"luxon";const J="bin";class Q{constructor(e,t,s){this.items=e,this.query=t,this.geometryType=s.geometryType,this.hasM=s.hasM,this.hasZ=s.hasZ,this.fieldsIndex=s.fieldsIndex,this.objectIdField=s.objectIdField,this.spatialReference=s.spatialReference,this.featureAdapter=s.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new p(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:s,outStatistics:i}=this.query,a=t?.length;if(!!!a)return 1;const n=new Map,r=new Map,o=new Set;for(const l of i){const{statisticType:i}=l,a="exceedslimit"!==i?l.onStatisticField:void 0;if(!r.has(a)){const s=[];for(const i of t){const t=this._getAttributeValues(e,i,this.items,n);s.push(t)}r.set(a,this._calculateUniqueValues(s,this.items,e.returnDistinctValues))}const u=r.get(a);for(const t in u){const{data:i,items:a}=u[t],n=i.join(",");s&&!e.validateItems(a,s)||o.add(n)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;o(this.query.outSR)&&!l(t.spatialReference,this.query.outSR)?e.queryGeometry=f({spatialReference:this.query.outSR,...g(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=f({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,s){const i=this.featureAdapter,a=X(this.hasZ,this.hasM),{point:n}=e,r="number"==typeof e.distance?e.distance:e.distance.x,o="number"==typeof e.distance?e.distance:e.distance.y;function l(e,t){const s=(e-n.x)/r,i=(t-n.y)/o;return s*s+i*i}const p={candidates:[]},f="esriGeometryPolygon"===this.geometryType,h="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,y=this._getPointCreator(t,this.spatialReference,s),g=new L(null,0),x=new L(null,0),I={x:0,y:0,z:0};for(const u of this.items){const e=i.getObjectId(u),t=i.getGeometryWithCurves?.(u);if(null!=t){v(t,e);continue}const s=i.getGeometry(u);null==s||_(s,e)}return p.candidates.sort((e,t)=>e.distance-t.distance),p;function _(t,s){const{coords:i}=t,r=t.isPoint?W:t.lengths;if(g.coords=i,x.coords=i,e.returnEdge){let e=0;for(let t=0;t<r.length;t++){const i=r[t],o=e;for(let t=0;t<i;t++,e+=a){if(!f&&t===i-1)continue;if(g.coordsIndex=e,x.coordsIndex=t===i-1?o:e+a,!Y(I,n,g,x))continue;const r=l(I.x,I.y);r<=1&&p.candidates.push(new F(s,y(I),Math.sqrt(r),y(g),y(x)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<r.length;t++){const i=r[t],n=e,o=x;o.coordsIndex=n;for(let t=0;t<i;t++,e+=a){if(g.coordsIndex=e,f&&t===i-1&&g.x===o.x&&g.y===o.y)continue;const a=l(g.x,g.y);a<=1&&p.candidates.push(new T(s,y(g),Math.sqrt(a)))}}}else if(h&&"ends"===e.vertexMode){let e=0;const t=[];for(let s=0;s<r.length;s++){t.push(e);const i=r[s];e+=i*a,i>1&&t.push(e-a)}for(const i of t){g.coordsIndex=i;const e=l(g.x,g.y);e<=1&&p.candidates.push(new T(s,y(g),Math.sqrt(e)))}}}function v(t,s){const{candidates:i}=p,a={x:0,y:0,z:0};if(e.returnEdge){const e=[n.x,n.y],r=new L(e,0),o=new L(e,0);for(const{segments:n}of t.parts)for(const{start:t,curve:p}of n){const{curvePoint:n}=u(t,p,e),f=l(...n);if(f>1)continue;[a.x,a.y]=n,r.coords=t,o.coords=c(p);const h=m(p)?null:d(p);i.push(new F(s,y(a),Math.sqrt(f),y(r),y(o),!1,h))}}function r(e){a.x=t.vertexXY[2*e],a.y=t.vertexXY[2*e+1];const n=l(a.x,a.y);n>1||(a.z=t.vertexZ?.[e]??0,i.push(new T(s,y(a),Math.sqrt(n))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)r(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":r(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const s=t.partOffsets[e],i=t.partOffsets[e+1]-1;r(s),i!==s&&r(i)}}}}_getPointCreator(e,t,s){const i=null==s||l(t,s)?e=>e:e=>g(e,t,s),{hasZ:a}=this,n=0;return a&&e?({x:e,y:t,z:s})=>i({x:e,y:t,z:s}):({x:e,y:t})=>i({x:e,y:t,z:n})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,minValue:r,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=I(m)||_(m)||v(m),p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:l,timeZone:u},this.items),f=E({normalizationType:a,normalizationField:i,minValue:r,maxValue:o}),h={value:.5,fieldType:m?.type},y=V(m)?A({values:p,supportsNullCount:f,percentileParams:h,outStatisticTypes:c}):w({values:p,minValue:r,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:h,outStatisticTypes:c});return N(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:s,domains:i,returnAllCodedValues:a,scale:n,timeZone:r}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:s,scale:n,timeZone:r},this.items,!1),l=D(o);return P(l,i,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items),f=q(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return O(f,r)}async createHistogramResponse(e){const{field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:s,normalizationField:i,normalizationType:a,normalizationTotal:n,scale:m,timeZone:d},this.items);return j(p,{field:t,normalizationField:i,normalizationType:a,normalizationTotal:n,classificationMethod:r,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,s){if(e.length>1&&t?.length)for(const i of t.slice().reverse()){const{compare:t,fieldOrExpression:a,fieldInfo:n}=K(i,this.fieldsIndex);e.sort((e,i)=>t(s(e,a,n),s(i,a,n)))}}_topNFeatures(t,s,i,a){if(t.length>1&&s?.length){const n=s.map(e=>{const{compare:t,fieldOrExpression:s,fieldInfo:i}=K(e,this.fieldsIndex);return(e,n)=>t(a(e,s,i),a(n,s,i))}).reduceRight((e,t)=>(s,i)=>{const a=t(s,i);return 0===a||Number.isNaN(a)?e(s,i):a}),r=[];for(const s of t)e(r,s,i,n);return r}return t.slice(0,i)}_createFeatureQueryResponse(e){const{items:t,geometryType:s,hasM:i,hasZ:a,objectIdField:n,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:d,returnZ:p,returnM:h}=e,y=null!=m&&t.length>(d||0)+m,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:s,hasM:i&&h,hasZ:a&&p,objectIdFieldName:n,spatialReference:f(u||o),transform:c&&r(c)||null}}_createFeatures(e,t){const s=new p(e,this.featureAdapter,this.fieldsIndex),{hasM:i,hasZ:a}=this,{orderByFields:n,quantizationParameters:o,returnGeometry:l,returnCentroid:u,maxAllowableOffset:c,resultOffset:m,resultRecordCount:d,returnZ:f=!1,returnM:g=!1}=e,x=a&&f,F=i&&g;let T;const I=m||0,_=null!=d?I+d:null;null!=_&&_<=5e3&&_<t.length?T=this._topNFeatures(t,n,_,(e,t,i)=>s.getFieldValue(e,t,i)):(T=[...t],this._sortFeatures(T,n,(e,t,i)=>s.getFieldValue(e,t,i))),(I>0||null!=_)&&(T=T.slice(I,_??void 0));const v=[];let V=0;if(this.geometryType&&(l||u)){const e=r(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const i of T){const a=this.featureAdapter.getGeometry(i),n=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),geometry:h(this.geometryType,a,c,e,x,F)});t&&a&&!n.geometry&&(n.centroid=y(this,this.featureAdapter.getCentroid(i,this),e)),v[V++]=n}else if(!l&&u)for(const i of T)v[V++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:y(this,this.featureAdapter.getCentroid(i,this),e)});else for(const i of T)v[V++]=this._addFeatureJSONMetadata(i,{attributes:s.getAttributes(i),centroid:y(this,this.featureAdapter.getCentroid(i,this),e),geometry:h(this.geometryType,this.featureAdapter.getGeometry(i),c,e,x,F)})}else for(const r of T){const e=s.getAttributes(r);e&&(v[V++]=this._addFeatureJSONMetadata(r,{attributes:e}))}return v}_addFeatureJSONMetadata(e,t){const s=this.featureAdapter.getMetadata?.(e);return void 0!==s&&(t.metadata=s),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,s=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,i=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>s)e=!0;else{const t=X(this.hasZ,this.hasM),s=this.featureAdapter;e=this.items.reduce((e,t)=>{const i=s.getGeometry(t);return e+(null!=i&&i.coords.length||0)},0)/t>i}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,s={attributes:{}}){const i=[],a=new Map,n=new Map,r=new Map,o=new Map,l=new p(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:m,orderByFields:d,resultRecordCount:f}=e,h=c?.length,y=!!h,g=y?c[0]:null,x=y&&!this.fieldsIndex.get(g);for(const p of u??[]){const{outStatisticFieldName:e,statisticType:u}=p,d=p,f="exceedslimit"!==u?p.onStatisticField:void 0,F="percentile_disc"===u||"percentile_cont"===u,T="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,I=y&&1===h&&(f===g||x)&&"count"===u;if(y){if(!r.has(f)){const e=[];for(const s of c){const i=this._getAttributeValues(l,s,t,a);e.push(i)}r.set(f,this._calculateUniqueValues(e,t,!T&&l.returnDistinctValues))}const s=r.get(f);if(!s)continue;const i=Object.keys(s);for(const n of i){const{count:i,data:r,items:u,itemPositions:p}=s[n],h=r.join(",");if(!m||l.validateItems(u,m)){const s=o.get(h)||{attributes:{}};if(T){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(d,u);s.aggregateGeometries[t]=e}else{let n=null;if(I)n=i;else{const e=this._getAttributeValues(l,f,t,a),s=p.map(t=>e[t]);n=F&&"statisticParameters"in d?this._getPercentileValue(d,s):this._getStatisticValue(d,s,null,l.returnDistinctValues)}s.attributes[e]=n}let n=0;c.forEach((e,t)=>s.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++n]=r[t]),o.set(h,s)}}}else if(T){s.aggregateGeometries||(s.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:i}=await this._getAggregateGeometry(d,t);s.aggregateGeometries[i]=e}else{const i=this._getAttributeValues(l,f,t,a);s.attributes[e]=F&&"statisticParameters"in d?this._getPercentileValue(d,i):this._getStatisticValue(d,i,n,l.returnDistinctValues)}const _="min"!==u&&"max"!==u||!V(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;i.push({name:e,alias:e,type:_||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[s];return this._sortFeatures(F,d,(e,t)=>e.attributes[t]),f&&(F.length=Math.min(f,F.length)),{fields:i,features:F}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return I(t)||_(t)||v(t)||S(t)}async _getAggregateGeometry(e,t){const{convexHull:r,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:d}=this,p=t.map(e=>h(d,c.getGeometry(e))),f=r(m,p,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=f?a(f):n(o(m,p));y.aggregateGeometries={...e,spatialReference:m},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=f?s(f):i(n(o(m,p)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=f,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,s,i){const{onStatisticField:a,statisticType:n}=e;let r=null;r=s?.has(a)?s.get(a):V(this.fieldsIndex.get(a))||this._isAnyDateField(a)?A({values:t,returnDistinct:i}):w({values:i?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),s&&s.set(a,r);return r["var"===n?"variance":n]}_getPercentileValue(e,t){const{onStatisticField:s,statisticParameters:i,statisticType:a}=e,{value:n,orderBy:r}=i,o=this.fieldsIndex.get(s);return C(t,{value:n,orderBy:r,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,s,i){if(i.has(t))return i.get(t);const a=this.fieldsIndex.get(t),n=s.map(s=>e.getFieldValue(s,t,a));return i.set(t,n),n}_calculateUniqueValues(e,t,s){const i={},a=t.length;for(let n=0;n<a;n++){const a=t[n],r=[];for(const t of e)r.push(t[n]);const o=r.join(",");null==i[o]?i[o]={count:1,data:r,items:[a],itemPositions:[n]}:(s||i[o].count++,i[o].items.push(a),i[o].itemPositions.push(n))}return i}async _getDataValues(e,s,i=!0){const a=new p(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:n,scale:r,timeZone:o}=e;return n?a.getExpressionValues(s,n,{viewingMode:"map",scale:r,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(s,t(e),i)}_calculateHistogramBins(e,t,s){if(null==t.min&&null==t.max)return[];const i=t.intervals,a=t.min??0,n=t.max??0,r=i.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=s[o];if(null!=t&&t>=a&&t<=n){const e=Z(i,t);e>-1&&(r[e].count++,r[e].items.push(l))}}return r}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:s,outAlias:i,valueType:a}=t,n=[],r=[{name:i??s,alias:i??s,type:a??"esriFieldTypeString"},{name:J,alias:J,type:"esriFieldTypeInteger"}],o=new p(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[s],(e,t,s)=>o.getFieldValue(e,t,s));const c=this._getAttributeValues(o,s,u,l),m=this._calculateUniqueValues([c],u,o.returnDistinctValues);for(const d in m){const{items:t}=m[d],a=await this._createBinsResponse(e,t);if(n.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[i??s]:d}}))),a.fields)for(const e of a.fields)r.some(t=>t.name===e.name)||r.push(e)}return{fields:r,features:n}}async _createBinsResponse(e,t){const s=e.bin;switch(t=t??this.items,s.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(b.fromJSON(s),e,t);case"dateBin":return this._createDateBinsResponse(R.fromJSON(s),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(B.fromJSON(s),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(M.fromJSON(s),e,t)}}async _createAutoIntervalBinsResponse(e,t,s){const{field:i,normalizationField:a,numBins:n,normalizationType:r,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),m=G(c,{field:i,normalizationField:a,normalizationType:r,normalizationTotal:o,numBins:n,minValue:x(r?e.normalizationMinValue:l,!1),maxValue:x(r?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,s);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,s){const{field:i,interval:a,start:n,end:r,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),p=S(this.fieldsIndex.get(i)),f=z.toJSON(m),h=d.filter(Boolean).sort((e,t)=>e-t),y=null!=n?x(n,p):h[0],g=null!=r?x(r,p):h[h.length-1],F=[];if(null!=y&&null!=g){const e={zone:t.outTimeReference?.ianaTimeZone??U},s=u?.unit?z.toJSON(u.unit):"milliseconds",i={[s]:u?.value||0},n=k.fromMillis(y,e).minus(i),r=k.fromMillis(g,e).minus(i),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const s=(e.weekday-t+7)%7;return e.minus({days:s}).startOf("day")};if("last"===o){let e="week"===f?((e,t)=>d(e,t).plus({days:7}))(r,m):r;for(;e>n;){const t=e.minus({[f]:a.value});if(t<n){F.unshift([l?t.plus(i).toMillis():n.plus(i).toMillis(),e.plus(i).toMillis()]);break}F.unshift([t.plus(i).toMillis(),e.plus(i).toMillis()]),e=t}}else{let e="first"===o?n:"week"===f?d(n,m):n.startOf(f);for(;e<=r;){const t=e.plus({[f]:a.value});if(t>r){F.push([e.plus(i).toMillis(),l?t.plus(i).toMillis():r.plus(i).toMillis()]);break}F.push([e.plus(i).toMillis(),t.plus(i).toMillis()]),e=t}}}const T=this._calculateHistogramBins(d,{intervals:F,min:y,max:g},s);return this._createFeaturesFromHistogramBins(T,t)}async _createFixedBoundariesBinsResponse(e,t,s){const{field:i}=e,a=await this._getDataValues({field:i||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},s),n=S(this.fieldsIndex.get(i)),r=e.boundaries.map(e=>x(e,n)).sort((e,t)=>e-t),o=[];for(let c=0;c<r.length-1;c++)o.push([r[c],r[c+1]]);const l={intervals:o,min:r.at(0),max:r.at(-1)},u=this._calculateHistogramBins(a,l,s);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,s){const{field:i,interval:a,normalizationType:n,start:r,end:o}=e,l=await this._getDataValues({field:i||e.expression,normalizationField:e.normalizationField,normalizationType:n,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},s),u=S(this.fieldsIndex.get(i)),c=G(l,{field:i,classificationMethod:"defined-interval",definedInterval:a,minValue:x(n?e.normalizationMinValue:r,u),maxValue:x(n?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,s);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:s,lowerBoundaryAlias:i}=t,a=i||"lowerBoundary",n=s||"upperBoundary",r=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:n,alias:n,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:J,alias:J,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const p of e){const{minValue:e,maxValue:s,items:i}=p,f={attributes:{}};let h;if(f.attributes[a]=m&&d&&null!=e?k.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(f.attributes[n]=m&&d&&null!=s?k.fromMillis(s,{zone:d}).toISO():s),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},i),f.attributes[J]=++c,"flat"===t.bin.jsonStyle?r.push(...h.features.map(({attributes:{EXPR_1:e,...t},...s})=>({...s,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),r.push(f))):(t.bin?.splitBy&&(f.attributes[J]=++c),h=await this._createStatisticsQueryResponse(t,i,f),r.push(f)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&r.reverse(),{fields:o,features:r}}}function Y(e,t,s,i){const a=i.x-s.x,n=i.y-s.y,r=t.x-s.x,o=t.y-s.y,l=a*a+n*n;if(0===l)return!1;const u=r*a+o*n,c=Math.min(1,Math.max(0,u/l));return e.x=s.x+a*c,e.y=s.y+n*c,!0}function X(e,t){return e?t?4:3:t?3:2}class L{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const W=[1];function K(e,t){const s=e.split(" "),i=s[0],a=t.get(i),n=!!s[1]&&"desc"===s[1].toLowerCase();return{compare:H(a?.type,n,"case-insensitive"),fieldOrExpression:i,fieldInfo:a}}export{Q as QueryEngineResult};
|
|
2
|
+
import{insertSortedStableTopN as e}from"../../../core/arrayUtils.js";import{clone as t}from"../../../core/lang.js";import{polygonCentroid as i,extentCentroid as s}from"../../../geometry/support/centroid.js";import{getPolygonExtent as a,getGeometryExtent as r}from"../../../geometry/support/extentUtils.js";import{toQuantizationTransform as n}from"../../../geometry/support/quantizationUtils.js";import{isValid as o,equals as l}from"../../../geometry/support/spatialReferenceUtils.js";import{closestPointOnCurve as u}from"../../../geometry/support/curves/closestPointOnCurve.js";import{getEndpoint as c,isCoordinate as m,cloneCurve as d}from"../../../geometry/support/curves/curveUtils.js";import p from"./AttributesBuilder.js";import{cleanFromGeometryEngine as f,getGeometry as h,transformCentroid as y}from"./geometryUtils.js";import{project as g}from"./projectionSupport.js";import{getDateInNumber as x}from"./queryUtils.js";import{SnappingCandidateEdge as F,SnappingCandidateVertex as T}from"./SnappingCandidate.js";import{isDateField as I,isDateOnlyField as _,isTimestampOffsetField as v,isStringField as V,isTimeOnlyField as S}from"../../support/fieldUtils.js";import b from"../../../rest/support/AutoIntervalBinParameters.js";import z from"../../../rest/support/DateBinParameters.js";import{unitsDict as R}from"../../../rest/support/DateBinUtils.js";import B from"../../../rest/support/FixedBoundariesBinParameters.js";import M from"../../../rest/support/FixedIntervalBinParameters.js";import{calculateStringStatistics as A,calculateStatistics as w,processSummaryStatisticsResult as N,calculateUniqueValuesCount as D,createUVResult as P,calculateClassBreaks as q,resolveCBResult as O,calculateHistogram as j,calculatePercentile as C,binIndex as G,getBinParams as Z,isNullCountSupported as E,getAttributeComparator as H}from"../../../statistics/utils.js";import{utc as U}from"../../../time/constants.js";import{DateTime as k}from"luxon";const J="bin";class Q{constructor(e,t,i){this.items=e,this.query=t,this.geometryType=i.geometryType,this.hasZ=!!t.returnZ&&i.hasZ,this.hasM=!!t.returnM&&i.hasM,this.fieldsIndex=i.fieldsIndex,this.objectIdField=i.objectIdField,this.spatialReference=i.spatialReference,this.featureAdapter=i.featureAdapter}get size(){return this.items.length}createQueryResponseForCount(){const e=new p(this.query,this.featureAdapter,this.fieldsIndex);if(!this.query.outStatistics)return e.countDistinctValues(this.items);const{groupByFieldsForStatistics:t,having:i,outStatistics:s}=this.query,a=t?.length;if(!!!a)return 1;const r=new Map,n=new Map,o=new Set;for(const l of s){const{statisticType:s}=l,a="exceedslimit"!==s?l.onStatisticField:void 0;if(!n.has(a)){const i=[];for(const s of t){const t=this._getAttributeValues(e,s,this.items,r);i.push(t)}n.set(a,this._calculateUniqueValues(i,this.items,e.returnDistinctValues))}const u=n.get(a);for(const t in u){const{data:s,items:a}=u[t],r=s.join(",");i&&!e.validateItems(a,i)||o.add(r)}}return o.size}async createQueryResponse(){let e;if(this.query.outStatistics){e=this.query.outStatistics.some(e=>"exceedslimit"===e.statisticType)?this._createExceedsLimitQueryResponse():await this._createStatisticsQueryResponse(this.query,this.items)}else e=this._createFeatureQueryResponse(this.query);if(this.query.returnQueryGeometry){const t=this.query.geometry;o(this.query.outSR)&&!l(t.spatialReference,this.query.outSR)?e.queryGeometry=f({spatialReference:this.query.outSR,...g(t,t.spatialReference,this.query.outSR)}):e.queryGeometry=f({spatialReference:this.query.outSR,...t})}return e}createSnappingResponse(e,t,i){const s=this.featureAdapter,{point:a}=e,r="number"==typeof e.distance?e.distance:e.distance.x,n="number"==typeof e.distance?e.distance:e.distance.y;function o(e,t){const i=(e-a.x)/r,s=(t-a.y)/n;return i*i+s*s}const l={candidates:[]},p="esriGeometryPolygon"===this.geometryType,f="esriGeometryPolyline"===this.geometryType||"esriGeometryPoint"===this.geometryType,h=this._getPointCreator(t,this.spatialReference,i),y=new X(null,0),g=new X(null,0),x={x:0,y:0,z:0};for(const u of this.items){const e=s.getObjectId(u),t=s.getGeometryWithCurves?.(u);if(null!=t){_(t,e);continue}const i=s.getGeometry(u);null==i||I(i,e)}return l.candidates.sort((e,t)=>e.distance-t.distance),l;function I(t,i){const{coords:s,stride:r}=t,n=t.isPoint?L:t.lengths;if(y.coords=s,g.coords=s,e.returnEdge){let e=0;for(let t=0;t<n.length;t++){const s=n[t],u=e;for(let t=0;t<s;t++,e+=r){if(!p&&t===s-1)continue;if(y.coordsIndex=e,g.coordsIndex=t===s-1?u:e+r,!Y(x,a,y,g))continue;const n=o(x.x,x.y);n<=1&&l.candidates.push(new F(i,h(x),Math.sqrt(n),h(y),h(g)))}}}if("all"===e.vertexMode){let e=0;for(let t=0;t<n.length;t++){const s=n[t],a=e,u=g;u.coordsIndex=a;for(let t=0;t<s;t++,e+=r){if(y.coordsIndex=e,p&&t===s-1&&y.x===u.x&&y.y===u.y)continue;const a=o(y.x,y.y);a<=1&&l.candidates.push(new T(i,h(y),Math.sqrt(a)))}}}else if(f&&"ends"===e.vertexMode){let e=0;const t=[];for(let i=0;i<n.length;i++){t.push(e);const s=n[i];e+=s*r,s>1&&t.push(e-r)}for(const s of t){y.coordsIndex=s;const e=o(y.x,y.y);e<=1&&l.candidates.push(new T(i,h(y),Math.sqrt(e)))}}}function _(t,i){const{candidates:s}=l,r={x:0,y:0,z:0};if(e.returnEdge){const e=[a.x,a.y],n=new X(e,0),l=new X(e,0);for(const{segments:a}of t.parts)for(const{start:t,curve:p}of a){const{curvePoint:a}=u(t,p,e),f=o(...a);if(f>1)continue;[r.x,r.y]=a,n.coords=t,l.coords=c(p);const y=m(p)?null:d(p);s.push(new F(i,h(r),Math.sqrt(f),h(n),h(l),!1,y))}}function n(e){r.x=t.vertexXY[2*e],r.y=t.vertexXY[2*e+1];const a=o(r.x,r.y);a>1||(r.z=t.vertexZ?.[e]??0,s.push(new T(i,h(r),Math.sqrt(a))))}if("all"===e.vertexMode){const{vertexCount:e}=t;for(let t=0;t<e;++t)n(t);return}if("ends"===e.vertexMode)switch(t.type){case"point":n(0);break;case"polyline":for(let e=0;e<t.partCount;++e){const i=t.partOffsets[e],s=t.partOffsets[e+1]-1;n(i),s!==i&&n(s)}}}}_getPointCreator(e,t,i){const s=null==i||l(t,i)?e=>e:e=>g(e,t,i),{hasZ:a}=this,r=0;return a&&e?({x:e,y:t,z:i})=>s({x:e,y:t,z:i}):({x:e,y:t})=>s({x:e,y:t,z:r})}async createSummaryStatisticsResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,minValue:n,maxValue:o,scale:l,timeZone:u,outStatisticTypes:c}=e,m=this.fieldsIndex.get(t),d=I(m)||_(m)||v(m),p=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:l,timeZone:u},this.items),f=E({normalizationType:a,normalizationField:s,minValue:n,maxValue:o}),h={value:.5,fieldType:m?.type},y=V(m)?A({values:p,supportsNullCount:f,percentileParams:h,outStatisticTypes:c}):w({values:p,minValue:n,maxValue:o,useSampleStdDev:!a,supportsNullCount:f,percentileParams:h,outStatisticTypes:c});return N(y,c,d)}async createUniqueValuesResponse(e){const{field:t,valueExpression:i,domains:s,returnAllCodedValues:a,scale:r,timeZone:n}=e,o=await this._getDataValues({field:t,field2:e.field2,field3:e.field3,fieldDelimiter:e.fieldDelimiter,valueExpression:i,scale:r,timeZone:n},this.items,!1),l=D(o);return P(l,s,a,e.fieldDelimiter)}async createClassBreaksResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items),f=q(p,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numClasses:c});return O(f,n)}async createHistogramResponse(e){const{field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c,scale:m,timeZone:d}=e,p=await this._getDataValues({field:t,valueExpression:i,normalizationField:s,normalizationType:a,normalizationTotal:r,scale:m,timeZone:d},this.items);return j(p,{field:t,normalizationField:s,normalizationType:a,normalizationTotal:r,classificationMethod:n,standardDeviationInterval:o,minValue:l,maxValue:u,numBins:c})}_sortFeatures(e,t,i){if(e.length>1&&t?.length)for(const s of t.slice().reverse()){const{compare:t,fieldOrExpression:a,fieldInfo:r}=W(s,this.fieldsIndex);e.sort((e,s)=>t(i(e,a,r),i(s,a,r)))}}_topNFeatures(t,i,s,a){if(t.length>1&&i?.length){const r=i.map(e=>{const{compare:t,fieldOrExpression:i,fieldInfo:s}=W(e,this.fieldsIndex);return(e,r)=>t(a(e,i,s),a(r,i,s))}).reduceRight((e,t)=>(i,s)=>{const a=t(i,s);return 0===a||Number.isNaN(a)?e(i,s):a}),n=[];for(const i of t)e(n,i,s,r);return n}return t.slice(0,s)}_createFeatureQueryResponse(e){const{items:t,geometryType:i,hasM:s,hasZ:a,objectIdField:r,spatialReference:o}=this,{outFields:l,outSR:u,quantizationParameters:c,resultRecordCount:m,resultOffset:d,returnZ:p,returnM:h}=e,y=null!=m&&t.length>(d||0)+m,g=l&&(l.includes("*")?[...this.fieldsIndex.fields]:l.map(e=>this.fieldsIndex.get(e)));return{exceededTransferLimit:y,features:this._createFeatures(e,t),fields:g,geometryType:i,hasM:s&&h,hasZ:a&&p,objectIdFieldName:r,spatialReference:f(u||o),transform:c&&n(c)||null}}_createFeatures(e,t){const i=new p(e,this.featureAdapter,this.fieldsIndex),{hasM:s,hasZ:a}=this,{orderByFields:r,quantizationParameters:o,returnGeometry:l,returnCentroid:u,maxAllowableOffset:c,resultOffset:m,resultRecordCount:d,returnZ:f=!1,returnM:g=!1}=e,x=a&&f,F=s&&g;let T;const I=m||0,_=null!=d?I+d:null;null!=_&&_<=5e3&&_<t.length?T=this._topNFeatures(t,r,_,(e,t,s)=>i.getFieldValue(e,t,s)):(T=[...t],this._sortFeatures(T,r,(e,t,s)=>i.getFieldValue(e,t,s))),(I>0||null!=_)&&(T=T.slice(I,_??void 0));const v=[];let V=0;if(this.geometryType&&(l||u)){const e=n(o)??void 0,t="esriGeometryPolygon"===this.geometryType||"esriGeometryPolyline"===this.geometryType;if(l&&!u)for(const s of T){const a=this.featureAdapter.getGeometry(s),r=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),geometry:h(this.geometryType,a,c,e,x,F)});t&&a&&!r.geometry&&(r.centroid=y(this,this.featureAdapter.getCentroid(s,this),e)),v[V++]=r}else if(!l&&u)for(const s of T)v[V++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:y(this,this.featureAdapter.getCentroid(s,this),e)});else for(const s of T)v[V++]=this._addFeatureJSONMetadata(s,{attributes:i.getAttributes(s),centroid:y(this,this.featureAdapter.getCentroid(s,this),e),geometry:h(this.geometryType,this.featureAdapter.getGeometry(s),c,e,x,F)})}else for(const n of T){const e=i.getAttributes(n);e&&(v[V++]=this._addFeatureJSONMetadata(n,{attributes:e}))}return v}_addFeatureJSONMetadata(e,t){const i=this.featureAdapter.getMetadata?.(e);return void 0!==i&&(t.metadata=i),t}_createExceedsLimitQueryResponse(){let e=!1,t=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY;for(const a of this.query.outStatistics??[])if("exceedslimit"===a.statisticType){t=null!=a.maxPointCount?a.maxPointCount:Number.POSITIVE_INFINITY,i=null!=a.maxRecordCount?a.maxRecordCount:Number.POSITIVE_INFINITY,s=null!=a.maxVertexCount?a.maxVertexCount:Number.POSITIVE_INFINITY;break}if("esriGeometryPoint"===this.geometryType)e=this.items.length>t;else if(this.items.length>i)e=!0;else{e=this.items.reduce((e,t)=>{const i=this.featureAdapter.getGeometry(t);return e+(i?.size??0)},0)>s}return{fields:[{name:"exceedslimit",type:"esriFieldTypeInteger",alias:"exceedslimit",sqlType:"sqlTypeInteger",domain:null,defaultValue:null}],features:[{attributes:{exceedslimit:Number(e)}}]}}async _createStatisticsQueryResponse(e,t,i={attributes:{}}){const s=[],a=new Map,r=new Map,n=new Map,o=new Map,l=new p(e,this.featureAdapter,this.fieldsIndex),u=e.outStatistics,{groupByFieldsForStatistics:c,having:m,orderByFields:d,resultRecordCount:f}=e,h=c?.length,y=!!h,g=y?c[0]:null,x=y&&!this.fieldsIndex.get(g);for(const p of u??[]){const{outStatisticFieldName:e,statisticType:u}=p,d=p,f="exceedslimit"!==u?p.onStatisticField:void 0,F="percentile_disc"===u||"percentile_cont"===u,T="EnvelopeAggregate"===u||"CentroidAggregate"===u||"ConvexHullAggregate"===u,I=y&&1===h&&(f===g||x)&&"count"===u;if(y){if(!n.has(f)){const e=[];for(const i of c){const s=this._getAttributeValues(l,i,t,a);e.push(s)}n.set(f,this._calculateUniqueValues(e,t,!T&&l.returnDistinctValues))}const i=n.get(f);if(!i)continue;const s=Object.keys(i);for(const r of s){const{count:s,data:n,items:u,itemPositions:p}=i[r],h=n.join(",");if(!m||l.validateItems(u,m)){const i=o.get(h)||{attributes:{}};if(T){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:t}=await this._getAggregateGeometry(d,u);i.aggregateGeometries[t]=e}else{let r=null;if(I)r=s;else{const e=this._getAttributeValues(l,f,t,a),i=p.map(t=>e[t]);r=F&&"statisticParameters"in d?this._getPercentileValue(d,i):this._getStatisticValue(d,i,null,l.returnDistinctValues)}i.attributes[e]=r}let r=0;c.forEach((e,t)=>i.attributes[this.fieldsIndex.get(e)?e:"EXPR_"+ ++r]=n[t]),o.set(h,i)}}}else if(T){i.aggregateGeometries||(i.aggregateGeometries={});const{aggregateGeometries:e,outStatisticFieldName:s}=await this._getAggregateGeometry(d,t);i.aggregateGeometries[s]=e}else{const s=this._getAttributeValues(l,f,t,a);i.attributes[e]=F&&"statisticParameters"in d?this._getPercentileValue(d,s):this._getStatisticValue(d,s,r,l.returnDistinctValues)}const _="min"!==u&&"max"!==u||!V(this.fieldsIndex.get(f))&&!this._isAnyDateField(f)?null:this.fieldsIndex.get(f)?.type;s.push({name:e,alias:e,type:_||"esriFieldTypeDouble"})}const F=y?Array.from(o.values()):[i];return this._sortFeatures(F,d,(e,t)=>e.attributes[t]),f&&(F.length=Math.min(f,F.length)),{fields:s,features:F}}_isAnyDateField(e){const t=this.fieldsIndex.get(e);return I(t)||_(t)||v(t)||S(t)}async _getAggregateGeometry(e,t){const{convexHull:n,union:o}=await import("../../../geometry/geometryEngineJSON.js"),{statisticType:l,outStatisticFieldName:u}=e,{featureAdapter:c,spatialReference:m,geometryType:d}=this,p=t.map(e=>h(d,c.getGeometry(e))),f=n(m,p,!0)[0],y={aggregateGeometries:null,outStatisticFieldName:null};if("EnvelopeAggregate"===l){const e=f?a(f):r(o(m,p));y.aggregateGeometries={...e,spatialReference:m},y.outStatisticFieldName=u||"extent"}else if("CentroidAggregate"===l){const e=f?i(f):s(r(o(m,p)));y.aggregateGeometries={x:e[0],y:e[1],spatialReference:m},y.outStatisticFieldName=u||"centroid"}else"ConvexHullAggregate"===l&&(y.aggregateGeometries=f,y.outStatisticFieldName=u||"convexHull");return y}_getStatisticValue(e,t,i,s){const{onStatisticField:a,statisticType:r}=e;let n=null;n=i?.has(a)?i.get(a):V(this.fieldsIndex.get(a))||this._isAnyDateField(a)?A({values:t,returnDistinct:s}):w({values:s?[...new Set(t)]:t,minValue:null,maxValue:null,useSampleStdDev:!0}),i&&i.set(a,n);return n["var"===r?"variance":r]}_getPercentileValue(e,t){const{onStatisticField:i,statisticParameters:s,statisticType:a}=e,{value:r,orderBy:n}=s,o=this.fieldsIndex.get(i);return C(t,{value:r,orderBy:n,fieldType:o?.type,isDiscrete:"percentile_disc"===a})}_getAttributeValues(e,t,i,s){if(s.has(t))return s.get(t);const a=this.fieldsIndex.get(t),r=i.map(i=>e.getFieldValue(i,t,a));return s.set(t,r),r}_calculateUniqueValues(e,t,i){const s={},a=t.length;for(let r=0;r<a;r++){const a=t[r],n=[];for(const t of e)n.push(t[r]);const o=n.join(",");null==s[o]?s[o]={count:1,data:n,items:[a],itemPositions:[r]}:(i||s[o].count++,s[o].items.push(a),s[o].itemPositions.push(r))}return s}async _getDataValues(e,i,s=!0){const a=new p(this.query,this.featureAdapter,this.fieldsIndex),{valueExpression:r,scale:n,timeZone:o}=e;return r?a.getExpressionValues(i,r,{viewingMode:"map",scale:n,spatialReference:this.query.outSR||this.spatialReference},{geometryType:this.geometryType,hasZ:this.hasZ,hasM:this.hasM},o):a.getDataValues(i,t(e),s)}_calculateHistogramBins(e,t,i){if(null==t.min&&null==t.max)return[];const s=t.intervals,a=t.min??0,r=t.max??0,n=s.map(([e,t])=>({minValue:e,maxValue:t,count:0,items:[]}));for(let o=0;o<e.length;o++){const t=e[o],l=i[o];if(null!=t&&t>=a&&t<=r){const e=G(s,t);e>-1&&(n[e].count++,n[e].items.push(l))}}return n}async createQueryBinsResponse(e){const t=e.bin?.splitBy;if(!t)return this._createBinsResponse(e);const{value:i,outAlias:s,valueType:a}=t,r=[],n=[{name:s??i,alias:s??i,type:a??"esriFieldTypeString"},{name:J,alias:J,type:"esriFieldTypeInteger"}],o=new p(e,this.featureAdapter,this.fieldsIndex),l=new Map,u=[...this.items];this._sortFeatures(u,[i],(e,t,i)=>o.getFieldValue(e,t,i));const c=this._getAttributeValues(o,i,u,l),m=this._calculateUniqueValues([c],u,o.returnDistinctValues);for(const d in m){const{items:t}=m[d],a=await this._createBinsResponse(e,t);if(r.push(...a.features.map(e=>({...e,attributes:{...e.attributes,[s??i]:d}}))),a.fields)for(const e of a.fields)n.some(t=>t.name===e.name)||n.push(e)}return{fields:n,features:r}}async _createBinsResponse(e,t){const i=e.bin;switch(t=t??this.items,i.type){case"autoIntervalBin":return this._createAutoIntervalBinsResponse(b.fromJSON(i),e,t);case"dateBin":return this._createDateBinsResponse(z.fromJSON(i),e,t);case"fixedBoundariesBin":return this._createFixedBoundariesBinsResponse(B.fromJSON(i),e,t);case"fixedIntervalBin":return this._createFixedIntervalBinsResponse(M.fromJSON(i),e,t)}}async _createAutoIntervalBinsResponse(e,t,i){const{field:s,normalizationField:a,numBins:r,normalizationType:n,normalizationTotal:o,start:l,end:u}=e,c=await this._getDataValues({field:e.field||e.expression,normalizationField:e.normalizationField,normalizationType:e.normalizationType,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),m=Z(c,{field:s,normalizationField:a,normalizationType:n,normalizationTotal:o,numBins:r,minValue:x(n?e.normalizationMinValue:l,!1),maxValue:x(n?e.normalizationMaxValue:u,!1)}),d=this._calculateHistogramBins(c,m,i);return this._createFeaturesFromHistogramBins(d,t)}async _createDateBinsResponse(e,t,i){const{field:s,interval:a,start:r,end:n,snapToData:o,returnFullIntervalBin:l,offset:u,firstDayOfWeek:c}=e,m=a.unit,d=await this._getDataValues({field:s||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},i),p=S(this.fieldsIndex.get(s)),f=R.toJSON(m),h=d.filter(Boolean).sort((e,t)=>e-t),y=null!=r?x(r,p):h[0],g=null!=n?x(n,p):h[h.length-1],F=[];if(null!=y&&null!=g){const e={zone:t.outTimeReference?.ianaTimeZone??U},i=u?.unit?R.toJSON(u.unit):"milliseconds",s={[i]:u?.value||0},r=k.fromMillis(y,e).minus(s),n=k.fromMillis(g,e).minus(s),m="number"==typeof c&&c>=1&&c<=7?c:7,d=(e,t)=>{const i=(e.weekday-t+7)%7;return e.minus({days:i}).startOf("day")};if("last"===o){let e="week"===f?((e,t)=>d(e,t).plus({days:7}))(n,m):n;for(;e>r;){const t=e.minus({[f]:a.value});if(t<r){F.unshift([l?t.plus(s).toMillis():r.plus(s).toMillis(),e.plus(s).toMillis()]);break}F.unshift([t.plus(s).toMillis(),e.plus(s).toMillis()]),e=t}}else{let e="first"===o?r:"week"===f?d(r,m):r.startOf(f);for(;e<=n;){const t=e.plus({[f]:a.value});if(t>n){F.push([e.plus(s).toMillis(),l?t.plus(s).toMillis():n.plus(s).toMillis()]);break}F.push([e.plus(s).toMillis(),t.plus(s).toMillis()]),e=t}}}const T=this._calculateHistogramBins(d,{intervals:F,min:y,max:g},i);return this._createFeaturesFromHistogramBins(T,t)}async _createFixedBoundariesBinsResponse(e,t,i){const{field:s}=e,a=await this._getDataValues({field:s||e.expression,timeZone:t.outTimeReference?.ianaTimeZone},i),r=S(this.fieldsIndex.get(s)),n=e.boundaries.map(e=>x(e,r)).sort((e,t)=>e-t),o=[];for(let c=0;c<n.length-1;c++)o.push([n[c],n[c+1]]);const l={intervals:o,min:n.at(0),max:n.at(-1)},u=this._calculateHistogramBins(a,l,i);return this._createFeaturesFromHistogramBins(u,t)}async _createFixedIntervalBinsResponse(e,t,i){const{field:s,interval:a,normalizationType:r,start:n,end:o}=e,l=await this._getDataValues({field:s||e.expression,normalizationField:e.normalizationField,normalizationType:r,normalizationTotal:e.normalizationTotal,timeZone:t.outTimeReference?.ianaTimeZone},i),u=S(this.fieldsIndex.get(s)),c=Z(l,{field:s,classificationMethod:"defined-interval",definedInterval:a,minValue:x(r?e.normalizationMinValue:n,u),maxValue:x(r?e.normalizationMaxValue:o,u)},!0),m=this._calculateHistogramBins(l,c,i);return this._createFeaturesFromHistogramBins(m,t)}async _createFeaturesFromHistogramBins(e,t){const{upperBoundaryAlias:i,lowerBoundaryAlias:s}=t,a=s||"lowerBoundary",r=i||"upperBoundary",n=[],o=[{name:a,alias:a,type:"esriFieldTypeDouble"},{name:r,alias:r,type:"esriFieldTypeDouble"}],l=t.bin?.stackBy?.value,u=t.bin?.stackBy?.outAlias;l&&o.push({name:J,alias:J,type:"esriFieldTypeInteger"},{name:u??l,alias:u??l,type:"esriFieldTypeString"});let c=0;const m="dateBin"===t.bin.type,d=t.outTimeReference?.ianaTimeZone;for(const p of e){const{minValue:e,maxValue:i,items:s}=p,f={attributes:{}};let h;if(f.attributes[a]=m&&d&&null!=e?k.fromMillis(e,{zone:d}).toISO():e,t.bin.hideUpperBound||(f.attributes[r]=m&&d&&null!=i?k.fromMillis(i,{zone:d}).toISO():i),l?(h=await this._createStatisticsQueryResponse({...t,groupByFieldsForStatistics:[l],orderByFields:[l]},s),f.attributes[J]=++c,"flat"===t.bin.jsonStyle?n.push(...h.features.map(({attributes:{EXPR_1:e,...t},...i})=>({...i,attributes:u??e?{...t,[u??e]:e,...f.attributes}:{...t,...f.attributes}}))):(f.stackedAttributes=h.features.map(({attributes:{EXPR_1:e,...t}})=>u??e?{...t,[u??e]:e}:t),n.push(f))):(t.bin?.splitBy&&(f.attributes[J]=++c),h=await this._createStatisticsQueryResponse(t,s,f),n.push(f)),h.fields)for(const t of h.fields)o.some(e=>e.name===t.name)||o.push(t)}return"desc"===t.binOrder&&n.reverse(),{fields:o,features:n}}}function Y(e,t,i,s){const a=s.x-i.x,r=s.y-i.y,n=t.x-i.x,o=t.y-i.y,l=a*a+r*r;if(0===l)return!1;const u=n*a+o*r,c=Math.min(1,Math.max(0,u/l));return e.x=i.x+a*c,e.y=i.y+r*c,!0}class X{constructor(e,t){this.coords=e,this.coordsIndex=t}get x(){return this.coords[this.coordsIndex]}get y(){return this.coords[this.coordsIndex+1]}get z(){return this.coords[this.coordsIndex+2]}}const L=[1];function W(e,t){const i=e.split(" "),s=i[0],a=t.get(s),r=!!i[1]&&"desc"===i[1].toLowerCase();return{compare:H(a?.type,r,"case-insensitive"),fieldOrExpression:s,fieldInfo:a}}export{Q as QueryEngineResult};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../../../core/Collection.js";import{toConst as s}from"../../../../core/compilerUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import o from"../../../../core/Logger.js";import{onAbortOrThrow as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import{QueueProcessor as u}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import p from"../../../../geometry/SpatialReference.js";import{set as c,create as d,expandWithRect as f,expandWithAABB as m,negativeInfinity as y,fromRect as h}from"../../../../geometry/support/aaBoundingBox.js";import{getQueryResultExtent as g,QueryEngine as w}from"../../data/QueryEngine.js";import{QueryEngineResult as _}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as F}from"../../data/queryUtils.js";import{createDrawingInfo as x}from"./clientSideDefaults.js";import{getParquetFileId as I,getParquetRowId as R}from"./parquetIdUtils.js";import S from"../../../support/Field.js";import C from"../../../support/FieldsIndex.js";import{fromParquetGeometryEncodingJSON as q}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as v,fromParquetJSONGeometryType as b,toParquetJSONGeometryType as E}from"../../../support/parquetUtils.js";import{loadParquetModule as O}from"../../../../libs/parquet/loadParquetModule.js";import{createParquetFile as Q,readGeoMetadata as j}from"../../../../libs/parquet/parquet.js";import{FeatureStoreQueryAdapter as T}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as P}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as M}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as A}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as G}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const B=new T,D=4,z="__OBJECTID",W=new TextDecoder;class U{constructor(){this._fileInfos=new Map,this._queue=new u({concurrency:D,process:(e,t)=>this._executeQuery(e,t)}),this._indexMap={}}async load(s){const a=s.spatialReference?p.fromJSON(s.spatialReference):void 0;if(a&&!a.isWGS84&&!a.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");const n=await v({urls:new r(s.urls),fields:s.fields?.map(e=>S.fromJSON(e)),geometryEncoding:s.geometryEncoding?q(s.geometryEncoding):null,geometryType:s.geometryType?b(s.geometryType):null,displayOptimization:s.displayOptimization,spatialReference:a},{customParameters:s.customParameters});if(!n.fields)throw new i("parquet:unsupported","Fields must be defined");let u;if(n.spatialReference&&n.geometryType){if(!n.spatialReference)throw new i("parquet:unsupported","SpatialReference must be defined");if(!n.spatialReference.isGeographic&&!n.spatialReference.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");n.spatialReference.isGeographic&&!n.spatialReference.isWGS84&&(o.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:n.spatialReference}),n.spatialReference=p.WGS84),u={geometry:n.geometryEncoding?{geometryType:E(n.geometryType),spatialReference:n.spatialReference.toJSON(),encoding:n.geometryEncoding.toJSON()}:null,displayOptimization:n.displayOptimization}}this.setCustomParameters(s.customParameters),this._geometryInfo=u;const l=s.urls;for(const e of l)this._addFile(e);this._capabilities=H(await this.getFileStatistics());const m=this._fileInfos.values().next().value;if(!m)return{layerDefinition:{},capabilities:H(null)};const h=await m,{fields:g}=n;if(null==g)throw new i("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",g);g.push(new S({name:z,type:"oid",alias:z}));for(const e of g){const t=h.file.columnForFieldName(e.name);null!=t&&(this._indexMap[e.name]=t)}const w=new C(g.map(e=>e.toJSON()));this._fieldsIndex=w;const _=E(n.geometryType??"point");if(this._metadata=A.createFeature({fieldsIndex:w.toJSON(),geometryType:_,featureIdInfo:{type:"object-id",fieldName:"rowId"},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:n.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:_,featureIdInfo:{type:"object-id",fieldName:"rowId"},hasM:!1,hasZ:!1,spatialReference:n.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},n.spatialReference){const e=await this.getFileInfos();this._fullExtent=V(e,n.spatialReference.toJSON())}if(null==this._fullExtent&&"location"===n.geometryEncoding?.type){const{xField:r,yField:s}=n.geometryEncoding,i=c(d(),y);for(const o of await this.getFileInfos())for(const a of o.file.rowGroups()){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,a.columnDescriptorForAttribute(r),!1),n=e(o,a.columnDescriptorForAttribute(s),!1),u=[t.minValue(),n.minValue(),t.maxValue(),n.maxValue()];f(i,u),a.free()}catch(F){o.error=F,o.hasError=!0}finally{t(o)}}this._fullExtent={xmin:i[0],ymin:i[1],xmax:i[3],ymax:i[4],spatialReference:n.spatialReference?.toJSON()}}return{capabilities:this._capabilities,layerDefinition:{fields:n.fields?.map(e=>e.toJSON()),drawingInfo:x(_),extent:this._fullExtent??void 0,geometryType:_,geometryEncoding:n.geometryEncoding?.toJSON(),displayOptimization:n.displayOptimization}}}destroy(){for(const e of this._fileInfos.values())e.then(e=>e.file.free);this._fileInfos.clear(),this._queue.destroy()}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async getFileId(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return(await t).id}async getFileInfo(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return t}async getFileInfos(){return Promise.all(Array.from(this._fileInfos.values()))}async getFileStatistics(){if(!this._fileInfos.size)return null;const e=(await this.getFileInfos()).reduce((e,t)=>e+t.file.byteLength(),0);return{featureCount:await this._getFeatureCount(),byteLength:e}}async updateFiles(e){const t=new Set(e);for(const[r,s]of this._fileInfos.entries())t.has(r)?t.delete(r):(s.then(e=>e.file.free()),this._fileInfos.delete(r));await Promise.all(Array.from(t.values()).map(e=>this._addFile(e)))}async queryFeatures(e,t){this._validateQuery(e),Z(e)||(e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0),(e.outStatistics||e.returnDistinctValues)&&(e.returnGeometry=void 0);return(await this._enqueueQuery(e,t)).createQueryResponse()}async queryFeatureCount(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return this._getFeatureCount();r.outFields=void 0,r.returnGeometry=void 0;return(await this._enqueueQuery(r,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,8e3):8e3,r.resultOffset=r.resultOffset??0,r.returnGeometry=void 0,r.outFields=void 0;return(await this._enqueueQuery(r,t)).items.map(e=>e.getObjectId())}async queryExtent(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!N(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const o=c(d(),y),a=d(),n=await this._enqueueQuery(r,t);let u=0;for(const s of n.items)s.getBounds(a)&&(m(o,a),u+=1);return{count:u,extent:g(o,i,r.outSR?s(r.outSR):i,i,!1)}}async queryStream(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=(await O()).Query.new();"tile"===t.type&&(i.setExtent(t.extent),i.setQuantizationTransform(t.transform),i.setScale(t.scale)),i.setOutFields(t.outFields.filter(e=>null!=this._indexMap[e])),i.setOutSpatialReference(t.outSpatialReference.wkid),i.setReturnGeometry(!0),t.where&&await this._setWhereClause(i,s.file,t.where);const o=await s.file.executeQuery(i,r.signal),n=s.streamIdCounter++,u=a(r.signal,e=>{const t=s.streams.get(n);null!=t&&(t.handle.remove(),s.streams.delete(n))});return s.streams.set(n,{stream:o,handle:u}),n}async getStreamNext(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=s.streams.get(t);if(!i)return null;const o=await i.stream.next(r.signal);return null==o&&(i.handle.remove(),s.streams.delete(t)),o?.serialize().buffer}async createPatch(e,t,r,s,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const o=await this.getFileInfo(e);return(await o.file.createChunkPatch(t,r,s,i.signal)).serialize().buffer}async _getFile(e){for(const t of await this.getFileInfos())if(t.id===e)return t.file;throw new Error(`InternalError: File ${e} does not exist`)}_addFile(e){const t=this._fileInfos.size;this._fileInfos.set(e,this._createFileInfo(e,t))}async _createFileInfo(e,t){return{id:t,file:await Q(e,{geometryInfo:this._geometryInfo,getCustomParameters:()=>this._customParameters}),streamIdCounter:0,streams:new Map}}async _getFeatureCount(){return(await this.getFileInfos()).reduce((e,t)=>e+t.file.numRows(),0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new i("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new i("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new i("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,r){const s=this._indexMap,o=this._fieldsIndex,a={getAttribute(e,r){const i=t.readAttribute(e.rowGroup,e.row,s[r]);if(null==i)return null;const a=o.get(r);return"esriFieldTypeString"===a.type||"esriFieldTypeDateOnly"===a.type||"esriFieldTypeTimeOnly"===a.type||"esriFieldTypeTimestampOffset"===a.type?W.decode(i):i}},n=await l(r,this._fieldsIndex);if(!n.isStandardized)throw new i("sql-parse-error","expression is not standardized");const u=(e,t)=>n.testFeatureCompiled({rowGroup:e,row:t},a,null);e.setWhere(r),e.setWhereEvaluator(u),e.setWhereFields(n.fieldNames)}async*_fetchChunks(e,t){const r=await O();for(const s of await this.getFileInfos()){const i=r.Query.new();i.setOutFields(e.fields),i.setReturnGeometry(e.returnGeometry),e.where&&await this._setWhereClause(i,s.file,e.where);const o=await s.file.executeQuery(i),a=[],u=o.next(t);for(let e=0;e<D;e++)a.push(o.next(t));let l=await u;for(;null!=l;){n(t);const e=new G(this._metadata,this._indexMap,l,s.id),r=k([new P(e,null,0,!1)],this._queryEngineParams),i=a.shift();a.push(o.next(t)),yield r,l=await i}}}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){const r=await this._getReadParams(e);if(e.where=void 0,e.objectIds?.length){const r=new Map;for(const t of e.objectIds){const e=I(t),s=R(t);let i=r.get(e);i||(i=[],r.set(e,i)),i.push(s)}const s=[];for(const[i,o]of r.entries()){const r=await this._executeFileIdQuery(e,i,o,t);for(const e of r)s.push(e)}return new _(s,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}let s=e.resultRecordCount??await this._getFeatureCount(),i=e.resultOffset??0;e.resultRecordCount=void 0,e.resultOffset=void 0;const o=[];for await(const a of this._fetchChunks(r,t)){const r=await a.executeQueryForOpaqueFeatures(e,t);if(r.length>i){const t=r.slice(i,Math.min(i+s,r.length));for(const e of t)o.push(e);if(i=0,s-=t.length,0===s)return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}else i-=r.length}return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}async _executeFileIdQuery(e,t,r,s){const i=await this._getReadParams(e),o=(await O()).Query.new();o.setOutFields(i.fields),o.setReturnGeometry(i.returnGeometry),o.setIds(new Uint32Array(r));const a=await this._getFile(t),n=await a.executeQuery(o,s);let u=await n.next(s),l=0;const p=[];for(;null!=u;){const e=new G(this._metadata,this._indexMap,u,t),r=new P(e,null,l++,!1);p.push(r),u=await n.next(s)}return k(p,this._queryEngineParams).executeQueryForOpaqueFeatures(e,s)}async _getReadParams(e){const t=new Set;if(e.outStatistics)for(const r of e.outStatistics)null!=r.onStatisticField&&t.add(r.onStatisticField);if(e.outFields)for(const r of e.outFields)t.add(r);return{fields:(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e]),returnGeometry:!!e.returnGeometry||!!e.geometry,where:e.where}}}function N(e){for(const t in e){const r=t;switch(r){case"resultOffset":case"resultRecordCount":case"aggregateIds":case"distance":case"gdbVersion":case"geometry":case"having":case"timeExtent":case"objectIds":case"historicMoment":case"where":return null!=e[r]}}return!1}function k(e,t){const r=new M;for(const s of e)r.insert(s);return new w({...t,featureStore:r})}function J(e){switch(e.length){case 4:return h(d(),e);case 6:return e;default:throw new i("parquet:protocol-violation","Invalid Geoparquet file. BoundingBox size must be 4 or 6.",{bbox:e})}}function V(e,t){const r=c(d(),y);for(const s of e){const e=j(s.file);if(!e)return null;const t=e.columns[e.primary_column];if(!t.bbox)return null;const i=J(t.bbox);m(r,i)}return{xmin:r[0],ymin:r[1],xmax:r[3],ymax:r[4],spatialReference:t}}function H(e){const t=e?.featureCount;let r=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(r=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:8e3,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,supportsCacheHint:!1,supportsCentroid:!0,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:r,supportsExtent:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:r,supportsPagination:!0,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!0,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:r,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function Z(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{U as default};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../../../core/Collection.js";import{toConst as s}from"../../../../core/compilerUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import o from"../../../../core/Logger.js";import{onAbortOrThrow as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import{QueueProcessor as u}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import p from"../../../../geometry/SpatialReference.js";import{set as c,create as d,expandWithRect as f,expandWithAABB as m,negativeInfinity as y,fromRect as h}from"../../../../geometry/support/aaBoundingBox.js";import{getQueryResultExtent as g,QueryEngine as w}from"../../data/QueryEngine.js";import{QueryEngineResult as _}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as F}from"../../data/queryUtils.js";import{createDrawingInfo as x}from"./clientSideDefaults.js";import{getParquetFileId as I,getParquetRowId as R}from"./parquetIdUtils.js";import S from"../../../support/Field.js";import C from"../../../support/FieldsIndex.js";import{fromParquetGeometryEncodingJSON as q}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as v,fromParquetJSONGeometryType as b,toParquetJSONGeometryType as E}from"../../../support/parquetUtils.js";import{loadParquetModule as O}from"../../../../libs/parquet/loadParquetModule.js";import{createParquetFile as Q,readGeoMetadata as j}from"../../../../libs/parquet/parquet.js";import{FeatureStoreQueryAdapter as T}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as M}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as P}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as A}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as G}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const B=new T,D=4,z="__OBJECTID",W=new TextDecoder;class U{constructor(){this._fileInfos=new Map,this._queue=new u({concurrency:D,process:(e,t)=>this._executeQuery(e,t)}),this._indexMap={}}async load(s){const a=s.spatialReference?p.fromJSON(s.spatialReference):void 0;if(a&&!a.isWGS84&&!a.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");const n=await v({urls:new r(s.urls),fields:s.fields?.map(e=>S.fromJSON(e)),geometryEncoding:s.geometryEncoding?q(s.geometryEncoding):null,geometryType:s.geometryType?b(s.geometryType):null,displayOptimization:s.displayOptimization,spatialReference:a},{customParameters:s.customParameters});if(!n.fields)throw new i("parquet:unsupported","Fields must be defined");let u;if(n.spatialReference&&n.geometryType){if(!n.spatialReference)throw new i("parquet:unsupported","SpatialReference must be defined");if(!n.spatialReference.isGeographic&&!n.spatialReference.isWebMercator)throw new i("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");n.spatialReference.isGeographic&&!n.spatialReference.isWGS84&&(o.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:n.spatialReference}),n.spatialReference=p.WGS84),u={geometry:n.geometryEncoding?{geometryType:E(n.geometryType),spatialReference:n.spatialReference.toJSON(),encoding:n.geometryEncoding.toJSON()}:null,displayOptimization:n.displayOptimization}}this.setCustomParameters(s.customParameters),this._geometryInfo=u;const l=s.urls;for(const e of l)this._addFile(e);this._capabilities=H(await this.getFileStatistics());const m=this._fileInfos.values().next().value;if(!m)return{layerDefinition:{},capabilities:H(null)};const h=await m,{fields:g}=n;if(null==g)throw new i("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",g);g.push(new S({name:z,type:"oid",alias:z}));for(const e of g){const t=h.file.columnForFieldName(e.name);null!=t&&(this._indexMap[e.name]=t)}const w=new C(g.map(e=>e.toJSON()));this._fieldsIndex=w;const _=E(n.geometryType??"point");if(this._metadata=A.createFeature({fieldsIndex:w.toJSON(),geometryType:_,hasZ:!1,hasM:!1,featureIdInfo:{type:"object-id",fieldName:"rowId"},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:n.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:_,featureIdInfo:{type:"object-id",fieldName:"rowId"},hasM:!1,hasZ:!1,spatialReference:n.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},n.spatialReference){const e=await this.getFileInfos();this._fullExtent=V(e,n.spatialReference.toJSON())}if(null==this._fullExtent&&"location"===n.geometryEncoding?.type){const{xField:r,yField:s}=n.geometryEncoding,i=c(d(),y);for(const o of await this.getFileInfos())for(const a of o.file.rowGroups()){const o={stack:[],error:void 0,hasError:!1};try{const t=e(o,a.columnDescriptorForAttribute(r),!1),n=e(o,a.columnDescriptorForAttribute(s),!1),u=[t.minValue(),n.minValue(),t.maxValue(),n.maxValue()];f(i,u),a.free()}catch(F){o.error=F,o.hasError=!0}finally{t(o)}}this._fullExtent={xmin:i[0],ymin:i[1],xmax:i[3],ymax:i[4],spatialReference:n.spatialReference?.toJSON()}}return{capabilities:this._capabilities,layerDefinition:{fields:n.fields?.map(e=>e.toJSON()),drawingInfo:x(_),extent:this._fullExtent??void 0,geometryType:_,geometryEncoding:n.geometryEncoding?.toJSON(),displayOptimization:n.displayOptimization}}}destroy(){for(const e of this._fileInfos.values())e.then(e=>e.file.free);this._fileInfos.clear(),this._queue.destroy()}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async getFileId(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return(await t).id}async getFileInfo(e){const t=this._fileInfos.get(e);if(!t)throw new Error(`InternalError: File ${e} does not exist`);return t}async getFileInfos(){return Promise.all(Array.from(this._fileInfos.values()))}async getFileStatistics(){if(!this._fileInfos.size)return null;const e=(await this.getFileInfos()).reduce((e,t)=>e+t.file.byteLength(),0);return{featureCount:await this._getFeatureCount(),byteLength:e}}async updateFiles(e){const t=new Set(e);for(const[r,s]of this._fileInfos.entries())t.has(r)?t.delete(r):(s.then(e=>e.file.free()),this._fileInfos.delete(r));await Promise.all(Array.from(t.values()).map(e=>this._addFile(e)))}async queryFeatures(e,t){this._validateQuery(e),Z(e)||(e.resultRecordCount=e.resultRecordCount?Math.min(e.resultRecordCount,8e3):8e3,e.resultOffset=e.resultOffset??0),(e.outStatistics||e.returnDistinctValues)&&(e.returnGeometry=void 0);return(await this._enqueueQuery(e,t)).createQueryResponse()}async queryFeatureCount(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return this._getFeatureCount();r.outFields=void 0,r.returnGeometry=void 0;return(await this._enqueueQuery(r,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!N(r))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,8e3):8e3,r.resultOffset=r.resultOffset??0,r.returnGeometry=void 0,r.outFields=void 0;return(await this._enqueueQuery(r,t)).items.map(e=>e.getObjectId())}async queryExtent(e,t){const r=await F(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!N(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const o=c(d(),y),a=d(),n=await this._enqueueQuery(r,t);let u=0;for(const s of n.items)s.getBounds(a)&&(m(o,a),u+=1);return{count:u,extent:g(o,i,r.outSR?s(r.outSR):i,i,!1)}}async queryStream(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=(await O()).Query.new();"tile"===t.type&&(i.setExtent(t.extent),i.setQuantizationTransform(t.transform),i.setScale(t.scale)),i.setOutFields(t.outFields.filter(e=>null!=this._indexMap[e])),i.setOutSpatialReference(t.outSpatialReference.wkid),i.setReturnGeometry(!0),t.where&&await this._setWhereClause(i,s.file,t.where);const o=await s.file.executeQuery(i,r.signal),n=s.streamIdCounter++,u=a(r.signal,e=>{const t=s.streams.get(n);null!=t&&(t.handle.remove(),s.streams.delete(n))});return s.streams.set(n,{stream:o,handle:u}),n}async getStreamNext(e,t,r){if(!r.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this.getFileInfo(e),i=s.streams.get(t);if(!i)return null;const o=await i.stream.next(r.signal);return null==o&&(i.handle.remove(),s.streams.delete(t)),o?.serialize().buffer}async createPatch(e,t,r,s,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const o=await this.getFileInfo(e);return(await o.file.createChunkPatch(t,r,s,i.signal)).serialize().buffer}async _getFile(e){for(const t of await this.getFileInfos())if(t.id===e)return t.file;throw new Error(`InternalError: File ${e} does not exist`)}_addFile(e){const t=this._fileInfos.size;this._fileInfos.set(e,this._createFileInfo(e,t))}async _createFileInfo(e,t){return{id:t,file:await Q(e,{geometryInfo:this._geometryInfo,getCustomParameters:()=>this._customParameters}),streamIdCounter:0,streams:new Map}}async _getFeatureCount(){return(await this.getFileInfos()).reduce((e,t)=>e+t.file.numRows(),0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new i("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new i("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new i("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,r){const s=this._indexMap,o=this._fieldsIndex,a={getAttribute(e,r){const i=t.readAttribute(e.rowGroup,e.row,s[r]);if(null==i)return null;const a=o.get(r);return"esriFieldTypeString"===a.type||"esriFieldTypeDateOnly"===a.type||"esriFieldTypeTimeOnly"===a.type||"esriFieldTypeTimestampOffset"===a.type?W.decode(i):i}},n=await l(r,this._fieldsIndex);if(!n.isStandardized)throw new i("sql-parse-error","expression is not standardized");const u=(e,t)=>n.testFeatureCompiled({rowGroup:e,row:t},a,null);e.setWhere(r),e.setWhereEvaluator(u),e.setWhereFields(n.fieldNames)}async*_fetchChunks(e,t){const r=await O();for(const s of await this.getFileInfos()){const i=r.Query.new();i.setOutFields(e.fields),i.setReturnGeometry(e.returnGeometry),e.where&&await this._setWhereClause(i,s.file,e.where);const o=await s.file.executeQuery(i),a=[],u=o.next(t);for(let e=0;e<D;e++)a.push(o.next(t));let l=await u;for(;null!=l;){n(t);const e=new G(this._metadata,this._indexMap,l,s.id),r=k([new M(e,null,0,!1)],this._queryEngineParams),i=a.shift();a.push(o.next(t)),yield r,l=await i}}}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){const r=await this._getReadParams(e);if(e.where=void 0,e.objectIds?.length){const r=new Map;for(const t of e.objectIds){const e=I(t),s=R(t);let i=r.get(e);i||(i=[],r.set(e,i)),i.push(s)}const s=[];for(const[i,o]of r.entries()){const r=await this._executeFileIdQuery(e,i,o,t);for(const e of r)s.push(e)}return new _(s,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}let s=e.resultRecordCount??await this._getFeatureCount(),i=e.resultOffset??0;e.resultRecordCount=void 0,e.resultOffset=void 0;const o=[];for await(const a of this._fetchChunks(r,t)){const r=await a.executeQueryForOpaqueFeatures(e,t);if(r.length>i){const t=r.slice(i,Math.min(i+s,r.length));for(const e of t)o.push(e);if(i=0,s-=t.length,0===s)return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}else i-=r.length}return new _(o,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,objectIdField:"rowId",hasM:!1,hasZ:!1,featureAdapter:B})}async _executeFileIdQuery(e,t,r,s){const i=await this._getReadParams(e),o=(await O()).Query.new();o.setOutFields(i.fields),o.setReturnGeometry(i.returnGeometry),o.setIds(new Uint32Array(r));const a=await this._getFile(t),n=await a.executeQuery(o,s);let u=await n.next(s),l=0;const p=[];for(;null!=u;){const e=new G(this._metadata,this._indexMap,u,t),r=new M(e,null,l++,!1);p.push(r),u=await n.next(s)}return k(p,this._queryEngineParams).executeQueryForOpaqueFeatures(e,s)}async _getReadParams(e){const t=new Set;if(e.outStatistics)for(const r of e.outStatistics)null!=r.onStatisticField&&t.add(r.onStatisticField);if(e.outFields)for(const r of e.outFields)t.add(r);return{fields:(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e]),returnGeometry:!!e.returnGeometry||!!e.geometry,where:e.where}}}function N(e){for(const t in e){const r=t;switch(r){case"resultOffset":case"resultRecordCount":case"aggregateIds":case"distance":case"gdbVersion":case"geometry":case"having":case"timeExtent":case"objectIds":case"historicMoment":case"where":return null!=e[r]}}return!1}function k(e,t){const r=new P;for(const s of e)r.insert(s);return new w({...t,featureStore:r})}function J(e){switch(e.length){case 4:return h(d(),e);case 6:return e;default:throw new i("parquet:protocol-violation","Invalid Geoparquet file. BoundingBox size must be 4 or 6.",{bbox:e})}}function V(e,t){const r=c(d(),y);for(const s of e){const e=j(s.file);if(!e)return null;const t=e.columns[e.primary_column];if(!t.bbox)return null;const i=J(t.bbox);m(r,i)}return{xmin:r[0],ymin:r[1],xmax:r[3],ymax:r[4],spatialReference:t}}function H(e){const t=e?.featureCount;let r=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(r=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:8e3,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,supportsCacheHint:!1,supportsCentroid:!0,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:r,supportsExtent:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:r,supportsPagination:!0,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!0,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:r,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function Z(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{U as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{property as
|
|
2
|
+
import{__decorate as e}from"tslib";import{property as t,subclass as r}from"../../core/accessorSupport/decorators.js";import{highlightPixels as n}from"../raster/functions/pixelUtils.js";import{convertVectorFieldData as o,sampleVectorField as s}from"../raster/functions/vectorFieldUtils.js";import i from"../support/RasterJobHandler.js";import{getDefaultBandCombination as a,normalizeRendererJSON as l}from"../../renderers/support/rasterRendererHelper.js";import{createFlowMesh as c}from"../../views/2d/engine/flow/dataUtils.js";const d=d=>{const h=d;let b=class extends h{constructor(){super(...arguments),this._rasterJobHandlerConfig={instance:null,refCount:0,connectionPromise:null}}get _rasterJobHandler(){return this._rasterJobHandlerConfig.instance}increaseRasterJobHandlerUsage(){this._rasterJobHandlerConfig.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandlerConfig.refCount--,this._rasterJobHandlerConfig.refCount<=0&&this._shutdownJobHandler()}async convertVectorFieldData(e,t,r){if(null==e)return null;const n=this._rasterJobHandler;return n?n.convertVectorFieldData({pixelBlock:e,dataType:t},r):o(e,t)}async sampleVectorFieldData(e,t){const r=this._rasterJobHandler;return r?r.sampleVectorFieldData(e,t):s(e.pixelBlock,e.srcDataType,e.tileSize,e.offset,e.maximumVoidPercentage)}async createFlowMesh(e,t){const r=this._rasterJobHandler;return r?r.createFlowMesh(e,t):c(e.meshType,e.simulationSettings,e.flowData,e.startInfo,null!=t.signal?t.signal:(new AbortController).signal)}async highlightPixels(e,t){const r=this,{bandIds:o}=r,s="imagery"===r.type?r.rasterInfo:r.raster.rasterInfo,i=o?.length?o:a(s),l=e.highlightOptions.map(e=>{const t={...e},r="bandId"in t?[t.bandId??0]:[t.xBandId,t.yBandId];for(let n=0;n<r.length;n++){const e=r[n];if(null==e)return;const t=i?.length?i.indexOf(e):e;if(t<0||t>2)return;r[n]=t}return"bandId"in t?t.bandId=r[0]:(t.xBandId=r[0],t.yBandId=r[1]),t}).filter(e=>null!=e);if(0===l.length)return;const c=this._rasterJobHandler;c?await c.highlightPixels({...e,highlightOptions:l},t):n({...e,highlightOptions:l})}_initJobHandler(){const{_rasterJobHandlerConfig:e}=this;if(e.connectionPromise)return e.connectionPromise;const t=new i;return e.connectionPromise=t.initialize().then(()=>{e.instance=t,this.notifyChange("_rasterJobHandler")},()=>{}),e.connectionPromise}_shutdownJobHandler(){const{_rasterJobHandlerConfig:e}=this;e.instance?.destroy(),e.instance=null,e.connectionPromise=null,e.refCount=0,this.notifyChange("_rasterJobHandler"),this._cachedRendererJson=void 0}async _updateSymbolizer(e,t,r,n){const o=this._rasterJobHandlerConfig.instance;if(!o)return;const s=l({...t.toJSON(),variableName:r});JSON.stringify(this._cachedRendererJson)!==JSON.stringify(s)&&(n&&(e.rasterInfo=n),e.rendererJSON=s,e.bind(),await o.updateSymbolizer(e),this._cachedRendererJson=t.toJSON())}async _symbolize(e,t){const{pixelData:r,bandIds:n,simpleStretchParams:o}=e,s=this._rasterJobHandler;if(s){const e=await s.symbolize({...r,simpleStretchParams:o,bandIds:n},t);return{extent:r.extent,pixelBlock:e}}const i=e.symbolizer.symbolize({...r,simpleStretchParams:o,bandIds:n});return{extent:r.extent,pixelBlock:i}}};return e([t({clonable:!1})],b.prototype,"_rasterJobHandler",null),e([t({clonable:!1})],b.prototype,"_cachedRendererJson",void 0),e([t({clonable:!1})],b.prototype,"_rasterJobHandlerConfig",void 0),b=e([r("esri.layers.mixins.RasterJobHandlerMixin")],b),b};export{d as RasterJobHandlerMixin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{JSONMap as t}from"../../../core/jsonMap.js";import{isValidPixelBlock as e}from"./pixelUtils.js";import n from"../../support/PixelBlock.js";const r=new Map;r.set("meter-per-second",1),r.set("kilometer-per-hour",.277778),r.set("knots",.514444),r.set("feet-per-second",.3048),r.set("mile-per-hour",.44704);const o=180/Math.PI,
|
|
2
|
+
import{JSONMap as t}from"../../../core/jsonMap.js";import{isValidPixelBlock as e}from"./pixelUtils.js";import n from"../../support/PixelBlock.js";const r=new Map;r.set("meter-per-second",1),r.set("kilometer-per-hour",.277778),r.set("knots",.514444),r.set("feet-per-second",.3048),r.set("mile-per-hour",.44704);const o=180/Math.PI,s=5,i=new t({esriMetersPerSecond:"meter-per-second",esriKilometersPerHour:"kilometer-per-hour",esriKnots:"knots",esriFeetPerSecond:"feet-per-second",esriMilesPerHour:"mile-per-hour"});function a(t,e){return r.get(t)/r.get(e)||1}function h(t){return(450-t)%360}function l(t,e="geographic"){const[n,r]=t,s=Math.sqrt(n*n+r*r);let i=Math.atan2(r,n)*o;return i=(360+i)%360,"geographic"===e&&(i=h(i)),[s,i]}function c(t,e="geographic"){let n=t[1];"geographic"===e&&(n=h(n)),n%=360;const r=t[0];return[r*Math.cos(n/o),r*Math.sin(n/o)]}function u(t,n,r,o="geographic"){if(!e(t)||null==r)return t;const s="vector-magdir"===n?t.clone():f(t,n),i=s.pixels[1];for(let e=0;e<i.length;e++)i[e]="geographic"===o?(i[e]+r[e]+270)%360:(i[e]+360-r[e])%360;return"vector-magdir"===n?s:f(s,"vector-magdir")}function f(t,r,o="geographic",s=1){if(!e(t))return t;const{pixels:i,width:a,height:h}=t,u=a*h,f=i[0],p=i[1],m=t.pixelType.startsWith("f")?t.pixelType:"f32",g=n.createEmptyBand(m,u),d=n.createEmptyBand(m,u);let M=0;for(let e=0;e<h;e++)for(let t=0;t<a;t++)"vector-uv"===r?([g[M],d[M]]=l([f[M],p[M]],o),g[M]*=s):([g[M],d[M]]=c([f[M],p[M]],o),g[M]*=s,d[M]*=s),M++;const x=new n({pixelType:m,width:t.width,height:t.height,mask:t.mask,validPixelCount:t.validPixelCount,maskIsAlpha:t.maskIsAlpha,pixels:[g,d]});return x.updateStatistics(),x}function p(t,n,r=1){if(1===r||!e(t))return t;const o=t.clone(),{pixels:s,width:i,height:a}=o,h=s[0],l=s[1];let c=0;for(let e=0;e<a;e++)for(let t=0;t<i;t++)"vector-uv"===n?(h[c]*=r,l[c]*=r):h[c]*=r,c++;return o.updateStatistics(),o}function m(t,e,n,r,o){null!=o&&o.spatialReference.equals(t.spatialReference)||(o=t);const s=o.xmin,i=o.ymax,a=t.width/e,h=t.height/n,l=(a+h)/2,c=a*r,u=h*r;return(t=t.clone()).xmin=s+Math.floor((t.xmin-s)/c)*c,t.xmax=s+Math.ceil((t.xmax-s)/c)*c,t.ymin=i+Math.floor((t.ymin-i)/u)*u,t.ymax=i+Math.ceil((t.ymax-i)/u)*u,{extent:t,width:Math.round(t.width/a),height:Math.round(t.height/h),resolution:l}}const g=d(0,0,0);function d(t=0,e=0,n=Math.PI,r=!0){r&&(n=(2*Math.PI-n)%(2*Math.PI));const o=r?-1:1,s=13*o,i=-7*o,a=-2*o,h=-16*o,l=21.75,[c,u]=x(0,e+s,n,l),[f,p]=x(t-5.5,e+i,n,l),[m,g]=x(t+5.5,e+i,n,l),[d,M]=x(t-1.5,e+a,n,l),[k,w]=x(t+1.5,e+a,n,l),[y,P]=x(t-1.5,e+h,n,l),[b,v]=x(t+1.5,e+h,n,l);return[c,u,f,p,d,M,k,w,m,g,y,P,b,v]}function M(t=0,e=Math.PI,n=!0){n&&(e=(2*Math.PI-e)%(2*Math.PI));const r=10,o=n?-1:1,i=5*o,a=20*o,h=25*o,l=45,c=0,u=0,f=2,p=0,m=f*o,g=n?1:-1,d=r/2*g;let[M,k]=[c+d,u-a],[w,y]=[M+f*g,k],[P,b]=[w-p*g,y+m],[v,I]=[c-d,u-h],[A,_]=[v+p*g,I-m],U=Math.ceil(t/s),S=Math.floor(U/10);U-=8*S;const D=[],F=[];for(let s=0;s<U/2;s++,S--){S<=0&&U%2==1&&s===(U-1)/2&&(v=c,A=v+p*g,I=(I+k)/2,_=I-m);const[t,n]=x(v,I,e,l);if(S>0){const[r,o]=x(w,I,e,l),[s,i]=x(M,k,e,l);D.push(r),D.push(o),D.push(t),D.push(n),D.push(s),D.push(i)}else{const[r,o]=x(w,y,e,l),[s,i]=x(P,b,e,l),[a,h]=x(A,_,e,l);F.push(t),F.push(n),F.push(a),F.push(h),F.push(s),F.push(i),F.push(r),F.push(o)}I+=i,k+=i,y+=i,b+=i,_+=i}const[N,j]=x(c+d,u+a,e,l),J=(r/2+f)*g,[O,q]=x(c+J,u+a,e,l),[B,E]=x(c+d,u-h,e,l),[T,C]=x(c+J,u-h,e,l);return{pennants:D,barbs:F,shaft:[N,j,O,q,B,E,T,C]}}function x(t,e,n,r=1){const o=Math.sqrt(t*t+e*e)/r,s=(2*Math.PI+Math.atan2(e,t))%(2*Math.PI);return[o,(2*Math.PI+s-n)%(2*Math.PI)]}const k=[0,1,3,6,10,16,21,27,33,40,47,55,63],w=[0,.5,1,1.5,2],y=[0,.25,.5,1,1.5,2,2.5,3,3.5,4];function P(t,e,n,r){const o=a(r||"knots",n);let s;for(s=1;s<e.length;s++)if(s===e.length-1){if(t<e[s]*o)break}else if(t<=e[s]*o)break;return Math.min(s-1,e.length-2)}function b(t,e,n,r,o){let s=0;switch(e){case"beaufort_kn":s=P(t,k,"knots",n);break;case"beaufort_km":s=P(t,k,"kilometer-per-hour",n);break;case"beaufort_ft":s=P(t,k,"feet-per-second",n);break;case"beaufort_m":s=P(t,k,"meter-per-second",n);break;case"classified_arrow":s=P(t,o??[],r,n);break;case"ocean_current_m":s=P(t,w,"meter-per-second",n);break;case"ocean_current_kn":s=P(t,y,"knots",n)}return s}function v(t,e){const{style:n,inputUnit:r,outputUnit:o,breakValues:s}=e,a=i.fromJSON(r),h=i.fromJSON(o),l=7*6,c=15;let u=0,f=0;const{width:p,height:m,mask:M}=t,x=t.pixels[0],k=t.pixels[1],w=null!=M?M.filter(t=>t>0).length:p*m,y=new Float32Array(w*l),P=new Uint32Array(c*w),v=e.invertDirection?d(0,0,0,!1):g;for(let i=0;i<m;i++)for(let t=0;t<p;t++){const e=i*p+t;if(!M||M[i*p+t]){const r=(k[e]+360)%360/180*Math.PI,o=b(x[e],n,a,h,s);for(let n=0;n<v.length;n+=2)y[u++]=(t+.5)/p,y[u++]=(i+.5)/m,y[u++]=v[n],y[u++]=v[n+1]+r,y[u++]=o,y[u++]=x[e];const c=7*(u/l-1);P[f++]=c,P[f++]=c+1,P[f++]=c+2,P[f++]=c+0,P[f++]=c+4,P[f++]=c+3,P[f++]=c+0,P[f++]=c+2,P[f++]=c+3,P[f++]=c+2,P[f++]=c+5,P[f++]=c+3,P[f++]=c+5,P[f++]=c+6,P[f++]=c+3}}return{vertexData:y,indexData:P}}const I=[];function A(t,e){if(0===I.length)for(let s=0;s<30;s++)I.push(M(5*s,0,!e.invertDirection));const n=a(i.fromJSON(e.inputUnit),"knots"),{width:r,height:o,mask:h}=t,l=t.pixels[0],c=t.pixels[1],u=6,f=[],p=[];let m=0,g=0;for(let i=0;i<o;i++)for(let t=0;t<r;t++){const e=i*r+t,a=l[e]*n;if((!h||h[i*r+t])&&a>=s){const n=(c[e]+360)%360/180*Math.PI,{pennants:s,barbs:h,shaft:l}=I[Math.min(Math.floor(a/5),29)];if(s.length+h.length===0)continue;let d=f.length/u;const M=(t+.5)/r,x=(i+.5)/o;for(let t=0;t<s.length;t+=2)f[m++]=M,f[m++]=x,f[m++]=s[t],f[m++]=s[t+1]+n,f[m++]=0,f[m++]=a;for(let t=0;t<h.length;t+=2)f[m++]=M,f[m++]=x,f[m++]=h[t],f[m++]=h[t+1]+n,f[m++]=0,f[m++]=a;for(let t=0;t<l.length;t+=2)f[m++]=M,f[m++]=x,f[m++]=l[t],f[m++]=l[t+1]+n,f[m++]=0,f[m++]=a;for(let t=0;t<s.length/6;t++)p[g++]=d,p[g++]=d+1,p[g++]=d+2,d+=3;for(let t=0;t<h.length/8;t++)p[g++]=d,p[g++]=d+1,p[g++]=d+2,p[g++]=d+1,p[g++]=d+2,p[g++]=d+3,d+=4;p[g++]=d+0,p[g++]=d+1,p[g++]=d+2,p[g++]=d+1,p[g++]=d+3,p[g++]=d+2,d+=4}}return{vertexData:new Float32Array(f),indexData:new Uint32Array(p)}}function _(t,e){const n=4*6;let r=0,o=0;const{width:h,height:l,mask:c}=t,u=t.pixels[0],f=[],p=[],m=a(i.fromJSON(e.inputUnit),"knots"),g="wind_speed"===e.style?s:Number.MAX_VALUE;for(let s=0;s<l;s++)for(let t=0;t<h;t++){const e=u[s*h+t]*m;if((!c||c[s*h+t])&&e<g){for(let n=0;n<4;n++)f[r++]=(t+.5)/h,f[r++]=(s+.5)/l,f[r++]=n<2?-.5:.5,f[r++]=n%2==0?-.5:.5,f[r++]=0,f[r++]=e;const i=4*(r/n-1);p[o++]=i,p[o++]=i+1,p[o++]=i+2,p[o++]=i+1,p[o++]=i+2,p[o++]=i+3}}return{vertexData:new Float32Array(f),indexData:new Uint32Array(p)}}function U(t,e){return"simple_scalar"===e.style?_(t,e):"wind_speed"===e.style?A(t,e):v(t,e)}function S(t,e,r,o=[0,0],s=.5){const{width:i,height:a,mask:h}=t,[u,f]=t.pixels,[p,m]=o,g=Math.round((i-p)/r),d=Math.round((a-m)/r),M=g*d,x=new Float32Array(M),k=new Float32Array(M),w=new Uint8Array(M),y="vector-uv"===e;for(let n=0;n<d;n++)for(let t=0;t<g;t++){let e=0;const o=n*g+t,d=Math.max(0,n*r+m),M=Math.max(0,t*r+p),P=Math.min(a,d+r),b=Math.min(i,M+r);for(let t=d;t<P;t++)for(let n=M;n<b;n++){const r=t*i+n;if(!h||h[r]){e++;const t=y?[u[r],f[r]]:[u[r],(360+f[r])%360],[n,s]=y?t:c(t);x[o]+=n,k[o]+=s}}if(e>=(P-d)*(b-M)*(1-s)){w[o]=1;const[t,n]=l([x[o]/e,k[o]/e]);x[o]=t,k[o]=n}else w[o]=0,x[o]=0,k[o]=0}const P=new n({width:g,height:d,pixels:[x,k],mask:w});return P.updateStatistics(),P}export{u as convertToLocalDirections,f as convertVectorFieldData,p as convertVectorFieldUnit,U as createVFMeshData,_ as createVFScalarData,a as getUnitConversionFactor,S as sampleVectorField,m as snapImageToSymbolTile,i as unitKebabDict,l as uvComponentToVector};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import{removeMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as t}from"../../core/promiseUtils.js";import{open as i}from"../../core/workers.js";import a from"./PixelBlock.js";class s{constructor(){this._workerThread=null,this._destroyed=!1,this._onClientConnectedHandle=null,this._symbolizerState=null,this._rasterFunctionState=null}async initialize(){const e=await i("RasterWorker");this._destroyed?e.close():(this._onClientConnectedHandle=r(this._onClientConnectedHandle),this._workerThread=e,this._onClientConnectedHandle=e.onClientConnected(e=>{this._symbolizerState&&e.invoke("updateSymbolizer",this._symbolizerState).catch(e=>t(e)),this._rasterFunctionState&&e.invoke("updateRasterFunction",this._rasterFunctionState).catch(e=>t(e))}))}destroy(){this._destroyed=!0,this._onClientConnectedHandle=r(this._onClientConnectedHandle),this._workerThread&&(this._workerThread.close(),this._workerThread=null)}async convertVectorFieldData(e,r){o(this._workerThread);const t=e.pixelBlock.getTransferableObject().pixelBlock,i=await this._workerThread.invoke("convertVectorFieldData",{pixelBlock:t,type:e.dataType},r);return i?new a(i):null}async convertPixelBlockToFeatures(e,r){o(this._workerThread);const t=await this._workerThread.invoke("convertPixelBlockToFeatures",{pixelBlock:e.pixelBlock.toJSON(),extent:e.extent.toJSON(),fieldNames:e.fieldNames,skipFactor:e.skipFactor,pixelIdOffset:e.pixelIdOffset,imageRowSize:e.imageRowSize},r),i=e.extent.spatialReference?.toJSON();return t.forEach(e=>e.geometry.spatialReference=i),t}computeStatisticsHistograms(e,r){o(this._workerThread);const{transferList:t,pixelBlock:i}=e.pixelBlock.getTransferableObject();return r?.transferPixelsToWorker&&(r={...r,transferList:t}),this._workerThread.invoke("computeStatisticsHistograms",{...e,pixelBlock:i},r)}async transformPixels(e,r){o(this._workerThread);const{transferList:t,pixelBlock:i}=e.pixelBlock.getTransferableObject();r?.transferPixelsToWorker&&(r={...r,transferList:t});const s=await this._workerThread.invoke("transformPixels",{...e,pixelBlock:i},r);return a.fromJSON(s)}async compositeBands(e,r){o(this._workerThread);const t=e.pixelBlocks.map(e=>e?.getTransferableObject()),i={pixelBlocks:t.map(e=>e?.pixelBlock)};if(r?.transferPixelsToWorker){const e=t.flatMap(e=>e?.transferList).filter(e=>null!=e);r={...r,transferList:e}}const s=await this._workerThread.invoke("compositeBands",i,r);return s?a.fromJSON(s):null}async decode(e,r){o(this._workerThread);const t=await this._workerThread.invoke("decode",e,{...r,transferList:[e.data]});return t?new a(t):null}async symbolize(e,r){o(this._workerThread);const t=e.pixelBlock?.getTransferableObject().pixelBlock,i={extent:e.extent?.toJSON(),pixelBlock:t,simpleStretchParams:e.simpleStretchParams,bandIds:e.bandIds},s=await this._workerThread.invoke("symbolize",i,r);return s?new a(s):null}async highlightPixels(e,r){o(this._workerThread);const t={pixelBlock:e.pixelBlock?.toJSON(),renderedPixelBlock:e.renderedPixelBlock?.toJSON(),highlightOptions:e.highlightOptions},i=await this._workerThread.invoke("highlightPixels",t,r);e.renderedPixelBlock.pixels=i.pixels,e.renderedPixelBlock.mask=i.mask,e.renderedPixelBlock.maskIsAlpha=i.maskIsAlpha}async updateSymbolizer(e,r){o(this._workerThread);const t=e?.rendererJSON?.histograms;this._symbolizerState={symbolizerJSON:e.toJSON(),histograms:t},await Promise.all(this._workerThread.broadcast("updateSymbolizer",this._symbolizerState,r))}async updateRasterFunction(e,r){o(this._workerThread),this._rasterFunctionState={rasterFunctionJSON:e.toJSON()},await Promise.all(this._workerThread.broadcast("updateRasterFunction",this._rasterFunctionState,r))}async process(e,r){o(this._workerThread);const t=await this._workerThread.invoke("process",{extent:e.extent?.toJSON(),primaryPixelSizes:e.primaryPixelSizes?.map(e=>null!=e?e.toJSON():null),primaryPixelBlocks:e.primaryPixelBlocks.map(e=>e?.getTransferableObject().pixelBlock),primaryRasterIds:e.primaryRasterIds,parameters:e.parameters},r);return t?new a(t):null}async stretch(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t={srcPixelBlock:e.pixelBlock.getTransferableObject().pixelBlock,stretchParams:e.stretchParams},i=await this._workerThread.invoke("stretch",t,r);return i?new a(i):null}async split(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t={srcPixelBlock:e.pixelBlock.getTransferableObject().pixelBlock,tileSize:e.tileSize,maximumPyramidLevel:e.maximumPyramidLevel,useBilinear:e.useBilinear},i=await this._workerThread.invoke("split",t,r);return i&&i.forEach((e,r)=>{i.set(r,e?a.fromJSON(e):null)}),i}async clipTile(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t=e.pixelBlock.getTransferableObject().pixelBlock,i={...e,pixelBlock:t},s=await this._workerThread.invoke("clipTile",i,r);return s?a.fromJSON(s):null}async estimateStatisticsHistograms(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t={srcPixelBlock:e.pixelBlock.getTransferableObject().pixelBlock};return await this._workerThread.invoke("estimateStatisticsHistograms",t,r)}async mosaicAndTransform(e,r){if(o(this._workerThread),!e?.srcPixelBlocks?.length)return{pixelBlock:null};const t=e.srcPixelBlocks.map(e=>e?.getTransferableObject()),i={...e,srcPixelBlocks:t.map(e=>e?.pixelBlock)};if(r?.transferPixelsToWorker){const e=t.flatMap(e=>e?.transferList).filter(e=>null!=e);r={...r,transferList:e}}const s=await this._workerThread.invoke("mosaicAndTransform",i,r);return{pixelBlock:s.pixelBlock?new a(s.pixelBlock):null,localNorthDirections:s.localNorthDirections}}async createFlowMesh(e,r){o(this._workerThread);const t={buffer:e.flowData.data.buffer,maskBuffer:e.flowData.mask.buffer,width:e.flowData.width,height:e.flowData.height},{meshType:i,simulationSettings:a,startInfo:s}=e,l=await this._workerThread.invoke("createFlowMesh",{meshType:i,flowData:t,simulationSettings:a,startInfo:s},{...r,transferList:[t.buffer,t.maskBuffer]});return{vertexData:new Float32Array(l.vertexBuffer),indexData:new Uint32Array(l.indexBuffer),pathData:new Float32Array(l.pathBuffer)}}getProjectionOffsetGrid(e,r){o(this._workerThread);const t=null!=e.datumTransformation?e.datumTransformation.steps.map(e=>({wkid:e.wkid,wkt:e.wkt,isInverse:e.isInverse})):null,i=null!=e.rasterTransform?e.rasterTransform.toJSON():null,a={projectedExtent:e.projectedExtent.toJSON(),srcBufferExtent:e.srcBufferExtent.toJSON(),pixelSize:e.pixelSize,hasWrapAround:e.hasWrapAround,spacing:e.spacing,datumTransformationSteps:t,rasterTransform:i,isAdaptive:e.isAdaptive,includeGCSGrid:e.includeGCSGrid};return this._workerThread.invoke("getProjectionOffsetGrid",a,r)}}function o(r){if(null==r)throw new e("raster-jobhandler:no-connection","no available worker connection")}export{s as default};
|
|
2
|
+
import e from"../../core/Error.js";import{removeMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as t}from"../../core/promiseUtils.js";import{open as i}from"../../core/workers.js";import a from"./PixelBlock.js";class s{constructor(){this._workerThread=null,this._destroyed=!1,this._onClientConnectedHandle=null,this._symbolizerState=null,this._rasterFunctionState=null}async initialize(){const e=await i("RasterWorker");this._destroyed?e.close():(this._onClientConnectedHandle=r(this._onClientConnectedHandle),this._workerThread=e,this._onClientConnectedHandle=e.onClientConnected(e=>{this._symbolizerState&&e.invoke("updateSymbolizer",this._symbolizerState).catch(e=>t(e)),this._rasterFunctionState&&e.invoke("updateRasterFunction",this._rasterFunctionState).catch(e=>t(e))}))}destroy(){this._destroyed=!0,this._onClientConnectedHandle=r(this._onClientConnectedHandle),this._workerThread&&(this._workerThread.close(),this._workerThread=null)}async convertVectorFieldData(e,r){o(this._workerThread);const t=e.pixelBlock.getTransferableObject().pixelBlock,i=await this._workerThread.invoke("convertVectorFieldData",{pixelBlock:t,type:e.dataType},r);return i?new a(i):null}async convertPixelBlockToFeatures(e,r){o(this._workerThread);const t=await this._workerThread.invoke("convertPixelBlockToFeatures",{pixelBlock:e.pixelBlock.toJSON(),extent:e.extent.toJSON(),fieldNames:e.fieldNames,skipFactor:e.skipFactor,pixelIdOffset:e.pixelIdOffset,imageRowSize:e.imageRowSize},r),i=e.extent.spatialReference?.toJSON();return t.forEach(e=>e.geometry.spatialReference=i),t}computeStatisticsHistograms(e,r){o(this._workerThread);const{transferList:t,pixelBlock:i}=e.pixelBlock.getTransferableObject();return r?.transferPixelsToWorker&&(r={...r,transferList:t}),this._workerThread.invoke("computeStatisticsHistograms",{...e,pixelBlock:i},r)}sampleVectorFieldData(e,r){o(this._workerThread);const{transferList:t,pixelBlock:i}=e.pixelBlock.getTransferableObject();return r?.transferPixelsToWorker&&(r={...r,transferList:t}),this._workerThread.invoke("sampleVectorFieldData",{...e,pixelBlock:i},r)}async transformPixels(e,r){o(this._workerThread);const{transferList:t,pixelBlock:i}=e.pixelBlock.getTransferableObject();r?.transferPixelsToWorker&&(r={...r,transferList:t});const s=await this._workerThread.invoke("transformPixels",{...e,pixelBlock:i},r);return a.fromJSON(s)}async compositeBands(e,r){o(this._workerThread);const t=e.pixelBlocks.map(e=>e?.getTransferableObject()),i={pixelBlocks:t.map(e=>e?.pixelBlock)};if(r?.transferPixelsToWorker){const e=t.flatMap(e=>e?.transferList).filter(e=>null!=e);r={...r,transferList:e}}const s=await this._workerThread.invoke("compositeBands",i,r);return s?a.fromJSON(s):null}async decode(e,r){o(this._workerThread);const t=await this._workerThread.invoke("decode",e,{...r,transferList:[e.data]});return t?new a(t):null}async symbolize(e,r){o(this._workerThread);const t=e.pixelBlock?.getTransferableObject().pixelBlock,i={extent:e.extent?.toJSON(),pixelBlock:t,simpleStretchParams:e.simpleStretchParams,bandIds:e.bandIds},s=await this._workerThread.invoke("symbolize",i,r);return s?new a(s):null}async highlightPixels(e,r){o(this._workerThread);const t={pixelBlock:e.pixelBlock?.toJSON(),renderedPixelBlock:e.renderedPixelBlock?.toJSON(),highlightOptions:e.highlightOptions},i=await this._workerThread.invoke("highlightPixels",t,r);e.renderedPixelBlock.pixels=i.pixels,e.renderedPixelBlock.mask=i.mask,e.renderedPixelBlock.maskIsAlpha=i.maskIsAlpha}async updateSymbolizer(e,r){o(this._workerThread);const t=e?.rendererJSON?.histograms;this._symbolizerState={symbolizerJSON:e.toJSON(),histograms:t},await Promise.all(this._workerThread.broadcast("updateSymbolizer",this._symbolizerState,r))}async updateRasterFunction(e,r){o(this._workerThread),this._rasterFunctionState={rasterFunctionJSON:e.toJSON()},await Promise.all(this._workerThread.broadcast("updateRasterFunction",this._rasterFunctionState,r))}async process(e,r){o(this._workerThread);const t=await this._workerThread.invoke("process",{extent:e.extent?.toJSON(),primaryPixelSizes:e.primaryPixelSizes?.map(e=>null!=e?e.toJSON():null),primaryPixelBlocks:e.primaryPixelBlocks.map(e=>e?.getTransferableObject().pixelBlock),primaryRasterIds:e.primaryRasterIds,parameters:e.parameters},r);return t?new a(t):null}async stretch(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t={srcPixelBlock:e.pixelBlock.getTransferableObject().pixelBlock,stretchParams:e.stretchParams},i=await this._workerThread.invoke("stretch",t,r);return i?new a(i):null}async split(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t={srcPixelBlock:e.pixelBlock.getTransferableObject().pixelBlock,tileSize:e.tileSize,maximumPyramidLevel:e.maximumPyramidLevel,useBilinear:e.useBilinear},i=await this._workerThread.invoke("split",t,r);return i&&i.forEach((e,r)=>{i.set(r,e?a.fromJSON(e):null)}),i}async clipTile(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t=e.pixelBlock.getTransferableObject().pixelBlock,i={...e,pixelBlock:t},s=await this._workerThread.invoke("clipTile",i,r);return s?a.fromJSON(s):null}async estimateStatisticsHistograms(e,r){if(o(this._workerThread),!e?.pixelBlock)return null;const t={srcPixelBlock:e.pixelBlock.getTransferableObject().pixelBlock};return await this._workerThread.invoke("estimateStatisticsHistograms",t,r)}async mosaicAndTransform(e,r){if(o(this._workerThread),!e?.srcPixelBlocks?.length)return{pixelBlock:null};const t=e.srcPixelBlocks.map(e=>e?.getTransferableObject()),i={...e,srcPixelBlocks:t.map(e=>e?.pixelBlock)};if(r?.transferPixelsToWorker){const e=t.flatMap(e=>e?.transferList).filter(e=>null!=e);r={...r,transferList:e}}const s=await this._workerThread.invoke("mosaicAndTransform",i,r);return{pixelBlock:s.pixelBlock?new a(s.pixelBlock):null,localNorthDirections:s.localNorthDirections}}async createFlowMesh(e,r){o(this._workerThread);const t={buffer:e.flowData.data.buffer,maskBuffer:e.flowData.mask.buffer,width:e.flowData.width,height:e.flowData.height},{meshType:i,simulationSettings:a,startInfo:s}=e,l=await this._workerThread.invoke("createFlowMesh",{meshType:i,flowData:t,simulationSettings:a,startInfo:s},{...r,transferList:[t.buffer,t.maskBuffer]});return{vertexData:new Float32Array(l.vertexBuffer),indexData:new Uint32Array(l.indexBuffer),pathData:new Float32Array(l.pathBuffer)}}getProjectionOffsetGrid(e,r){o(this._workerThread);const t=null!=e.datumTransformation?e.datumTransformation.steps.map(e=>({wkid:e.wkid,wkt:e.wkt,isInverse:e.isInverse})):null,i=null!=e.rasterTransform?e.rasterTransform.toJSON():null,a={projectedExtent:e.projectedExtent.toJSON(),srcBufferExtent:e.srcBufferExtent.toJSON(),pixelSize:e.pixelSize,hasWrapAround:e.hasWrapAround,spacing:e.spacing,datumTransformationSteps:t,rasterTransform:i,isAdaptive:e.isAdaptive,includeGCSGrid:e.includeGCSGrid};return this._workerThread.invoke("getProjectionOffsetGrid",a,r)}}function o(r){if(null==r)throw new e("raster-jobhandler:no-connection","no available worker connection")}export{s as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import e from"../../geometry/Extent.js";import r from"../../geometry/Point.js";import t from"../../geometry/operators/support/GeographicTransformation.js";import{decode as s}from"../raster/formats/RasterCodec.js";import{transformPixels as o}from"../raster/functions/pixelTransformUtils.js";import{convertPixelBlockToFeatures as i,compositeBands as n,highlightPixels as l,split as a,clipTile as m,mosaic as c,approximateTransform as f,getLocalArithmeticNorthRotations as p}from"../raster/functions/pixelUtils.js";import{create as u}from"../raster/functions/rasterFunctionHelper.js";import{load as x,getProjectionOffsetGrid as d}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as S,estimateStatisticsHistograms as h}from"../raster/functions/stretchUtils.js";import{convertVectorFieldData as k,convertToLocalDirections as
|
|
2
|
+
import e from"../../geometry/Extent.js";import r from"../../geometry/Point.js";import t from"../../geometry/operators/support/GeographicTransformation.js";import{decode as s}from"../raster/formats/RasterCodec.js";import{transformPixels as o}from"../raster/functions/pixelTransformUtils.js";import{convertPixelBlockToFeatures as i,compositeBands as n,highlightPixels as l,split as a,clipTile as m,mosaic as c,approximateTransform as f,getLocalArithmeticNorthRotations as p}from"../raster/functions/pixelUtils.js";import{create as u}from"../raster/functions/rasterFunctionHelper.js";import{load as x,getProjectionOffsetGrid as d}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as S,estimateStatisticsHistograms as h}from"../raster/functions/stretchUtils.js";import{convertVectorFieldData as k,sampleVectorField as g,convertToLocalDirections as B}from"../raster/functions/vectorFieldUtils.js";import{readTransform as O}from"../raster/transforms/utils.js";import y from"./PixelBlock.js";import P from"../../renderers/support/RasterSymbolizer.js";import{createFlowMesh as N}from"../../views/2d/engine/flow/dataUtils.js";function J(e){if(!e)return{result:null,transferList:[]};const{pixelBlock:r,transferList:t}=e.getTransferableObject();return{result:r,transferList:t}}class b{convertVectorFieldData(e){const r=y.fromJSON(e.pixelBlock),t=J(k(r,e.type));return Promise.resolve(t)}convertPixelBlockToFeatures(r){const t=i({pixelBlock:y.fromJSON(r.pixelBlock),extent:e.fromJSON(r.extent),fieldNames:r.fieldNames,skipFactor:r.skipFactor,skipSpatialReference:!0,pixelIdOffset:r.pixelIdOffset,imageRowSize:r.imageRowSize});return Promise.resolve(t)}sampleVectorFieldData(e){const r=y.fromJSON(e.pixelBlock),t=J(g(r,e.srcDataType,e.tileSize,e.offset,e.maximumVoidPercentage));return Promise.resolve(t)}transformPixels(e){const r=y.fromJSON(e.pixelBlock),t=o(r,e.transformType,e.transformParameters);return Promise.resolve(J(t))}computeStatisticsHistograms(e){const r=y.fromJSON(e.pixelBlock),t=S(r,{histogramSize:e.histogramSize,includeSkewnessKurtosis:e.includeSkewnessKurtosis});return Promise.resolve(t)}compositeBands(e){const r=e.pixelBlocks.map(e=>e&&y.fromJSON(e)),t=J(n(r));return Promise.resolve(t)}async decode(e){return J(await s(e.data,e.options))}symbolize(r){const t=r.pixelBlock?y.fromJSON(r.pixelBlock):null,s=r.extent?e.fromJSON(r.extent):null,o=J(this.symbolizer.symbolize({...r,pixelBlock:t,extent:s}));return Promise.resolve(o)}highlightPixels(e){const r=y.fromJSON(e.pixelBlock),t=y.fromJSON(e.renderedPixelBlock);return l({pixelBlock:r,renderedPixelBlock:t,highlightOptions:e.highlightOptions}),Promise.resolve(t.toJSON())}async updateSymbolizer(e){this.symbolizer=P.fromJSON(e.symbolizerJSON),e.histograms&&"rasterStretch"===this.symbolizer?.rendererJSON.type&&(this.symbolizer.rendererJSON.histograms=e.histograms)}async updateRasterFunction(e){this.rasterFunction=u(e.rasterFunctionJSON)}async process(t){return J(this.rasterFunction.process({extent:e.fromJSON(t.extent),primaryPixelBlocks:t.primaryPixelBlocks.map(e=>null!=e?y.fromJSON(e):null),primaryPixelSizes:t.primaryPixelSizes?.map(e=>null!=e?r.fromJSON(e):null),primaryRasterIds:t.primaryRasterIds},t.parameters))}stretch(e){const r=J(this.symbolizer.simpleStretch(y.fromJSON(e.srcPixelBlock),e.stretchParams));return Promise.resolve(r)}estimateStatisticsHistograms(e){const r=h(y.fromJSON(e.srcPixelBlock));return Promise.resolve(r)}split(e){const r=a(y.fromJSON(e.srcPixelBlock),e.tileSize,e.maximumPyramidLevel??0,!1===e.useBilinear),t=[];let s;return r&&(s=new Map,r.forEach((e,r)=>{if(e){const{pixelBlock:o,transferList:i}=e.getTransferableObject();s.set(r,o),i.forEach(e=>{t.includes(e)||t.push(e)})}})),Promise.resolve({result:s,transferList:t})}clipTile(e){const r=y.fromJSON(e.pixelBlock),t=J(m({...e,pixelBlock:r}));return Promise.resolve(t)}async mosaicAndTransform(e){const r=e.srcPixelBlocks.map(e=>e?new y(e):null),t=c(r,e.srcMosaicSize,{blockWidths:e.blockWidths,alignmentInfo:e.alignmentInfo,clipOffset:e.clipOffset,clipSize:e.clipSize});let s,o=t;e.coefs&&(o=f(t,e.destDimension,e.coefs,e.sampleSpacing,e.interpolation)),e.projectDirections&&e.gcsGrid&&(s=p(e.destDimension,e.gcsGrid),o=B(o,e.isUV?"vector-uv":"vector-magdir",s));const{result:i,transferList:n}=J(o);return{result:{pixelBlock:i,localNorthDirections:s},transferList:n}}async createFlowMesh(e,r){const t={data:new Float32Array(e.flowData.buffer),mask:new Uint8Array(e.flowData.maskBuffer),width:e.flowData.width,height:e.flowData.height},{vertexData:s,indexData:o,pathData:i}=await N(e.meshType,e.simulationSettings,t,e.startInfo,r.signal);return{result:{vertexBuffer:s.buffer,indexBuffer:o.buffer,pathBuffer:i.buffer},transferList:[s.buffer,o.buffer]}}async getProjectionOffsetGrid(r){const s=e.fromJSON(r.projectedExtent),o=e.fromJSON(r.srcBufferExtent);let i=null;r.datumTransformationSteps?.length&&(i=new t({steps:r.datumTransformationSteps})),await x();const n=r.rasterTransform?O(r.rasterTransform):null;return d({...r,projectedExtent:s,srcBufferExtent:o,datumTransformation:i,rasterTransform:n})}}export{b as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{isSome as s}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{stripHTMLSanitizer as a}from"../../core/sanitizerUtils.js";import{property as o,subclass as l}from"../../core/accessorSupport/decorators.js";import{featureHasFields as n,extractSubstitutionTemplatesFromString as c}from"./fieldUtils.js";import{loadArcade as d}from"../../support/loadArcade.js";const p="relationships/",u="expression/",f=/<br\s*\/*>/gi;let h=class extends t{constructor(e){super(e),this._featureUtils=null,this.effectivePopupTemplate=null}get _arcadeTask(){if(this.expressionsUsedInTitle.length>0){return this._get("_arcadeTask")||i(()=>d())}return null}get featureUtilsPromise(){return this._get("featureUtilsPromise")??import("../../
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{isSome as s}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{stripHTMLSanitizer as a}from"../../core/sanitizerUtils.js";import{property as o,subclass as l}from"../../core/accessorSupport/decorators.js";import{featureHasFields as n,extractSubstitutionTemplatesFromString as c}from"./fieldUtils.js";import{loadArcade as d}from"../../support/loadArcade.js";const p="relationships/",u="expression/",f=/<br\s*\/*>/gi;let h=class extends t{constructor(e){super(e),this._featureUtils=null,this.effectivePopupTemplate=null}get _arcadeTask(){if(this.expressionsUsedInTitle.length>0){return this._get("_arcadeTask")||i(()=>d())}return null}get featureUtilsPromise(){return this._get("featureUtilsPromise")??import("../../popup/support/featureUtils.js").then(e=>this._featureUtils=e)}get calculatedExpressions(){const e=new r;if(!this.expressionsUsedInTitle.length)return e;if(!this._arcadeTask?.value){for(const t of this.expressionsUsedInTitle??[])e.push({name:t.name,invalid:!0});return e}for(const t of this.expressionsUsedInTitle)try{const s=this._arcadeTask.value.arcade.parseScript(t.expression,["$layer","$map","$datastore"]);if(s.isAsync){e.push({name:t.name,invalid:!0});break}e.push({name:t.name,syntax:s,invalid:!1,func:this._arcadeTask.value.arcade.compileScript(s,{vars:{$feature:"any"}})})}catch{e.push({name:t.name,invalid:!0});break}return e}get expressionsUsedInTitle(){let e=this.effectivePopupTemplate?.title??"";return"string"!=typeof e?[]:(e=e.toLowerCase(),this.effectivePopupTemplate?.expressionInfos?.filter(t=>e.includes(`{expression/${t.name.toLowerCase()}}`))??[])}get fieldInfoMap(){return this._featureUtils?this._createFieldInfoMap(this._featureUtils.getAllFieldInfos(this.effectivePopupTemplate)):null}get hasBadExpressions(){return this.calculatedExpressions.some(e=>!0===e.invalid)}get requiredFields(){const e=new Set;if(this._arcadeTask?.value&&!this.hasBadExpressions)for(const s of this.calculatedExpressions?.toArray()??[])try{const t=this._arcadeTask.value.arcade.extractFieldLiterals(s.syntax);for(const s of t){const t=s.split("."),i=this.fieldsIndex.get(t.at(-1)??"");i&&e.add(i.name)}}catch{}const t=this._extractFieldNames(this.workingTitle);for(const s of t){const t=this.fieldsIndex.get(s);t&&e.add(t.name)}return null!=this.objectIdField&&e.add(this.objectIdField),e}get titleFromDisplayField(){let e="";return this.displayField&&(e=this.fieldsIndex.get(this.displayField)?.name??""),e||(e=this.fieldsIndex.get(this.objectIdField)?.name??""),e?`{${e}}`:""}get workingTitle(){const e=this.effectivePopupTemplate?this.effectivePopupTemplate.title:"";return""===e||null==e||this.hasBadExpressions||"string"!=typeof e?this.titleFromDisplayField:e}async getTitle(e,t,s){const i=t.getObjectId()??t.attributes[e.objectIdField];return(await this.getTitles(e,[t],s)).get(i)??""}async getTitles(e,t,s){const i=new Map,r=s?.timeZone??"system";try{const[{substituteFieldsInLinksAndAttributes:o}]=await Promise.all([this.featureUtilsPromise,this._arcadeTask?.promise]);s?.fetchMissingFields&&(t=await this._checkAndReQueryGraphics(e,t));const{fieldInfoMap:l,workingTitle:n}=this,c=n&&l;t.forEach(t=>{const d=t.getObjectId()??t.attributes[e.objectIdField];let p=c?o({attributes:t.attributes,expressionAttributes:null,fieldInfoMap:l,globalAttributes:this._createFormattedAttributes(e,t,r).global,layer:e,text:n}):"";s?.removeHTML&&(p=a.sanitize(p).replaceAll(f," ")),i.set(d,p)})}catch{}return i}async _checkAndReQueryGraphics(e,t){const i=t.map(t=>t.getObjectId()??t.attributes[e.objectIdField]).filter(s);if(i.length!==t.length)return t;if(t.some(e=>!n(e,this.requiredFields))){const s=e.createQuery();s.where="1=1",s.outFields=[...this.requiredFields],s.objectIds=i;const r=await e.queryFeatures(s);if(r?.features.length===t.length)return r.features}return t}_createFieldInfoMap(e){const t=new Map;if(!e)return t;for(const s of e){if(!s.fieldName)continue;const e=this.fieldsIndex.get(s.fieldName),i=e?.name??s.fieldName;s.fieldName=i,t.set(i.toLowerCase(),s)}return t}_createFormattedAttributes(e,t,s="system"){const i=this.effectivePopupTemplate?.fieldInfos??[],r={};if(!this._featureUtils)return{};if(!this.hasBadExpressions&&this.calculatedExpressions.length>0&&this._arcadeTask?.value){const s=this._arcadeTask.value.Feature.createFromGraphicLikeObject(t.geometry,t.attributes,e,null);for(const e of this.calculatedExpressions)try{r[`expression/${e.name}`]=e.func({vars:{$feature:s}})}catch{}}const a={...t.attributes,...r};return{global:this._featureUtils.formatAttributes({fieldInfos:i,attributes:a,graphic:t,timeZone:s,layer:e,fieldInfoMap:this.fieldInfoMap}),content:[]}}_extractFieldNames(e){return c(e).filter(e=>!(e.startsWith(p)||e.startsWith(u)))}};e([o({readOnly:!0})],h.prototype,"_arcadeTask",null),e([o()],h.prototype,"_featureUtils",void 0),e([o({readOnly:!0})],h.prototype,"featureUtilsPromise",null),e([o({readOnly:!0})],h.prototype,"calculatedExpressions",null),e([o()],h.prototype,"displayField",void 0),e([o()],h.prototype,"effectivePopupTemplate",void 0),e([o()],h.prototype,"expressionsUsedInTitle",null),e([o()],h.prototype,"fieldsIndex",void 0),e([o()],h.prototype,"fieldInfoMap",null),e([o()],h.prototype,"fields",void 0),e([o()],h.prototype,"objectIdField",void 0),e([o()],h.prototype,"requiredFields",null),h=e([l("esri.layers.support.TitleCreator")],h);export{h as default};
|