UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 4.42 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{property as o}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{createCoveragePolygon as s}from"../../../layers/orientedImagery/core/coverageUtils.js";import n from"../../../layers/orientedImagery/core/ExposurePoint.js";import{InvalidDirectionError as a,FeatureSectorNotFoundError as l}from"./errors.js";import{queryNextLocationFeatures as c,querySequenceCount as d,queryAfterSequenceField as u,querySequenceFeaturesAroundPoint as g,queryOffsetSequenceFeatures as w}from"./queries.js";let p=class extends r{constructor(e){super(e),this.viewModel=null}get currentNode(){return this.viewModel.currentNode}get layer(){return this.viewModel.layer}get navigationNodes(){return this.viewModel.navigationNodes}async _queryAndHandleFeatureResponse(e,r,o,i){const{error:s,nextLocation:n,response:a}=await c(e,r,o,i);if(t(i),s)throw s;this.viewModel.selectedPoint=n,await this.viewModel.processFeatureResponse(a,n,{signal:i?.signal,loadBestImage:!1})}async afterNavigate(e,r,t){return await this.viewModel.selectBestFeature(r.id,t),r}async navigate(e,r){let t;if("direction"in r?t=await this.navigateInDirection(e,r):("step"in r||"goTo"in r)&&(t=await this.navigateInSequence(e,r)),!t)throw new Error("No next node found");return await this.afterNavigate(e,t,r)}async navigateBySkippingSteps(e,r){const{step:t}=r,{layer:o}=this,{floorFilterClause:i}=this.viewModel;if(!o)throw new Error("Layer is not defined");const a=e.attributes.sequenceOrder;if(0===await d(o,i,{signal:r.signal})||!a)throw new Error("No sequence found");const{response:l,error:c}=await u(o,a,t,1,i,{signal:r.signal});if(c)throw new Error("Error querying sequence features");const w=l?.features[0];if(!w)throw new Error("No next node found");const p=n.fromJSON({...w.toJSON(),layer:o}),{response:f,error:h,nextLocation:v}=await g(o,s(p).polygon.centroid,i,{signal:r.signal});if(h)throw new Error("Error querying sequence features");const y=[...f.features];y.push(w),f.features=y,this.viewModel.selectedPoint=v;const m=w.attributes.objectId;return await this.viewModel.processFeatureResponse(f,v,{signal:r.signal,loadBestImage:!1}),this.viewModel.selectedPoint=v,this.viewModel.navigationNodes.find((e=>e.id===m))}async navigateInDirection(e,r){const{viewModel:t}=this,{layer:o,floorFilterClause:i}=t,{direction:s,signal:n}=r,c=e?.[s];if(!c)throw new a(s);const d=t.getFeatureSectorById(c.id);if(!d)throw new l(c);const[u,g]=d.split("_"),w=g??u,p=`NEAR_${w}`,h=`FAR_${w}`,v=t.getActiveSectors();return f(d,v.includes(p),v.includes(h),w,p,h)&&await this._queryAndHandleFeatureResponse(o,c,i,{signal:n}),c}async navigateInSequence(e,r){return"step"in r?this.navigateBySkippingSteps(e,r):this.navigateTo(r)}async navigateTo(e){const{goTo:r}=e,{layer:t}=this,{floorFilterClause:o}=this.viewModel;if(!t)throw new Error("Layer is not defined");const i="number"==typeof r?r:1,a=this.viewModel.navigationNodes.find((e=>e.id===i));if(a)return a;const{response:l,error:c}=await w(t,i,1,"end"===r?"DESC":"ASC",o,{signal:e.signal});if(c)throw new Error("Error querying sequence features");const d=l?.features[0];if(!d)throw new Error("No next node found");const u=n.fromJSON({...d.toJSON(),layer:t}),{polygon:p}=s(u),{response:f,error:h,nextLocation:v}=await g(t,p.centroid,o,{signal:e.signal});if(h)throw new Error("Error querying sequence features");const y=[...f.features];y.push(d),f.features=y,this.viewModel.selectedPoint=v;const m=d.attributes.objectId;return await this.viewModel.processFeatureResponse(f,v,{signal:e.signal,loadBestImage:!1}),this.viewModel.selectedPoint=v,this.viewModel.navigationNodes.find((e=>e.id===m))}};function f(e,r,t,o,i,s){return e===s||e===i&&!t||e===o&&!r&&!t}e([o()],p.prototype,"currentNode",null),e([o()],p.prototype,"layer",null),e([o()],p.prototype,"navigationNodes",null),e([o({constructOnly:!0})],p.prototype,"viewModel",void 0),p=e([i("esri.widgets.OrientedImageryViewer.navigation.NavigationManager")],p);export{p as default};