// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("../../../geometry ../../../Graphic ../../../core/arrayUtils ../../../core/Logger ../../../core/promiseUtils ../../../layers/orientedImagery/transformations/imageToGroundUtils ../../../layers/orientedImagery/transformations/utils ../symbols ../../../geometry/Polygon".split(" "),function(E,p,z,A,q,x,B,r,y){class C{constructor(D){this.viewModel=D;this.createFootprints=async b=>{await q.waitTick(b);const {coveragePolygons:d,currentBestFeature:c,isAdditionalCoverageVisible:e}=this.viewModel;for(const a of d)a?.imageID=== c.attributes.objectId?this.viewModel.bestFeatureFootprint=new p({attributes:{imageID:a?.imageID},geometry:a,symbol:r.activePolygonSymbol,visible:!1}):this.viewModel.additionalFootprints.push(new p({attributes:{imageID:a?.imageID},geometry:a,symbol:r.polygonSymbol.clone(),visible:e}))};this.updateFootprint=async(b,d)=>{const {activeViewer:c,currentBestFeature:e,currentCoverageVisible:a,footprintExtent:t}=this.viewModel,m=c?.imageSize;if(e&&m&&t)try{const g=await x.transformPoints(b,{feature:e,imageProperties:{width:m[0], height:m[1]},options:d,footprintExtent:t});q.throwIfAborted(d);const f=g.filter(z.isSome);if(f.length){var h=[f.map(({x:k,y:u})=>[k,u,1])];h[0].push(h[0][0]);var v=new y({rings:h,spatialReference:f[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new p({geometry:v,attributes:{imageID:e.attributes.objectId},symbol:r.activePolygonSymbol,visible:a}))}}catch(g){q.isAbortError(g)||A.getLogger(this.viewModel).error("update-footprint",g)}};this.updateFootprintPanorama=async(b,d)=>{const {horizontalFieldOfView:c, pitch:e,verticalFieldOfView:a,yaw:t}=b,{activeViewer:m,currentBestFeature:h,currentCoverageVisible:v,footprintExtent:g}=this.viewModel,f=m?.imageSize;if(h&&f&&g){var {cameraPitch:k,objectId:u}=h.attributes;if(180e+k+a/2)b=[[-c/2,a/2],[c/2,a/2],...(0>e-a/2?[[-c/2,-a/2],[c/2,-a/2]]:[[c/2,-a/2],[-c/2,-a/2]])];else if(180>e+k-a/2&&180B.convertOrientationToPixelLocation(t+l,e+n,f[0],f[1]));b=await x.transformPoints(b,{feature:h,imageProperties:{width:f[0],height:f[1]},options:d,footprintExtent:g});q.throwIfAborted(d);d=[b.map(({x:l,y:n})=>[l,n,1])];d[0].push(d[0][0]);d=new y({rings:d,spatialReference:b[0].spatialReference});this.viewModel.updateCurrentCoveragePolygon(new p({geometry:d,attributes:{imageID:u},symbol:r.activePolygonSymbol.clone(),visible:v}))}}}}}return C});