Custom Gis Application with Arcgis Javascript API with modern layouting
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

62 lines
30 KiB

// All material copyright Esri, All Rights Reserved, unless otherwise specified.
// See https://js.arcgis.com/4.30/esri/copyright.txt for details.
//>>built
define("require ../../chunks/tslib.es6 ../../geometry ../../Graphic ../../core/arrayUtils ../../core/asyncUtils ../../core/Collection ../../core/deprecate ../../core/Error ../../core/Evented ../../core/JSONSupport ../../core/lang ../../core/Logger ../../core/mathUtils ../../core/maybe ../../core/promiseUtils ../../core/reactiveUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/accessorSupport/decorators/subclass ../../geometry/support/jsonUtils ../../geometry/support/webMercatorUtils ../../layers/GraphicsLayer ../../layers/orientedImagery/queries ../../layers/orientedImagery/core/bestImageUtils ../../layers/orientedImagery/core/coverageUtils ../../layers/orientedImagery/transformations/groundToImageUtils ../../layers/orientedImagery/transformations/imageToGroundUtils ../../layers/orientedImagery/transformations/utils ../../rest/support/AttachmentQuery ../../views/input/InputManager ../PanoramicViewer ./constants ./symbols ./utils ./components/ImageViewer ../../geometry/Point ../../geometry/SpatialReference ../../geometry/Polygon".split(" "),
function(Q,f,e,v,N,K,x,O,Z,aa,R,S,y,T,u,z,q,g,oa,ba,ca,U,da,ea,fa,L,V,W,I,ha,ia,ja,A,E,C,ka,G,P,la){const X=a=>Object.freeze(Object.defineProperty({__proto__:null,default:a},Symbol.toStringTag,{value:"Module"})),ma=new Set(["JPG","JPEG"]),na=/\.(\w+)$/;e=class extends aa.EventedAccessor{constructor(a){super(a);this.additionalFeatures=new x;this.bestFeatureAngle=0;this.coverageFrustums=new x;this.coveragePolygons=new x;this.currentBestFeature=null;this.currentCoverageVisible=!0;this.determineWorkflowForFeature=
()=>{u.abortMaybe(this._featureChangedTask);this._featureChangedTask=K.createTask(async b=>{const {currentBestFeature:c,selectedPoint:d,view:h}=this;h?.closePopup();if(c&&d){this._initialCurrentCoverageUpdate=!0;try{await this._updatePointsAndPolygons({signal:b}),await this._loadImage({signal:b})}catch(k){z.isAbortError(k)||(this.loadImageError(k),y.getLogger(this).error("#loadIImage()","error occured while loading image",k))}}})};this.disabled=!1;this.displayMessage={key:"onLoadMessage",type:"info"};
this.drawFootprint=()=>{this.bestFeatureFootprint&&this.updateCurrentCoveragePolygon(this.bestFeatureFootprint)};this.features=new x;this.isAdditionalPointSourcesVisible=this.isAdditionalCoverageVisible=!1;this.localPort=this.layer=null;this.mapImageConversionToolState=!1;this.navigatorCurrentBestFeature=null;this.pointSources=new x;this.previousFeatureAngle=0;this.selectedPoint=null;this.shouldShowSelectedImage=!1;this.updateFootprint=async(b,c)=>{"image-loaded"===this.state&&await this._adapter?.updateFootprint(b,
c)};this.updateFootprintPanorama=async(b,c)=>{await this._adapter?.updateFootprintPanorama(b,c)};this._adapter=null;this.additionalFootprints=new x;this.additionalCameraLocations=new x;this._highlightedFeatureHandle=this._fetchFeaturesController=this.bestFeatureCurrentFootprint=null;this._imageViewer=new ka;this.bestFeatureFootprint=null;this._initialCurrentCoverageUpdate=!0;this._loading=!1;this._overlays=new da({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}});this._panoramicViewer=
new ja;this._suitabilities=this._openPopupTask=this._featureChangedTask=this.footprintExtent=this._crossSymbol=this._sectorData=this._referencePointOnImage=this._referencePointOnGround=null;this._transformController=new AbortController;this._updateFootprintTask=null;this.highlight=b=>{if(this._overlaysView){this.removeHighlight();var c=this.additionalFootprints.find(({attributes:{imageID:d}})=>d===Number(b));this._highlightedFeatureHandle=c?this._overlaysView?.highlight(c):null}};this.loadImageFromSource=
async(b,c)=>{const {mode:d,imageRotation:h,options:k}=c;var m="string"===typeof b;const l=m?b:b.url;b=m?b.match(na)?.[1]??"":b.datasetFormat;b||((m=await C.getContentType(l,{...c.options}))&&(b=m.split("/")[1]),b??="UNKNOWN FORMAT");switch(d){case "default":this._imageViewer.imageSource={datasetFormat:b.toUpperCase(),url:l};c=new URL(l);this._imageViewer.customParameters=Object.fromEntries(c.searchParams);this._imageViewer.imageRotation=h??0;await this._imageViewer.loadImage(k);break;case "panoramic":if(this._loading=
!0,ma.has(b.toUpperCase())){({selectedPoint:b}=this);const {pitch:n,yaw:p,cameraLocation:t,viewAngle:r}=c;this._panoramicViewer.imageSource=l;c=p??0;"number"===typeof r?c=r-c:t&&b&&(c=await I.getInitialAngle(t,b)-c);this._panoramicViewer.pitch=n??0;this._panoramicViewer.yaw=c;this._loading=!1;await this._panoramicViewer.loadImage(k)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:b})}};this.loadImageViewer=b=>{this._imageViewer.container=b};this.loadPanoramicViewer=
b=>{this._panoramicViewer.container=b};this.removeHighlight=()=>this._highlightedFeatureHandle?.remove();this.toggleImageAttributes=()=>{u.abortMaybe(this._openPopupTask);this._openPopupTask=K.createTask(async b=>{const {currentBestFeature:c,popupEnabled:d,layer:h,view:k}=this;k?.closePopup();if(k&&c&&d&&h){var {attributes:m,geometry:l}=c,n=new v({geometry:l,attributes:m.toJSON(),popupTemplate:h.popupTemplate});z.throwIfAborted(b);await k.openPopup({features:[n],location:m.location.clone()})}})};
this._getImageSourceFromAttachment=async(b,c,d)=>{var h=new ha({objectIds:[c]});d=(await b.queryAttachments(h,d))[`${c}`]?.[0];h=d?.url;if(!h)throw new Z("NoAttachmentError","no attachments found",{[b.objectIdField]:c,layer:b});return{datasetFormat:d.contentType.split("/")[1].toUpperCase(),url:h}};this._loadImage=async b=>{const {currentBestFeature:c,layer:d,mode:h}=this;this.clearGraphics();if(d&&c&&"none"!==h){var {attributes:k}=c,{imagePath:m,imageRotation:l,cameraHeading:n,cameraRoll:p,cameraPitch:t,
objectId:r,cameraOrientation:D,location:w}=k;k=(p??0)+(l??0);var H=w.spatialReference.isWGS84&&4!==D?.type?U.geographicToWebMercator(w):new G(w),J=m;if("FA"===m)try{J=await this._getImageSourceFromAttachment(d,r,b)}catch(B){if(z.isAbortError(B))return;if(C.isNoAttachmentError(B)){y.getLogger(this).error(B);this.setMessage("noAttachment","error",`${d.objectIdField}: ${r}`);return}y.getLogger(this).error(B,{[d.objectIdField]:r,layer:d});this.setMessage("imageLoadError","error",`query-attachments-failed:${d.objectIdField} ${r}`);
return}try{await this.loadImageFromSource(J,{imageRotation:k,options:b,pitch:t,yaw:n,mode:h,cameraLocation:H}),z.throwIfAborted(b),await this.transformAndPlotSelectedLocation(b)}catch(B){z.isAbortError(B)||this.loadImageError(B)}}};this._mapImageConversionToolViewClickHandler=b=>{b.stopPropagation();b.preventDefault();b.mapPoint&&this.plotMapPoint(b.mapPoint)};this._viewClickHandler=b=>{if("mouse"!==b.pointerType||0===b.button)b.stopPropagation(),b.preventDefault(),b.mapPoint&&this.loadBestImage(b.mapPoint)};
this.plotSelectedPointOnImage=async(b,c)=>{await z.waitTick(c);if(b)if(c=new G({...(R.isSerializable(b)?b.toJSON():b),spatialReference:P.WebMercator}),"default"===this.mode)c.x-=.5,c.y=.5-c.y,this._crossSymbol=new v({geometry:c,symbol:E.crossSymbol}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode&&({imageSize:c}=this._panoramicViewer,c)){var [d,h]=c,{heading:k,pitch:m}=I.convertPixelToHeadingPitch(b,d,h);b=I.convertHeadingPitchToSphereVertex(k,m);this._crossSymbol=
new v({geometry:new G(b,P.WebMercator),symbol:E.crossSymbol3D});this._panoramicViewer.addGraphic(this._crossSymbol,0)}};this.handleSectorClick=this.handleSectorClick.bind(this);this.searchBestImage=this.searchBestImage.bind(this);this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this);this.updateSuitabilities=this.updateSuitabilities.bind(this);this.determineWorkflowForFeature=this.determineWorkflowForFeature.bind(this);this.selectBestFeature=this.selectBestFeature.bind(this);
this.drawFootprint=this.drawFootprint.bind(this)}initialize(){this.addHandles([q.watch(()=>this.view,async a=>{if(a){this._loading=!0;switch(a.type){case "2d":({default:a}=await new Promise((b,c)=>Q(["./adapters/OrientedImageryViewerViewModelAdapter2D"],d=>b(X(d)),c)));this._adapter=new a(this);break;case "3d":({default:a}=await new Promise((b,c)=>Q(["./adapters/OrientedImageryViewerViewModelAdapter3D"],d=>b(X(d)),c))),this._adapter=new a(this)}this._loading=!1}else this._adapter=null},q.syncAndInitial),
q.watch(()=>this.view?.map,(a,b)=>{b?.layers.remove(this._overlays);a?.layers.add(this._overlays)},q.initial),q.watch(()=>this.view?.map?.allLayers?.length,a=>{a&&this.view?.map?.layers.reorder(this._overlays,a-1)},q.initial),q.watch(()=>[this.state,this.mapImageConversionToolState,this.view],()=>{this.removeHandles("view-click");if("disabled"!==this.state&&null!=this.view){this.addHandles(this.view.on("click",this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:
this._viewClickHandler,ia.ViewEventPriorities.WIDGET),"view-click");this.removeHandles("image-click");var {mapImageConversionToolState:a,mode:b}=this;if(a&&"none"!==b)switch(b){case "default":this._imageViewer.clickAction="pixel-location";this.addHandles(this._imageViewer.on("pixel-location",async c=>{this.plotReferencePointOnImage(c);const d=this.currentBestFeature;d&&(c=(await W.transformPoints([c.toJSON()],{feature:d,imageProperties:{width:this._imageViewer.imageSize[0],height:this._imageViewer.imageSize[1]},
options:{signal:this._transformController?.signal},footprintExtent:this.footprintExtent}))[0])&&this.plotReferencePointOnGround(c)}),"image-click");break;case "panoramic":this._panoramicViewer.clickAction="pixel-location",this.addHandles(this._panoramicViewer.on("pixel-location",async c=>{this.plotReferencePointOnImage(c);const d=this.currentBestFeature,{imageSize:h}=this._panoramicViewer;d&&c&&h&&(c=(await W.transformPoints([c],{feature:d,imageProperties:{width:h[0],height:h[1]},options:{signal:this._transformController?.signal},
footprintExtent:this.footprintExtent}))[0])&&this.plotReferencePointOnGround(c)}),"image-click")}}},q.syncAndInitial),q.watch(()=>this.bestFeatureAngle,(a,b)=>{this.previousFeatureAngle=b??0},q.syncAndInitial),q.watch(()=>this.currentBestFeature,(a,b)=>{this.determineWorkflowForFeature(a,b)},{sync:!0}),q.watch(()=>this.mode,a=>{this.removeHandles("interaction-handles");switch(a){case "default":this.addHandles(q.watch(()=>this._imageViewer.imagePointsInView,b=>{b&&(u.abortMaybe(this._updateFootprintTask),
this._updateFootprintTask=K.createTask(async c=>{await this.updateFootprint(b,{signal:c})}))},{...q.syncAndInitial,equals:(b,c)=>N.equals(b,c,S.equalsShallow)}),"interaction-handles");break;case "panoramic":this.addHandles(q.watch(()=>{const {currentBestFeature:b}=this,{imageSize:c,vfov:d,hfov:h,pitch:k,yaw:m}=this._panoramicViewer;return b&&c?[d,h,m,k]:null},b=>{if(b&&"image-loading"!==this.state){var [c,d,h,k]=b;u.abortMaybe(this._updateFootprintTask);this._updateFootprintTask=K.createTask(async m=>
{await this.updateFootprintPanorama({verticalFieldOfView:c,horizontalFieldOfView:d,yaw:h,pitch:k},{signal:m})})}},{...q.syncAndInitial,equals:(b,c)=>N.equals(b,c,S.equalsShallow)}),"interaction-handles")}},q.syncAndInitial),q.watch(()=>[this.brightness,this.contrast,this.sharpness],()=>{const {_imageViewer:a,brightness:b,contrast:c,mode:d,sharpness:h}=this;"default"===d&&(a.brightness=b,a.contrast=c,a.sharpness=h)},q.syncAndInitial)])}destroy(){this._updateFootprintTask=u.abortMaybe(this._updateFootprintTask);
this._cancelFetchingFeatures();this.coverageFrustums.destroy();this.coveragePolygons.destroy();this.pointSources.destroy();this.additionalFootprints.destroy();this.additionalCameraLocations.destroy();this.bestFeatureFootprint=u.destroyMaybe(this.bestFeatureFootprint);this.bestFeatureCurrentFootprint=u.destroyMaybe(this.bestFeatureCurrentFootprint);this._crossSymbol=u.destroyMaybe(this._crossSymbol);this._referencePointOnGround=u.destroyMaybe(this._referencePointOnGround);this._referencePointOnImage=
u.destroyMaybe(this._referencePointOnImage);this._overlays&&this.view?.map?.remove(this._overlays);this._overlays.destroy()}get activeLayer(){O.deprecatedProperty(y.getLogger(this),"activeLayer",{replacement:"layer"});return this.layer}set activeLayer(a){O.deprecatedProperty(y.getLogger(this),"activeLayer",{replacement:"layer"});this.layer=a}get activeViewer(){const {_imageViewer:a,_panoramicViewer:b,mode:c}=this;switch(c){case "default":return a;case "panoramic":return b;default:return null}}get brightness(){return this._get("brightness")??
0}set brightness(a){this._set("brightness",10<a?10:-10>a?-10:a)}get contrast(){return this._get("contrast")??0}set contrast(a){this._set("contrast",T.clamp(a,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){return C.isTifOrMrf(this.currentBestFeature?.attributes.imagePath.trim())}get imageLoaded(){O.deprecatedProperty(y.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state \x3d\x3d\x3d "image-loaded"',version:"4.29",warnOnce:!0});return"image-loaded"===
this.state}get imagePointsInView(){const {mode:a,_imageViewer:b}=this;return"default"===a?b.imagePointsInView:null}get mode(){const a=this.currentBestFeature?.attributes;if(!a)return"none";const {horizontalFieldOfView:b,isSpherical:c}=a;return 360===b||c?"panoramic":"default"}get popupEnabled(){return null!==this.layer&&this.layer.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const {_sectorData:a}=this;return a?A.sectorsInOrder.map(b=>a[b]):null}get sharpness(){return this._get("sharpness")??
0}set sharpness(a){this._set("sharpness",T.clamp(a,0,1))}get state(){const {mode:a,disabled:b}=this;if(b)return"disabled";if(this._loading)return"image-loading";switch(a){case "default":return this._imageViewer.state;case "panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const {features:a}=this;return a?new x(a.map(({attributes:{imagePath:b,objectId:c,cameraRoll:d,imageRotation:h}})=>{b=b.trim();return C.isTifOrMrf(b)?{url:b,objectId:c,rotation:(d??0)+(h??0)}:null}).filter(N.isSome)):
null}set view(a){this._set("view",a)}get _overlaysView(){return this.view?.layerViews.find(({layer:a})=>a===this._overlays)}filterByFootprints(a,b){const c=[],d=[],h=[];a.forEach(k=>{const {layer:{coveragePercent:m},attributes:l}=k;let n;const {polygon:p,frustum:t}=L.createCoveragePolygon(l);n=p.clone();l.isInspection&&(n=L.computePolygonForInspection(l));m&&(n=L.resizePolygon(n,m));if(L.checkIfPolygonContainsSelectedPoint(n,b)){h.push(k);const {cameraHeading:r,geometry:D,objectId:w,cameraHeight:H}=
l;k=D.clone();k.z=H;k.imageID=w;this.pointSources.push(k);-999!==r&&(c.push(p),t&&d.push(t))}});return{features:h,polygons:c,frustums:d}}getCurrentCoveragePolygon(){return this.bestFeatureCurrentFootprint}getCurrentBestFeaturePolygon(){return this.bestFeatureFootprint}handleSectorClick(a){isNaN(a)||(a=this._sectorData?.[A.sectorsInOrder[a]],a?.length&&this._updateCurrentBestFeature(a.at(0)))}handleFeatureClick(a){const {sector:b,featureIndexInSector:c}=a;isNaN(c)||(a=this._sectorData?.[b],a?.length&&
this._updateCurrentBestFeature(a.at(c)))}async loadBestImage(a){this._loading=!0;this.view?.closePopup();this.displayMessage=null;this.selectedPoint=a.spatialReference.isGeographic?U.geographicToWebMercator(a):a.clone();this.features.removeAll();this.currentBestFeature=null;this.additionalFeatures.removeAll();this.additionalFootprints.removeAll();this.additionalCameraLocations.removeAll();this.bestFeatureCurrentFootprint=u.destroyMaybe(this.bestFeatureCurrentFootprint);this._overlays?.removeAll();
await this._fetchFeaturesWithController(a)}loadImageError(a){y.getLogger(this).error("oriented-imagery-viewer:load-image",a);this.setMessage("imageLoadError","error",a.message)}async plotMapPoint(a){this.plotReferencePoint(a);return this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:a,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(a){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());
null!=a&&(this._referencePointOnGround=new v({geometry:new G({...a.toJSON()}),symbol:E.diamondSymbol}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(a){if("image-loaded"===this.state)switch(this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage.destroy()),
this.mode){case "default":a=R.isSerializable(a)?a.toJSON():a;a.x-=.5;a.y=.5-a.y;this._referencePointOnImage=new v({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:E.diamondSymbol});this._imageViewer.addGraphic(this._referencePointOnImage,0);break;case "panoramic":const {imageSize:k}=this._panoramicViewer;if(k){var [b,c]=k,{heading:d,pitch:h}=I.convertPixelToHeadingPitch(a,b,c);a=I.convertHeadingPitchToSphereVertex(d,h);this._referencePointOnImage=new v({geometry:new G(a,
P.WebMercator),symbol:E.diamondSymbol3D});this._panoramicViewer.addGraphic(this._referencePointOnImage,0)}}}resetImage(){this.setMessage("onLoadMessage","info");switch(this.mode){case "default":this._imageViewer.clearImage();this._imageViewer.clearGraphics();break;case "panoramic":this._panoramicViewer.clearGraphics()}this._cancelFetchingFeatures()}async searchBestImage(a,b){try{const c=await ea.searchImages(a,b);c&&await this._processFeatureResponse(c,a.point,{signal:b?.signal})}catch(c){z.isAbortError(c)||
(this.setMessage("imageLoadError","error",c.message),y.getLogger(this).error("error occurred while finding best image",c))}}selectBestFeature(a){this.currentBestFeature=this.features?.find(({attributes:b})=>b.objectId===Number(a))}setAdditionalCameraLocationsVisibility(a){this.additionalCameraLocations.forEach(b=>{b.visible=a})}setAdditionalCoverageVisibility(a){this.additionalFootprints.forEach(b=>{b.visible=a})}setCurrentCoverageVisibility(a){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=
a);this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=a)}setMapImageConversionToolState(a){this.mapImageConversionToolState=a}async transformAndPlotReferencePointOnImage(a){const {selectedLocation:b,options:c}=a;var d=this.bestFeatureFootprint?.geometry;a=ca.isPolygon(d)&&d.contains(b);d="mesh"===d?.type&&d?.extent.contains(b);if(a||d)if(a=await this.transformPoint(b,c))return this.plotReferencePointOnImage(a),{x:a.x,y:a.y}}updateSuitabilities(a){this._suitabilities=a.sort((b,
c)=>b.suitability-c.suitability);a=this._suitabilities.map(b=>b.feature);this._updateFeatures(a);this._groupFeaturesBySectors();this._initialCurrentCoverageUpdate=!0}_cancelFetchingFeatures(a){const b=this._fetchFeaturesController;b&&b.abort(a);this._fetchFeaturesController=null}async _fetchFeatures(a,b){if(this.view){var c=this.layer;if(c){var d={include:c};if(a=this.view.toScreen(a))d=await this.view.hitTest(a,d),this._processHitTestResults(c,d,b)}}}async _fetchFeaturesWithController(a){this._cancelFetchingFeatures();
const b=new AbortController,{signal:c}=b;this._fetchFeaturesController=b;try{await this._fetchFeatures(a,{signal:c}).finally(()=>{this._fetchFeaturesController=null})}catch(d){this.setMessage("imageLoadError","error"),y.getLogger(this).error("error occurred while fetching features",d)}}_groupFeaturesBySectors(){const {_suitabilities:a,additionalFeatures:b,currentBestFeature:c,features:d}=this;if(a&&b&&c&&d){this._sectorData={};for(var h of A.sectorsInOrder)this._sectorData[h]=new x;h=a.map((l,n)=>
({...l,featureIndex:n}));h.sort((l,n)=>l.trueSuitability-n.trueSuitability);var k=h.map(({distance:l})=>l),m=Math.max(...k);h.forEach(l=>{const {distance:n,angle:p,featureIndex:t}=l;var r=n/m*A.sectorsRadii[2],D=C.calculateSegment(n,m),w=C.calculateDirection(p);if(this._sectorData){l=A.sectorsRadii[3]+r*Math.sin(p*Math.PI/180);r=A.sectorsRadii[3]+r*Math.cos(p*Math.PI/180);var H=d.at(t),J=H===this.currentBestFeature,B=this.currentBestFeature?.attributes.cameraPitch&&5>this.currentBestFeature?.attributes.cameraPitch;
if(J&&B)var F=-90;else{F=l-A.sectorsRadii[3];const M=r-A.sectorsRadii[3];let Y=180*Math.acos(M/Math.sqrt(F**2+M**2))/Math.PI;if(0>F&&0>M||0>F&&0<M)Y*=-1;F=Y}D=""===D?w:`${D}_${w}`;J&&(F===this.bestFeatureAngle?this.previousFeatureAngle=F:this.bestFeatureAngle=F,this.navigatorCurrentBestFeature=B?null:{x:l,y:r,direction:w});w=this._sectorData[D];w.add({angle:p,featureIndex:t,x:l,y:r,objectID:H.attributes.objectId,sector:D,featureIndexInSector:w.length})}})}else this._sectorData=null}async _processFeatureResponse(a,
b,c){({features:a}=a);if(a?.length){this.coveragePolygons.removeAll();this.coverageFrustums.removeAll();this.pointSources.removeAll();var {features:d,polygons:h,frustums:k}=this.filterByFootprints(a,b);if(d.length){this.coveragePolygons.addMany(h);this.coverageFrustums.addMany(k);a=new la({spatialReference:h[0].spatialReference});for(var {rings:m}of h)a.addRing(m[0]);m=[];for(var {geometry:l}of d)a.contains(l)||m.push(l);a.addRing(m);l=a.extent;C.scaleExtent(l,2);this.footprintExtent=l;if(this.view?.supportsGround)try{var n=
await this.view.map.ground.createElevationSampler(l,c)}catch(p){z.isAbortError(p)||y.getLogger(this).error(p)}((d[0].elevationSample=n)||d[0].attributes.elevationSource)&&l&&(c=await V.updateElevation([b],{feature:d[0],footprintExtent:l,options:c}),c[0]&&(b.elevation=c[0].z));d[0].elevationSample&&d.forEach(p=>{p.elevationSample=d[0].elevationSample});this._suitabilities=fa.calculateSuitabilities({features:d,selectedPoint:b,camera:C.isSceneView(this.view)?this.view.camera:null,currentImage:this.currentBestFeature});
this.updateSuitabilities(this._suitabilities);this.currentBestFeature=this._suitabilities.map(p=>p.feature)[0];this._loading=!1}else this.setMessage("noImageError","error"),this.currentBestFeature=null}else this.setMessage("noImageError","error"),this.currentBestFeature=null}async _processHitTestResults(a,b,c){const {screenPoint:d,results:[h]}=b;b="graphic"===h?.type&&this.shouldShowSelectedImage;const k=h?.mapPoint??this.view?.toMap(d);k&&(a={layerInstanceOrURL:a,point:k,queryParams:{where:a.definitionExpression??
"1\x3d1",maximumDistance:a.maximumDistance,objectIds:b?[h.graphic.getAttribute(a.objectIdField)]:void 0}},await this.searchBestImage(a,c))}_updateFeatures(a){a.length?(this.features.removeAll(),this.features.addMany(a),this.currentBestFeature=a[0],1<a.length?this.additionalFeatures.addMany(a.slice(1)):this.additionalFeatures.removeAll()):(this.currentBestFeature=null,this.additionalFeatures.removeAll())}async _updatePointsAndPolygons(a){const {pointSources:b,currentBestFeature:c,currentCoverageVisible:d,
isAdditionalPointSourcesVisible:h}=this;if(c){this.additionalFootprints.removeAll();this.additionalCameraLocations.removeAll();this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureFootprint=this.bestFeatureCurrentFootprint=null);await this._adapter?.createFootprints(a);z.throwIfAborted(a);for(const k of b)k.imageID===c.attributes.objectId?this.currentBestFeatureLocation=new v({attributes:{imageID:k.imageID},geometry:k,symbol:E.activeSourcePointSymbol,visible:d}):
this.additionalCameraLocations.push(new v({attributes:{imageID:k.imageID},geometry:k,symbol:E.sourcePointSymbol,visible:h}))}}_updateCurrentBestFeature(a){if(a){this.currentBestFeature=this.features?.at(a.featureIndex);var b=this.currentBestFeature?.attributes.cameraPitch&&5>this.currentBestFeature?.attributes.cameraPitch;if(b)var c=-90;else{c=a.x-A.sectorsRadii[3];const d=a.y-A.sectorsRadii[3];let h=180*Math.acos(d/Math.sqrt(c**2+d**2))/Math.PI;if(0>c&&0>d||0>c&&0<d)h*=-1;c=h}c===this.bestFeatureAngle?
this.previousFeatureAngle=c:this.bestFeatureAngle=c;this.navigatorCurrentBestFeature=b?null:{x:a.x,y:a.y,direction:a.sector.includes("_")?a.sector.split("_")[1]:a.sector}}}clearGraphics(){this._imageViewer.clearGraphics();this._panoramicViewer.clearGraphics()}plotReferencePoint(a){"mapPoint"in a?this.plotReferencePointOnGround(a.mapPoint):this.plotReferencePointOnGround(a)}setMessage(a,b,c,d){this._loading=!1;this.displayMessage={key:a,type:b,data:c,map:d}}async transformAndPlotSelectedLocation(a){const {currentBestFeature:b,
selectedPoint:c,state:d}=this;this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=u.destroyMaybe(this._crossSymbol));if(c&&b&&"image-loaded"===d)try{var h=await this.transformPoint(c,a);z.throwIfAborted(a);await this.plotSelectedPointOnImage(h,a)}catch(k){z.isAbortError(k)||y.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:k,selectedPoint:c,feature:b})}}async transformPoint(a,
b){if("none"!==this.mode&&(a=await V.transformPoints([a],{feature:this.currentBestFeature,imageProperties:"default"===this.mode?this._imageViewer.viewModel.image.serviceRasterInfo:{width:this._panoramicViewer.imageSize?.[0],height:this._panoramicViewer.imageSize?.[1]},options:b},"3d"===this.view?.type),a.length))return a[0]}updateCurrentCoveragePolygon(a){const {additionalFootprints:b,additionalCameraLocations:c,currentBestFeature:d,currentBestFeatureLocation:h,currentCoverageVisible:k,selectedPoint:m,
view:l,_adapter:n}=this,{attributes:{objectId:p},elevationSample:t}=d;if(this._initialCurrentCoverageUpdate)this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=u.destroyMaybe(this.bestFeatureCurrentFootprint),a&&(a.visible=k,this.bestFeatureCurrentFootprint=a),l&&(a=[...b,...c,this.bestFeatureCurrentFootprint,h].filter(C.isGraphic),l.supportsGround&&t&&n?.updateGroundElevation&&n.updateGroundElevation(a,t),m&&a.push(new v({geometry:m.clone(),symbol:E.crossSymbol.clone(),
attributes:{imageID:p}})),this._overlays.graphics.addMany(a));else if(l){this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=u.destroyMaybe(this.bestFeatureCurrentFootprint));const r=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;a&&(this.bestFeatureCurrentFootprint=a,l?.supportsGround&&t&&n?.updateGroundElevation&&n.updateGroundElevation([a],t),a.visible=
this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,0<=r?r:this._overlays.graphics.length-1))}}};f.__decorate([g.property()],e.prototype,"activeLayer",null);f.__decorate([g.property({readOnly:!0})],e.prototype,"activeViewer",null);f.__decorate([g.property()],e.prototype,"additionalFeatures",void 0);f.__decorate([g.property()],e.prototype,"bestFeatureAngle",void 0);f.__decorate([g.property({type:Number})],e.prototype,"brightness",null);f.__decorate([g.property({type:Number})],
e.prototype,"contrast",null);f.__decorate([g.property()],e.prototype,"coverageFrustums",void 0);f.__decorate([g.property()],e.prototype,"coveragePolygons",void 0);f.__decorate([g.property()],e.prototype,"currentBestFeature",void 0);f.__decorate([g.property()],e.prototype,"currentCoverageVisible",void 0);f.__decorate([g.property({json:{write:!1}})],e.prototype,"determineWorkflowForFeature",void 0);f.__decorate([g.property()],e.prototype,"disabled",void 0);f.__decorate([g.property()],e.prototype,"displayMessage",
void 0);f.__decorate([g.property()],e.prototype,"drawFootprint",void 0);f.__decorate([g.property({readOnly:!0})],e.prototype,"featureCount",null);f.__decorate([g.property()],e.prototype,"features",void 0);f.__decorate([g.property({readOnly:!0})],e.prototype,"imageGalleryEnabled",null);f.__decorate([g.property({readOnly:!0})],e.prototype,"imageLoaded",null);f.__decorate([g.property()],e.prototype,"imagePointsInView",null);f.__decorate([g.property()],e.prototype,"isAdditionalCoverageVisible",void 0);
f.__decorate([g.property()],e.prototype,"isAdditionalPointSourcesVisible",void 0);f.__decorate([g.property()],e.prototype,"layer",void 0);f.__decorate([g.property({type:Number})],e.prototype,"localPort",void 0);f.__decorate([g.property()],e.prototype,"mapImageConversionToolState",void 0);f.__decorate([g.property({readOnly:!0,value:"none"})],e.prototype,"mode",null);f.__decorate([g.property()],e.prototype,"navigatorCurrentBestFeature",void 0);f.__decorate([g.property()],e.prototype,"pointSources",
void 0);f.__decorate([g.property({readOnly:!0})],e.prototype,"popupEnabled",null);f.__decorate([g.property()],e.prototype,"previousFeatureAngle",void 0);f.__decorate([g.property()],e.prototype,"referencePoint",null);f.__decorate([g.property({readOnly:!0})],e.prototype,"sectorData",null);f.__decorate([g.property()],e.prototype,"selectedPoint",void 0);f.__decorate([g.property({type:Number})],e.prototype,"sharpness",null);f.__decorate([g.property()],e.prototype,"shouldShowSelectedImage",void 0);f.__decorate([g.property({readOnly:!0})],
e.prototype,"state",null);f.__decorate([g.property({readOnly:!0})],e.prototype,"thumbnails",null);f.__decorate([g.property()],e.prototype,"updateFootprint",void 0);f.__decorate([g.property()],e.prototype,"updateFootprintPanorama",void 0);f.__decorate([g.property({value:null})],e.prototype,"view",null);f.__decorate([g.property()],e.prototype,"_adapter",void 0);f.__decorate([g.property({type:x.ofType(v)})],e.prototype,"additionalFootprints",void 0);f.__decorate([g.property({type:x.ofType(v)})],e.prototype,
"additionalCameraLocations",void 0);f.__decorate([g.property()],e.prototype,"bestFeatureCurrentFootprint",void 0);f.__decorate([g.property()],e.prototype,"_fetchFeaturesController",void 0);f.__decorate([g.property()],e.prototype,"_highlightedFeatureHandle",void 0);f.__decorate([g.property()],e.prototype,"_imageViewer",void 0);f.__decorate([g.property({type:v})],e.prototype,"bestFeatureFootprint",void 0);f.__decorate([g.property()],e.prototype,"_initialCurrentCoverageUpdate",void 0);f.__decorate([g.property()],
e.prototype,"_loading",void 0);f.__decorate([g.property()],e.prototype,"_overlays",void 0);f.__decorate([g.property({readOnly:!0})],e.prototype,"_overlaysView",null);f.__decorate([g.property()],e.prototype,"_panoramicViewer",void 0);f.__decorate([g.property()],e.prototype,"_referencePointOnGround",void 0);f.__decorate([g.property()],e.prototype,"_referencePointOnImage",void 0);f.__decorate([g.property()],e.prototype,"currentBestFeatureLocation",void 0);f.__decorate([g.property()],e.prototype,"_sectorData",
void 0);f.__decorate([g.property()],e.prototype,"footprintExtent",void 0);return e=f.__decorate([ba.subclass("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],e)});