@arcgis/core 4.34.1 → 4.34.3
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/{fdaf8fb5a3cc7abea44b.js → 1a206387dc9f5f1b0f79.js} +1 -1
- package/assets/esri/core/workers/chunks/{7010d1eb303a13c72f81.js → 999da9a02ecdf6129c69.js} +1 -1
- package/assets/esri/core/workers/chunks/e7689eb3c45be276acfb.js +1 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +0 -1
- 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/interfaces.d.ts +10 -10
- package/kernel.js +1 -1
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
- package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
- package/widgets/FeatureTable/support/templateUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/mixins/TriangulatedImageMeasurementMixin.js +1 -1
- package/widgets/VideoPlayer/VideoPlayerViewModel.js +1 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/assets/esri/core/workers/chunks/4a38b1402cd48ced5d0f.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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as c}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as d}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,syncAndInitial as M,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isSerializable as A}from"../../core/support/jsonUtils.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as G}from"../../geometry/geometryEngineAsync.js";import T from"../../geometry/Multipoint.js";import O from"../../geometry/Point.js";import R from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as B}from"../../geometry/projectionUtils.js";import x from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as H}from"../../geometry/support/centroid.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as D}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import U from"../../layers/GraphicsLayer.js";import N from"../../layers/MediaLayer.js";import{searchImages as W,getSortedLayerFeatures as q}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as $}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as J,computePolygonForInspection as Z,resizePolygon as K,checkIfPolygonContainsSelectedPoint as Q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as de,transformGraphicCoordinatesToPixel as me,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as we}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import _e from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Me}from"../../views/input/InputManager.js";import Ie from"../PanoramicVideoViewer.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ve,videoExtent as Se,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Ce,sectorsRadii as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Te,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Re}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{getModeCorrectedPoint as xe,calculateCorrectedPixel as He,getUnitRateFromSpatialReference as Ee,calculateHeightFromTemporaryDistance as De,getModeCorrectedPoints as ze,computeTriangulatedVector as Ue,computeTriangulatedPoint as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,cameraOverlaySymbol3D as Ke,cameraOverlaySymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at,sourcePointSymbol as it}from"./symbols.js";import{isNoAttachmentError as rt,getContentType as st,isTifOrMrf as ot,filterOILLayerView as nt,assignElevationSampleToFeatures as ct,calculateDirection as lt,calculateSegment as ht,isSceneView as ut,isGraphic as dt}from"./utils.js";import{disableVideoZoomAndPan as mt}from"./videoViewerUtils.js";import pt from"./components/ImageViewer.js";import gt from"./components/NavigationNode.js";import yt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as vt,NoFeatureFoundWithObjectIdError as wt}from"./navigation/errors.js";import{queryFeatureByObjectIds as ft}from"./navigation/queries.js";import{ImageMeasurementService as Ft}from"./services/ImageMeasurementService.js";import _t from"../Sketch/SketchViewModel.js";const bt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},Mt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),It=new Set(["MRF","TIFF","TIF"]),Pt=/\.(\w+)$/,Vt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let St=class extends(c(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=Ve,this.cameraPitchThreshold=Ve,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.directionMode="Relative",this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadDepthImage(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new pt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new f,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,a)=>{"default"===this.mode&&"image-loaded"!==this.state||this.mode.includes("video")&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t,a))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new Fe({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new pt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Ie,this._panoramicViewer=new Pe,this._panoramicMeasurementViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new C,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]:null)!==t&&(e.visible=!e.visible)})},this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await ee(e,r,i);return ge(n,o)},this.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ye(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new vt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(bt.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,Me.WIDGET),bt.click)},this._createImageClickHandle=()=>{this.removeHandles(bt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:B(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],bt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(bt.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),bt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(bt.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await B(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,bt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(bt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");re(!s,l)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await B(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,bt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?z(h):new O(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await se(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Pt)?.[1]:e.datasetFormat;if(!l)try{l=await st(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(Mt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await se(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,It.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=D(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await w(a),!e)return;const i=new O({...A(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new O(n,x.WebMercator),symbol:qe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._initializeMeasurementService(),this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(bt.interactionHandles),e){case"default":this.addHandles(b(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:a}=this;if(e&&t?.loaded&&a)return{videoExtent:Se,bestFeatureFootprint:a}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e.videoExtent,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e?.videoExtent,t?.videoExtent,h)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),bt.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(bt.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),bt.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",d(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",d(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!ot(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return ot(t)||je(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ke}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(nt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?we(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:a}=this;if(!this.isFulfilled()||t||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return ot(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new U({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new U({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(this.displayMessage=null),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){return this._measurementService?.computeHeight(e,t,a)}async calculateAreaMeasurement(e,t,a){return this._measurementService?.calculateAreaMeasurement(e,t,a)}async calculateDistanceMeasurement(e,t,a){return this._measurementService?.calculateDistanceMeasurement(e,t,a)}async calculateAccuracy(e,t,a){return this._measurementService?.calculateAccuracy(e,t,a)}async calculateLocationAccuracy(e,t,a="default",i){return this._measurementService?.calculateLocationAccuracy(e,t,a,i)}async calculateAccuracyPanoramic(e,t,a=!1,i){return this._measurementService?.calculateAccuracyPanoramic(e,t,a,i)}async calculateHeightMeasurementInfo(e,t,a){return this._measurementService?.calculateHeightMeasurementInfo(e,t,a)}async calculateTriangulatedMeasurements(e){await(this._measurementService?.calculateTriangulatedMeasurements(e))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw Vt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Vt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Vt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Vt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Vt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Vt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Vt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const{polygon:l,frustum:h}=J(n);if(c=l.clone(),n.isInspection&&(c=Z(n)),o&&(c=K(c,o)),a||!t||Q(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),c!==ke&&(i.push(l),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ue(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const c=xe(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=He(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Ee(o.attributes.location.spatialReference),u=De(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=xe(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),ct(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async processFeatureElevation(e,t,a){if(!t)return;const{features:i,polygons:r}=this.filterByFootprints(e,t,!0);if(!i?.length)return;const s=await this.processElevationSample(r,i,a);return v(a),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new _e({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:a});else{const i=new j({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=ze(e,i,r),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await B(a,o)),n.push(a)}return Ue(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=J(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n="panoramic"===o?Ke():Qe();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Te(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(m.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Oe(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Re(s,d,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new R({rings:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de));return new t({attributes:s,layer:e,symbol:r,geometry:new T({points:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new O({x:e.x-.5,y:.5-e.y,spatialReference:x.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new O(n,x.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await B(h,x.WebMercator));const u=await le(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&he(u.elevationSample)&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=ce(o,r[0],r[1]);d=await ee(m,{...e,cameraLocation:h},u)}else{const e=ue(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new O({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=A(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new O({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new O(n,x.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e,t)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(me(s,m,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new R({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(de))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map(e=>e.map(de))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await W(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=Ue(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async updateFeatureCache(e,t){const a=await q(e,t);a.features?.length&&(this.featureCache=a.features)}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=Ue(e,a);i&&this.measurementVectors.push(i);const r=await Ne(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Le[2],c=ht(t,l),h=lt(i);if(!this._sectorData)return;const u=Le[3]+n*Math.sin(i*Math.PI/180),d=Le[3]+n*Math.cos(i*Math.PI/180);let m;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)m=-90;else{const e=u-Le[3],t=d-Le[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),m=i}const w=""===c?h:`${c}_${h}`;g&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=v?null:{x:u,y:d,direction:h}),o[`${p.attributes.objectId}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new Ft(this))}_initializeSketchTriangular(){if(!this.activeTriangulatedViewer)return;const e="panoramic"===this.mode;this.sketchTriangular=new _t({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(bt.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Ce)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new N({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(mt(this.videoMapView),bt.videoPlayerHandles),this.videoViewModel=new yt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=A(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new O({spatialReference:x.WebMercator,...i}),symbol:et}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new O({spatialReference:x.WebMercator,...i}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=oe(e,s,o),l=ne(n,c),h=new t({geometry:new O(l,x.WebMercator),symbol:tt});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await G(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return $({features:e,selectedPoint:t,camera:ut(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=D(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await B(o,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(d,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await ft(e,t,a,i);if(v(i),!r?.features?.length)throw new wt(t);const s=J(r.features[0].attributes).polygon,o=O.fromJSON(H(s)),n=Y(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await W(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(bt.activeViewerCursorHandles),t&&this.removeHandles(bt.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=he(a),{location:s,cameraHeight:o}=e[0].attributes,n=await le(s.spatialReference,s.z,o,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[c,...l]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=c.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new gt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0])),"panoramic-video"===this.mode&&this._loadVideo()}_updateFootprintWithFeatures(e,t){const a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+E([e,t])),t.addRing(a),this.footprintExtent=be(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:it,visible:s}));"video"!==o&&"panoramic-video"!==o||!n||this.featureCache.length||await this.updateFeatureCache(n,i.geometry.spatialReference)}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Le[3],i=e.y-Le[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:c},elevationSample:l}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,c,{elevationSample:l,elevationSource:o});t.elevationSample=u.elevationSample;const d=Array.isArray(e)?e:[e];let m,p=await Promise.all(d.map(e=>new Promise(t=>{if(!e.hasZ)return t(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await B(h,x.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await B(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);m=ge(p,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:h}=this;if(!r)return;const{attributes:{objectId:u},elevationSample:d}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(dt);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,d),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],d)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e],d),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],St.prototype,"activeLayer",null),e([S({readOnly:!0})],St.prototype,"activeViewer",null),e([S()],St.prototype,"activeTriangulatedViewer",null),e([S()],St.prototype,"accuracyParametersMissing",null),e([S()],St.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalFootprints",void 0),e([S()],St.prototype,"areaMeasurementResult",void 0),e([S()],St.prototype,"areaMeasurementAccuracy",void 0),e([S()],St.prototype,"bestFeatureAngle",void 0),e([S()],St.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],St.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],St.prototype,"brightness",null),e([S()],St.prototype,"cameraHeadingThreshold",void 0),e([S()],St.prototype,"cameraPitchThreshold",void 0),e([S()],St.prototype,"clickAction",void 0),e([S()],St.prototype,"videoViewModel",void 0),e([S()],St.prototype,"collectionId",void 0),e([S({type:Number})],St.prototype,"contrast",null),e([S()],St.prototype,"conversionProps",void 0),e([S()],St.prototype,"coverageFrustums",void 0),e([S()],St.prototype,"coveragePolygons",void 0),e([S()],St.prototype,"currentBestFeature",void 0),e([S()],St.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],St.prototype,"currentBestFeatureLocation",void 0),e([S()],St.prototype,"currentCoverageVisible",void 0),e([S()],St.prototype,"currentNode",null),e([S()],St.prototype,"depthImage",void 0),e([S()],St.prototype,"depthImageNotSupported",null),e([S()],St.prototype,"directionMode",void 0),e([S()],St.prototype,"featureCache",void 0),e([S()],St.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],St.prototype,"disabled",void 0),e([S()],St.prototype,"displayMessage",void 0),e([S()],St.prototype,"displayNewMeasurementButton",void 0),e([S()],St.prototype,"distanceMeasurementResult",void 0),e([S()],St.prototype,"distanceAccuracyArray",void 0),e([S()],St.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],St.prototype,"featureCount",null),e([S()],St.prototype,"features",void 0),e([S()],St.prototype,"groundCoordinates",void 0),e([S()],St.prototype,"groundCoordinatesAccuracy",void 0),e([S()],St.prototype,"heightMeasurementPixels",void 0),e([S()],St.prototype,"heightGraphic",void 0),e([S()],St.prototype,"heightMeasurementResult",void 0),e([S()],St.prototype,"heightMeasurementAccuracy",void 0),e([S()],St.prototype,"measurementAngle",void 0),e([S()],St.prototype,"tempDistance",void 0),e([S({readOnly:!0})],St.prototype,"imageGalleryEnabled",null),e([S()],St.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],St.prototype,"imageLoaded",null),e([S()],St.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],St.prototype,"invalidCameraHeading",null),e([S()],St.prototype,"imagePointsInView",null),e([S()],St.prototype,"imageMeasurementViewer",void 0),e([S()],St.prototype,"isAdditionalCoverageVisible",void 0),e([S()],St.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],St.prototype,"measurementVectors",void 0),e([S()],St.prototype,"layer",void 0),e([S()],St.prototype,"layerView",null),e([S({readOnly:!0})],St.prototype,"layerFloorFilterClause",null),e([S({type:Number})],St.prototype,"localPort",void 0),e([S()],St.prototype,"mapImageConversionToolState",void 0),e([S()],St.prototype,"measureType",void 0),e([S()],St.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],St.prototype,"mode",null),e([S()],St.prototype,"navigationMode",void 0),e([S()],St.prototype,"navigatorCurrentBestFeature",void 0),e([S()],St.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],St.prototype,"overlayedCameraLocations",void 0),e([S()],St.prototype,"overlayedMapFeatures",void 0),e([S()],St.prototype,"panoramicVideoLoaded",null),e([S()],St.prototype,"pixelCoordinates",void 0),e([S()],St.prototype,"preserveAngle",void 0),e([S()],St.prototype,"pointSources",void 0),e([S({readOnly:!0})],St.prototype,"popupEnabled",null),e([S()],St.prototype,"previousFeatureAngle",void 0),e([S()],St.prototype,"referencePoint",null),e([S({readOnly:!0})],St.prototype,"sectorData",null),e([S()],St.prototype,"selectedPoint",void 0),e([S({type:Number})],St.prototype,"sharpness",null),e([S()],St.prototype,"shouldShowSelectedImage",void 0),e([S()],St.prototype,"sketch",void 0),e([S()],St.prototype,"sketchTriangular",void 0),e([S()],St.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],St.prototype,"draw",void 0),e([S()],St.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],St.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],St.prototype,"state",null),e([S({readOnly:!0})],St.prototype,"thumbnails",null),e([S()],St.prototype,"triangularMeasurementActive",void 0),e([S()],St.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],St.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],St.prototype,"triangulatedAreaMeasurement",void 0),e([S()],St.prototype,"triangulatedAreaAccuracy",void 0),e([S()],St.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],St.prototype,"triangulatedPoint",void 0),e([S()],St.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],St.prototype,"updateFootprint",void 0),e([S()],St.prototype,"updateFootprintPanorama",void 0),e([S()],St.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],St.prototype,"view",null),e([S()],St.prototype,"videoElement",void 0),e([S()],St.prototype,"videoLayer",void 0),e([S()],St.prototype,"videoMapView",void 0),e([S()],St.prototype,"_adapter",void 0),e([S()],St.prototype,"_defaultGraphicsLayer",null),e([S()],St.prototype,"_highlightedFeatureHandle",void 0),e([S()],St.prototype,"_imageViewer",void 0),e([S()],St.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],St.prototype,"_locationPointOnImage",void 0),e([S()],St.prototype,"_measurementService",void 0),e([S()],St.prototype,"_correctedLocationPointOnImage",void 0),e([S()],St.prototype,"_overlays",void 0),e([S({readOnly:!0})],St.prototype,"_overlaysView",null),e([S()],St.prototype,"_panoramicVideoViewer",void 0),e([S()],St.prototype,"_panoramicViewer",void 0),e([S()],St.prototype,"_panoramicMeasurementViewer",void 0),e([S()],St.prototype,"_referencePointOnGround",void 0),e([S()],St.prototype,"_referencePointOnImage",void 0),e([S()],St.prototype,"_sectorData",void 0),e([S()],St.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],St.prototype,"_updatingHandles",void 0),e([S()],St.prototype,"footprintExtent",void 0),e([S()],St.prototype,"_featureChangedTask",void 0),St=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],St);const kt=St;export{kt as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as c}from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as d}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,syncAndInitial as M,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isSerializable as A}from"../../core/support/jsonUtils.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as G}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as B}from"../../geometry/projectionUtils.js";import x from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as H}from"../../geometry/support/centroid.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as D}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import U from"../../layers/GraphicsLayer.js";import N from"../../layers/MediaLayer.js";import{searchImages as W,getSortedLayerFeatures as q}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as $}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as J,computePolygonForInspection as Z,resizePolygon as K,checkIfPolygonContainsSelectedPoint as Q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as de,transformGraphicCoordinatesToPixel as me,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as we}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import _e from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Me}from"../../views/input/InputManager.js";import Ie from"../PanoramicVideoViewer.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ve,videoExtent as Se,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Ce,sectorsRadii as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Re,isValidDataCaptureLayer as Te,constructGraphicFromImageGeometry as Oe}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{getModeCorrectedPoint as xe,calculateCorrectedPixel as He,getUnitRateFromSpatialReference as Ee,calculateHeightFromTemporaryDistance as De,getModeCorrectedPoints as ze,computeTriangulatedVector as Ue,computeTriangulatedPoint as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,cameraOverlaySymbol3D as Ke,cameraOverlaySymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at,sourcePointSymbol as it}from"./symbols.js";import{isNoAttachmentError as rt,getContentType as st,isTifOrMrf as ot,filterOILLayerView as nt,assignElevationSampleToFeatures as ct,calculateDirection as lt,calculateSegment as ht,isSceneView as ut,isGraphic as dt}from"./utils.js";import{disableVideoZoomAndPan as mt}from"./videoViewerUtils.js";import pt from"./components/ImageViewer.js";import gt from"./components/NavigationNode.js";import yt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as vt,NoFeatureFoundWithObjectIdError as wt}from"./navigation/errors.js";import{queryFeatureByObjectIds as ft}from"./navigation/queries.js";import{ImageMeasurementService as Ft}from"./services/ImageMeasurementService.js";import _t from"../Sketch/SketchViewModel.js";const bt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},Mt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),It=new Set(["MRF","TIFF","TIF"]),Pt=/\.(\w+)$/,Vt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let St=class extends(c(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=Ve,this.cameraPitchThreshold=Ve,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.depthImage=null,this.directionMode="Relative",this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadDepthImage(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new pt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new f,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t,a)=>{"default"===this.mode&&"image-loaded"!==this.state||this.mode.includes("video")&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t,a))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new Fe({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new pt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Ie,this._panoramicViewer=new Pe,this._panoramicMeasurementViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new C,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]:null)!==t&&(e.visible=!e.visible)})},this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await ee(e,r,i);return ge(n,o)},this.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ye(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new vt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(bt.click),this.disabled||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,Me.WIDGET),bt.click)},this._createImageClickHandle=()=>{this.removeHandles(bt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:B(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],bt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(bt.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),bt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(bt.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await B(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,bt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(bt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");re(!s,l)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await B(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,bt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new T(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?z(h):new T(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await se(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Pt)?.[1]:e.datasetFormat;if(!l)try{l=await st(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(Mt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await se(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,It.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new T(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return rt(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=D(t.x,t.spatialReference),this.plotMapPoint(e.mapPoint)}},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await w(a),!e)return;const i=new T({...A(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new T(n,x.WebMercator),symbol:qe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view,this.disabled],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._initializeMeasurementService(),this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},M),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),b(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},M),b(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(bt.interactionHandles),e){case"default":this.addHandles(b(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e,videoElement:t,bestFeatureFootprint:a}=this;if(e&&t?.loaded&&a)return{videoExtent:Se,bestFeatureFootprint:a}},e=>{e?.videoExtent&&e?.bestFeatureFootprint&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e.videoExtent,void 0,{signal:t})}))},{...M,equals:(e,t)=>a(e?.videoExtent,t?.videoExtent,h)&&e?.bestFeatureFootprint===t?.bestFeatureFootprint}),bt.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),bt.interactionHandles)}},M),b(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},M),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(bt.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),bt.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy(),this._panoramicMeasurementViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",d(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",d(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!ot(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return ot(t)||je(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ke}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(nt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?we(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}get state(){const{mode:e,_updatingHandles:{updating:t},_featureChangedTask:a}=this;if(!this.isFulfilled()||t||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return ot(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new U({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new U({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(this.displayMessage=null),this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){return this._measurementService?.computeHeight(e,t,a)}async calculateAreaMeasurement(e,t,a){return this._measurementService?.calculateAreaMeasurement(e,t,a)}async calculateDistanceMeasurement(e,t,a){return this._measurementService?.calculateDistanceMeasurement(e,t,a)}async calculateAccuracy(e,t,a){return this._measurementService?.calculateAccuracy(e,t,a)}async calculateLocationAccuracy(e,t,a="default",i){return this._measurementService?.calculateLocationAccuracy(e,t,a,i)}async calculateAccuracyPanoramic(e,t,a=!1,i){return this._measurementService?.calculateAccuracyPanoramic(e,t,a,i)}async calculateHeightMeasurementInfo(e,t,a){return this._measurementService?.calculateHeightMeasurementInfo(e,t,a)}async calculateTriangulatedMeasurements(e){await(this._measurementService?.calculateTriangulatedMeasurements(e))}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw Vt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Vt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Vt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Vt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Vt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Vt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Vt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const{polygon:l,frustum:h}=J(n);if(c=l.clone(),n.isInspection&&(c=Z(n)),o&&(c=K(c,o)),a||!t||Q(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),c!==ke&&(i.push(l),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ue(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,x.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const c=xe(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=He(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Ee(o.attributes.location.spatialReference),u=De(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=xe(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._defaultGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),ct(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async processFeatureElevation(e,t,a){if(!t)return;const{features:i,polygons:r}=this.filterByFootprints(e,t,!0);if(!i?.length)return;const s=await this.processElevationSample(r,i,a);return v(a),s}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new _e({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:a});else{const i=new j({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=ze(e,i,r),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await B(a,o)),n.push(a)}return Ue(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=J(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n="panoramic"===o?Ke():Qe();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Re(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(m.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Te(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Oe(s,d,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:d,spatialReference:x.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new T({x:e.x-.5,y:.5-e.y,spatialReference:x.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new T(n,x.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await B(h,x.WebMercator));const u=await le(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&he(u.elevationSample)&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=ce(o,r[0],r[1]);d=await ee(m,{...e,cameraLocation:h},u)}else{const e=ue(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new T({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=A(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new T({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new T(n,x.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e,t)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(me(s,m,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(de))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map(e=>e.map(de))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await W(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=Ue(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async updateFeatureCache(e,t){const a=await q(e,t);a.features?.length&&(this.featureCache=a.features)}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a,view:i}=this,r=Ue(e,a);r&&this.measurementVectors.push(r);let s=await Ne(this.measurementVectors);v(t),s?.spatialReference&&i?.spatialReference&&!s.spatialReference.equals(i.spatialReference)&&(s=await B(s,i.spatialReference)),this.triangulatedPoint=s??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Le[2],c=ht(t,l),h=lt(i);if(!this._sectorData)return;const u=Le[3]+n*Math.sin(i*Math.PI/180),d=Le[3]+n*Math.cos(i*Math.PI/180);let m;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)m=-90;else{const e=u-Le[3],t=d-Le[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),m=i}const w=""===c?h:`${c}_${h}`;g&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=v?null:{x:u,y:d,direction:h}),o[`${p.attributes.objectId}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new Ft(this))}_initializeSketchTriangular(){if(!this.activeTriangulatedViewer)return;const e="panoramic"===this.mode;this.sketchTriangular=new _t({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(bt.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Ce)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new N({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(mt(this.videoMapView),bt.videoPlayerHandles),this.videoViewModel=new yt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=A(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new T({spatialReference:x.WebMercator,...i}),symbol:et}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:x.WebMercator,...i}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=oe(e,s,o),l=ne(n,c),h=new t({geometry:new T(l,x.WebMercator),symbol:tt});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.videoElement?.content?.pause(),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await G(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return $({features:e,selectedPoint:t,camera:ut(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=D(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await B(o,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(d,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await ft(e,t,a,i);if(v(i),!r?.features?.length)throw new wt(t);const s=J(r.features[0].attributes).polygon,o=T.fromJSON(H(s)),n=Y(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await W(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(bt.activeViewerCursorHandles),t&&this.removeHandles(bt.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),bt.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=he(a),{location:s,cameraHeight:o}=e[0].attributes,n=await le(s.spatialReference,s.z,o,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[c,...l]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=c.z,e.forEach((e,t)=>{e.attributes.elevation=l[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new gt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0])),"panoramic-video"===this.mode&&this._loadVideo()}_updateFootprintWithFeatures(e,t){const a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+E([e,t])),t.addRing(a),this.footprintExtent=be(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:it,visible:s}));"video"!==o&&"panoramic-video"!==o||!n||this.featureCache.length||await this.updateFeatureCache(n,i.geometry.spatialReference)}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Le[3],i=e.y-Le[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._panoramicMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:c},elevationSample:l}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,c,{elevationSample:l,elevationSource:o});t.elevationSample=u.elevationSample;const d=Array.isArray(e)?e:[e];let m,p=await Promise.all(d.map(e=>new Promise(t=>{if(!e.hasZ)return t(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await B(h,x.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await B(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);m=ge(p,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:h}=this;if(!r)return;const{attributes:{objectId:u},elevationSample:d}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(dt);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,d),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],d)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,"3d"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e],d),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],St.prototype,"activeLayer",null),e([S({readOnly:!0})],St.prototype,"activeViewer",null),e([S()],St.prototype,"activeTriangulatedViewer",null),e([S()],St.prototype,"accuracyParametersMissing",null),e([S()],St.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],St.prototype,"additionalFootprints",void 0),e([S()],St.prototype,"areaMeasurementResult",void 0),e([S()],St.prototype,"areaMeasurementAccuracy",void 0),e([S()],St.prototype,"bestFeatureAngle",void 0),e([S()],St.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],St.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],St.prototype,"brightness",null),e([S()],St.prototype,"cameraHeadingThreshold",void 0),e([S()],St.prototype,"cameraPitchThreshold",void 0),e([S()],St.prototype,"clickAction",void 0),e([S()],St.prototype,"videoViewModel",void 0),e([S()],St.prototype,"collectionId",void 0),e([S({type:Number})],St.prototype,"contrast",null),e([S()],St.prototype,"conversionProps",void 0),e([S()],St.prototype,"coverageFrustums",void 0),e([S()],St.prototype,"coveragePolygons",void 0),e([S()],St.prototype,"currentBestFeature",void 0),e([S()],St.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],St.prototype,"currentBestFeatureLocation",void 0),e([S()],St.prototype,"currentCoverageVisible",void 0),e([S()],St.prototype,"currentNode",null),e([S()],St.prototype,"depthImage",void 0),e([S()],St.prototype,"depthImageNotSupported",null),e([S()],St.prototype,"directionMode",void 0),e([S()],St.prototype,"featureCache",void 0),e([S()],St.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],St.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],St.prototype,"disabled",void 0),e([S()],St.prototype,"displayMessage",void 0),e([S()],St.prototype,"displayNewMeasurementButton",void 0),e([S()],St.prototype,"distanceMeasurementResult",void 0),e([S()],St.prototype,"distanceAccuracyArray",void 0),e([S()],St.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],St.prototype,"featureCount",null),e([S()],St.prototype,"features",void 0),e([S()],St.prototype,"groundCoordinates",void 0),e([S()],St.prototype,"groundCoordinatesAccuracy",void 0),e([S()],St.prototype,"heightMeasurementPixels",void 0),e([S()],St.prototype,"heightGraphic",void 0),e([S()],St.prototype,"heightMeasurementResult",void 0),e([S()],St.prototype,"heightMeasurementAccuracy",void 0),e([S()],St.prototype,"measurementAngle",void 0),e([S()],St.prototype,"tempDistance",void 0),e([S({readOnly:!0})],St.prototype,"imageGalleryEnabled",null),e([S()],St.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],St.prototype,"imageLoaded",null),e([S()],St.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],St.prototype,"invalidCameraHeading",null),e([S()],St.prototype,"imagePointsInView",null),e([S()],St.prototype,"imageMeasurementViewer",void 0),e([S()],St.prototype,"isAdditionalCoverageVisible",void 0),e([S()],St.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],St.prototype,"measurementVectors",void 0),e([S()],St.prototype,"layer",void 0),e([S()],St.prototype,"layerView",null),e([S({readOnly:!0})],St.prototype,"layerFloorFilterClause",null),e([S({type:Number})],St.prototype,"localPort",void 0),e([S()],St.prototype,"mapImageConversionToolState",void 0),e([S()],St.prototype,"measureType",void 0),e([S()],St.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],St.prototype,"mode",null),e([S()],St.prototype,"navigationMode",void 0),e([S()],St.prototype,"navigatorCurrentBestFeature",void 0),e([S()],St.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],St.prototype,"overlayedCameraLocations",void 0),e([S()],St.prototype,"overlayedMapFeatures",void 0),e([S()],St.prototype,"panoramicVideoLoaded",null),e([S()],St.prototype,"pixelCoordinates",void 0),e([S()],St.prototype,"preserveAngle",void 0),e([S()],St.prototype,"pointSources",void 0),e([S({readOnly:!0})],St.prototype,"popupEnabled",null),e([S()],St.prototype,"previousFeatureAngle",void 0),e([S()],St.prototype,"referencePoint",null),e([S({readOnly:!0})],St.prototype,"sectorData",null),e([S()],St.prototype,"selectedPoint",void 0),e([S({type:Number})],St.prototype,"sharpness",null),e([S()],St.prototype,"shouldShowSelectedImage",void 0),e([S()],St.prototype,"sketch",void 0),e([S()],St.prototype,"sketchTriangular",void 0),e([S()],St.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],St.prototype,"draw",void 0),e([S()],St.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],St.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],St.prototype,"state",null),e([S({readOnly:!0})],St.prototype,"thumbnails",null),e([S()],St.prototype,"triangularMeasurementActive",void 0),e([S()],St.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],St.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],St.prototype,"triangulatedAreaMeasurement",void 0),e([S()],St.prototype,"triangulatedAreaAccuracy",void 0),e([S()],St.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],St.prototype,"triangulatedPoint",void 0),e([S()],St.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],St.prototype,"updateFootprint",void 0),e([S()],St.prototype,"updateFootprintPanorama",void 0),e([S()],St.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],St.prototype,"view",null),e([S()],St.prototype,"videoElement",void 0),e([S()],St.prototype,"videoLayer",void 0),e([S()],St.prototype,"videoMapView",void 0),e([S()],St.prototype,"_adapter",void 0),e([S()],St.prototype,"_defaultGraphicsLayer",null),e([S()],St.prototype,"_highlightedFeatureHandle",void 0),e([S()],St.prototype,"_imageViewer",void 0),e([S()],St.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],St.prototype,"_locationPointOnImage",void 0),e([S()],St.prototype,"_measurementService",void 0),e([S()],St.prototype,"_correctedLocationPointOnImage",void 0),e([S()],St.prototype,"_overlays",void 0),e([S({readOnly:!0})],St.prototype,"_overlaysView",null),e([S()],St.prototype,"_panoramicVideoViewer",void 0),e([S()],St.prototype,"_panoramicViewer",void 0),e([S()],St.prototype,"_panoramicMeasurementViewer",void 0),e([S()],St.prototype,"_referencePointOnGround",void 0),e([S()],St.prototype,"_referencePointOnImage",void 0),e([S()],St.prototype,"_sectorData",void 0),e([S()],St.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],St.prototype,"_updatingHandles",void 0),e([S()],St.prototype,"footprintExtent",void 0),e([S()],St.prototype,"_featureChangedTask",void 0),St=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],St);const kt=St;export{kt 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}from"../../../../core/promiseUtils.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as o}from"../../../../layers/orientedImagery/transformations/utils.js";import{getModeCorrectedPoints as
|
|
5
|
+
import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}from"../../../../core/promiseUtils.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as o}from"../../../../layers/orientedImagery/transformations/utils.js";import{getModeCorrectedPoints as n,computeTriangulatedVector as c,computeTriangulatedAreaMeasurement as m,computeTriangulatedDistanceMeasurement as u}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as l}from"../../mixins/TriangulatedSketchHandlerMixin.js";let d=[],p=class extends(l(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if(this._preventLeftMouseDrag(),"distance"===t){const t=e.graphics[0].geometry;d=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;d=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?await this._updateTriangularMeasurements(d):await this.viewModel.processMeasurementVectors(d))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:i}=this.viewModel,o=a?.imageSize;if(!e||!t||!o)return;const m=n(e,r,o),u=i?.spatialReference,l=[];for(let n=0;n<m.length;n++){const e={x:m[n][0],y:m[n][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:o,mode:r});u&&!a.spatialReference.equals(u)&&(a=await s(a,u)),l.push(a)}return c(l,t)}async _updateTriangularMeasurements(e,t){const{measureType:r,mode:i,activeTriangulatedViewer:s,triangularMeasurementActive:n,currentBestFeatureMeasurementImage:c,updatingTriangularMeasurementState:l}=this.viewModel;if(!(n&&c&&l&&s?.imageSize&&2===this.viewModel.measurementVectors?.length))return;const[d,p]=s.imageSize;this.viewModel.measurementVectors.splice(-1);const g=await this._computeMeasurementVector(e,c);if(a(t),g&&this.viewModel.measurementVectors.push(g),2===this.viewModel.measurementVectors.length){switch(r){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await u(this.viewModel.measurementVectors),a(t);const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]}),s="default"===i?await this.viewModel.calculateAccuracy(e,"distance"):await this.viewModel.calculateAccuracyPanoramic(r,"distance",!0);if(a(t),s&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(s/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:s,angleAccuracy:e}}break}case"area":if(c?.geometry.spatialReference){const e=await m(this.viewModel.measurementVectors,c.geometry.spatialReference);a(t),this.viewModel.triangulatedAreaMeasurement=e}}if(this.viewModel.updatingTriangularMeasurementState=!1,"panoramic"===this.viewModel.mode){this.viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}_preventLeftMouseDrag(){const{mode:e,activeTriangulatedViewer:t}=this.viewModel;if("panoramic"!==e||!t)return;let a=null;t.imageRenderer.on("pointer-down",e=>{a=e.button}),t.imageRenderer.on("drag",e=>{0===a&&e.stopPropagation()})}};e([r()],p.prototype,"type",void 0),p=e([i("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],p);const g=p;export{g 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.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as n}from"../../core/promiseUtils.js";import{formatArea as e,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as i,determinant as s}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as u,fromValues as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{j as m,i as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as w,project as M}from"../../geometry/projectionUtils.js";import R from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{e as L}from"../../chunks/simplifyOperator.js";import{isSupported as I,geodesicLengths as W,geodesicAreas as k}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as q,imageToWorld as G}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as A,scaleWithFactor as D}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as U,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const S=1e5,F="meters",T="square-meters";function H(t,n){let e=180*Math.atan2(-t.y+n.y,t.x-n.x)/Math.PI;return e<0&&(e+=180),e*Math.PI/180}function V(t,n){let e=180*Math.atan2(-t.y+n.y,t.x-n.x)/Math.PI;return e<0&&(e+=180),e*Math.PI/180}function C(t,n,e){if(!t?.length||!n?.length||!e)return;const[r,a]=t,[,o]=n,i=o-a;return[r+i*Math.cos(e),a+i*Math.sin(e)]}async function J(t,n,e){if(await v(),I(t)){const t=W([n],F)[0];return{area:k([e],T)[0],perimeter:t}}const r=R.WGS84,a=M(n,r),o=M(e,r);let i=j(o,S);if(i=i?L(i):null,!i)return null;const s=W([a],F)[0];return{area:k([i],T)[0],perimeter:s}}async function K(t,e,r,a,o=!1,i){if(e.length<2||!a||!r||!t)return null;const s=zt(r,t);if(!s)return null;const c=e.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map(n=>It([u,l],n,t,o,!1)),m=await Promise.all(f);n(i);let p=0;for(const n of m){if(!n)return null;const t=Math.abs(n-a);p=Math.max(t,p)}return p}async function N(t,e,r,a,o,i=!1,s){if(e.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=dt(r,t),u=e.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(n=>Wt([l,f],n,t,o,i,!1)),p=await Promise.all(m);n(s);let h=0;for(const n of p){if(!n)return 0;const t=Math.abs(n-a);h=Math.max(t,h)}return h}function Q(t,n,e=1){const r=Mt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*e/n}async function X(t){await b();const n=t.spatialReference;if(n.isGeographic){if(I(n))return W([t],F)[0];const e=M(t,R.WGS84);return W([e],F)[0]}return n.isWebMercator?O(t,{unit:F}):E(t,{unit:F})}function Y(t){if(!t?.length)throw new Error("Invalid deviations array");const[n,e,r]=[0,1,2].map(n=>t.map(t=>t[n]).filter(t=>null!==t)).map(t=>t.length?jt(t):0);return[n,e,r]}function Z(t,n){const e=L(n);if(!e)return null;const r=E(t,{unit:F});return{area:z(e,{unit:T}),perimeter:r}}function $(t,n){return[(t[1][0]-t[0][0])/n,(t[1][1]-t[0][1])/n,(t[1][2]-t[0][2])/n]}async function _(t,n){await Promise.all([d(),v(),b()]);let e=j(n,S);if(e=e?L(e):null,!e)return null;const r=O(t,{unit:F});return{area:P(e,{unit:T}),perimeter:r}}async function tt(t,e,r){if(!e||!t)throw new Error("Missing required parameters");const a=await G(t,e);n(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...l}=e;return B(o,l)}async function nt(t,e,r,a){const{attributes:o}=r,{location:i}=o,{updateElevationProps:s,...c}=e;if(!t||!e)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await w(u,R.WebMercator));const l=await q(t,{...c,cameraLocation:u},s);n(a);const f=l.clone();return f.z?f.z+=20:f.z=20,U(f,c)}function et(t,n,e,r,a=0,o=1,i){const{averageElevation:s,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:n.x,y:n.y,z:n.z?n.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([e[0].x,e[0].y],[h.x,h.y]),x=e.at(0),w=e.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return et(M,n,e,r,a+1,Math.abs(t-M))}function rt(t,n,e,r,a=0,o=1,i){const{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:n.x,y:n.y,z:n.z?n.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=U(p,m),g=f([e[0].x,e[0].y],[h.x,h.y]),x=e.at(0),w=e.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return rt(M,n,e,r,a+1,Math.abs(t-M))}function at(t,n,e){return new x({paths:[[[t.x,t.y,t.z??0],[n.x,n.y,n.z??0]]],spatialReference:e})}function ot(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function it(t,n){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/n)**2+(t[0][2]-t[1][2])**2)}function st(t,n){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/n}function ct(n){return t(Math.atan((n[1][2]-n[0][2])/Math.sqrt((n[1][0]-n[0][0])**2+(n[1][1]-n[0][1])**2)))}function ut(n){let e=90-t(Math.atan2(n[1][1]-n[0][1],n[1][0]-n[0][0]));return e<0&&(e+=360),e}function lt(t,n){return new y({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:n})}async function ft(t){if(2===t?.length){const n=[];let e=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:i}=r;for(let t=0;t<i.length;t++){const i=at(r.camera,r.measurePoints[t],o),s=at(a.camera,a.measurePoints[t],o),c=await Dt(i,s);if(!c)return null;const u=lt(c,o);u.spatialReference.isWebMercator&&(e=ot(u.y)),n.push([u.x,u.y,u.z??0])}if(n?.length>1){return{distance:it(n,e),horizontalDistance:st(n,e),verticalDistance:Math.abs(n[0][2]-n[1][2]),slope:ct(n),aspect:ut(n)}}}return null}async function mt(t){const n=t[0].camera.spatialReference;if(2!==t?.length)return null;const[e,r]=t,{camera:a,measurePoints:o}=e,{camera:i,measurePoints:s}=r,c=at(a,o[0],n),u=at(i,s[0],n),l=await Dt(c,u);return l?lt(l,n)??null:null}async function pt(t,n){if(!t?.length)return null;const e=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:i}=r;for(let l=0;l<i.length;l++){const t=at(r.camera,r.measurePoints[l],o),n=at(a.camera,a.measurePoints[l],o),i=await Dt(t,n);if(!i)return null;const s=lt(i,o);e.push([s.x,s.y,s.z??0])}if(e?.length<2)return null;const s=new x({paths:[e],spatialReference:n}),c=new g({rings:[e],spatialReference:n});if(n.isGeographic){const t=await J(n,s,c);return t?.area??null}if(n.isWebMercator){const t=await _(s,c);return t?.area??null}const u=Z(s,c);return u?.area??null}function ht(t,n){if(!t)return null;return{camera:n.geometry.clone(),measurePoints:Array.isArray(t)?t:[t]}}async function yt(t,n){const{updateElevationProps:e,...r}=n;return await G(t,r,e)}async function gt(t,n){const{updateElevationProps:e,...r}=n;return q(t,r,e)}function xt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function wt(t){const n=t.map(t=>[t.x,t.y]),e=t[0].spatialReference;return new x({paths:[n],spatialReference:e})}function Mt(t,n){return t.map(t=>({x:n?.5+t[0]:t[0],y:n?.5-t[1]:t[1]}))}function Rt(t,n,e,a,i){const s="measurement"===t?n:e;if(i&&s)return r(a,o(s,F),i,3)||null}function zt(t,n){const{cameraPitch:e,cameraRoll:r,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(n.every(t=>0===t)||!n||!n.length)return null;const[u,l,,f,m]=n,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],x=[-l,0,l],w=[];for(const M of p)for(const n of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=e+M,f.cameraRoll=r+n,f.cameraLocation=new y({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function dt(t,n){const{cameraHeading:e,cameraLocation:r}=t,{x:a,y:o,z:i,spatialReference:s}=r;if(n.every(t=>0===t)||!n||!n.length)throw new Error("Invalid parameters");const[c,u,l]=n,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const n of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=e+g,u.cameraLocation=new y({x:a+n,y:o+r,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function Pt(t,n,e,a,i){const s="measurement"===t?n:jt(e);if(i&&s)return r(a,o(s,F),i,3)||null}function vt(t,n,r,o,i){const s="measurement"===t?n:r;if(i&&s)return e(o,a(s,T),i,3)||null}function jt(t){return Math.sqrt(t.reduce((t,n)=>t+n**2,0))}function bt(t,n,e){if("default"===n)return t;const r={x:t[0],y:t[1],z:t[2]},a=A(r,e[0],e[1]);return[a.x,a.y]}function Ot(t){return t.metersPerUnit}function Et(t,n,e){let r=[];return r="panoramic"===n?t.map(([t,n,r])=>{const{x:a,y:o}=A({x:t,y:n,z:r},e[0],e[1]);return[a-.5,-.5-o]}):t.map(([t,n])=>[t-.5,-.5-n]),r}function Lt(t,n){return t.map(t=>A({x:t[0],y:t[1],z:t[2]},n[0],n[1]))}async function It(t,e,r,a=!1,o=!1,i){if(!t||!e||t.length<2)return null;const s=Mt(t,a);if(!s||s.length<2)return null;const[c,u]=[s[0],s.at(-1)];if(!u)return null;const l=[c],m=await G(c,e);n(i);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:x,...w}=e,M=B(p,w),R=f([c.x,c.y],[M.x,M.y]),z=H(c,M);if(!z)return;const d=C([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Ot(e.cameraLocation.spatialReference)/R;if(!o)return P;const v=et(P,m,l,e,0,1);return v?.value}async function Wt(t,e,r,a,o=!1,i=!1,s){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=e;if(!t||!e||t.length<2)throw new Error("Invalid parameters");const p=Mt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let x=u.clone();x.spatialReference.isGeographic&&(x=await w(x,R.WebMercator));const M=await q(h,{...m,cameraLocation:x},l);n(s);const z=M.clone();z.z?z.z+=20:z.z=20;const d=U(z,m),P=f([h.x,h.y],[d.x,d.y]),v=H(h,d);if(!v)return;const j=C([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Ot(e.cameraLocation.spatialReference)/P;if(!i)return b;const O=rt(b,M,g,e,0,1);return O?.value}async function kt(t,n,e=!1){if(t.length<3)return null;const r=Mt(t,e),a=await yt(r,n),o=a.map(({x:t,y:n})=>[t,n]);t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new x({paths:[o],spatialReference:i}),c=new g({rings:[o],spatialReference:i});return i.isGeographic?J(i,s,c):i.isWebMercator?_(s,c):Z(s,c)}async function qt(t,e,r=!1,a){if(t.length<3)return null;const o=Mt(t,r),i=await gt(o,e);n(a);const s=i.map(({x:t,y:n})=>[t,n]);t.push(t[0]),s.push(s[0]);const c=i[0].spatialReference,u=new x({paths:[s],spatialReference:c}),l=new g({rings:[s],spatialReference:c});return c.isGeographic?J(c,u,l):c.isWebMercator?_(u,l):Z(u,l)}async function Gt(t,n,e=!1){const r=Mt(t,e);return X(wt(await yt(r,n)))}async function At(t,e,r=!1,a){const o=Mt(t,r),i=await gt(o,e);n(a);return X(wt(i))}async function Dt(t,n){const e=c(),r=t.paths[0][0],a=n.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(n)):(o=E(t),u=E(n));const l=$(t.paths[0],o),f=$(n.paths[0],u),m=Ut(l,f),[p,h,y]=l,[g,x,w]=f.map(t=>-t),[M,R,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];i(e,p,g,M,h,x,R,y,w,z);const j=s(e);if(0===j)return null;i(e,d,g,M,P,x,R,v,w,z);const L=s(e);i(e,p,d,M,h,P,R,y,v,z);const I=s(e);i(e,p,g,d,h,x,P,y,w,v);const W=L/j,k=I/j,q=s(e)/j;return{distance:Math.abs(q/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Bt(r,W,l),pointOnB:Bt(a,k,f)}}function Ut(t,n){const e=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),n[0],n[1],n[2]),o=p(e,r,a);return[o[0],o[1],o[2]]}function Bt(t,n,e){return[t[0]+n*e[0],t[1]+n*e[1],t[2]+n*e[2]]}function St(t,n){const e=l(t[0],t[1],t[2]),r=l(n[0],n[1],n[2]);return h(u(),e,r)}function Ft(t,n,e){const r=D(t,n,e);return[r[0],r[1],r[2]]}export{H as calculateAngle,V as calculateAnglePano,C as calculateCorrectedPixel,K as calculateHeightAccuracy,N as calculateHeightAccuracyPanoramic,Q as calculateHeightFromTemporaryDistance,Y as calculateLocationAccuracyFromDeviations,nt as calculateReferenceImagePointPanoramic,tt as calculateTempImagePoint,et as computeHeightIteratively,rt as computeHeightIterativelyPanoramic,pt as computeTriangulatedAreaMeasurement,ft as computeTriangulatedDistanceMeasurement,mt as computeTriangulatedPoint,ht as computeTriangulatedVector,xt as copyToClipboard,Mt as formatPixels,zt as generateCombinations,dt as generateCombinationsPanoramic,vt as getConvertedArea,Pt as getConvertedDistance,Rt as getConvertedHeight,bt as getModeCorrectedPoint,Et as getModeCorrectedPoints,Lt as getPixelLocationFromSphereVertices,jt as getRootOfSumOfSquaredErrors,Ot as getUnitRateFromSpatialReference,It as heightMeasurement2D,Wt as heightMeasurementPanoramic,kt as pixelAreaMeasurement2D,qt as pixelAreaMeasurementPanoramic,Gt as pixelDistanceMeasurement2D,At as pixelDistanceMeasurementPanoramic,Ft as scale,Dt as solveSkewLinesIntersection,St as subtract};
|
|
5
|
+
import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{formatArea as n,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as i,determinant as s}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as u,fromValues as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{j as m,i as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import w from"../../geometry/Polyline.js";import{projectWithZConversion as x,project as R}from"../../geometry/projectionUtils.js";import M from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{e as L}from"../../chunks/simplifyOperator.js";import{isSupported as I,geodesicLengths as W,geodesicAreas as k}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as q,imageToWorld as G}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as A,scaleWithFactor as D}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as U,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const S=1e5,F="meters",T="square-meters";function H(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function V(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function C(t,e,n){if(!t?.length||!e?.length||!n)return;const[r,a]=t,[,o]=e,i=o-a;return[r+i*Math.cos(n),a+i*Math.sin(n)]}async function J(t,e,n){if(await v(),I(t)){const t=W([e],F)[0];return{area:k([n],T)[0],perimeter:t}}const r=M.WGS84,a=R(e,r),o=R(n,r);let i=j(o,S);if(i=i?L(i):null,!i)return null;const s=W([a],F)[0];return{area:k([i],T)[0],perimeter:s}}async function K(t,n,r,a,o=!1,i){if(n.length<2||!a||!r||!t)return null;const s=zt(r,t);if(!s)return null;const c=n.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=s.map(e=>It([u,l],e,t,o,!1)),m=await Promise.all(f);e(i);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-a);p=Math.max(t,p)}return p}async function N(t,n,r,a,o,i=!1,s){if(n.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=dt(r,t),u=n.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(e=>Wt([l,f],e,t,o,i,!1)),p=await Promise.all(m);e(s);let h=0;for(const e of p){if(!e)return 0;const t=Math.abs(e-a);h=Math.max(t,h)}return h}function Q(t,e,n=1){const r=Rt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*n/e}async function X(t){await b();const e=t.spatialReference;if(e.isGeographic){if(I(e))return W([t],F)[0];const n=R(t,M.WGS84);return W([n],F)[0]}return e.isWebMercator?O(t,{unit:F}):E(t,{unit:F})}function Y(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,n,r]=[0,1,2].map(e=>t.map(t=>t[e]).filter(t=>null!==t)).map(t=>t.length?jt(t):0);return[e,n,r]}function Z(t,e){const n=L(e);if(!n)return null;const r=E(t,{unit:F});return{area:z(n,{unit:T}),perimeter:r}}function $(t,e){return[(t[1][0]-t[0][0])/e,(t[1][1]-t[0][1])/e,(t[1][2]-t[0][2])/e]}async function _(t,e){await Promise.all([d(),v(),b()]);let n=j(e,S);if(n=n?L(n):null,!n)return null;const r=O(t,{unit:F});return{area:P(n,{unit:T}),perimeter:r}}async function tt(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await G(t,n);e(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:i,cameraPitch:s,cameraRoll:c,farDistance:u,...l}=n;return B(o,l)}async function et(t,n,r,a){const{attributes:o}=r,{location:i}=o,{updateElevationProps:s,...c}=n;if(!t||!n)throw new Error("Missing parameters");let u=i.clone();u.spatialReference.isGeographic&&(u=await x(u,M.WebMercator));const l=await q(t,{...c,cameraLocation:u},s);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,U(f,c)}function nt(t,e,n,r,a=0,o=1,i){const{averageElevation:s,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),w=n.at(0),x=n.at(-1);if(!w||!x)return null;const R=f([w.x,w.y],[x.x,x.y])*t/g;return nt(R,e,n,r,a+1,Math.abs(t-R))}function rt(t,e,n,r,a=0,o=1,i){const{averageElevation:s,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Ot(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=U(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),w=n.at(0),x=n.at(-1);if(!w||!x)return null;const R=f([w.x,w.y],[x.x,x.y])*t/g;return rt(R,e,n,r,a+1,Math.abs(t-R))}async function at(t,e,n){return t.spatialReference&&!e.spatialReference.equals(t.spatialReference)&&(e=await x(e,t.spatialReference)),new w({paths:[[[t.x,t.y,t.z??0],[e.x,e.y,e.z??0]]],spatialReference:n})}function ot(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function it(t,e){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e)**2+(t[0][2]-t[1][2])**2)}function st(t,e){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e}function ct(e){return t(Math.atan((e[1][2]-e[0][2])/Math.sqrt((e[1][0]-e[0][0])**2+(e[1][1]-e[0][1])**2)))}function ut(e){let n=90-t(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0]));return n<0&&(n+=360),n}function lt(t,e){return new y({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:e})}async function ft(t){if(2===t?.length){const e=[];let n=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:i}=r;for(let t=0;t<i.length;t++){const i=await at(r.camera,r.measurePoints[t],o),s=await at(a.camera,a.measurePoints[t],o),c=await Dt(i,s);if(!c)return null;const u=lt(c,o);u.spatialReference.isWebMercator&&(n=ot(u.y)),e.push([u.x,u.y,u.z??0])}if(e?.length>1){return{distance:it(e,n),horizontalDistance:st(e,n),verticalDistance:Math.abs(e[0][2]-e[1][2]),slope:ct(e),aspect:ut(e)}}}return null}async function mt(t){const e=t[0].camera.spatialReference;if(2!==t?.length)return null;const[n,r]=t,{camera:a,measurePoints:o}=n,{camera:i,measurePoints:s}=r,c=await at(a,o[0],e),u=await at(i,s[0],e),l=await Dt(c,u);return l?lt(l,e)??null:null}async function pt(t,e){if(!t?.length)return null;const n=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:i}=r;for(let l=0;l<i.length;l++){const t=await at(r.camera,r.measurePoints[l],o),e=await at(a.camera,a.measurePoints[l],o),i=await Dt(t,e);if(!i)return null;const s=lt(i,o);n.push([s.x,s.y,s.z??0])}if(n?.length<2)return null;const s=new w({paths:[n],spatialReference:e}),c=new g({rings:[n],spatialReference:e});if(e.isGeographic){const t=await J(e,s,c);return t?.area??null}if(e.isWebMercator){const t=await _(s,c);return t?.area??null}const u=Z(s,c);return u?.area??null}function ht(t,e){if(!t)return null;return{camera:e.geometry.clone(),measurePoints:Array.isArray(t)?t:[t]}}async function yt(t,e){const{updateElevationProps:n,...r}=e;return await G(t,r,n)}async function gt(t,e){const{updateElevationProps:n,...r}=e;return q(t,r,n)}function wt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function xt(t){const e=t.map(t=>[t.x,t.y]),n=t[0].spatialReference;return new w({paths:[e],spatialReference:n})}function Rt(t,e){return t.map(t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]}))}function Mt(t,e,n,a,i){const s="measurement"===t?e:n;if(i&&s)return r(a,o(s,F),i,3)||null}function zt(t,e){const{cameraPitch:n,cameraRoll:r,cameraLocation:a}=t,{x:o,y:i,z:s,spatialReference:c}=a;if(e.every(t=>0===t)||!e||!e.length)return null;const[u,l,,f,m]=e,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],w=[-l,0,l],x=[];for(const R of p)for(const e of h)for(const a of g)for(const u of g)for(const l of w){const f={...t};f.cameraPitch=n+R,f.cameraRoll=r+e,f.cameraLocation=new y({x:o+a,y:i+u,z:s?s+l:0,spatialReference:{wkid:c.wkid}}),x.push(f)}return x}function dt(t,e){const{cameraHeading:n,cameraLocation:r}=t,{x:a,y:o,z:i,spatialReference:s}=r;if(e.every(t=>0===t)||!e||!e.length)throw new Error("Invalid parameters");const[c,u,l]=e,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=n+g,u.cameraLocation=new y({x:a+e,y:o+r,z:i?i+c:0,spatialReference:{wkid:s.wkid}}),h.push(u)}return h}function Pt(t,e,n,a,i){const s="measurement"===t?e:jt(n);if(i&&s)return r(a,o(s,F),i,3)||null}function vt(t,e,r,o,i){const s="measurement"===t?e:r;if(i&&s)return n(o,a(s,T),i,3)||null}function jt(t){return Math.sqrt(t.reduce((t,e)=>t+e**2,0))}function bt(t,e,n){if("default"===e)return t;const r={x:t[0],y:t[1],z:t[2]},a=A(r,n[0],n[1]);return[a.x,a.y]}function Ot(t){return t.metersPerUnit}function Et(t,e,n){let r=[];return r="panoramic"===e?t.map(([t,e,r])=>{const{x:a,y:o}=A({x:t,y:e,z:r},n[0],n[1]);return[a-.5,-.5-o]}):t.map(([t,e])=>[t-.5,-.5-e]),r}function Lt(t,e){return t.map(t=>A({x:t[0],y:t[1],z:t[2]},e[0],e[1]))}async function It(t,n,r,a=!1,o=!1,i){if(!t||!n||t.length<2)return null;const s=Rt(t,a);if(!s||s.length<2)return null;const[c,u]=[s[0],s.at(-1)];if(!u)return null;const l=[c],m=await G(c,n);e(i);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:w,...x}=n,R=B(p,x),M=f([c.x,c.y],[R.x,R.y]),z=H(c,R);if(!z)return;const d=C([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Ot(n.cameraLocation.spatialReference)/M;if(!o)return P;const v=nt(P,m,l,n,0,1);return v?.value}async function Wt(t,n,r,a,o=!1,i=!1,s){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=n;if(!t||!n||t.length<2)throw new Error("Invalid parameters");const p=Rt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let w=u.clone();w.spatialReference.isGeographic&&(w=await x(w,M.WebMercator));const R=await q(h,{...m,cameraLocation:w},l);e(s);const z=R.clone();z.z?z.z+=20:z.z=20;const d=U(z,m),P=f([h.x,h.y],[d.x,d.y]),v=H(h,d);if(!v)return;const j=C([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Ot(n.cameraLocation.spatialReference)/P;if(!i)return b;const O=rt(b,R,g,n,0,1);return O?.value}async function kt(t,e,n=!1){if(t.length<3)return null;const r=Rt(t,n),a=await yt(r,e),o=a.map(({x:t,y:e})=>[t,e]);t.push(t[0]),o.push(o[0]);const i=a[0].spatialReference,s=new w({paths:[o],spatialReference:i}),c=new g({rings:[o],spatialReference:i});return i.isGeographic?J(i,s,c):i.isWebMercator?_(s,c):Z(s,c)}async function qt(t,n,r=!1,a){if(t.length<3)return null;const o=Rt(t,r),i=await gt(o,n);e(a);const s=i.map(({x:t,y:e})=>[t,e]);t.push(t[0]),s.push(s[0]);const c=i[0].spatialReference,u=new w({paths:[s],spatialReference:c}),l=new g({rings:[s],spatialReference:c});return c.isGeographic?J(c,u,l):c.isWebMercator?_(u,l):Z(u,l)}async function Gt(t,e,n=!1){const r=Rt(t,n);return X(xt(await yt(r,e)))}async function At(t,n,r=!1,a){const o=Rt(t,r),i=await gt(o,n);e(a);return X(xt(i))}async function Dt(t,e){const n=c(),r=t.paths[0][0],a=e.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(e)):(o=E(t),u=E(e));const l=$(t.paths[0],o),f=$(e.paths[0],u),m=Ut(l,f),[p,h,y]=l,[g,w,x]=f.map(t=>-t),[R,M,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];i(n,p,g,R,h,w,M,y,x,z);const j=s(n);if(0===j)return null;i(n,d,g,R,P,w,M,v,x,z);const L=s(n);i(n,p,d,R,h,P,M,y,v,z);const I=s(n);i(n,p,g,d,h,w,P,y,x,v);const W=L/j,k=I/j,q=s(n)/j;return{distance:Math.abs(q/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Bt(r,W,l),pointOnB:Bt(a,k,f)}}function Ut(t,e){const n=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),e[0],e[1],e[2]),o=p(n,r,a);return[o[0],o[1],o[2]]}function Bt(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function St(t,e){const n=l(t[0],t[1],t[2]),r=l(e[0],e[1],e[2]);return h(u(),n,r)}function Ft(t,e,n){const r=D(t,e,n);return[r[0],r[1],r[2]]}export{H as calculateAngle,V as calculateAnglePano,C as calculateCorrectedPixel,K as calculateHeightAccuracy,N as calculateHeightAccuracyPanoramic,Q as calculateHeightFromTemporaryDistance,Y as calculateLocationAccuracyFromDeviations,et as calculateReferenceImagePointPanoramic,tt as calculateTempImagePoint,nt as computeHeightIteratively,rt as computeHeightIterativelyPanoramic,pt as computeTriangulatedAreaMeasurement,ft as computeTriangulatedDistanceMeasurement,mt as computeTriangulatedPoint,ht as computeTriangulatedVector,wt as copyToClipboard,Rt as formatPixels,zt as generateCombinations,dt as generateCombinationsPanoramic,vt as getConvertedArea,Pt as getConvertedDistance,Mt as getConvertedHeight,bt as getModeCorrectedPoint,Et as getModeCorrectedPoints,Lt as getPixelLocationFromSphereVertices,jt as getRootOfSumOfSquaredErrors,Ot as getUnitRateFromSpatialReference,It as heightMeasurement2D,Wt as heightMeasurementPanoramic,kt as pixelAreaMeasurement2D,qt as pixelAreaMeasurementPanoramic,Gt as pixelDistanceMeasurement2D,At as pixelDistanceMeasurementPanoramic,Ft as scale,Dt as solveSkewLinesIntersection,St as subtract};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../../intl.js";import{formatLength as t,formatAngle as r}from"../../../core/quantityFormatUtils.js";import{createLength as a,createAngle as n}from"../../../core/quantityUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{copyToClipboard as
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../intl.js";import{formatLength as t,formatAngle as r}from"../../../core/quantityFormatUtils.js";import{createLength as a,createAngle as n}from"../../../core/quantityUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{getMetersPerUnitOfSR as i}from"../../../layers/orientedImagery/core/utils.js";import{copyToClipboard as c,getConvertedArea as u}from"../imageMeasurementUtils.js";import{ImageMeasurementMixin as o}from"./ImageMeasurementMixin.js";import{substitute as g}from"../../../intl/substitute.js";const m=m=>{const l=o(m);let d=class extends l{copyActiveMeasurementResults(e,t){t?this.copyTriangularMeasurementResult(e):this.copyGroundMeasurementResult(e)}copyGroundMeasurementResult(e){let t,r;switch(e){case"area":t={measurement:this.getConvertedAreaString("measurement"),accuracy:this.getConvertedAreaString("accuracy")},r="{measurement} ± {accuracy}";break;case"distance":t={measurement:this.getConvertedDistanceString("measurement"),accuracy:this.getConvertedDistanceString("accuracy")},r="{measurement} ± {accuracy}";break;case"height":t={measurement:this.getConvertedHeightString("measurement"),accuracy:this.getConvertedHeightString("accuracy")},r="{measurement} ± {accuracy}"}const a=g(r,t);c(a)}copyTriangularMeasurementResult(e){let t=null;switch(e){case"area":t=this.copyTriangularAreaMeasurements();break;case"distance":t=this.copyTriangularDistanceMeasurements()}t&&c(t)}copyTriangularAreaMeasurements(){const e={measurement:this.getConvertedTriangularAreaString("measurement"),accuracy:this.getConvertedTriangularAreaString("accuracy")};return g("{measurement} ± {accuracy}",e)}copyTriangularDistanceMeasurements(){const{oiViewModel:e}=this,{triangulatedDistanceMeasurement:t,triangulatedDistanceAccuracy:r}=e;if(!t)return;const{distance:a,horizontalDistance:n,verticalDistance:s,slope:i,aspect:c}=t,{distanceAccuracy:u=0,angleAccuracy:o=0}=r??{},m={distance:this.getConvertedTriangularDistanceMeasurementString(a),distanceAccuracy:this.getConvertedTriangularDistanceMeasurementString(u,!0),horizontal:this.getConvertedTriangularDistanceMeasurementString(n),vertical:this.getConvertedTriangularDistanceMeasurementString(s),slope:this.getConvertedTriangularDistanceAngularResultsString(i),angleAccuracy:this.getConvertedTriangularDistanceAngularResultsString(o),aspect:this.getConvertedTriangularDistanceAngularResultsString(c)};return g(" Distance : {distance} ± {distanceAccuracy} , Horizontal : {horizontal} ± {distanceAccuracy}, Vertical : {vertical} ± {distanceAccuracy}, Slope : {slope} ± {angleAccuracy}, Aspect : {aspect} ± {angleAccuracy}",m)}getConvertedTriangularDistanceMeasurementString(e,r=!1){const{measurementUnitMessages:n,pixelMeasurementUnit:s,oiViewModel:{currentBestFeature:c}}=this;if(!c)return;const u=r?e:e*i(c.attributes.location.spatialReference);return t(n,a(u,"meters"),s,3)||null}getConvertedTriangularDistanceAngularResultsString(e){return r(n(e,"degrees"),"arithmetic",3)||null}getConvertedTriangularAreaString(e){const{oiViewModel:t,measurementUnitMessages:r,pixelAreaMeasurementUnit:a,messages:n}=this,{triangulatedAreaAccuracy:s,triangulatedAreaMeasurement:i}=t;return u(e,i,s,r,a)??n.startMeasurement}};return d=e([s("esri.widgets.OrientedImageryViewer.mixins.TriangulatedImageMeasurementMixin")],d),d};export{m as TriangulatedImageMeasurementMixin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{watch as r,initial as l}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../core/Accessor.js";import{watch as r,initial as l}from"../../core/reactiveUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{videoMetadataEntryId as a}from"../../layers/video/videoUtils.js";function s(e,t){const r={};for(const l of t){const t=e.get(l);t&&(r[t.name]=t.value)}return r}let y=class extends t{constructor(e){super(e),this.followingMode="follow-both",this.layer=null,this.seekLength=10,this.view=null}initialize(){this.addHandles([r(()=>this.layer,(e,t)=>{t&&t.pause(),e&&e.load().then(()=>this._followTelemetry()).catch(()=>{})},l),r(()=>[this.followingMode],()=>this._followTelemetry(),l)])}get buffered(){return this.layer?.buffered||0}get currentTime(){return this.layer?.currentTime||0}get duration(){return this.layer?.duration||0}get ended(){return this.layer?.ended??!0}get metadata(){const e=this.layer?.metadata;return e?{missionInfo:s(e,[a.MissionId,a.PrecisionTimeStamp]),platformInfo:s(e,[a.PlatformTailNumber,a.PlatformTrueAirspeed,a.PlatformCallSign,a.PlatformDesignation,a.PlatformGroundRange]),frameInfo:s(e,[a.FrameCenterElevation,a.FrameCenterLatitude,a.FrameCenterLongitude])}:null}get playing(){return this.layer?.playing??!1}get state(){return this.layer?.loadError?"error":this.layer?.state??"not-ready"}play(){this.layer?.play()}pause(){this.layer?.pause()}seekBackward(){if(this.layer){const e=this.layer.currentTime-this.seekLength;e<=0?this.layer.reset():this.layer.setCurrentTime(e)}}seekForward(){if(this.layer){const e=this.layer.currentTime+this.seekLength;e>=this.layer.duration?this.layer.reset():this.layer.setCurrentTime(e)}}seekToBeginning(){this.layer?.setCurrentTime(0)}seekToEnding(){this.layer?.setCurrentTime(this.layer.duration)}seekTo(e){this.layer?.setCurrentTime(e)}toggleSensorDisplay(){this.layer?.telemetryDisplay&&(this.layer.telemetryDisplay.sensorLocation=!this.layer.telemetryDisplay.sensorLocation)}toggleSensorSightLineDisplay(){this.layer?.telemetryDisplay&&(this.layer.telemetryDisplay.lineOfSight=!this.layer.telemetryDisplay.lineOfSight)}toggleFrameDisplay(){this.layer?.telemetryDisplay&&(this.layer.telemetryDisplay.frame=!this.layer.telemetryDisplay.frame)}toggleSensorTrailDisplay(){this.layer?.telemetryDisplay&&(this.layer.telemetryDisplay.sensorTrail=!this.layer.telemetryDisplay.sensorTrail)}toggleFrameCenterDisplay(){this.layer?.telemetryDisplay&&(this.layer.telemetryDisplay.frameCenter=!this.layer.telemetryDisplay.frameCenter)}toggleFrameOutlineDisplay(){this.layer?.telemetryDisplay&&(this.layer.telemetryDisplay.frameOutline=!this.layer.telemetryDisplay.frameOutline)}changePlaybackSpeed(e){this.layer&&(this.layer.playbackRate=e)}changeGraphicsColor(e){e&&this.layer.updateTelemetryColor(e)}_followTelemetry(){this.removeHandles("follow"),this.view&&this.layer&&this.addHandles(r(()=>this.layer?.telemetry,()=>{const e=[],t="follow-sensor"===this.followingMode||"follow-both"===this.followingMode,r="follow-frame"===this.followingMode||"follow-both"===this.followingMode;t&&this.layer?.telemetry.sensorLocation&&e.push(this.layer.telemetry.sensorLocation),r&&this.layer?.telemetry.frameCenter&&e.push(this.layer.telemetry.frameCenter),e.length?this.view?.goTo(e).catch(()=>{}):this.layer?.initialExtent&&"none"!==this.followingMode&&this.view?.goTo(this.layer.initialExtent).catch(()=>{})},l),"follow")}};e([i({readOnly:!0})],y.prototype,"buffered",null),e([i({readOnly:!0})],y.prototype,"currentTime",null),e([i({readOnly:!0})],y.prototype,"duration",null),e([i({readOnly:!0})],y.prototype,"ended",null),e([i()],y.prototype,"followingMode",void 0),e([i()],y.prototype,"layer",void 0),e([i({readOnly:!0})],y.prototype,"metadata",null),e([i({readOnly:!0})],y.prototype,"playing",null),e([i()],y.prototype,"seekLength",void 0),e([i({readOnly:!0})],y.prototype,"state",null),e([i()],y.prototype,"view",void 0),y=e([o("esri.widgets.VideoPlayer.VideoPlayerViewModel")],y);const n=y;export{n as default};
|