@arcgis/core 4.31.0-next.20240708 → 4.31.0-next.20240709
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0975e54c50383375cc09.js → 14cf7411e8318a1bccb9.js} +1 -1
- package/assets/esri/core/workers/chunks/{71852b8437ec66b9ef06.js → 2123ab24163a532ebc8d.js} +1 -1
- package/assets/esri/core/workers/chunks/{c91b3800cf3891bf2d59.js → 252ff37bf5e12dae0b18.js} +1 -1
- package/assets/esri/core/workers/chunks/2799007b5f3f4a2e364c.js +51 -0
- package/assets/esri/core/workers/chunks/{ff5e6d823d512f87a527.js → 2dddb8a989b9c96572fe.js} +1 -1
- package/assets/esri/core/workers/chunks/3375de864347a847393d.js +1042 -0
- package/assets/esri/core/workers/chunks/543f9db420c99d429637.js +1 -0
- package/assets/esri/core/workers/chunks/{812e18c65aa6e398c338.js → 5b6c89dc41067d81c952.js} +1 -1
- package/assets/esri/core/workers/chunks/{5089a12084a8a8fb93d8.js → 61e5179fb49866241128.js} +1 -1
- package/assets/esri/core/workers/chunks/632e3ba2b8a881df29a0.js +1 -0
- package/assets/esri/core/workers/chunks/{1cc4a89c96a36d6b3d52.js → 7767559d56d16b644655.js} +1 -1
- package/assets/esri/core/workers/chunks/{43e83f4d827f59ff556a.js → 8087288f00dfdcc479b9.js} +1 -1
- package/assets/esri/core/workers/chunks/{a5fbe1c95e49093e5af4.js → 8cce4b218568638e6e64.js} +1 -1
- package/assets/esri/core/workers/chunks/{c7e2a97cb7bcd153bcef.js → 8e326def543268f8a08e.js} +1 -1
- package/assets/esri/core/workers/chunks/92cb45b18e151db007dc.js +1 -0
- package/assets/esri/core/workers/chunks/b2e8cc76381077b78d4c.js +1 -0
- package/assets/esri/core/workers/chunks/b6a8132708afcd988fa9.js +1 -0
- package/assets/esri/core/workers/chunks/{b4d850e82a8ae902d684.js → c44cc686774ff53c0a94.js} +1 -1
- package/assets/esri/core/workers/chunks/c52701477405c1fb2072.js +1 -0
- package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js → cfc2a1858a8bbb284979.js} +2 -2
- package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js.LICENSE.txt → cfc2a1858a8bbb284979.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/d9863289c69d2550cd49.js +1 -0
- package/assets/esri/core/workers/chunks/e1f4df3a5b0b31521b3c.js +1 -0
- package/assets/esri/core/workers/chunks/{61505947371cebab9cbe.js → fdebfe55cd097714ec11.js} +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +13 -18
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/AtmosphereCompositing.glsl.js +6 -9
- package/chunks/BlendLayers.glsl.js +1 -7
- package/chunks/BlendWeights.glsl.js +45 -51
- package/chunks/Blur.glsl.js +1 -3
- package/chunks/ChapmanAtmosphere.glsl.js +3 -8
- package/chunks/CheckerBoard.glsl.js +3 -9
- package/chunks/Clouds.glsl.js +21 -10
- package/chunks/CloudsComposition.glsl.js +3 -7
- package/chunks/ColorMaterial.glsl.js +3 -9
- package/chunks/ComponentShader.glsl.js +35 -50
- package/chunks/Compositing.glsl.js +5 -7
- package/chunks/DefaultMaterial.glsl.js +68 -73
- package/chunks/EdgeDetect.glsl.js +5 -10
- package/chunks/EdgeShader.glsl.js +37 -60
- package/chunks/Fog.glsl.js +4 -9
- package/chunks/HUDCompositing.glsl.js +1 -3
- package/chunks/HUDMaterial.glsl.js +8 -14
- package/chunks/Heatmap.glsl.js +4 -7
- package/chunks/HeatmapDensity.glsl.js +5 -11
- package/chunks/HighlightApply.glsl.js +133 -152
- package/chunks/HighlightDownsample.glsl.js +29 -32
- package/chunks/ImageMaterial.glsl.js +11 -21
- package/chunks/LaserlinePath.glsl.js +4 -9
- package/chunks/LineCallout.glsl.js +91 -108
- package/chunks/LineMarker.glsl.js +2 -8
- package/chunks/Magnifier.glsl.js +4 -9
- package/chunks/MeasurementArrow.glsl.js +9 -15
- package/chunks/NativeLine.glsl.js +8 -12
- package/chunks/NoiseTextureAtlas.glsl.js +89 -86
- package/chunks/OITCompositing.glsl.js +2 -3
- package/chunks/OverlayCompositing.glsl.js +2 -4
- package/chunks/Path.glsl.js +31 -55
- package/chunks/Pattern.glsl.js +16 -20
- package/chunks/PointRenderer.glsl.js +39 -48
- package/chunks/Precipitation.glsl.js +15 -27
- package/chunks/RasterColorizer.glsl.js +25 -33
- package/chunks/RealisticTree.glsl.js +53 -65
- package/chunks/SSAO.glsl.js +7 -10
- package/chunks/SSAOBlur.glsl.js +10 -14
- package/chunks/ShadedColorMaterial.glsl.js +12 -15
- package/chunks/ShadowCastAccumulate.glsl.js +2 -4
- package/chunks/ShadowCastVisualize.glsl.js +12 -19
- package/chunks/ShadowHighlight.glsl.js +46 -50
- package/chunks/SimpleAtmosphere.glsl.js +4 -13
- package/chunks/SlicePlaneMaterial.glsl.js +3 -7
- package/chunks/Stars.glsl.js +3 -7
- package/chunks/Terrain.glsl.js +20 -61
- package/chunks/TextureOnly.glsl.js +2 -4
- package/chunks/Viewshed.glsl.js +20 -38
- package/chunks/WaterSurface.glsl.js +34 -60
- package/core/workers/registry.js +1 -1
- package/interfaces.d.ts +34 -4
- package/layers/WCSLayer.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
- package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
- package/package.json +3 -3
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/ShaderBuilder2D.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +5 -0
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +5 -0
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +5 -0
- package/views/3d/layers/graphics/pipeline/PBFPointFeaturesView.js +5 -0
- package/views/3d/layers/graphics/pipeline/TestSymbol.js +5 -0
- package/views/3d/layers/graphics/pipeline/Tile.js +5 -0
- package/views/3d/layers/graphics/pipeline/Tile3DFetcher.js +5 -0
- package/views/3d/layers/graphics/pipeline/Tile3DProcessor.js +5 -0
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/layers/support/projectExtentUtils.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js +3 -5
- package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +29 -59
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -12
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/TextureTransformUV.glsl.js +6 -6
- package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -4
- package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
- package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/enums.js +1 -1
- package/views/webgl/heatmapTextureUtils.js +1 -1
- package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/assets/esri/core/workers/chunks/0cb2eb96ffb1dbed00eb.js +0 -1
- package/assets/esri/core/workers/chunks/0d6ed27fc9948f4ea061.js +0 -1
- package/assets/esri/core/workers/chunks/225b947ba4b2fcfd5630.js +0 -1
- package/assets/esri/core/workers/chunks/7c7c3068da3bf7467685.js +0 -1
- package/assets/esri/core/workers/chunks/85e5cdd723f68dec8c25.js +0 -1
- package/assets/esri/core/workers/chunks/aed0db145187d9eb52f2.js +0 -51
- package/assets/esri/core/workers/chunks/cf9a32a03b3d3b66effb.js +0 -1
- package/assets/esri/core/workers/chunks/e840e54455eb500b501d.js +0 -1098
- package/assets/esri/core/workers/chunks/fec53ce15ae52f8cb802.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../rasterFormats/RasterCodec.js";import{clip as f}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",C="server returns an exception";let b=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=e?.signal,n=await this._getCapabilities(i);if(this.capabilities=n,!this.version){let e=n.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=n.capabilitiesVersion:(e=n.supportedVersions.find((e=>"2.0.1"===e))||n.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const s=n.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!s.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=s[0].id);const r=s.find((e=>e.id===this.coverageId));if(null==r)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const o=await this._describeCoverage(i);this.coverageInfo=o[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=r.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(n.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:r,spatialReference:o}=this.rasterInfo,a=2**e,l=r.x*a,c=r.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:c},i,n,u,o,[d,p]),g=this.rasterInfo.extent,m=h.xmax>g.xmax,w=h.ymin<g.ymin,v=m||w;let y=h,x=d,C=p;if(v&&(y=h.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(C=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*C))),null==y||x<=1||C<=1)return null;const b=await this._getCoverage(y,x,C,a,s);if(!b)return null;const{coverageDescription:I}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=s;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===I.version){const t=I.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===I.version){const t=I.range.find((t=>t.identifier===e));$=t?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:C,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==T)return null;if(T&&(T.width!==x||T.height!==C))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return v?f(T,{x:0,y:0},{width:p,height:p}):T}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(s){if(!n(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version?.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(r){if(!n(r))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw r}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:r}=this.rasterInfo,o=s.center,l=new g({xmin:o.x-n.x,xmax:o.x+n.x,ymin:o.y-n.y,ymax:o.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=r){const e=r.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:h}=this,f="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!f)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!m&&f&&("2.0"===u&&(h.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,r,o,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,n,s,r,o,l):"1.1"===d?this._getCoverage110Parameters(e,n,s,o,l):this._getCoverage100Parameters(e,n,s,o),u="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:o.signal,responseType:"array-buffer"});if("1.0"===d)return u.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const f=c(u);if(f.isMultipart&&f.data){const e=f.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",C,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,r=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:u}=n;let h;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),h=t.map((e=>I(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${r}`,bbox:s,width:t,height:i,time:h,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:r,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(l),h=w[u],f=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=s.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=g.useEPSGAxis&&o(c),b=C?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,$=this.ioConfig.use2GridOffsets,S=C?$?`${y},${v}`:`${y},0,0,${v}`:$?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,_=Math.abs(y)/2,R=e.ymin+_,D=e.ymax-_,E=C?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,P=s.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let A,G=P&&h&&a?f?`${P.identifier}[${P.axis[0].identifier}[${a.join(",")}]]`:`${P.identifier}:${h}[${P.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=r&&r.length)for(let o=0;o<r.length;o++){let e=r[o].values;const t=r[o].dimensionName?.toLowerCase(),i=r[o].variableName?.toLowerCase();if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)A=e.map((e=>I(e))).join(",");else{const n=s.range.find((e=>e.identifier.toLowerCase()===i));if(n){const i=n.axis.find((e=>e.identifier.toLowerCase()===t));i&&(G=f?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+h+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:b,gridOffsets:S,gridBaseCRS:d,timeSequence:A,rangeSubset:G}}_getCoverage201Parameters(e,t,i,n,s,r){const{multidimensionalDefinition:o,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:h,domainSet:f,rangeType:g}=r,m=h.isEastFirst?0:1,w=1-m,{axisLabels:v}=h,y=v[m],x=v[w],C=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,b=C,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=f.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=I(e,!0)),$.push(v[D]+",http://www.opengis.net("+t+")")}else $.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=o&&o.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<o.length;i++){const n=v.find((e=>e===o[i].dimensionName)),s=e.find((e=>e===o[i].variableName));if(t.includes(s)||t.push(s),n){let e=o[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map((e=>I(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(n+",http://www.opengis.net")));-1===i&&$.push(n+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(s.bandIds?s.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),L=!r.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:_,scaleFactor:R,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:C,subsettingcrs:b}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(n)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};function I(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}e([s({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([s()],b.prototype,"tileType",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),b=e([r("esri.layers.support.rasterDatasets.WCSRaster")],b);const $=b;export{$ as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../rasterFormats/RasterCodec.js";import{clip as f}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",C="server returns an exception";let b=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer",this.tileType="Raster"}async open(e){await this.init();const i=e?.signal,s=await this._getCapabilities(i);if(this.capabilities=s,!this.version){let e=s.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.capabilitiesVersion:(e=s.supportedVersions.find((e=>"2.0.1"===e))||s.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const n=s.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!n.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=n[0].id);const r=n.find((e=>e.id===this.coverageId));if(null==r)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const o=await this._describeCoverage(i);this.coverageInfo=o[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=r.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(s.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,s,n={}){if(this.isBlockOutside(e,i,s))return null;const{nativePixelSize:r,spatialReference:o}=this.rasterInfo,a=2**e,l=r.x*a,c=r.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:c},i,s,u,o,[d,p]),g=this.rasterInfo.extent,m=h.xmax>g.xmax,w=h.ymin<g.ymin,v=m||w;let y=h,x=d,C=p;if(v&&(y=h.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(C=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*C))),null==y||x<=1||C<=1)return null;const b=await this._getCoverage(y,x,C,a,n);if(!b)return null;const{coverageDescription:I}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=n;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===I.version){const t=I.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===I.version){const t=I.range.find((t=>t.identifier===e));$=t?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:C,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==T)return null;if(T&&(T.width!==x||T.height!==C))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return v?f(T,{x:0,y:0},{width:p,height:p}):T}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(n){if(!s(n))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw n}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},n=this.version?.slice(0,3);"1.0"===n?i.coverage=this.coverageId:"1.1"===n?i.identifiers=this.coverageId:"2.0"===n&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(r){if(!s(r))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw r}}async _getPixelTypeAndBandCount(e){const{pixelSize:s,extent:n,multidimensionalInfo:r}=this.rasterInfo,o=n.center,l=new g({xmin:o.x-s.x,xmax:o.x+s.x,ymin:o.y-s.y,ymax:o.y+s.y,spatialReference:n.spatialReference});let c=[];if(null!=r){const e=r.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:h}=this,f="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!f)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!m&&f&&("2.0"===u&&(h.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,s,n,r,o,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,s,n,r,o,l):"1.1"===d?this._getCoverage110Parameters(e,s,n,o,l):this._getCoverage100Parameters(e,s,n,o),u="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:o.signal,responseType:"array-buffer"});if("1.0"===d)return u.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const f=c(u);if(f.isMultipart&&f.data){const e=f.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",C,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,s){const n=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,r=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=s,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:u}=s;let h;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),h=t.map((e=>I(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${r}`,bbox:n,width:t,height:i,time:h,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,s,n){const{multidimensionalDefinition:r,bandIds:a,interpolation:l}=s,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(l),h=w[u],f=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=n.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=g.useEPSGAxis&&o(c),b=C?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,$=this.ioConfig.use2GridOffsets,S=C?$?`${y},${v}`:`${y},0,0,${v}`:$?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,_=Math.abs(y)/2,R=e.ymin+_,D=e.ymax-_,E=C?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,P=n.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let A,G=P&&h&&a?f?`${P.identifier}[${P.axis[0].identifier}[${a.join(",")}]]`:`${P.identifier}:${h}[${P.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=r&&r.length)for(let o=0;o<r.length;o++){let e=r[o].values;const t=r[o].dimensionName?.toLowerCase(),i=r[o].variableName?.toLowerCase();if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)A=e.map((e=>I(e))).join(",");else{const s=n.range.find((e=>e.identifier.toLowerCase()===i));if(s){const i=s.axis.find((e=>e.identifier.toLowerCase()===t));i&&(G=f?s.identifier+"["+i.identifier+"["+e.join(",")+"]]":s.identifier+":"+h+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:b,gridOffsets:S,gridBaseCRS:d,timeSequence:A,rangeSubset:G}}_getCoverage201Parameters(e,t,i,s,n,r){const{multidimensionalDefinition:o,interpolation:a}=n,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:h,domainSet:f,rangeType:g}=r,m=h.isEastFirst?0:1,w=1-m,{axisLabels:v}=h,y=v[m],x=v[w],C=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,b=C,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=f.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=I(e,!0)),$.push(v[D]+",http://www.opengis.net("+t+")")}else $.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=o&&o.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<o.length;i++){const s=v.find((e=>e===o[i].dimensionName)),n=e.find((e=>e===o[i].variableName));if(t.includes(n)||t.push(n),s){let e=o[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=s.toLowerCase().includes("time")?e.map((e=>I(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(s+",http://www.opengis.net")));-1===i&&$.push(s+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,s+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(n.bandIds?n.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),L=!r.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=L?null:`${y}(${t}),${x}(${i})`,R=L?1/s:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:_,scaleFactor:R,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:C,subsettingcrs:b}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const s=t[e];null!=s&&("subset"===e?"string"==typeof s&&s.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(s)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};function I(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}e([n({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([n({readOnly:!0})],b.prototype,"tileType",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),b=e([r("esri.layers.support.rasterDatasets.WCSRaster")],b);const $=b;export{$ as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e}from"../../../core/arrayUtils.js";import n from"../DimensionalDefinition.js";function t(e,n,
|
|
5
|
+
import{isSome as e}from"../../../core/arrayUtils.js";import n from"../DimensionalDefinition.js";function t(e,n,a){const i=n.shift();if(0===a.length){const e=[];a.push({sliceId:-1,multidimensionalDefinition:e})}const s=a.length;for(let t=0;t<s;t++){const n=a.shift().multidimensionalDefinition;i.values?.forEach((t=>{a.push({sliceId:-1,multidimensionalDefinition:[...n,{variableName:e,dimensionName:i.name,values:[t]}]})}))}n.length&&t(e,n,a)}function a(e,n){const a=[];let i=0;return(n?e.variables.filter((e=>e.name.toLowerCase()===n.toLowerCase())):[...e.variables].sort(((e,n)=>e.name>n.name?1:-1))).forEach((e=>{const n=[],s=[...e.dimensions].sort(((e,n)=>e.name>n.name?-1:1));t(e.name,s,n),n.forEach((e=>{a.push({...e,sliceId:i++})}))})),a}function i(e,n,t){let a=e;if(n&&(n=[...n].sort(((e,n)=>e.dimensionName<n.dimensionName?-1:1))).forEach((({dimensionName:e,values:n,isSlice:t})=>{n.length&&(a=a.filter((a=>{const i=a.multidimensionalDefinition.find((n=>n.dimensionName===e));if(null==i)return!1;const s=i.values[0];return"number"==typeof s?"number"==typeof n[0]?n.includes(s):n.some((e=>e[0]<=s&&e[1]>=s)):"number"==typeof n[0]?n.some((e=>s[0]<=e&&s[1]>=e)):t?n.some((e=>e[0]===s[0]&&e[0]===s[1])):n.some((e=>e[0]>=s[0]&&e[0]<=s[1]||e[1]>=s[0]&&e[1]<=s[1]||e[0]<s[0]&&e[1]>s[1]))})))})),a.length&&null!=t?.start&&null!=t.end){const e=t.start.getTime(),n=t.end.getTime(),i=a[0].multidimensionalDefinition.findIndex((e=>"StdTime"===e.dimensionName));i>-1&&(a=a.filter((t=>{const a=t.multidimensionalDefinition[i].values[0];return e<=a&&n>=a})))}return a.map((e=>e.sliceId))}function s(e,n){return Array.isArray(e)?n[0]===n[1]?e[0]===n[0]||e[1]===n[0]:e[0]>=n[0]&&e[0]<=n[1]&&e[1]>=n[0]&&e[1]<=n[1]:e>=n[0]&&e<=n[1]}function r(e,n){return e[0]<=n[0]&&e[1]>=n[0]||e[0]<=n[1]&&e[1]>=n[1]||e[0]>=n[0]&&e[1]<=n[1]}function l(e){return 1===e.length?[e[0],e[0]]:[e[0],e[e.length-1]]}function u(e,n,t){if(!n?.subsetDefinitions?.length)return e;let a;if(t){const{variables:i}=n;if(i.length&&!i.includes(t))return null;const s=n.subsetDefinitions.find((n=>n.dimensionName===e.name&&n.variableName===t));if(!s?.values?.length)return e;a=l(s.values)}else{const t=n.dimensions.find((({name:n})=>n===e.name));a=t?.extent}const i=a;if(!i?.length)return e;const r=e.values.filter((e=>s(e,i)));return{...e,extent:[...i],values:r}}function o(e,n,t){if(!n?.subsetDefinitions?.length)return!1;const{variables:a}=n;if(a.length&&e.some((({variableName:e})=>e&&!a.includes(e))))return!0;for(let i=0;i<e.length;i++){const a=e[i],u=n.subsetDefinitions.find((e=>(""===a.variableName||e.variableName===a.variableName)&&e.dimensionName===a.dimensionName));if(u?.values.length){const e=l(u.values);if(!a.isSlice&&2===a.values.length&&!Array.isArray(a.values[0])&&a.values[0]!==a.values[1]&&t){if(!r(a.values,e))return!0}else if(a.values.some((n=>!s(n,e))))return!0}}return!1}function m(e,n){if(null==e)return{isOutside:!1};const{geometry:t,timeExtent:a,multidimensionalDefinition:i}=n;let s=null;if(null!=a&&(s=c(e,a),null==s))return{isOutside:!0};const{areaOfInterest:r}=e;if(r&&t){const e="point"===t.type?t:"extent"===t.type?t.center:"polygon"===t.type?t.centroid:null;if(e&&!r.contains(e))return{isOutside:!0}}return null!=i&&i.length&&o(i,e,!0)?{isOutside:!0}:{isOutside:!1,intersection:{geometry:t,timeExtent:s,multidimensionalDefinition:i}}}function c(e,t){const a=e.dimensions.find((({name:e})=>"StdTime"===e));if(null==a||null==t.start&&null==t.end)return t;t=t.clone();const{start:i,end:s}=t.toJSON(),r=i===s?[i]:null!=i&&null!=s?[i,s]:[i??s];if(2===r.length&&a?.extent.length&&(r[0]=Math.max(r[0],a.extent[0]),r[1]=Math.min(r[1],a.extent[1]??a.extent[0]),r[1]<r[0]))return null;return o([new n({variableName:"",dimensionName:"StdTime",isSlice:1===r.length,values:r})],e,!0)?null:(t.start=new Date(r[0]),t.end=new Date(r[1]??r[0]),t)}function f(e,n={}){const{multidimensionalInfo:t,keyProperties:a}=e;if(null==t)return null;const{variableName:i,multidimensionalSubset:s,multidimensionalDefinition:r}=n,l=null!=r?r[0]?.variableName:null,u=i||l||a?.DefaultVariable;let{variables:o}=t;s?.variables?.length&&(o=o.filter((({name:e})=>s.variables.includes(e))));return u?o.find((({name:e})=>e===u))??o[0]:o[0]}function d(e,t={}){const a=f(e,t);if(!a)return null;const i=[],{dimensions:s,name:r}=a;if(0===s.length)return[new n({variableName:r,dimensionName:"",values:[],isSlice:!0})];for(let l=0;l<s.length;l++){const e=u(s[l],t.multidimensionalSubset,r);if(!e)return null;const{values:a,extent:o}=e;let m=a?.[0]??o?.[0];"stdz"===e.name.toLowerCase()&&!e.hasRanges&&o&&Math.abs(o[1])<=Math.abs(o[0])&&(m=a?.length?a[a.length-1]:o[1]),i.push(new n({variableName:r,dimensionName:e.name,values:[m],isSlice:!t.useRangeForRangedDimensionInfo||!!e.hasRanges}))}return i}function h(e){return!!e?.length&&e.some((e=>{if(null==e.values)return!0;const n=e.values.length;return 0===n||n>1||!e.isSlice&&Array.isArray(e.values[0])}))}function g(n,t){if(null==t||null==n)return null;let a=t.variables.map((e=>({...e})));return n?.variables?.length&&(a=a.filter((({name:e})=>n.variables.includes(e))),a.forEach((t=>{t.dimensions=t.dimensions.map((e=>u(e,n,t.name))).filter(e)}))),a}function v(e,n){const{values:t}=n;if(t?.length){const n=Array.isArray(t[0]),a=Array.isArray(e);return n!==a?-1:n&&a?t.findIndex((n=>n[0]===e[0]&&n[1]===e[1])):t.indexOf(e)}const{extent:a}=n;if(Array.isArray(e)||!a||e<a[0]||e>a[1])return-1;const i=n.interval||1;if("ISO8601"!==n.unit)return Math.round((e-a[0])/i);const s=a[0];let r=-1;switch(n.intervalUnit?.toLowerCase()||"days"){case"seconds":r=Math.round((e-s)/1e3/i);break;case"minutes":r=Math.round((e-s)/6e4/i);break;case"hours":r=Math.round((e-s)/36e5/i);break;case"days":r=Math.round((e-s)/864e5/i);break;case"months":{const n=new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear(),t=new Date(s).getUTCMonth(),a=new Date(e).getUTCMonth();r=0===n?a-t:a+11-t+12*(n-1)}break;case"years":r=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/i);break;case"decades":r=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/10/i)}return r}function b(e){let n=e.values?.length;if(n)return n;const{extent:t,unit:a}=e,i=e.interval||1,s=t?t[1]-t[0]:0;if("ISO8601"!==a)return Math.round(s/i);switch(e.intervalUnit?.toLowerCase()??"seconds"){case"seconds":n=Math.round(s/1e3/i);break;case"minutes":n=Math.round(s/6e4/i);break;case"hours":n=Math.round(s/36e5/i);break;case"days":n=Math.round(s/864e5/i);break;case"months":if(t){const e=new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear(),a=new Date(t[0]).getUTCMonth(),i=new Date(t[1]).getUTCMonth();n=0===e?i-a+1:i+11-a+12*(e-1)+1}else n=0;break;case"years":n=t?Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/i):0;break;case"decades":n=t?Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/10/i):0;break;default:n=0}return n}function D(e){if(2!==e.extent?.length||!e.interval)return[];const{extent:[n,t],interval:a}=e;if("ISO8601"===e.unit){const i=e.intervalUnit?.toLowerCase()??"days";return["decades","years","months","days","hours","minutes","seconds"].includes(i)?y(n,t,a,i):[]}const i=Math.round((t-n)/a);return Array.from({length:i},((e,s)=>s===i-1?t:n+s*a))}function y(e,n,t,a){const i=[];let s=e;const r=new Date(e);for(;s<=n;)switch(i.push(s),a){case"decades":r.setUTCFullYear(r.getUTCFullYear()+10*t),s=r.getTime();break;case"years":r.setUTCFullYear(r.getUTCFullYear()+t),s=r.getTime();break;case"months":r.setUTCMonth(r.getUTCMonth()+t),s=r.getTime();break;case"days":s+=864e5*t;break;case"hours":s+=36e5*t;break;case"minutes":s+=6e4*t;break;case"seconds":s+=1e3*t}return 1===i.length?i[1]=n:i[i.length-1]=n,i}function w(e,n){let t=0;const a=e[0].variableName,i=[...n.variables].sort(((e,n)=>e.name>n.name?1:-1));for(let s=0;s<i.length;s++){const n=i[s],r=[...n.dimensions].sort(((e,n)=>e.name>n.name?-1:1));if(n.name!==a){t+=r.map((e=>b(e))).reduce(((e,n)=>e*n));continue}const l=r.map((e=>b(e))),u=r.length;for(let a=0;a<u;a++){const n=e.find((e=>e.dimensionName===r[a].name));if(null==n)return null;const i=v(n.values[0],r[a]);if(-1===i)return null;l.shift(),t+=a===u-1?i:i*l.reduce(((e,n)=>e*n))}break}return t}export{a as createSlices,d as getDefaultMultidimensionalDefinition,f as getDefaultVariableInfo,D as getDimensionValues,i as getSliceIds,w as getSliceIndex,g as getSubsetVariablesFromMdInfo,y as getTimeDimensionValues,o as hasExcludedVariableOrDimension,m as intersectMultimensionalSubset,h as isMultiSliceOrRangeDefinition};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../geometry/Extent.js";import t from"../../../geometry/Polygon.js";import{isAxesOrderReversedForWkid as n}from"../../ogc/crsUtils.js";import i from"../RasterInfo.js";import{getElements as s,isSameTagIgnoreNS as a,getElementValue as o,getElementValues as l,getNodeNameIgnoreNS as r,getElement as u,getSpaceDelimitedNumericValues as m}from"./xmlUtilities.js";function p(e){return{requestResponseCRSs:l(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:l(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function c(e,t){const n=l(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):o(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function d(e){return null==e?["nearest"]:e.map((e=>{const t=e.toLowerCase();return t.includes("nearest")?"nearest":t.includes("linear")?"bilinear":t.includes("cubic")?"cubic":null})).filter((e=>!!e))}function f(t){const n=s(t,"pos"),i=m(n[0]),a=m(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:4326}})}function g(e,t){const n=l(e,t);return n?.length&&""!==n[0]&&!isNaN(Number(n[0]))?n.map((e=>Number(e))):null}function h(e){const t=m(e,"MinimumValue"),n=m(e,"MaximumValue");return t.length&&n.length?t.map(((e,t)=>({min:e,max:n[t],avg:-1,stddev:-1}))):null}function b(e){return null==e?null:e.every((t=>t===e[0]))?e[0]:e}function x(e){const t=[],n=s(e,"RangeSet");let i=[];for(let a=0;a<n.length;a++){const e=o(n[a],"name"),r=o(n[a],"label"),u=[],m=g(n[a],"nullValues/singleValue"),p=s(n[a],"AxisDescription");for(let t=0;t<p.length;t++){const e=o(p[t],"name"),n=o(p[t],"label"),s=l(p[t],"singleValue");if(0===s.length){const e=o(p[t],"min"),n=o(p[t],"max"),i=Number(o(p[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)s.push(t.toString())}"band"===e.toLowerCase()&&(i=s),u.push({name:e,label:n,values:s})}t.push({name:e,label:r,nullValues:m,axis:u})}return{rangeSet:t,bandNames:i}}function v(e=null){if(!e)return{resolution:null,units:null};let t=e.toUpperCase();const n=["Y","M","D"],i=["H","M","S"],s=["Years","Months","Days","Hours","Minutes","Seconds"];let a,o,l;return t.includes("PT")?(t=t.slice(2),l=i.findIndex((e=>t.includes(e))),a=s[3+l],o=parseFloat(t.substring(0,t.length-1))):(t=t.slice(1),l=n.findIndex((e=>t.includes(e))),l>-1&&(a=s[l]),o=parseFloat(t.substring(0,t.length-1))),{resolution:o,units:a}}function D(e){const t=s(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(o(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=u(e,"timePeriod")||u(e,"TimePeriod");if(n){return{begin:new Date(o(n,"beginPosition")||o(n,"BeginPosition")),end:new Date(o(n,"endPosition")||o(n,"EndPosition")),...v(o(n,"timeResolution")||o(n,"TimeResolution"))}}return null}function w(t){const n=u(t,"spatialDomain"),i=u(n,"Envelope")||u(n,"EnvelopeWithTimePeriod"),a=i.getAttribute("srsName").split(":"),l=a[a.length-1],r=s(i,"pos"),p=m(r[0]),c=m(r[1]),d=parseInt(l,10),f=isNaN(d)?null:{wkid:d},g=new e({xmin:p[0],ymin:p[1],xmax:c[0],ymax:c[1],spatialReference:f}),h=u(n,"RectifiedGrid"),b=o(h,"low").split(" "),x=o(h,"high").split(" "),v=parseInt(x[0],10)-parseInt(b[0],10)+1,w=parseInt(x[1],10)-parseInt(b[1],10)+1,y=m(n,"origin/pos"),S=s(n,"offsetVector"),L={envelope:g,columns:v,rows:w,offset:{x:parseFloat(o(S[0]).split(" ")[0]),y:parseFloat(o(S[1]).split(" ")[1])},origin:{x:y[0],y:y[1]}},I=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:L,temporalDomain:I?D(I):null}}function y(e){const t={version:"1.0"};let n,s=[];for(let i=0;i<e.childNodes.length;i++){const r=e.childNodes[i];if(1===r.nodeType)if(a(r,"description"))t.description=o(r);else if(a(r,"name"))t.name=o(r);else if(a(r,"label"))t.label=o(r);else if(a(r,"supportedFormats"))t.supportedFormats=l(r,"formats");else if(a(r,"supportedCRSs"))t.supportedCRSs=p(r);else if(a(r,"supportedInterpolations"))t.supportedInterpolations=c(r,"1.0.0");else if(a(r,"lonLatEnvelope"))t.lonLatEnvelope=f(r);else if(a(r,"rangeSet")){const e=x(r);t.rangeSet=e.rangeSet,s=e.bandNames;const i=e.rangeSet[0].nullValues;i?.length&&(n=b(i))}else a(r,"domainSet")&&(t.domainSet=w(r))}const r=d(t.supportedInterpolations),{name:u,description:m,label:g,lonLatEnvelope:h,supportedFormats:v}=t,{spatialDomain:D}=t.domainSet,y={x:Math.abs(D.offset.x),y:Math.abs(D.offset.y)},L=S(t.domainSet),I=new i({width:D.columns,height:D.rows,pixelSize:y,extent:D.envelope,spatialReference:D.envelope.spatialReference,bandCount:s.length||1,noDataValue:n,multidimensionalInfo:L});return{id:u,title:t.name,description:m||g,lonLatEnvelope:h,rasterInfo:I,bandNames:s,supportedFormats:v,supportedInterpolations:r,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function S(e){if(!e.temporalDomain)return null;const{begin:t,end:n,values:i,units:s,resolution:a}=e.temporalDomain;return{variables:[{name:"default",description:"",dimensions:[{name:"StdTime",description:"",unit:"ISO8601",values:i?.map((e=>e.getTime())),hasRegularIntervals:!i,interval:a,intervalUnit:s,extent:[t.getTime(),n.getTime()]}]}]}}function L(e,t){const n=[],i=s(e,"Field");let a,r=[];for(let m=0;m<i.length;m++){const e=o(i[m],"Identifier"),p=o(i[m],"Description"),d=o(i[m],"Definition"),f=o(i[m],"Abstract"),b=o(i[m],"Title"),x=g(i[m],"NullValue"),v=u(i[m],"AllowedValues"),D=v?h(v):null,w=c(i[m],"1.1.0"),y=[],S=s(i[m],"Axis");for(let n=0;n<S.length;n++){const e=S[n].getAttribute("identifier"),i=o(S[n],"UOM"),s=o(S[n],"DataType"),u=l(S[n],"Key");t&&!e.toLowerCase().includes("band")||(r=u,a=x),y.push({identifier:e,uom:i,dataType:s,values:u,bandNoDataValues:a})}n.push({identifier:e,description:p,definition:d,abstract:f,title:b,supportedInterpolations:w,axis:y,nullValues:x,statistics:D})}return{rangeSet:n,bandNames:r,bandNoDataValues:a,statistics:n[0].statistics}}function I(e,t){if(!t.temporalDomain)return null;const n=e.filter((e=>!e.identifier.toLowerCase().includes("field_1")&&!e.axis.some((e=>e.identifier.includes("band"))))),i=[];if(n.length&&n.forEach((e=>{const t=e.axis.map((e=>{const t=e.values.map((t=>{if("ISO8601"===e.uom){return(t=t.trim()).toLowerCase().includes("z")?new Date(t).getTime():new Date(t+"Z").getTime()}return parseFloat(t.trim())})),n=[Math.min.apply(null,t),Math.max.apply(null,t)];return{name:e.identifier.trim(),description:"",field:e.identifier.trim(),unit:e.uom?e.uom.trim():"",hasRegularIntervals:!1,values:t,extent:n}}));i.push({name:e.identifier.trim(),description:e.description?.trim()??"",unit:"",dimensions:t,statistics:e.statistics})})),t.temporalDomain){const{begin:e,end:n,values:s,units:a,resolution:o}=t.temporalDomain;i.some((e=>e.dimensions.some((e=>"stdtime"===e.name.toLowerCase()))))||i.forEach((t=>{t.dimensions.push({name:"StdTime",description:"",unit:"ISO8601",values:s?.map((e=>e.getTime())),hasRegularIntervals:!s,interval:o,intervalUnit:a,extent:[e.getTime(),n.getTime()]})}))}return i.length?{variables:i}:null}function C(t){const i=u(t,"SpatialDomain"),a=u(i,"GridCRS"),l=o(a,"GridBaseCRS"),r=o(a,"GridOrigin"),p=r?.split(" ").map((e=>parseFloat(e)))??[0,0],c=m(a,"GridOffsets"),d=s(i,"BoundingBox");let f,g,h,b;for(let n=0;n<d.length;n++){const t=d[n].getAttribute("crs")?.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=m(d[n],"LowerCorner"),t=m(d[n],"UpperCorner");f=t[0]-e[0]+1,g=t[1]-e[1]+1}else if(t.indexOf("epsg")>0){const i=t.split(":");h=parseInt(i[i.length-1],10);const s=m(d[n],"LowerCorner"),a=m(d[n],"UpperCorner");b=new e({xmin:s[0],ymin:s[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:h}})}}const x=f>g,v=b.xmax-b.xmin>b.ymax-b.ymin;let w=!1;n(h)&&(x===v?w=!1:(w=!0,b=new e({xmin:b.ymin,ymin:b.xmin,xmax:b.ymax,ymax:b.xmax,spatialReference:{wkid:h}})));const y={columns:f,rows:g,origin:{x:p[0],y:p[1]},offset:{x:c[0],y:c[c.length-1]},gridBaseCRS:l,envelope:b,useEPSGAxis:w},S=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:y,temporalDomain:S?D(S):null}}function R(e,t){const n=[],s=[],a={supportedFormats:n,supportedCRSs:s,version:"1.1"};let l,u,m=[];for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const p=r(t).toLowerCase();switch(p){case"title":case"abstract":case"identifier":a[p]=o(t);break;case"supportedformat":{const e=o(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=o(t);s.includes(e)||s.push(e)}break;case"range":{const e=L(t,!!a.domain?.temporalDomain);a.range=e.rangeSet,m=e.bandNames;const{bandNoDataValues:n}=e;n?.length&&(l=b(n)),u=e.statistics}break;case"domain":a.domain=C(t)}}const p=d(a.range[0].supportedInterpolations),{identifier:c,abstract:f,title:g,domain:h,range:x}=a,v={x:Math.abs(h.spatialDomain.offset.x),y:Math.abs(h.spatialDomain.offset.y)},D=I(x,h);D&&(l=x[0].nullValues,1===l?.length&&(l=l[0]));const w=new i({width:h.spatialDomain.columns,height:h.spatialDomain.rows,pixelSize:v,extent:h.spatialDomain.envelope,spatialReference:h.spatialDomain.envelope.spatialReference,bandCount:m.length||1,noDataValue:l,statistics:u,multidimensionalInfo:D});return{id:c,title:a.title,description:f||g,lonLatEnvelope:null,bandNames:m,rasterInfo:w,supportedFormats:n,supportedInterpolations:p,coverageDescription:a,version:t,useEPSGAxis:h.spatialDomain.useEPSGAxis}}function T(t){const n=u(t,"Envelope")||u(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),s=i.slice(i.lastIndexOf("/")+1),l=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),r=m(n,"lowerCorner"),p=m(n,"upperCorner"),c=!["y","lat","latitude","north","nor","n","b"].includes(l[0].toLowerCase());let d;const f=parseInt(s,10),g=isNaN(f)?null:{wkid:f};d=new e(c?{xmin:r[0],ymin:r[1],xmax:p[0],ymax:p[1],spatialReference:g}:{xmin:r[1],ymin:r[0],xmax:p[1],ymax:p[0],spatialReference:g});const h={mins:r,maxs:p},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(a(n,"EnvelopeWithTimePeriod")){x=new Date(o(t,"beginPosition")||o(t,"BeginPosition")),v=new Date(o(t,"endPosition")||o(t,"EndPosition"));const e=b?.findIndex((e=>"oledatetime"===e?.toLowerCase()));e>-1&&(b[e]="ISO8601")}return{envelope:d,axisLabels:l,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:c}}function M(e,t){const n=[],i=s(e,"DataRecord"),a=[];let l,r=[];for(let p=0;p<i.length;p++){const e=s(i[p],"field"),c=[];for(let n=0;n<e.length;n++){const i=e[n].getAttribute("name"),s=o(e[n],"description")||"",p=u(e[n],"uom")?.getAttribute("code")||"",d=m(e[n],"interval"),f=g(e[n],"nilValue")?.[0];t&&!i.toLowerCase().includes("band")||(a.push(i),d?.length&&(l=l||[],l.push({min:d[0],max:d[1],avg:-1,stddev:-1})),r.push(f)),c.push({name:i,description:s,uom:p,allowedValues:d,nilValue:f})}n.push(c)}return r.some((e=>null!=e))||(r=null),{rangeType:n,bandNames:a,bandStats:l,bandNoDataValues:r}}function N(e){let t=1,n="";const i=.01;return Math.abs(e-1/24)<1/24*i?n="Hours":Math.abs(e-1)<1*i?n="Days":e<1?(t=Math.round(24*e),n="Hours"):e>28-i&&e<31+i||Math.round(e/30)<12?n="Months":e>365-i&&e<366+i&&(n="Years"),{interval:t,intervalUnit:n}}function P(e,t,n){if(n.axisLabels.length<=2)return null;const i=[];for(let a=0;a<e.length;a++){const t=e[a];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const s=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const s=(t.uomLabels?.length??0)>i?t.uomLabels?.[i]:"",a=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===s.toLowerCase()||"oledatetime"===s.toLowerCase();let o,l;if(a){const e=N(n.offset[i]);o=e.interval,l=e.intervalUnit}else o=n.offset[i],l=s;const r=[];a?(r.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),r.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(r.push(t.envelopeAllDims.mins[i]),r.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:t.uomLabels&&t.uomLabels.length>i?t.uomLabels[i].trim():"",hasRegularIntervals:!0,extent:r,interval:o,intervalUnit:l})}if(i.forEach((t=>{const{allowedValues:n}=t,i=2===n?.length?[{min:n[0],max:n[1],avg:-1,stddev:-1}]:null;s.push({name:t.name.trim(),description:t.description?.trim()??"",unit:t.uom.trim(),statistics:i,dimensions:e})})),s.length)return{variables:s}}return null}function E(e,t){const n=u(e,"RectifiedGrid"),i=m(n,"low"),a=m(n,"high"),l=[];for(let s=0;s<i.length;s++)l.push(a[s]-i[s]+1);const r=o(n,"axisLabels").split(" "),p=m(n,"origin/pos"),c=s(n,"offsetVector"),d=[];for(let s=0;s<c.length;s++){const e=m(c[s]),t=e.findIndex((e=>0!==e));d[t]=e[t]}const f=["y","lat","latitude","north","nor","n","b"];let g=!1;if(t?.length&&r?.length){g=[...t].sort(((e,t)=>e<t?-1:1)).join(",")===[...r].sort(((e,t)=>e<t?-1:1)).join(",")}const h=g?r:t;let b,x,v;return f.includes(h[0].toLowerCase())?(b=l[1],x=l[0],v={y:Math.abs(d[0]),x:Math.abs(d[1])}):(b=l[0],x=l[1],v={x:Math.abs(d[0]),y:Math.abs(d[1])}),{columns:b,rows:x,origin:p,offset:d,resolution:v,gridSamples:l,axisLabels:r,hasSameAxisLabelsAsBoundedBy:g}}function V(e){const n=u(e,"EarthObservation");if(!n)return null;const i=u(n,"phenomenonTime"),s=i?D(i):null,a=u(n,"phenomenonTime"),l=a?D(a):null,r=o(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let m=null;if(r){const e=r.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);m=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phenomenonTime:s,resultTime:l,footprint:m,identifier:o(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:o(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:o(e,"metaDataProperty/EarthObservationMetaData/status")}}}function A(e){const t={version:"2.0"};let n,s,r=[];for(let i=0;i<e.childNodes.length;i++){const m=e.childNodes[i];if(1===m.nodeType)if(a(m,"coverageId"))t.coverageId=o(m);else if(a(m,"ServiceParameters"))t.serviceParameters={supportedFormats:l(m,"nativeFormat")};else if(a(m,"boundedBy"))t.boundedBy=T(m);else if(a(m,"rangeType")){const e=M(m,t.boundedBy?.axisLabels.length>2||t.domainSet?.axisLabels.length>2);t.rangeType=e.rangeType,r=e.bandNames,n=e.bandStats;const{bandNoDataValues:i}=e;i?.length&&(s=b(i))}else if(a(m,"domainSet"))t.domainSet=E(m,t.boundedBy?.axisLabels);else if(a(m,"metadata")){const e=u(m,"EOMetadata");t.eoMetadata=e?V(e):null}}const{coverageId:m,boundedBy:p,domainSet:c,rangeType:d,serviceParameters:f}=t,g=P(d,p,c);!n&&g&&(n=g?.variables[0].statistics),null!=g&&(s=d[0][0].nilValue);return{id:m,title:m,description:m,lonLatEnvelope:null,bandNames:r,rasterInfo:new i({width:c.columns,height:c.rows,pixelSize:c.resolution,extent:p.envelope,spatialReference:p.envelope.spatialReference,bandCount:r.length||1,statistics:n,noDataValue:s,multidimensionalInfo:g}),supportedFormats:f.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function F(e,t){let n=null;if("string"==typeof e){n=(new DOMParser).parseFromString(e,"text/xml")}else n=e;if("1.0.0"===t){return s(n,"CoverageOffering").map((e=>y(e)))}const i=s(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>R(e,t))):i.map((e=>A(e)))}export{F as parseCoverages,d as standardizeInterpolations};
|
|
5
|
+
import e from"../../../geometry/Extent.js";import t from"../../../geometry/Polygon.js";import{isAxesOrderReversedForWkid as n}from"../../ogc/crsUtils.js";import i from"../RasterInfo.js";import{getDimensionValues as s}from"./multidimensionalUtils.js";import{getElements as a,isSameTagIgnoreNS as o,getElementValue as l,getElementValues as r,getNodeNameIgnoreNS as u,getElement as m,getSpaceDelimitedNumericValues as p}from"./xmlUtilities.js";function c(e){e.variables.forEach((e=>e.dimensions.forEach((e=>e.values??=s(e)))))}function d(e){return{requestResponseCRSs:r(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:r(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function f(e,t){const n=r(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):l(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function g(e){return null==e?["nearest"]:e.map((e=>{const t=e.toLowerCase();return t.includes("nearest")?"nearest":t.includes("linear")?"bilinear":t.includes("cubic")?"cubic":null})).filter((e=>!!e))}function h(t){const n=a(t,"pos"),i=p(n[0]),s=p(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:s[0],ymax:s[1],spatialReference:{wkid:4326}})}function b(e,t){const n=r(e,t);return n?.length&&""!==n[0]&&!isNaN(Number(n[0]))?n.map((e=>Number(e))):null}function x(e){const t=p(e,"MinimumValue"),n=p(e,"MaximumValue");return t.length&&n.length?t.map(((e,t)=>({min:e,max:n[t],avg:-1,stddev:-1}))):null}function v(e){return null==e?null:e.every((t=>t===e[0]))?e[0]:e}function D(e){const t=[],n=a(e,"RangeSet");let i=[];for(let s=0;s<n.length;s++){const e=l(n[s],"name"),o=l(n[s],"label"),u=[],m=b(n[s],"nullValues/singleValue"),p=a(n[s],"AxisDescription");for(let t=0;t<p.length;t++){const e=l(p[t],"name"),n=l(p[t],"label"),s=r(p[t],"singleValue");if(0===s.length){const e=l(p[t],"min"),n=l(p[t],"max"),i=Number(l(p[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)s.push(t.toString())}"band"===e.toLowerCase()&&(i=s),u.push({name:e,label:n,values:s})}t.push({name:e,label:o,nullValues:m,axis:u})}return{rangeSet:t,bandNames:i}}function w(e=null){if(!e)return{resolution:null,units:null};let t=e.toUpperCase();const n=["Y","M","D"],i=["H","M","S"],s=["Years","Months","Days","Hours","Minutes","Seconds"];let a,o,l;return t.includes("PT")?(t=t.slice(2),l=i.findIndex((e=>t.includes(e))),a=s[3+l],o=parseFloat(t.substring(0,t.length-1))):(t=t.slice(1),l=n.findIndex((e=>t.includes(e))),l>-1&&(a=s[l]),o=parseFloat(t.substring(0,t.length-1))),{resolution:o,units:a}}function y(e){const t=a(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(l(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=m(e,"timePeriod")||m(e,"TimePeriod");if(n){return{begin:new Date(l(n,"beginPosition")||l(n,"BeginPosition")),end:new Date(l(n,"endPosition")||l(n,"EndPosition")),...w(l(n,"timeResolution")||l(n,"TimeResolution"))}}return null}function S(t){const n=m(t,"spatialDomain"),i=m(n,"Envelope")||m(n,"EnvelopeWithTimePeriod"),s=i.getAttribute("srsName").split(":"),o=s[s.length-1],r=a(i,"pos"),u=p(r[0]),c=p(r[1]),d=parseInt(o,10),f=isNaN(d)?null:{wkid:d},g=new e({xmin:u[0],ymin:u[1],xmax:c[0],ymax:c[1],spatialReference:f}),h=m(n,"RectifiedGrid"),b=l(h,"low").split(" "),x=l(h,"high").split(" "),v=parseInt(x[0],10)-parseInt(b[0],10)+1,D=parseInt(x[1],10)-parseInt(b[1],10)+1,w=p(n,"origin/pos"),S=a(n,"offsetVector"),I={envelope:g,columns:v,rows:D,offset:{x:parseFloat(l(S[0]).split(" ")[0]),y:parseFloat(l(S[1]).split(" ")[1])},origin:{x:w[0],y:w[1]}},L=m(t,"temporalDomain")||m(t,"TemporalDomain");return{spatialDomain:I,temporalDomain:L?y(L):null}}function I(e){const t={version:"1.0"};let n,s=[];for(let i=0;i<e.childNodes.length;i++){const a=e.childNodes[i];if(1===a.nodeType)if(o(a,"description"))t.description=l(a);else if(o(a,"name"))t.name=l(a);else if(o(a,"label"))t.label=l(a);else if(o(a,"supportedFormats"))t.supportedFormats=r(a,"formats");else if(o(a,"supportedCRSs"))t.supportedCRSs=d(a);else if(o(a,"supportedInterpolations"))t.supportedInterpolations=f(a,"1.0.0");else if(o(a,"lonLatEnvelope"))t.lonLatEnvelope=h(a);else if(o(a,"rangeSet")){const e=D(a);t.rangeSet=e.rangeSet,s=e.bandNames;const i=e.rangeSet[0].nullValues;i?.length&&(n=v(i))}else o(a,"domainSet")&&(t.domainSet=S(a))}const a=g(t.supportedInterpolations),{name:u,description:m,label:p,lonLatEnvelope:c,supportedFormats:b}=t,{spatialDomain:x}=t.domainSet,w={x:Math.abs(x.offset.x),y:Math.abs(x.offset.y)},y=L(t.domainSet),I=new i({width:x.columns,height:x.rows,pixelSize:w,extent:x.envelope,spatialReference:x.envelope.spatialReference,bandCount:s.length||1,noDataValue:n,multidimensionalInfo:y});return{id:u,title:t.name,description:m||p,lonLatEnvelope:c,rasterInfo:I,bandNames:s,supportedFormats:b,supportedInterpolations:a,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function L(e){if(!e.temporalDomain)return null;const{begin:t,end:n,values:i,units:s,resolution:a}=e.temporalDomain,o={variables:[{name:"default",description:"",dimensions:[{name:"StdTime",description:"",unit:"ISO8601",values:i?.map((e=>e.getTime())),hasRegularIntervals:!i,interval:a,intervalUnit:s,extent:[t.getTime(),n.getTime()]}]}]};return c(o),o}function C(e,t){const n=[],i=a(e,"Field");let s,o=[];for(let u=0;u<i.length;u++){const e=l(i[u],"Identifier"),p=l(i[u],"Description"),c=l(i[u],"Definition"),d=l(i[u],"Abstract"),g=l(i[u],"Title"),h=b(i[u],"NullValue"),v=m(i[u],"AllowedValues"),D=v?x(v):null,w=f(i[u],"1.1.0"),y=[],S=a(i[u],"Axis");for(let n=0;n<S.length;n++){const e=S[n].getAttribute("identifier"),i=l(S[n],"UOM"),a=l(S[n],"DataType"),u=r(S[n],"Key");t&&!e.toLowerCase().includes("band")||(o=u,s=h),y.push({identifier:e,uom:i,dataType:a,values:u,bandNoDataValues:s})}n.push({identifier:e,description:p,definition:c,abstract:d,title:g,supportedInterpolations:w,axis:y,nullValues:h,statistics:D})}return{rangeSet:n,bandNames:o,bandNoDataValues:s,statistics:n[0].statistics}}function R(e,t){if(!t.temporalDomain)return null;const n=e.filter((e=>!e.identifier.toLowerCase().includes("field_1")&&!e.axis.some((e=>e.identifier.includes("band"))))),i=[];if(n.length&&n.forEach((e=>{const t=e.axis.map((e=>{const t=e.values.map((t=>{if("ISO8601"===e.uom){return(t=t.trim()).toLowerCase().includes("z")?new Date(t).getTime():new Date(t+"Z").getTime()}return parseFloat(t.trim())})),n=[Math.min.apply(null,t),Math.max.apply(null,t)];return{name:e.identifier.trim(),description:"",field:e.identifier.trim(),unit:e.uom?e.uom.trim():"",hasRegularIntervals:!1,values:t,extent:n}}));i.push({name:e.identifier.trim(),description:e.description?.trim()??"",unit:"",dimensions:t,statistics:e.statistics})})),t.temporalDomain){const{begin:e,end:n,values:s,units:a,resolution:o}=t.temporalDomain;i.some((e=>e.dimensions.some((e=>"stdtime"===e.name.toLowerCase()))))||i.forEach((t=>{t.dimensions.push({name:"StdTime",description:"",unit:"ISO8601",values:s?.map((e=>e.getTime())),hasRegularIntervals:!s,interval:o,intervalUnit:a,extent:[e.getTime(),n.getTime()]})}))}if(i.length){const e={variables:i};return c(e),e}return null}function T(t){const i=m(t,"SpatialDomain"),s=m(i,"GridCRS"),o=l(s,"GridBaseCRS"),r=l(s,"GridOrigin"),u=r?.split(" ").map((e=>parseFloat(e)))??[0,0],c=p(s,"GridOffsets"),d=a(i,"BoundingBox");let f,g,h,b;for(let n=0;n<d.length;n++){const t=d[n].getAttribute("crs")?.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=p(d[n],"LowerCorner"),t=p(d[n],"UpperCorner");f=t[0]-e[0]+1,g=t[1]-e[1]+1}else if(t.indexOf("epsg")>0){const i=t.split(":");h=parseInt(i[i.length-1],10);const s=p(d[n],"LowerCorner"),a=p(d[n],"UpperCorner");b=new e({xmin:s[0],ymin:s[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:h}})}}const x=f>g,v=b.xmax-b.xmin>b.ymax-b.ymin;let D=!1;n(h)&&(x===v?D=!1:(D=!0,b=new e({xmin:b.ymin,ymin:b.xmin,xmax:b.ymax,ymax:b.xmax,spatialReference:{wkid:h}})));const w={columns:f,rows:g,origin:{x:u[0],y:u[1]},offset:{x:c[0],y:c[c.length-1]},gridBaseCRS:o,envelope:b,useEPSGAxis:D},S=m(t,"temporalDomain")||m(t,"TemporalDomain");return{spatialDomain:w,temporalDomain:S?y(S):null}}function M(e,t){const n=[],s=[],a={supportedFormats:n,supportedCRSs:s,version:"1.1"};let o,r,m=[];for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const p=u(t).toLowerCase();switch(p){case"title":case"abstract":case"identifier":a[p]=l(t);break;case"supportedformat":{const e=l(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=l(t);s.includes(e)||s.push(e)}break;case"range":{const e=C(t,!!a.domain?.temporalDomain);a.range=e.rangeSet,m=e.bandNames;const{bandNoDataValues:n}=e;n?.length&&(o=v(n)),r=e.statistics}break;case"domain":a.domain=T(t)}}const p=g(a.range[0].supportedInterpolations),{identifier:c,abstract:d,title:f,domain:h,range:b}=a,x={x:Math.abs(h.spatialDomain.offset.x),y:Math.abs(h.spatialDomain.offset.y)},D=R(b,h);D&&(o=b[0].nullValues,1===o?.length&&(o=o[0]));const w=new i({width:h.spatialDomain.columns,height:h.spatialDomain.rows,pixelSize:x,extent:h.spatialDomain.envelope,spatialReference:h.spatialDomain.envelope.spatialReference,bandCount:m.length||1,noDataValue:o,statistics:r,multidimensionalInfo:D});return{id:c,title:a.title,description:d||f,lonLatEnvelope:null,bandNames:m,rasterInfo:w,supportedFormats:n,supportedInterpolations:p,coverageDescription:a,version:t,useEPSGAxis:h.spatialDomain.useEPSGAxis}}function N(t){const n=m(t,"Envelope")||m(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),s=i.slice(i.lastIndexOf("/")+1),a=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),r=p(n,"lowerCorner"),u=p(n,"upperCorner"),c=!["y","lat","latitude","north","nor","n","b"].includes(a[0].toLowerCase());let d;const f=parseInt(s,10),g=isNaN(f)?null:{wkid:f};d=new e(c?{xmin:r[0],ymin:r[1],xmax:u[0],ymax:u[1],spatialReference:g}:{xmin:r[1],ymin:r[0],xmax:u[1],ymax:u[0],spatialReference:g});const h={mins:r,maxs:u},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(o(n,"EnvelopeWithTimePeriod")){x=new Date(l(t,"beginPosition")||l(t,"BeginPosition")),v=new Date(l(t,"endPosition")||l(t,"EndPosition"));const e=b?.findIndex((e=>"oledatetime"===e?.toLowerCase()));e>-1&&(b[e]="ISO8601")}return{envelope:d,axisLabels:a,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:c}}function E(e,t){const n=[],i=a(e,"DataRecord"),s=[];let o,r=[];for(let u=0;u<i.length;u++){const e=a(i[u],"field"),c=[];for(let n=0;n<e.length;n++){const i=e[n].getAttribute("name"),a=l(e[n],"description")||"",u=m(e[n],"uom")?.getAttribute("code")||"",d=p(e[n],"interval"),f=b(e[n],"nilValue")?.[0];t&&!i.toLowerCase().includes("band")||(s.push(i),d?.length&&(o=o||[],o.push({min:d[0],max:d[1],avg:-1,stddev:-1})),r.push(f)),c.push({name:i,description:a,uom:u,allowedValues:d,nilValue:f})}n.push(c)}return r.some((e=>null!=e))||(r=null),{rangeType:n,bandNames:s,bandStats:o,bandNoDataValues:r}}function P(e){let t=1,n="";const i=.01;return Math.abs(e-1/24)<1/24*i?n="Hours":Math.abs(e-1)<1*i?n="Days":e<1?(t=Math.round(24*e),n="Hours"):e>28-i&&e<31+i||Math.round(e/30)<12?n="Months":e>365-i&&e<366+i&&(n="Years"),{interval:t,intervalUnit:n}}function V(e,t,n){if(n.axisLabels.length<=2)return null;const i=[];for(let a=0;a<e.length;a++){const t=e[a];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const s=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const s=t.uomLabels?.[i]?.trim()??"",a=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===s.toLowerCase()||"oledatetime"===s.toLowerCase();let o,l;if(a){const e=P(n.offset[i]);o=e.interval,l=e.intervalUnit}else o=n.offset[i],l=s;const r=[];a?(r.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),r.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(r.push(t.envelopeAllDims.mins[i]),r.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:a?"ISO8601":s,hasRegularIntervals:!0,extent:r,interval:o,intervalUnit:l})}if(i.forEach((t=>{const{allowedValues:n}=t,i=2===n?.length?[{min:n[0],max:n[1],avg:-1,stddev:-1}]:null;s.push({name:t.name.trim(),description:t.description?.trim()??"",unit:t.uom.trim(),statistics:i,dimensions:e})})),s.length){const e={variables:s};return c(e),e}}return null}function A(e,t){const n=m(e,"RectifiedGrid"),i=p(n,"low"),s=p(n,"high"),o=[];for(let a=0;a<i.length;a++)o.push(s[a]-i[a]+1);const r=l(n,"axisLabels").split(" "),u=p(n,"origin/pos"),c=a(n,"offsetVector"),d=[];for(let a=0;a<c.length;a++){const e=p(c[a]),t=e.findIndex((e=>0!==e));d[t]=e[t]}const f=["y","lat","latitude","north","nor","n","b"];let g=!1;if(t?.length&&r?.length){g=[...t].sort(((e,t)=>e<t?-1:1)).join(",")===[...r].sort(((e,t)=>e<t?-1:1)).join(",")}const h=g?r:t;let b,x,v;return f.includes(h[0].toLowerCase())?(b=o[1],x=o[0],v={y:Math.abs(d[0]),x:Math.abs(d[1])}):(b=o[0],x=o[1],v={x:Math.abs(d[0]),y:Math.abs(d[1])}),{columns:b,rows:x,origin:u,offset:d,resolution:v,gridSamples:o,axisLabels:r,hasSameAxisLabelsAsBoundedBy:g}}function F(e){const n=m(e,"EarthObservation");if(!n)return null;const i=m(n,"phenomenonTime"),s=i?y(i):null,a=m(n,"phenomenonTime"),o=a?y(a):null,r=l(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let u=null;if(r){const e=r.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);u=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phenomenonTime:s,resultTime:o,footprint:u,identifier:l(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:l(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:l(e,"metaDataProperty/EarthObservationMetaData/status")}}}function O(e){const t={version:"2.0"};let n,s,a=[];for(let i=0;i<e.childNodes.length;i++){const u=e.childNodes[i];if(1===u.nodeType)if(o(u,"coverageId"))t.coverageId=l(u);else if(o(u,"ServiceParameters"))t.serviceParameters={supportedFormats:r(u,"nativeFormat")};else if(o(u,"boundedBy"))t.boundedBy=N(u);else if(o(u,"rangeType")){const e=E(u,t.boundedBy?.axisLabels.length>2||t.domainSet?.axisLabels.length>2);t.rangeType=e.rangeType,a=e.bandNames,n=e.bandStats;const{bandNoDataValues:i}=e;i?.length&&(s=v(i))}else if(o(u,"domainSet"))t.domainSet=A(u,t.boundedBy?.axisLabels);else if(o(u,"metadata")){const e=m(u,"EOMetadata");t.eoMetadata=e?F(e):null}}const{coverageId:u,boundedBy:p,domainSet:c,rangeType:d,serviceParameters:f}=t,g=V(d,p,c);!n&&g&&(n=g?.variables[0].statistics),null!=g&&(s=d[0][0].nilValue);return{id:u,title:u,description:u,lonLatEnvelope:null,bandNames:a,rasterInfo:new i({width:c.columns,height:c.rows,pixelSize:c.resolution,extent:p.envelope,spatialReference:p.envelope.spatialReference,bandCount:a.length||1,statistics:n,noDataValue:s,multidimensionalInfo:g}),supportedFormats:f.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function B(e,t){let n=null;if("string"==typeof e){n=(new DOMParser).parseFromString(e,"text/xml")}else n=e;if("1.0.0"===t){return a(n,"CoverageOffering").map((e=>I(e)))}const i=a(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>M(e,t))):i.map((e=>O(e)))}export{B as parseCoverages,g as standardizeInterpolations};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/core",
|
|
3
|
-
"version": "4.31.0-next.
|
|
3
|
+
"version": "4.31.0-next.20240709",
|
|
4
4
|
"homepage": "https://js.arcgis.com",
|
|
5
5
|
"description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
|
|
6
6
|
"keywords": [
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"process": false
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@esri/arcgis-html-sanitizer": "~4.0.
|
|
28
|
+
"@esri/arcgis-html-sanitizer": "~4.0.3",
|
|
29
29
|
"@esri/calcite-colors": "~6.1.0",
|
|
30
30
|
"@esri/calcite-components": "^2.8.5",
|
|
31
|
-
"@vaadin/grid": "~24.3.
|
|
31
|
+
"@vaadin/grid": "~24.3.15",
|
|
32
32
|
"@zip.js/zip.js": "~2.7.45",
|
|
33
33
|
"luxon": "~3.4.4",
|
|
34
34
|
"marked": "~12.0.2",
|
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const c="20240709",e="1af9ccd72941b0a5cc6087965b9640df6e5ced6e";export{c as buildDate,e as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../core/Error.js";import"../../../../../core/has.js";import r from"../../../../../core/Logger.js";import{BindType as t}from"../../../../3d/webgl-engine/core/shaderTechnique/BindType.js";import{assert as n}from"../../../../3d/webgl-engine/lib/Util.js";const s=()=>r.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class i{constructor(){this._includedModules=new Map}include(e,r){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,r),e(this.builder,r))}}class o extends i{constructor(){super(...arguments),this.vertex=new u,this.fragment=new u,this.attributes=new m,this.varyings=new h,this.extensions=new l,this.constants=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,r=!0){const t=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,o=i.uniforms.generateSource(),a=i.code.generateSource(),c="vertex"===e?g:_(r),u=this.constants.generateSource().concat(i.constants.generateSource());return`${r?"#version 300 es":""}\n${t.join("\n")}\n${c}\n${u.join("\n")}\n${o.join("\n")}\n${n.join("\n")}\n${s.join("\n")}\n${a.join("\n")}`}generateBindPass(e){const r=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[t.Pass];n&&r.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[t.Pass];n&&r.set(e.name,n)}));const n=Array.from(r.values()),s=n.length;return(r,t)=>{for(let i=0;i<s;++i)n[i](e,r,t)}}generateBindDraw(e){const r=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[t.Draw];n&&r.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[t.Draw];n&&r.set(e.name,n)}));const n=Array.from(r.values()),s=n.length;return(r,t,i)=>{for(let o=0;o<s;++o)n[o](e,r,t
|
|
5
|
+
import e from"../../../../../core/Error.js";import"../../../../../core/has.js";import r from"../../../../../core/Logger.js";import{BindType as t}from"../../../../3d/webgl-engine/core/shaderTechnique/BindType.js";import{assert as n}from"../../../../3d/webgl-engine/lib/Util.js";const s=()=>r.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class i{constructor(){this._includedModules=new Map}include(e,r){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,r),e(this.builder,r))}}class o extends i{constructor(){super(...arguments),this.vertex=new u,this.fragment=new u,this.attributes=new m,this.varyings=new h,this.extensions=new l,this.constants=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,r=!0){const t=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,o=i.uniforms.generateSource(),a=i.code.generateSource(),c="vertex"===e?g:_(r),u=this.constants.generateSource().concat(i.constants.generateSource());return`${r?"#version 300 es":""}\n${t.join("\n")}\n${c}\n${u.join("\n")}\n${o.join("\n")}\n${n.join("\n")}\n${s.join("\n")}\n${a.join("\n")}`}generateBindPass(e){const r=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[t.Pass];n&&r.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[t.Pass];n&&r.set(e.name,n)}));const n=Array.from(r.values()),s=n.length;return(r,t)=>{for(let i=0;i<s;++i)n[i](e,r,t)}}generateBindDraw(e){const r=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[t.Draw];n&&r.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[t.Draw];n&&r.set(e.name,n)}));const n=Array.from(r.values()),s=n.length;return(r,t,i)=>{for(let o=0;o<s;++o)n[o](e,i,r,t)}}}class a{constructor(){this._entries=new Map}add(...e){for(const r of e)this._add(r)}get(e){return this._entries.get(e)}_add(r){if(null!=r){if(this._entries.has(r.name)&&!this._entries.get(r.name).equals(r))throw new e(`Duplicate uniform name ${r.name} for different uniform type`);this._entries.set(r.name,r)}else s().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((e=>null!=e.arraySize?`uniform ${e.type} ${e.name}[${e.arraySize}];`:`uniform ${e.type} ${e.name};`))}get entries(){return Array.from(this._entries.values())}}class c{constructor(){this._entries=new Array}add(e){this._entries.push(e)}generateSource(){return this._entries}}class u extends i{constructor(){super(...arguments),this.uniforms=new a,this.code=new c,this.constants=new d}get builder(){return this}}class m{constructor(){this._entries=new Array}add(e,r){this._entries.push([e,r])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class h{constructor(){this._entries=new Map}add(e,r){this._entries.has(e)&&n(this._entries.get(e)===r),this._entries.set(e,r)}generateSource(e){const r=new Array;return this._entries.forEach(((t,n)=>r.push("vertex"===e?`out ${t} ${n};`:`in ${t} ${n};`))),r}}class l{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const r="vertex"===e?l.ALLOWLIST_VERTEX:l.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>r.includes(e))).map((e=>`#extension ${e} : enable`))}}l.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],l.ALLOWLIST_VERTEX=[];class d{constructor(){this._entries=new Set}add(e,r,t){let n="ERROR_CONSTRUCTOR_STRING";switch(r){case"float":n=d._numberToFloatStr(t);break;case"int":n=d._numberToIntStr(t);break;case"bool":n=t.toString();break;case"vec2":n=`vec2(${d._numberToFloatStr(t[0])}, ${d._numberToFloatStr(t[1])})`;break;case"vec3":n=`vec3(${d._numberToFloatStr(t[0])}, ${d._numberToFloatStr(t[1])}, ${d._numberToFloatStr(t[2])})`;break;case"vec4":n=`vec4(${d._numberToFloatStr(t[0])}, ${d._numberToFloatStr(t[1])}, ${d._numberToFloatStr(t[2])}, ${d._numberToFloatStr(t[3])})`;break;case"ivec2":n=`ivec2(${d._numberToIntStr(t[0])}, ${d._numberToIntStr(t[1])})`;break;case"ivec3":n=`ivec3(${d._numberToIntStr(t[0])}, ${d._numberToIntStr(t[1])}, ${d._numberToIntStr(t[2])})`;break;case"ivec4":n=`ivec4(${d._numberToIntStr(t[0])}, ${d._numberToIntStr(t[1])}, ${d._numberToIntStr(t[2])}, ${d._numberToIntStr(t[3])})`;break;case"mat2":case"mat3":case"mat4":n=`${r}(${Array.prototype.map.call(t,(e=>d._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${r} ${e} = ${n};`),this}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}function _(e=!0){return`#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump sampler2D;\n#endif\n${e?"out vec4 fragColor;":""}\n`}const g="precision highp float;\nprecision highp sampler2D;";export{c as Code,i as Includes,o as ShaderBuilder2D,u as Stage,a as Uniforms};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{numericHash as t}from"../../../../../../core/string.js";import{FeatureTechniqueInstance as
|
|
5
|
+
import{numericHash as t}from"../../../../../../core/string.js";import{FeatureTechniqueInstance as n}from"./TechniqueInstance.js";import{castInstanceId as e}from"./mesh/instanceIdUtils.js";class s{constructor(){this._instanceById=new Map}destroy(){this._instanceById.clear()}get size(){return this._instanceById.size}entries(){return this._instanceById.entries()}updateStart(){this._instanceByIdNext=new Map}updateEnd(){if(!this._instanceByIdNext)throw new Error("InternalError: Found updateEnd call without corresponding updateStart");for(const t of this._instanceById.keys())this._instanceByIdNext.has(t)||this._instanceById.delete(t);for(const[t,n]of this._instanceByIdNext.entries()){const e=this._instanceById.get(t);e?e.setInput(n.getInput()):this._instanceById.set(t,n)}this._instanceByIdNext=null}values(){return this._instanceById.values()}ensureInstance(s,i){let r;if("object"==typeof i&&"optionalAttributes"in i&&"uniforms"in i){r=`${s.type}${JSON.stringify(i.optionalAttributes)}`;const t=i.uniforms;if("object"==typeof t)for(const n in t)r+=`${n}.${null!=t[n]}`}else r=`${s.type}.${JSON.stringify(i)}`;const a=t(r);if(this._instanceByIdNext){const t=new n(e(a),s,i);return this._instanceByIdNext.set(a,t),t}if(!this._instanceById.has(a)){const t=new n(e(a),s,i);this._instanceById.set(a,t)}return this._instanceById.get(a)}getInstance(t){return this._instanceById.get(t)}}export{s as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{tileSize as e,textureBindingRenderer0 as t,textureBindingRenderer1 as i}from"../../../definitions.js";import{FeatureTechnique as o}from"../FeatureTechnique.js";import{isHighlight as r,isHittest as s,getFeatureUniforms as n,getSelectionDefines as a,getFeaturePipelineState as l,getViewUniforms as d}from"../featureTechniqueUtils.js";import{TechniqueType as u}from"../TechniqueType.js";import{DotDensityPointShader as c}from"./DotDensityPointShader.js";import{DotDensityPolygonShader as p}from"./DotDensityPolygonShader.js";import{DotDensityResources as h}from"./DotDensityResources.js";import{FillShader as m}from"../shaders/FillShader.js";import{
|
|
5
|
+
import{tileSize as e,textureBindingRenderer0 as t,textureBindingRenderer1 as i}from"../../../definitions.js";import{FeatureTechnique as o}from"../FeatureTechnique.js";import{isHighlight as r,isHittest as s,getFeatureUniforms as n,getSelectionDefines as a,getFeaturePipelineState as l,getViewUniforms as d}from"../featureTechniqueUtils.js";import{TechniqueType as u}from"../TechniqueType.js";import{DotDensityPointShader as c}from"./DotDensityPointShader.js";import{DotDensityPolygonShader as p}from"./DotDensityPolygonShader.js";import{DotDensityResources as h}from"./DotDensityResources.js";import{FillShader as m}from"../shaders/FillShader.js";import{FramebufferBit as f}from"../../../../../../webgl/enums.js";class w extends o{constructor(){super(...arguments),this.type=u.DotDensity,this.shaders={polygon:new p,point:new c,fill:new m},this._resources=new Map}render(e,t){r(e)||s(e)?this._renderPolygons(e,t):this._renderDotDensity(e,t)}_renderPolygons(e,t){const{painter:i}=e;i.setShader({shader:this.shaders.fill,uniforms:{...n(e,t.target),visualVariableColor:null,visualVariableOpacity:null},defines:{...a(e)},optionalAttributes:{zoomRange:!1},useComputeBuffer:s(e)}),i.setPipelineState(l(e)),i.submitDraw(e,t)}_renderDotDensity(o,r){const{context:s,painter:u,requiredLevel:c}=o,p=r.instance.getInput().uniforms,h=this._getOrCreateResourcesRecord(s),m=h.getDotDensityTextures(s,e,p.seed),w=1/2**(c-r.target.key.level),g=e,x=g*window.devicePixelRatio*g*window.devicePixelRatio,D=1/w*(1/w),b=p.dotScale?o.state.scale/p.dotScale:1,y=p.dotValue*b*D;u.setShader({shader:this.shaders.polygon,uniforms:{...n(o,r.target),instance:{isActive:p.isActive,colors:p.colors,dotValue:Math.max(1,y)},draw:{dotTexture0:{unit:t,texture:m[0]},dotTexture1:{unit:i,texture:m[1]},tileZoomFactor:w,pixelRatio:window.devicePixelRatio,tileDotsOverArea:x/(e*window.devicePixelRatio*e*window.devicePixelRatio)}},defines:{...a(o),blending:p.blending},optionalAttributes:{},useComputeBuffer:!1}),u.setPipelineState(l(o));const P=s.getViewport();s.setViewport(0,0,e,e);const R=s.getBoundFramebufferObject(),S=h.getFBO(s);s.bindFramebuffer(S),s.setClearColor(0,0,0,0),u.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},depth:!1,stencil:!1}),u.updatePipelineState(s),s.clear(f.COLOR),u.submitDraw(o,r),s.bindFramebuffer(R),s.setViewport(P.x,P.y,P.width,P.height);const v=h.getFBO(s).colorTexture;u.setShader({shader:this.shaders.point,uniforms:{view:d(o,r.target),instance:{dotSize:p.dotSize},draw:{locations:{unit:t,texture:v},tileZoomFactor:1,pixelRatio:window.devicePixelRatio}},defines:{...a(o)},optionalAttributes:{},useComputeBuffer:!1}),u.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},depth:!1,stencil:!1}),u.submitDrawMesh(s,h.getDotDensityMesh(s))}shutdown(e){super.shutdown(e),this._resources.get(e)?.destroy(),this._resources.delete(e)}_getOrCreateResourcesRecord(e){let t=this._resources.get(e);return null==t&&(t=new h,this._resources.set(e,t)),t}}export{w as DotDensityTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{FeatureTechnique as e}from"../FeatureTechnique.js";import{isHighlight as t,isHittest as r,getFeatureUniforms as s,getSelectionDefines as i}from"../featureTechniqueUtils.js";import{TechniqueType as n}from"../TechniqueType.js";import{HeatmapResources as o}from"./HeatmapResources.js";import{HeatmapAccumulateShader as u}from"../shaders/HeatmapAccumulateShader.js";import{HeatmapResolveShader as a}from"../shaders/HeatmapResolveShader.js";import{CompareFunction as d,StencilOperation as l,
|
|
5
|
+
import{FeatureTechnique as e}from"../FeatureTechnique.js";import{isHighlight as t,isHittest as r,getFeatureUniforms as s,getSelectionDefines as i}from"../featureTechniqueUtils.js";import{TechniqueType as n}from"../TechniqueType.js";import{HeatmapResources as o}from"./HeatmapResources.js";import{HeatmapAccumulateShader as u}from"../shaders/HeatmapAccumulateShader.js";import{HeatmapResolveShader as a}from"../shaders/HeatmapResolveShader.js";import{CompareFunction as d,StencilOperation as l,FramebufferBit as c,TextureSamplingMode as h}from"../../../../../../webgl/enums.js";class p extends e{constructor(){super(...arguments),this.type=n.Heatmap,this.shaders={accumulate:new u,resolve:new a},this.postProcessingEnabled=!0,this._isBound=!1,this._resources=new Map,this.overrideStencilRef=f}shutdown(e){super.shutdown(e),this._resources.get(e)?.destroy(),this._resources.delete(e),this._prevFBO=null,this._unbind()}render(e,n){const{context:o,painter:u,state:a}=e,d=n.instance.getInput(),{isFieldActive:l}=d.uniforms,c=this._getOrCreateResourcesRecord(o),h=c.loadQualityProfile(o);if(t(e))return;r(e)||this._bind(e,c,d),u.setShader({shader:this.shaders.accumulate,uniforms:{...s(e,n.target),kernelControls:{radius:g(d,a),isFieldActive:l?1:0}},defines:{...i(e),...h.defines},optionalAttributes:{},useComputeBuffer:r(e)});const p=r(e)?w:_;u.setPipelineState(p),u.submitDraw(e,n)}postProcess(e,s){if(r(e)||t(e))return;const{context:i,painter:n}=e,o=this._resources.get(i);if(null==this._prevFBO||null==this._prevViewport||!o?.initialized)return;const{defines:u}=o.loadQualityProfile(i),{minDensity:a,maxDensity:d,radius:l}=s.getInput().uniforms,c=8,h=9,p=o.accumulateFramebuffer,m=o.resolveGradientTexture;n.setShader({shader:this.shaders.resolve,uniforms:{accumulatedDensity:{texture:{unit:c,texture:p.colorTexture},minAndInvRange:[a,1/(d-a)],normalization:3/(l*l*Math.PI)},gradient:{texture:{unit:h,texture:m}}},defines:u,optionalAttributes:{},useComputeBuffer:!1}),i.bindFramebuffer(this._prevFBO),i.setViewport(0,0,this._prevViewport.width,this._prevViewport.height),i.bindTexture(p.colorTexture,c),i.bindTexture(m,h),n.setPipelineState(b),n.submitDrawQuad(i),this._unbind()}_getOrCreateResourcesRecord(e){let t=this._resources.get(e);return null==t&&(t=new o,this._resources.set(e,t)),t}_unbind(){this._prevFBO=null,this._prevViewport=null,this._isBound=!1}_bind(e,t,r){if(this._isBound)return;const{context:s,state:i,pixelRatio:n}=e,o=s.getBoundFramebufferObject(),u=s.getViewport();this._prevFBO=o,this._prevViewport=u;const{gradient:a,gradientHash:d}=r.uniforms;t.ensureResolveGradientTexture(s,d,a);const{width:l,height:p}=u,f=m(g(r,i),n),_=l*f,w=p*f,b=t.ensureAccumulateFBO(s,_,w);s.blitFramebuffer(o,b,0,0,o.width,o.height,0,0,b.width,b.height,c.STENCIL,h.NEAREST),s.bindFramebuffer(b),s.setViewport(0,0,b.width,b.height),s.setColorMask(!0,!0,!0,!0),s.setClearColor(0,0,0,0),s.clear(c.COLOR),this._isBound=!0}}function m(e,t){const r=t>1.5?.25:.5;return e<1/(2*r)?1:r}function f(e){return e.key.level+1}const _={color:{write:[!0,!0,!0,!0],blendMode:"additive"},depth:!1,stencil:{write:!1,test:{ref:f,compare:d.GEQUAL,mask:255,op:{fail:l.KEEP,zFail:l.KEEP,zPass:l.REPLACE}}}},w={..._,stencil:!1},b={color:{write:[!0,!0,!0,!0],blendMode:"composite"},depth:!1,stencil:!1};function g(e,t){const{referenceScale:r,radius:s}=e.uniforms;return s*(0!==r?r/t.scale:1)}export{p as HeatmapTechnique};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{unitRGBAFromColor as a}from"../../../../../core/colorUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Evented.js";import o from"../../../../../core/Handles.js";import{handlesGroup as s,makeHandle as r,destroyHandle as l}from"../../../../../core/handleUtils.js";import{destroyMaybe as p,removeMaybe as d}from"../../../../../core/maybe.js";import{watch as u,initial as h,on as c}from"../../../../../core/reactiveUtils.js";import{property as m}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as g}from"../../../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as _}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as f,f as v,o as M,s as b,g as x,j as y}from"../../../../../chunks/vec32.js";import{fromValues as O,create as E}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as j}from"../../../../../core/support/UpdatingHandles.js";import I from"../../../../../geometry/Point.js";import S from"../../../../../geometry/Polyline.js";import H from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as V}from"../../../../../layers/graphics/dehydratedPoint.js";import{isVolumetricSymbol as w}from"../../../../../symbols/support/utils.js";import{Manipulator3D as T}from"../../Manipulator3D.js";import{createManipulatorMaterial as G,createManipulatorOutlineMaterial as A,placeAtObject as D}from"../../manipulatorUtils.js";import{RenderObject as L}from"../../RenderObject.js";import{SegmentLabels3D as P}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as C}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as N,screenToRenderPlaneFromEvent as U,convertToMapCoordinates as R}from"../dragEventPipeline3D.js";import{orientation as k}from"../geometryUtils.js";import{ManipulatorType as F}from"../ManipulatorType.js";import{canMoveZOperations as z}from"../manipulatorUtils.js";import{Settings as Z}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{discRadiusSmall as Y}from"../manipulations/config.js";import{ManipulationType as q,MoveManipulation as W}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as K}from"../manipulations/MoveXYObjectManipulation.js";import{createEdgeOffsetIntersectionPlane as B,createEdgeOffsetOperation as J,edgeOffsetRotationMatrix as Q,screenEdgeLengthSquared as $}from"./edgeOffsetUtils.js";import{createTooltipInfos as ee,connectTooltipToManipulatedObject as te,getUpdatedTranslateObjectTooltipInfo as ie,getUpdatedEdgeOffsetTooltipInfo as ae}from"./reshapeTooltipUtils.js";import{OutlineVisualElement as ne}from"../../visualElements/OutlineVisualElement.js";import{createExtrudedTriangle as oe,createSphereGeometry as se}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as re}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as le,addMapDelta as pe,createManipulatorDragEventPipeline as de,dragAtLocation as ue,addScreenDelta as he}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as ce,ManipulatorStateFlags as me}from"../../../../interactive/interfaces.js";import{AccumulationBehavior as ge}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as _e}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as fe}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as ve}from"../../../../interactive/tooltip/Tooltip.js";const Me=Symbol();let be=class extends t{get grabbingOrDragging(){return this._numGrabbing+this._numDragging>0}get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Ve.NONE,this._updatingHandles=new j,this._recreatingManipulators=!1,this._settings=new Z({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._vertexLaserLineVisualElement=null}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ee(this._sketchOptions,e),this._vertexManipulatorMaterial=G(a(i.color),i.renderOccluded),this._vertexManipulatorOutlineMaterial=A(a(i.outlineColor),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=A(a(i.hoverOutlineColor),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=G(a(n.color),n.renderOccluded),this._edgeManipulatorOutlineMaterial=A(a(n.outlineColor),n.renderOccluded);const o=t.edgeOffset;this._edgeOffsetManipulatorMaterial=G(a(o.color),o.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=G(a(o.hoverColor),o.renderOccluded,!1);const s=t.selected;this._selectedManipulatorMaterial=G(a(s.color),s.renderOccluded),this._selectedManipulatorOutlineMaterial=A(a(s.outlineColor),s.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=A(a(s.hoverOutlineColor),s.renderOccluded),this.tooltip=new ve({view:e}),this.addHandles([u((()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}}),(({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:a})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),a.applyColor(this._selectedManipulatorMaterial),a.applyOutline(this._selectedManipulatorOutlineMaterial),a.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)})),u((()=>this.object.visible),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,"edge"===t.type&&"edgeManipulator"in t&&(t.edgeManipulator.available=e)})),u((()=>this._numGrabbing+this._numDragging===0),(e=>this._toggleAutoHideManipulators(e))),u((()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")}),h),te(this.tooltip,this.object,(()=>this._tooltipsContext)),c((()=>this._operations),"vertex-update",(e=>{this._updateManipulatorPositions(e.vertices)}),{onListenerAdd:()=>this._recreateManipulators()}),c((()=>this._operations?.data),"change",(e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()}))])}destroy(){this._segmentLabels=p(this._segmentLabels),this.tooltip=p(this.tooltip),this._removeManipulators(),this._updatingHandles.destroy()}get updating(){return this._updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=p(this._moveManipulation),this._objectMoveManipulation=p(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const i of this._operations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return null!=this._operations&&this._operations.canRedo}get canUndo(){return null!=this._operations&&this._operations.canUndo}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=p(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new P({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],n=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),o=e===we.SELECTED_OR_ALL&&n;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||a.push(s),i++);this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(Ve.MOVING),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(Ve.RESHAPING),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(Me):this.tool.manipulators.forEach((({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,Me)})))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(Ve.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&n.push(o);this._moveVertices(n,e,ge.ACCUMULATE_STEPS),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case Ve.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Ve.MOVING:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case Ve.RESHAPING:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case Ve.MOVING:switch(this._reshapeEventState){case Ve.NONE:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case Ve.RESHAPING:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case Ve.RESHAPING:switch(this._reshapeEventState){case Ve.NONE:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case Ve.MOVING:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:a}=this;if(a){if(this._objectMoveManipulation=new K({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline(((t,i,n)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=a.createUndoGroup()),t))).next((e=>this._perObjectManipulatorDragAction(we.ALL,e))).next((e=>(this._updateTranslateObjectTooltip(q.XY,e),e))).next((t=>{"end"===t.action&&(this._resetTooltip(),e=d(e))})),n.next((()=>this._onDragCancel(!0,(()=>e=d(e)))))}))),this._objectMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._objectMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._objectMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))))}}_createMoveManipulation(e){const{object:t,tool:i,view:a,_operations:n}=this;if(!n)return;this._moveManipulation=new W({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&z(t.operations,t.elevationInfo),snapToScene:!1,radius:W.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator((e=>this.addHandles([e.events.on("immediate-click",(t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()})),this._watchAndUpdateGrabState(e,!1)])));const o=e=>t=>{this.addHandles(t.events.on("focus-changed",(({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})))};this._moveManipulation.xyManipulation.forEachManipulator(o(q.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(q.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(o(q.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=n.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline(((a,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:d}=fe({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new _e({editGeometryOperations:n,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new C}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(d),{steps:s=s.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===F.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(le(this.view,e,t.graphic??void 0)).next(...p).next(pe()).next((e=>this._perObjectManipulatorDragAction(we.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(a,e),e))),cancel:r}}),e,s,t.graphic),u((()=>t.visible),(()=>this._updateMoveManipulationPosition()),h),t.on("committed",(()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()})),u((()=>t.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?this.addHandles(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):this.removeHandles(t)}),h)])}_createVisualElements(){const{object:e,view:t}=this,i=X({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,F.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof ne?i.visualElement:null);const a=this._outlineVisualElement;if(null!=a){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(c((()=>a.events),"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,a=this._operations;if(e.component.vertices.length<=2||!a)return null;const n=a.data.spatialReference,o=this._settings.manipulators.edgeOffset,r=o.size/2,l=r+o.collisionPadding,p=r/l,d=p*Math.sqrt(3)/2;null==this._edgeOffsetManipulatorGeometryInside&&(this._edgeOffsetManipulatorGeometryInside=oe(this._edgeOffsetManipulatorMaterial,d,p/2,p/2,o.height,o.offset)),null==this._edgeOffsetManipulatorGeometryOutside&&(this._edgeOffsetManipulatorGeometryOutside=oe(this._edgeOffsetManipulatorMaterial,-d,p/2,p/2,o.height,-o.offset));const u=[new L(this._edgeOffsetManipulatorGeometryInside.instantiate(),me.Unfocused),new L(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),me.Focused),new L(this._edgeOffsetManipulatorGeometryOutside.instantiate(),me.Unfocused),new L(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),me.Focused)],h=new T({view:i,renderObjects:u,elevationInfo:"on-the-ground"!==t.mode||w(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:O(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:Ee(n)}),c=new T({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:Ee(n)}),m={manipulator:h,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:c,elevationInfo:t,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(m,o.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(m);const g=[];for(const s of[e.leftVertex,e.rightVertex]){const e=this._getManipulatorInfoFromHandle(s);null!=e&&g.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(m))))}m.locationUpdateHandle=s(g),this._manipulatorHandles.add(m.locationUpdateHandle,h),this._manipulatorHandles.add([this._watchAndUpdateGrabState(h,!0),this._watchAndUpdateGrabState(c,!0)],h),this._manipulatorHandles.add(de(h,this._createEdgeOffsetPipeline(m,t)),h),this._manipulatorHandles.add(de(c,((e,n,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(m,t)(e,n,o)}else if(this.enableMoveObject){const s=this.object.graphic,r=a.data.spatialReference,{elevationAlignedLocation:l}=e;n.next((e=>this._trackNumDragging(e))).next(ue(i,l)).next(N(i,l,t,r,s)).next(he()).next(pe()).next((e=>this._perObjectManipulatorDragAction(we.ALL,e))).next((e=>(this._updateTranslateObjectTooltip(q.XY,e),e))).next((e=>{"end"===e.action&&this._resetTooltip()})),o.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),h);const _=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([h.events.on("immediate-click",_),c.events.on("immediate-click",_),h.events.on("focus-changed",(({action:e})=>{"focus"===e?this._updateEdgeOffsetTooltip(null):this._resetTooltip()}))],h),this._manipulatorInfos.push(m),this.manipulators.addMany([h,c]),this.events.emit("manipulators-changed"),m}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,n=()=>{e.visibilityHandle=d(e.visibilityHandle);const n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),o=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=n&&null!=o&&$(n.manipulator.renderLocation,o.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,e.visibilityHandle=s([i.disableDisplay(),r((()=>{i.grabbable=!0,a.grabbable=this.enableMoveObject}))]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),r((()=>{d(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}))],i),n()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=B(this.view,e.manipulator.elevationAlignedLocation,J(t,e.handle,e.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,s=n.manipulator.renderLocation,r=null!=i?Q(i,o,s):_;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=f(v(Ie,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,n)=>{const o=this._operations;if(!o)return;this._clearSelection();const{step:s,cleanup:r}=this._initializeEdgeOffset(e,t,o);a.next((e=>this._trackNumDragging(e))).next(ue(this.view,i.elevationAlignedLocation)).next(s).next(U(this.view)).next(R(this.view,o.data.spatialReference)).next(pe()).next(xe()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),n.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t,i){const{view:n}=this,o=J(i.data.coordinateHelper,e.handle,t),r=i.createUndoGroup(),p=B(n,e.manipulator.elevationAlignedLocation,o);if(o.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);null!=t&&this._splitEdgeManipulator(t,1)}if(o.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);null!=t&&this._splitEdgeManipulator(t,0)}const c=()=>new S({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:i.data.spatialReference}),m=this._settings,g=new ne({view:n,isDraped:this.object.isDraped,geometry:c(),elevationInfo:e.elevationInfo,width:m.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0});let _;const f=()=>{this._cleanEdgeOffsetCollapsedEdges(e),_=d(_)},v=this.events.on("undo",f);return _=s([u((()=>a(this._accentColor)),(e=>g.color=e),h),l(g),u((()=>this.object.isDraped),(e=>g.isDraped=e)),this.object.on("committed",(()=>g.geometry=c())),r,v]),g.attached=!0,{step:e=>null==o||null==p?(f(),null):{...e,operation:o,plane:p},cleanup:f}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||null==t.operation)return t;this._updateEventState(Ve.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:n}=t;return(i||a||n)&&(this._offsetEdge(e,t),this.events.emit("reshape",{type:"reshape",object:this.object})),t}}_showEdgeOffsetTooltip(){return e=>(null!=e.signedDistance&&this.object.operations?this._updateEdgeOffsetTooltip(e):this._resetTooltip(),e)}_cleanEdgeOffsetCollapsedEdges(e){if(!this._operations)return;const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,n=e.handle.rightVertex,o=this._operations.data.coordinateHelper,s=[];if(t&&o.distance(t.pos,i.pos)<Se){const e=this._getManipulatorInfoFromHandle(i);null!=e&&s.push(e)}if(o.distance(i.pos,n.pos)<Se||a&&o.distance(a.pos,n.pos)<Se){const e=this._getManipulatorInfoFromHandle(n);null!=e&&s.push(e)}s.length&&this._removeVertices(s)}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const a=this.view,n=this._operations,o=this._settings;if(!n)return null;const r=n.data.type,l=n.data.spatialReference;if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=ye(o.manipulators.vertex);this._vertexManipulatorGeometry=se(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=se(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=ye(o.manipulators.edge);this._edgeManipulatorGeometry=se(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=se(this._edgeManipulatorOutlineMaterial,t,16,16)}const p="point"===r||"mesh"===r?[]:[new L(this._vertexManipulatorGeometry.instantiate(),He.Vertex|me.Unselected),new L(this._vertexManipulatorOutlineGeometry.instantiate(),He.Vertex|me.Unfocused|me.Unselected),new L(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),He.Vertex|me.Focused|me.Unselected),new L(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),me.Selected),new L(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),me.Selected|me.Unfocused),new L(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),me.Selected|me.Focused)];this.enableMidpoints&&p.push(new L(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),He.Edge|me.Focused|me.Unselected),new L(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),He.Edge|me.Focused|me.Unselected),new L(this._edgeManipulatorGeometry.instantiate(),He.Edge|me.Unfocused|me.Unselected),new L(this._edgeManipulatorOutlineGeometry.instantiate(),He.Edge|me.Unfocused|me.Unselected));const u=new T({view:a,renderObjects:p,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:Ee(l)});u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const h="edge"===e.type?{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:u,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(h),this.manipulators.add(u),this._updateManipulatorPosition(h),"edge"===h.type){const e=[];for(const t of[h.handle.leftVertex,h.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(h))))}h.locationUpdateHandle=s(e),this._manipulatorHandles.add(h.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const c=de(u,((e,i,o,s)=>{let r=null;const{snappingStep:p,cancelSnapping:u}=fe({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new _e({editGeometryOperations:n,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new C}),updatingHandles:this._updatingHandles,useZ:!1});o=o.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>r=d(r))),t))).next(u);const{elevationAlignedLocation:c}=e,m=this.object.graphic??void 0;i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&n&&(r=n.createUndoGroup()),"edge"===h.type){const t=this._splitEdgeManipulator(h);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:h,snapOrigin:h.handle.pos}})).next(ue(a,c)).next(N(a,c,t,l,m)).next(le(a,t,m)).next(...p).next(pe()).next((e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=d(r)),this._resetTooltip()}))}));return this._manipulatorHandles.add([c,u.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,h))),u.events.on("select-changed",(()=>{h.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()})),u.events.on("focus-changed",(()=>{this._resetTooltip()}))],u),this.events.emit("manipulators-changed"),h}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),null!=this.tool.snappingManager&&this.tool.snappingManager.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case Ve.NONE:break;case Ve.MOVING:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case Ve.RESHAPING:this.events.emit("reshape",{type:"reshape",object:this.object})}t&&t(),this.destroyed||this._updateEventState(Ve.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){const a=this._settings;switch(t.type){case"vertex":{e.state=He.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2;const{size:t,collisionPadding:n}=a.manipulators.vertex;e.radius=t/2+n,e.elevationInfo=i;const o=this._operations?.data.type;e.interactive=null!=o&&"point"!==o&&"mesh"!==o;break}case"edge":{e.state=He.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1;const{size:t,collisionPadding:n}=a.manipulators.edge;e.radius=t/2+n,e.elevationInfo="on-the-ground"!==i.mode||w(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Ve.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._objectMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!this._numGrabbing})))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,je),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=n.location,a=o.location,s=.5,r=i.x+s*(a.x-i.x),l=i.y+s*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=V(r,l,p,t.data.spatialReference)}else M(Ie,n.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Ie}}_splitEdgeManipulator(e,t=.5){const i=this._operations,a=i.splitEdge(e.handle,t).createdVertex;e.locationUpdateHandle=d(e.locationUpdateHandle);const n=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(a)):(o=e,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,n)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(Ve.RESHAPING),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.components.indexOf(a.component);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:a.index}],added:r}),s&&this._updateEventState(Ve.NONE),o}_updateMoveManipulationPosition(){const e=b(Ie,0,0,0);let t=0,i=!1,a=null,n=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,x(e,e,r.manipulator.renderLocation),null==a||r.selectedIndex>a.selectedIndex?(n=a,a=r):(null==n||r.selectedIndex>n.selectedIndex)&&(n=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&z(this._operations,o.elevationInfo),this._moveManipulation.angle=k(s),this._moveManipulation.radius=W.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&z(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=a){const e=a.handle.pos,t=null!=n?n.handle.pos:a.handle.leftEdge?.leftVertex?a.handle.leftEdge.leftVertex.pos:null,o=null==n&&a.handle.rightEdge?.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=Oe(t,e):o&&(i=Oe(e,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=Y}0!==t&&i?(y(e,e,1/t),je.spatialReference=this._operations.data.spatialReference,je.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,je),this._moveManipulation.elevationAlignedLocation=je):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?D(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(i){for(const a of e){const e=a.handle.component;if("vertex"===a.type&&i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdEdge;o?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.edges[0]))}}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}})),a=this._updateEventState(Ve.RESHAPING);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(Ve.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}}_moveVertices(e,t,i=("start"===t.action?ge.NEW_STEP:ge.ACCUMULATE_STEPS)){const a=this._operations;if(a){e.length>0&&a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t){if(null==t.operation||null==t.signedDistance)return;const i=this._operations;if(!i)return;const a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===re.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===re.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this.activeTooltipInfo=ie(e,t,this._tooltipsContext)}_updateEdgeOffsetTooltip(e){this.activeTooltipInfo=ae(this.object,e,this._tooltipsContext)}_resetTooltip(){this.activeTooltipInfo=this._defaultTooltipInfo}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return 1===e.length?e[0]:null}get _tooltipsContext(){const{events:e}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:this.tooltipInfos,activeTooltipInfo:this.activeTooltipInfo,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:{onReshapeStart:()=>e.emit("reshape",{type:"reshape-start",object:this.object}),onReshape:()=>e.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>e.emit("reshape",{type:"reshape-stop",object:this.object}),onMoveStart:()=>e.emit("move",{type:"move-start",object:this.object,dx:0,dy:0}),onMove:()=>e.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>e.emit("move",{type:"move-stop",object:this.object,dx:0,dy:0})}}}get test(){}};function xe(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}function ye(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function Oe(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Ee(e){return new I({x:0,y:0,z:0,spatialReference:e})}e([m()],be.prototype,"_numGrabbing",void 0),e([m()],be.prototype,"_numDragging",void 0),e([m()],be.prototype,"grabbingOrDragging",null),e([m()],be.prototype,"_operations",null),e([m()],be.prototype,"_segmentLabels",void 0),e([m({constructOnly:!0})],be.prototype,"tool",void 0),e([m()],be.prototype,"tooltip",void 0),e([m()],be.prototype,"activeTooltipInfo",void 0),e([m({readOnly:!0})],be.prototype,"updating",null),e([m()],be.prototype,"manipulators",null),e([m()],be.prototype,"view",null),e([m()],be.prototype,"object",null),e([m()],be.prototype,"enableZShape",null),e([m()],be.prototype,"enableDeleteVertices",null),e([m()],be.prototype,"enableZVertex",null),e([m()],be.prototype,"autoHideManipulators",null),e([m()],be.prototype,"enableMoveObject",null),e([m()],be.prototype,"enableMidpoints",null),e([m()],be.prototype,"enableEdgeOffset",null),e([m()],be.prototype,"_sketchOptions",null),e([m()],be.prototype,"_accentColor",null),e([m()],be.prototype,"_tooltipsContext",null),be=e([g("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],be);const je=V(0,0,void 0,H.WGS84),Ie=E(),Se=1e-6;var He,Ve,we;!function(e){e.Vertex=ce.Custom1,e.Edge=ce.Custom2}(He||(He={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(Ve||(Ve={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(we||(we={}));export{be as ReshapeOperation};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{unitRGBAFromColor as a}from"../../../../../core/colorUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Evented.js";import o from"../../../../../core/Handles.js";import{handlesGroup as s,makeHandle as r,destroyHandle as l}from"../../../../../core/handleUtils.js";import{destroyMaybe as p,removeMaybe as d}from"../../../../../core/maybe.js";import{watch as u,initial as h,on as c}from"../../../../../core/reactiveUtils.js";import{property as m}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as g}from"../../../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as _}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as f,f as v,o as M,s as b,g as x,j as y}from"../../../../../chunks/vec32.js";import{fromValues as O,create as E}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as j}from"../../../../../core/support/UpdatingHandles.js";import S from"../../../../../geometry/Point.js";import I from"../../../../../geometry/Polyline.js";import H from"../../../../../geometry/SpatialReference.js";import{makeDehydratedPoint as V}from"../../../../../layers/graphics/dehydratedPoint.js";import{isVolumetricSymbol as w}from"../../../../../symbols/support/utils.js";import{Manipulator3D as T}from"../../Manipulator3D.js";import{createManipulatorMaterial as A,createManipulatorOutlineMaterial as G,placeAtObject as D}from"../../manipulatorUtils.js";import{RenderObject as L}from"../../RenderObject.js";import{SegmentLabels3D as P}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as C}from"../../SnappingVisualizer3D.js";import{screenToMapXYAtLocation as N,screenToRenderPlaneFromEvent as U,convertToMapCoordinates as R}from"../dragEventPipeline3D.js";import{orientation as k}from"../geometryUtils.js";import{ManipulatorType as F}from"../ManipulatorType.js";import{canMoveZOperations as z}from"../manipulatorUtils.js";import{Settings as Z}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{discRadiusSmall as Y}from"../manipulations/config.js";import{ManipulationType as q,MoveManipulation as W}from"../manipulations/MoveManipulation.js";import{MoveXYObjectManipulation as K}from"../manipulations/MoveXYObjectManipulation.js";import{createEdgeOffsetIntersectionPlane as B,createEdgeOffsetOperation as J,edgeOffsetRotationMatrix as Q,screenEdgeLengthSquared as $}from"./edgeOffsetUtils.js";import{createTooltipInfos as ee,connectTooltipToManipulatedObject as te,getUpdatedTranslateObjectTooltipInfo as ie,getUpdatedEdgeOffsetTooltipInfo as ae}from"./reshapeTooltipUtils.js";import{OutlineVisualElement as ne}from"../../visualElements/OutlineVisualElement.js";import{createExtrudedTriangle as oe,createSphereGeometry as se}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as re}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as le,addMapDelta as pe,createManipulatorDragEventPipeline as de,dragAtLocation as ue,addScreenDelta as he}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as ce,ManipulatorStateFlags as me}from"../../../../interactive/interfaces.js";import{AccumulationBehavior as ge}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as _e}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as fe}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as ve}from"../../../../interactive/tooltip/Tooltip.js";const Me=Symbol();let be=class extends t{get grabbingOrDragging(){return this._numGrabbing+this._numDragging>0}get _operations(){return this.object.operations}constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Ve.NONE,this._updatingHandles=new j,this._recreatingManipulators=!1,this._settings=new Z({getTheme:()=>this.view.effectiveTheme}),this.events=new n,this.activeTooltipInfo=null,this._vertexLaserLineVisualElement=null}initialize(){const{view:e}=this,t=this._settings.manipulators,i=t.vertex;this.tooltipInfos=ee(this._sketchOptions,e),this._vertexManipulatorMaterial=A(a(i.color),i.renderOccluded),this._vertexManipulatorOutlineMaterial=G(a(i.outlineColor),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=G(a(i.hoverOutlineColor),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=A(a(n.color),n.renderOccluded),this._edgeManipulatorOutlineMaterial=G(a(n.outlineColor),n.renderOccluded);const o=t.edgeOffset;this._edgeOffsetManipulatorMaterial=A(a(o.color),o.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=A(a(o.hoverColor),o.renderOccluded,!1);const s=t.selected;this._selectedManipulatorMaterial=A(a(s.color),s.renderOccluded),this._selectedManipulatorOutlineMaterial=G(a(s.outlineColor),s.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=G(a(s.hoverOutlineColor),s.renderOccluded),this.tooltip=new ve({view:e}),this.addHandles([u((()=>{const e=this._settings.manipulators;return{vertexSettings:e.vertex,edgeSettings:e.edge,edgeOffsetSettings:e.edgeOffset,selectedSettings:e.selected}}),(({vertexSettings:e,edgeSettings:t,edgeOffsetSettings:i,selectedSettings:a})=>{e.applyColor(this._vertexManipulatorMaterial),e.applyOutline(this._vertexManipulatorOutlineMaterial),e.applyHoverOutline(this._vertexManipulatorHoverOutlineMaterial),t.applyColor(this._edgeManipulatorMaterial),t.applyOutline(this._edgeManipulatorOutlineMaterial),i.applyColor(this._edgeOffsetManipulatorMaterial),i.applyHover(this._edgeOffsetManipulatorHoverMaterial),a.applyColor(this._selectedManipulatorMaterial),a.applyOutline(this._selectedManipulatorOutlineMaterial),a.applyHoverOutline(this._selectedManipulatorHoverOutlineMaterial)})),u((()=>this.object.visible),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e,"edge"===t.type&&"edgeManipulator"in t&&(t.edgeManipulator.available=e)})),u((()=>this._numGrabbing+this._numDragging===0),(e=>this._toggleAutoHideManipulators(e))),u((()=>({labels:this._segmentLabels,enabled:this._sketchOptions.labels.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")}),h),te(this.tooltip,this.object,(()=>this._tooltipsContext)),c((()=>this._operations),"vertex-update",(e=>{this._updateManipulatorPositions(e.vertices)}),{onListenerAdd:()=>this._recreateManipulators()}),c((()=>this._operations?.data),"change",(e=>{"undo"!==e.operation&&"redo"!==e.operation||this._recreateManipulators()}))])}destroy(){this._segmentLabels=p(this._segmentLabels),this.tooltip=p(this.tooltip),this._removeManipulators(),this._updatingHandles.destroy()}get updating(){return this._updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get object(){return this.tool.object}get enableZShape(){return this.tool.enableZShape}get enableDeleteVertices(){return this.tool.enableDeleteVertices}get enableZVertex(){return this.tool.enableZVertex}get autoHideManipulators(){return this.tool.autoHideManipulators}get enableMoveObject(){return this.tool.enableMoveObject}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _sketchOptions(){return this.tool.sketchOptions}get _accentColor(){return this.view.effectiveTheme.accentColor}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));return this._removeVertices(e),e.length}onManipulatorSelectionChanged(){this.events.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=p(this._moveManipulation),this._objectMoveManipulation=p(this._objectMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._operations)return;const t=this.object.elevationInfo;for(const i of this._operations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createObjectMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return null!=this._operations&&this._operations.canRedo}get canUndo(){return null!=this._operations&&this._operations.canUndo}redo(){return this._operations?.redo()}undo(){return this.events.emit("undo"),this._operations?.undo()}_recreateManipulators(){if(!this._recreatingManipulators){if(this._recreatingManipulators=!0,this._removeManipulators(),this._resetTooltip(),this._operations&&this._segmentLabels?.context?.editGeometryOperations===this._operations||(this._segmentLabels=p(this._segmentLabels)),this._createManipulators(),!this._segmentLabels&&this._operations){const e=this._sketchOptions.labels;this._segmentLabels=new P({context:{view:this.view,editGeometryOperations:this._operations,elevationInfo:this.object.elevationInfo,labelOptions:e},visible:e.enabled})}this._recreatingManipulators=!1}}_perObjectManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],n=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),o=e===we.SELECTED_OR_ALL&&n;for(const s of this._manipulatorInfos)"vertex"===s.type&&(s.manipulator.grabbing||o&&!s.manipulator.selected||a.push(s),i++);this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(Ve.MOVING),this.destroyed)return t;this.events.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,object:this.object})}else{if(this._updateEventState(Ve.RESHAPING),this.destroyed)return t;this.events.emit("reshape",{type:"reshape",object:this.object})}return t}_toggleAutoHideManipulators(e){this.autoHideManipulators&&(e?this.removeHandles(Me):this.tool.manipulators.forEach((({manipulator:e})=>{const t=e.disableDisplay?.();t&&this.addHandles(t,Me)})))}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(Ve.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&n.push(o);this._moveVertices(n,e,ge.ACCUMULATE_STEPS),this.events.emit("reshape",{type:"reshape",object:this.object})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case Ve.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Ve.MOVING:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object});break;case Ve.RESHAPING:this.events.emit("reshape",{type:"reshape-stop",object:this.object})}break;case Ve.MOVING:switch(this._reshapeEventState){case Ve.NONE:this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object});break;case Ve.RESHAPING:this.events.emit("reshape",{type:"reshape-stop",object:this.object}),this.destroyed||this.events.emit("move",{type:"move-start",dx:0,dy:0,object:this.object})}break;case Ve.RESHAPING:switch(this._reshapeEventState){case Ve.NONE:this.events.emit("reshape",{type:"reshape-start",object:this.object});break;case Ve.MOVING:this.events.emit("move",{type:"move-stop",dx:0,dy:0,object:this.object}),this.destroyed||this.events.emit("reshape",{type:"reshape-start",object:this.object})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createObjectMoveManipulation(){const{tool:e,view:t,object:i,_operations:a}=this;if(a){if(this._objectMoveManipulation=new K({tool:e,view:t,object:i}),this.enableMoveObject){let e=null;this._manipulatorHandles.add(this._objectMoveManipulation.createDragPipeline(((t,i,n)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=a.createUndoGroup()),t))).next((e=>this._perObjectManipulatorDragAction(we.ALL,e))).next((e=>(this._updateTranslateObjectTooltip(q.XY,e),e))).next((t=>{"end"===t.action&&(this._resetTooltip(),e=d(e))})),n.next((()=>this._onDragCancel(!0,(()=>e=d(e)))))}))),this._objectMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._objectMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._objectMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()})))))}}_createMoveManipulation(e){const{object:t,tool:i,view:a,_operations:n}=this;if(!n)return;this._moveManipulation=new W({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&z(t.operations,t.elevationInfo),snapToScene:!1,radius:W.radiusForSymbol(t.graphic?.symbol)}),this._moveManipulation.forEachManipulator((e=>this.addHandles([e.events.on("immediate-click",(t=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.events.emit("immediate-click",{...t,object:this.object}),t.stopPropagation()})),this._watchAndUpdateGrabState(e,!1)])));const o=e=>t=>{this.addHandles(t.events.on("focus-changed",(({action:t})=>{"focus"===t?this._updateTranslateTooltip(e):this._resetTooltip()})))};this._moveManipulation.xyManipulation.forEachManipulator(o(q.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(q.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(o(q.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const s=n.data.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline(((a,o,s,r,l)=>{const{snappingStep:p,cancelSnapping:d}=fe({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new _e({editGeometryOperations:n,elevationInfo:e,pointer:l,excludeFeature:t.graphic,visualizer:new C}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(d),{steps:s=s.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===F.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(le(this.view,e,t.graphic??void 0)).next(...p).next(pe()).next((e=>this._perObjectManipulatorDragAction(we.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(a,e),e))),cancel:r}}),e,s,t.graphic),u((()=>t.visible),(()=>this._updateMoveManipulationPosition()),h),t.on("committed",(()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()})),u((()=>t.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?this.addHandles(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):this.removeHandles(t)}),h)])}_createVisualElements(){const{object:e,view:t}=this,i=X({view:t,object:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._objectMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,F.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.events.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof ne?i.visualElement:null);const a=this._outlineVisualElement;if(null!=a){const t=()=>{e.isDraped||this._updateMoveManipulationPosition()};this._manipulatorHandles.add(c((()=>a.events),"attachment-origin-changed",t,{onListenerAdd:t}))}this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=this.object.elevationInfo){const i=this.view,a=this._operations;if(e.component.vertices.length<=2||!a)return null;const n=a.data.spatialReference,o=this._settings.manipulators.edgeOffset,r=o.size/2,l=r+o.collisionPadding,p=r/l,d=p*Math.sqrt(3)/2;null==this._edgeOffsetManipulatorGeometryInside&&(this._edgeOffsetManipulatorGeometryInside=oe(this._edgeOffsetManipulatorMaterial,d,p/2,p/2,o.height,o.offset)),null==this._edgeOffsetManipulatorGeometryOutside&&(this._edgeOffsetManipulatorGeometryOutside=oe(this._edgeOffsetManipulatorMaterial,-d,p/2,p/2,o.height,-o.offset));const u=[new L(this._edgeOffsetManipulatorGeometryInside.instantiate(),me.Unfocused),new L(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),me.Focused),new L(this._edgeOffsetManipulatorGeometryOutside.instantiate(),me.Unfocused),new L(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),me.Focused)],h=new T({view:i,renderObjects:u,elevationInfo:"on-the-ground"!==t.mode||w(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:l,available:this.object.visible,collisionType:{type:"disc",direction:O(0,0,1)},collisionPriority:1,metadata:{deleting:!1},location:Ee(n)}),c=new T({view:i,worldSized:!0,worldOriented:!1,available:this.object.visible,collisionPriority:-10,cursor:this.enableMoveObject?"move":"default",metadata:{deleting:!1},location:Ee(n)}),m={manipulator:h,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:c,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(m,o.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(m);const g=[];for(const s of[e.leftVertex,e.rightVertex]){const e=this._getManipulatorInfoFromHandle(s);null!=e&&g.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(m))))}m.locationUpdateHandle=s(g),this._manipulatorHandles.add(m.locationUpdateHandle,h),this._manipulatorHandles.add([this._watchAndUpdateGrabState(h,!0),this._watchAndUpdateGrabState(c,!0)],h),this._manipulatorHandles.add(de(h,this._createEdgeOffsetPipeline(m,t)),h),this._manipulatorHandles.add(de(c,((e,n,o,s)=>{if("touch"===s){this._createEdgeOffsetPipeline(m,t)(e,n,o)}else if(this.enableMoveObject){const s=this.object.graphic,r=a.data.spatialReference,{elevationAlignedLocation:l}=e;n.next((e=>this._trackNumDragging(e))).next(ue(i,l)).next(N(i,l,t,r,s)).next(he()).next(pe()).next((e=>this._perObjectManipulatorDragAction(we.ALL,e))).next((e=>(this._updateTranslateObjectTooltip(q.XY,e),e))).next((e=>{"end"===e.action&&this._resetTooltip()})),o.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),h);const _=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.events.emit("immediate-click",{...e,object:this.object}),e.stopPropagation()};return this._manipulatorHandles.add([h.events.on("immediate-click",_),c.events.on("immediate-click",_),h.events.on("focus-changed",(({action:e})=>{"focus"===e?this._updateEdgeOffsetTooltip(null):this._resetTooltip()}))],h),this._manipulatorInfos.push(m),this.manipulators.addMany([h,c]),this.events.emit("manipulators-changed"),m}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,n=()=>{e.visibilityHandle=d(e.visibilityHandle);const n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),o=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=n&&null!=o&&$(n.manipulator.renderLocation,o.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,e.visibilityHandle=s([i.disableDisplay(),r((()=>{i.grabbable=!0,a.grabbable=this.enableMoveObject}))]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),r((()=>{d(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}))],i),n()}_updateEdgeOffsetManipulator(e){if(!this._operations)return;this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._operations.data,i=B(this.view,e.manipulator.elevationAlignedLocation,J(t,e.handle,e.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,s=n.manipulator.renderLocation,r=null!=i?Q(i,o,s):_;e.manipulator.modelTransform=r,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=r;const l=f(v(Se,o,s))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,n)=>{const o=this._operations;if(!o)return;this._clearSelection();const{step:s,cleanup:r}=this._initializeEdgeOffset(e,t,o);a.next((e=>this._trackNumDragging(e))).next(ue(this.view,i.elevationAlignedLocation)).next(s).next(U(this.view)).next(R(this.view,o.data.spatialReference)).next(pe()).next(xe()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),n.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t,i){const{view:n}=this,o=J(i.data.coordinateHelper,e.handle,t),r=i.createUndoGroup(),p=B(n,e.manipulator.elevationAlignedLocation,o);if(o.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);null!=t&&this._splitEdgeManipulator(t,1)}if(o.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);null!=t&&this._splitEdgeManipulator(t,0)}const c=()=>new I({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:i.data.spatialReference}),m=this._settings,g=new ne({view:n,isDraped:this.object.isDraped,geometry:c(),elevationInfo:t,width:m.visualElements.lineObjects.outline.width,attached:!1,isDecoration:!0});let _;const f=()=>{this._cleanEdgeOffsetCollapsedEdges(e),_=d(_)},v=this.events.on("undo",f);return _=s([u((()=>a(this._accentColor)),(e=>g.color=e),h),l(g),u((()=>this.object.isDraped),(e=>g.isDraped=e)),this.object.on("committed",(()=>g.geometry=c())),r,v]),g.attached=!0,{step:e=>null==o||null==p?(f(),null):{...e,operation:o,plane:p},cleanup:f}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||null==t.operation)return t;this._updateEventState(Ve.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:n}=t;return(i||a||n)&&(this._offsetEdge(e,t),this.events.emit("reshape",{type:"reshape",object:this.object})),t}}_showEdgeOffsetTooltip(){return e=>(null!=e.signedDistance&&this.object.operations?this._updateEdgeOffsetTooltip(e):this._resetTooltip(),e)}_cleanEdgeOffsetCollapsedEdges(e){if(!this._operations)return;const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,n=e.handle.rightVertex,o=this._operations.data.coordinateHelper,s=this.view.pixelSizeAt(o.vectorToDehydratedPoint(i.pos),o.spatialReference),r=[];if(t&&o.distance(t.pos,i.pos)<Ie){const e=this._getManipulatorInfoFromHandle(i);null!=e&&r.push(e)}if(o.distance(i.pos,n.pos)<s||a&&o.distance(a.pos,n.pos)<Ie){const e=this._getManipulatorInfoFromHandle(n);null!=e&&r.push(e)}r.length&&this._removeVertices(r)}_createVertexOrEdgeManipulator(e,t=this.object.elevationInfo,i=!1){const a=this.view,n=this._operations,o=this._settings;if(!n)return null;const r=n.data.type,l=n.data.spatialReference;if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=ye(o.manipulators.vertex);this._vertexManipulatorGeometry=se(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=se(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=ye(o.manipulators.edge);this._edgeManipulatorGeometry=se(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=se(this._edgeManipulatorOutlineMaterial,t,16,16)}const p="point"===r||"mesh"===r?[]:[new L(this._vertexManipulatorGeometry.instantiate(),He.Vertex|me.Unselected),new L(this._vertexManipulatorOutlineGeometry.instantiate(),He.Vertex|me.Unfocused|me.Unselected),new L(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),He.Vertex|me.Focused|me.Unselected),new L(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),me.Selected),new L(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),me.Selected|me.Unfocused),new L(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),me.Selected|me.Focused)];this.enableMidpoints&&p.push(new L(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),He.Edge|me.Focused|me.Unselected),new L(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),He.Edge|me.Focused|me.Unselected),new L(this._edgeManipulatorGeometry.instantiate(),He.Edge|me.Unfocused|me.Unselected),new L(this._edgeManipulatorOutlineGeometry.instantiate(),He.Edge|me.Unfocused|me.Unselected));const u=new T({view:a,renderObjects:p,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:this.object.visible,metadata:{deleting:!1},location:Ee(l)});u.selected=i,this._setTypeSpecificManipulatorSettings(u,e,t);const h="edge"===e.type?{manipulator:u,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:u,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(h),this.manipulators.add(u),this._updateManipulatorPosition(h),"edge"===h.type){const e=[];for(const t of[h.handle.leftVertex,h.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(h))))}h.locationUpdateHandle=s(e),this._manipulatorHandles.add(h.locationUpdateHandle,u)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(u,!0),u);const c=de(u,((e,i,o,s)=>{let r=null;const{snappingStep:p,cancelSnapping:u}=fe({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new _e({editGeometryOperations:n,elevationInfo:t,pointer:s,excludeFeature:this.object.graphic,visualizer:new C}),updatingHandles:this._updatingHandles,useZ:!1});o=o.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>r=d(r))),t))).next(u);const{elevationAlignedLocation:c}=e,m=this.object.graphic??void 0;i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&n&&(r=n.createUndoGroup()),"edge"===h.type){const t=this._splitEdgeManipulator(h);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:h,snapOrigin:h.handle.pos}})).next(ue(a,c)).next(N(a,c,t,l,m)).next(le(a,t,m)).next(...p).next(pe()).next((e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=d(r)),this._resetTooltip()}))}));return this._manipulatorHandles.add([c,u.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,h))),u.events.on("select-changed",(()=>{h.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition(),this._resetTooltip()})),u.events.on("focus-changed",(()=>{this._resetTooltip()}))],u),this.events.emit("manipulators-changed"),h}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&this.undo(),null!=this.tool.snappingManager&&this.tool.snappingManager.doneSnapping(),this._resetTooltip(),this._reshapeEventState){case Ve.NONE:break;case Ve.MOVING:this.events.emit("move",{type:"move",dx:0,dy:0,object:this.object});break;case Ve.RESHAPING:this.events.emit("reshape",{type:"reshape",object:this.object})}t&&t(),this.destroyed||this._updateEventState(Ve.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){const a=this._settings;switch(t.type){case"vertex":{e.state=He.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2;const{size:t,collisionPadding:n}=a.manipulators.vertex;e.radius=t/2+n,e.elevationInfo=i;const o=this._operations?.data.type;e.interactive=null!=o&&"point"!==o&&"mesh"!==o;break}case"edge":{e.state=He.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1;const{size:t,collisionPadding:n}=a.manipulators.edge;e.radius=t/2+n,e.elevationInfo="on-the-ground"!==i.mode||w(this.object.graphic?.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Ve.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{const{manipulator:t}=e,i=this._operations?.data.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=i&&"point"!==i&&"mesh"!==i,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._objectMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!this._numGrabbing})))}}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.events.emit("manipulators-changed"))}_removeManipulator(e){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),this.events.emit("manipulators-changed"),this._resetTooltip())}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPositions(e){for(const t of e)this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(t))}_updateManipulatorPosition(e){const t=this._operations;if(null!=e&&t)if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,je),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if("on-the-ground"===e.manipulator.elevationInfo?.mode){const i=n.location,a=o.location,s=.5,r=i.x+s*(a.x-i.x),l=i.y+s*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=V(r,l,p,t.data.spatialReference)}else M(Se,n.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=Se}}_splitEdgeManipulator(e,t=.5){const i=this._operations,a=i.splitEdge(e.handle,t).createdVertex;e.locationUpdateHandle=d(e.locationUpdateHandle);const n=this.object.elevationInfo;let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(a)):(o=e,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,n)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this._updateManipulatorPosition(o),this.enableEdgeOffset||this._resetTooltip(),this._updateSelection(e.manipulator);const s=this._updateEventState(Ve.RESHAPING),r=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.components.indexOf(a.component);return this.events.emit("vertex-add",{type:"vertex-add",object:this.object,vertices:[{coordinates:r,componentIndex:l,vertexIndex:a.index}],added:r}),s&&this._updateEventState(Ve.NONE),o}_updateMoveManipulationPosition(){const e=b(Se,0,0,0);let t=0,i=!1,a=null,n=null;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.selected?(t++,x(e,e,r.manipulator.renderLocation),null==a||r.selectedIndex>a.selectedIndex?(n=a,a=r):(null==n||r.selectedIndex>n.selectedIndex)&&(n=r)):i=!0);const o=this.object,s=this._operations?.data.geometry;if(0===t){const e=o.visible&&this.enableMoveObject;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&z(this._operations,o.elevationInfo),this._moveManipulation.angle=k(s),this._moveManipulation.radius=W.radiusForSymbol(o.graphic?.symbol)}else{const e=o.visible;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&z(this._operations,this.object.elevationInfo),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=a){const e=a.handle.pos,t=null!=n?n.handle.pos:a.handle.leftEdge?.leftVertex?a.handle.leftEdge.leftVertex.pos:null,o=null==n&&a.handle.rightEdge?.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=Oe(t,e):o&&(i=Oe(e,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=Y}0!==t&&i?(y(e,e,1/t),je.spatialReference=this._operations.data.spatialReference,je.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,je),this._moveManipulation.elevationAlignedLocation=je):null==this._outlineVisualElement||this.object.isDraped||null==this._outlineVisualElement.attachmentOrigin?D(this._moveManipulation,this.object):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=this._operations;if(i){for(const a of e){const e=a.handle.component;if("vertex"===a.type&&i.canRemoveVertex(e)){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const n=i.removeVertices([a.handle]),o=n.removedVertices?.[0].createdEdge;o?this._createVertexOrEdgeManipulator(o):this.enableEdgeOffset&&e.vertices.length<=2&&this._removeManipulator(this._getManipulatorInfoFromHandle(e.edges[0]))}}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:e.index}})),a=this._updateEventState(Ve.RESHAPING);if(this.destroyed)return;if(this.events.emit("vertex-remove",{type:"vertex-remove",object:this.object,removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(Ve.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}}_moveVertices(e,t,i=("start"===t.action?ge.NEW_STEP:ge.ACCUMULATE_STEPS)){const a=this._operations;if(a){e.length>0&&a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);for(const t of e)this._updateManipulatorPosition(t)}}_offsetEdge(e,t){if(null==t.operation||null==t.signedDistance)return;const i=this._operations;if(!i)return;const a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,this.enableDeleteVertices&&e.button===re.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===re.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){null!=this._defaultTooltipInfo?this._resetTooltip():this._updateTranslateObjectTooltip(e,t)}_updateTranslateObjectTooltip(e,t){this.activeTooltipInfo=ie(e,t,this._tooltipsContext)}_updateEdgeOffsetTooltip(e){this.activeTooltipInfo=ae(this.object,e,this._tooltipsContext)}_resetTooltip(){this.activeTooltipInfo=this._defaultTooltipInfo}get _defaultTooltipInfo(){const e=this._operations?.data.type;switch(e){case"polyline":case"polygon":return this._selectedVertexManipulatorInfo?this.tooltipInfos.selectedVertex:null;case"point":case"mesh":return this.tooltipInfos.movePoint;default:return null}}get _selectedVertexManipulatorInfo(){const e=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return 1===e.length?e[0]:null}get _tooltipsContext(){const{events:e}=this;return{sketchOptions:this._sketchOptions,tooltipInfos:this.tooltipInfos,activeTooltipInfo:this.activeTooltipInfo,selectedVertexManipulatorInfo:this._selectedVertexManipulatorInfo,callbacks:{onReshapeStart:()=>e.emit("reshape",{type:"reshape-start",object:this.object}),onReshape:()=>e.emit("reshape",{type:"reshape",object:this.object}),onReshapeStop:()=>e.emit("reshape",{type:"reshape-stop",object:this.object}),onMoveStart:()=>e.emit("move",{type:"move-start",object:this.object,dx:0,dy:0}),onMove:()=>e.emit("move",{type:"move",object:this.object,dx:0,dy:0}),onMoveStop:()=>e.emit("move",{type:"move-stop",object:this.object,dx:0,dy:0})}}}get test(){}};function xe(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}function ye(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}function Oe(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Ee(e){return new S({x:0,y:0,z:0,spatialReference:e})}e([m()],be.prototype,"_numGrabbing",void 0),e([m()],be.prototype,"_numDragging",void 0),e([m()],be.prototype,"grabbingOrDragging",null),e([m()],be.prototype,"_operations",null),e([m()],be.prototype,"_segmentLabels",void 0),e([m({constructOnly:!0})],be.prototype,"tool",void 0),e([m()],be.prototype,"tooltip",void 0),e([m()],be.prototype,"activeTooltipInfo",void 0),e([m({readOnly:!0})],be.prototype,"updating",null),e([m()],be.prototype,"manipulators",null),e([m()],be.prototype,"view",null),e([m()],be.prototype,"object",null),e([m()],be.prototype,"enableZShape",null),e([m()],be.prototype,"enableDeleteVertices",null),e([m()],be.prototype,"enableZVertex",null),e([m()],be.prototype,"autoHideManipulators",null),e([m()],be.prototype,"enableMoveObject",null),e([m()],be.prototype,"enableMidpoints",null),e([m()],be.prototype,"enableEdgeOffset",null),e([m()],be.prototype,"_sketchOptions",null),e([m()],be.prototype,"_accentColor",null),e([m()],be.prototype,"_tooltipsContext",null),be=e([g("esri.views.3d.interactive.editingTools.reshape.ReshapeOperation")],be);const je=V(0,0,void 0,H.WGS84),Se=E(),Ie=1e-6;var He,Ve,we;!function(e){e.Vertex=ce.Custom1,e.Edge=ce.Custom2}(He||(He={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(Ve||(Ve={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(we||(we={}));export{be as ReshapeOperation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{on as s}from"../../../../../../core/reactiveUtils.js";import{
|
|
5
|
+
import{on as s}from"../../../../../../core/reactiveUtils.js";import{scale as t}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{g as o,f as i,o as e,b as a,n,j as r,m as p,l as d,r as c}from"../../../../../../chunks/vec32.js";import{create as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as u,c as m,u as g}from"../../../../../../chunks/boundedPlane.js";import{sv3d as h}from"../../../../../../geometry/support/vectorStacks.js";import{mainAxis as b}from"../../geometryUtils.js";import{manipulatedObjectGeometry as f}from"../../manipulatedObjectUtils.js";import{evaluateElevationAlignmentAtPoint as B}from"../../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as y}from"../../../../layers/graphics/ElevationContext.js";import{apply as j,applyInverse as v,calculateOrientedBounds as _}from"../../../../../interactive/editGeometry/support/editPlaneUtils.js";import{autoSize2D as R}from"../../../../../support/extentUtils.js";class C{constructor(t,o){this._tool=t,this.mapBounds=u(),this.mapBoundsStart=u(),this.displayBounds=u(),t.addHandles(s((()=>t.object),"modified-externally",(()=>this._resetMapBounds()),{onListenerAdd:()=>this._resetMapBounds()})),this._onDisplayBoundsChanged=o}get displayBoundsMargin(){const{view:s,object:t}=this._tool,o=f(t),i=s.pointsOfInterest?.centerOnSurfaceFrequent.location??o?.extent?.center;return i?M*s.pixelSizeAt(i):0}backupMapBounds(){m(this.mapBounds,this.mapBoundsStart)}updateDisplayBounds(){this._calculateDisplayBounds(),this._onDisplayBoundsChanged?.()}updateMapBoundsFromOperation(s){j(s,this.mapBounds),this.updateDisplayBounds()}updateMapBoundsFromOperationInverse(s){v(s,this.mapBounds),this.updateDisplayBounds()}_resetMapBounds(){this._calculateMapBounds(),this.updateDisplayBounds()}_calculateMapBounds(){const{view:s,attachmentOrigin:o,object:i}=this._tool,e=i.operations?.data;if(!e)return;const a=e.geometry;this.spatialReference=a.spatialReference;const n=b(a);t(n,n,-1);const r=o?s.pixelSizeAt(o,a.spatialReference):0;_(n,e,x*r,this.mapBounds)}_calculateDisplayBounds(){const{view:s,attachmentOrigin:t}=this._tool,o=t?.z??B(this.mapBounds.origin,s.elevationProvider,y.fromElevationInfo(this._tool.object.elevationInfo),s.renderCoordsHelper),i=m(this.mapBounds);i.origin[2]=o??0,D(i,s.renderCoordsHelper,this.spatialReference,this.displayBoundsMargin,this.displayBounds)}}const M=10,x=80;function D(s,t,c,l=0,m){m||(m=u()),t.toRenderCoords(s.origin,c,m.origin);const b=h.get();o(b,s.origin,s.basis1),o(b,b,s.basis2),t.toRenderCoords(b,c,b);const f=h.get();o(f,s.origin,s.basis1),i(f,f,s.basis2),t.toRenderCoords(f,c,f);const B=h.get();i(B,s.origin,s.basis1),i(B,B,s.basis2),t.toRenderCoords(B,c,B);const y=h.get();i(y,s.origin,s.basis1),o(y,y,s.basis2),t.toRenderCoords(y,c,y);const j=e(h.get(),b,f,.5);i(j,j,m.origin);const v=e(h.get(),B,y,.5);i(v,m.origin,v),e(m.basis1,j,v,.5);const _=e(h.get(),y,b,.5);i(_,_,m.origin);const R=e(h.get(),f,B,.5);i(R,m.origin,R),e(m.basis2,_,R,.5);const C=a(h.get(),m.basis1,m.basis2),M=a(C,C,m.basis1);return n(M,M),r(m.basis2,M,p(m.basis2,M)),r(m.basis1,m.basis1,1+l/d(m.basis1)),r(m.basis2,m.basis2,1+l/d(m.basis2)),g(m),m}function O(s,t,o){return i(A,i(A,s.origin,s.basis1),s.basis2),c(k,A,s.basis1,2),c(U,k,s.basis2,2),c(S,A,s.basis2,2),A[2]=k[2]=U[2]=S[2]=t,R({topLeft:S,topRight:U,bottomRight:k,bottomLeft:A,spatialReference:o})}const S=l(),U=l(),k=l(),A=l();export{C as TransformBounds,O as mapPlaneAutoSize2D};
|