@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 8.71 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{_ as e}from"../chunks/tslib.es6.js";import t from"../request.js";import r from"../core/Error.js";import{clamp as o}from"../core/mathUtils.js";import{MultiOriginJSONMixin as i}from"../core/MultiOriginJSONSupport.js";import{watch as l,initial as s}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{reader as a}from"../core/accessorSupport/decorators/reader.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import u from"../geometry/Extent.js";import y from"../geometry/Polyline.js";import d from"../geometry/SpatialReference.js";import c from"./Layer.js";import{BlendLayer as m}from"./mixins/BlendLayer.js";import{CustomParametersMixin as h}from"./mixins/CustomParametersMixin.js";import{ScaleRangeLayer as f}from"./mixins/ScaleRangeLayer.js";import{parse as v}from"./support/arcgisLayerUrl.js";import{url as g}from"./support/commonProperties.js";import O from"./support/PlaybackInfo.js";import{getVideoLayerCapabilities as j}from"./support/serviceCapabilitiesUtils.js";import S from"./support/TelemetryData.js";import T from"./support/TelemetryDisplay.js";import b from"./support/VideoFrame.js";import C from"./video/VideoController.js";import{getFrameHorizonPoints as I,getGroundControlPoints as U,getTelemetryData as P,getServiceLayersInfo as x,getSensorTrailPoints as L,readVideoTimeExtent as N}from"./video/videoUtils.js";let w=class extends(m(f(i(h(c))))){constructor(e){super(e),this._trailPoints=[],this.capabilities=null,this.connectionInfo=null,this.controller=new C,this.copyright=null,this.created=null,this.description=null,this.elevationSource=null,this.frame=null,this.frameCount=null,this.fullExtent=null,this.initialExtent=null,this.layerId=null,this.playbackInfo=null,this.posterUrl=null,this.qualities=null,this.serviceItemId=null,this.sourceJSON=null,this.sourceQuality=null,this.sourceType=null,this.spatialReference=d.WGS84,this.telemetryDisplay=null,this.title=null,this.type="video",this.url=null,this.videoLayersInfo=null,this.videoTimeExtent=null}initialize(){this.telemetryDisplay=new T({frame:!1,frameCenter:!1,frameOutline:!0,lineOfSight:!0,sensorLocation:!0,sensorTrail:!0}),this.addHandles([l((()=>this.metadata),(()=>{this.notifyChange("telemetry"),this.notifyChange("groundControlPoints"),this.notifyChange("frameHorizonPoints")})),l((()=>this.telemetry?.sensorLocation),(e=>this._setSensorTrail(e)),s)])}load(e){const t=null!=e?e.signal:null;return this.addResolvingPromise(this._fetchService(t)),Promise.resolve(this)}get buffered(){return this.controller.buffered}readCapabilitiesFromService(e,t){return j(t)}readConnectionInfo(e,t){const r=Object.values(t.connectionUrl);return r?.length&&(this.controller.playerUrl=r[0]),t.connectionUrl}get currentTime(){return this.controller.currentTime}get duration(){return this.controller.duration}get ended(){return this.controller.ended}get frameHorizonPoints(){return I(this.metadata)}get groundControlPoints(){return U(this.metadata)}get loop(){return this.controller.loop}set loop(e){this.controller.loop=e}get metadata(){return this.controller?.currentMetadata}get mimeType(){return this.controller?.mimeType}get muted(){return this.controller.muted}set muted(e){this.controller.muted=e}get playbackRate(){return this.controller.rate}set playbackRate(e){this.controller.rate=e}get playerUrl(){return this.controller.playerUrl}get playing(){return this.controller.playing}get state(){return this.controller.state}get telemetry(){return P(this.metadata)}get videoElement(){return this.controller?.element}get videoHeight(){return this.controller?.videoHeight}readLayerInfosFromService(e,t){return x(t)}get videoWidth(){return this.controller?.videoWidth}get waiting(){return this.controller.waiting}play(){this.controller.play()}pause(){this.controller.pause()}reset(){this.controller.reset()}setCurrentTime(e){if(!this.duration)return;const t=o(e,0,this.duration);this.controller.setCurrentTime(t)}toGround(e,t){return this.controller?.sensorModel?.metadataSupportsTransforms?this.controller.sensorModel.transformImageToGeo(e,t):null}toVideo(e){if(!this.controller?.sensorModel?.metadataSupportsTransforms)return null;const t=this.controller.sensorModel.transformGeoToImage(e.x,e.y,e.z);return{x:t[0],y:t[1]}}async _fetchService(e){if(this.sourceJSON)return void this.read(this.sourceJSON,{origin:"service",url:this.parsedUrl});const o=v(this.parsedUrl?.path);if(null==o)throw new r("arcgis-layers:url-mismatch","The url is not a valid arcgis resource");let i=null;const{data:l,ssl:s}=await t(o.url.path,{query:{f:"json",...this.parsedUrl.query,...this.customParameters},signal:e}),n=l;if(this.url=o.url.path,s&&(this.url=this.url.replace(/^http:/i,"https:")),!n?.currentVersion)return n.currentVersion="11.2",this.sourceJSON=n,void this.read(this.sourceJSON,{origin:"service",url:this.parsedUrl});let a=o?.sublayer;if(null==a&&n.layers?.length&&(a=n.layers[0].id),null==a)throw new r("arcgis-layers:url-mismatch","The url is not a valid arcgis resource");this.url=`${o.url.path}/${a}`,i=await t(this.url,{query:{f:"json",...this.customParameters},signal:e});const p={...n,...i.data};this.sourceJSON=p,this.read(this.sourceJSON,{origin:"service",url:this.parsedUrl})}_setSensorTrail(e){if(!e)return;const t=L(e,this._trailPoints);this._trailPoints=[...t];const r=this._trailPoints.map((e=>e.toArray())),o=new y({hasZ:e.hasZ,paths:[r]});this.telemetry.sensorTrail=o.clone()}};e([n({readOnly:!0})],w.prototype,"buffered",null),e([n({readOnly:!0,json:{read:!1}})],w.prototype,"capabilities",void 0),e([a("service","capabilities",["supportsAppend","supportsCoverageQuery","supportsExportClip","supportsExportFrameset","supportsMensuration","supportsUpdate"])],w.prototype,"readCapabilitiesFromService",null),e([n({readOnly:!0})],w.prototype,"connectionInfo",void 0),e([a("connectionInfo",["connectionUrl"])],w.prototype,"readConnectionInfo",null),e([n()],w.prototype,"controller",void 0),e([n({type:String})],w.prototype,"copyright",void 0),e([n({readOnly:!0,type:Date})],w.prototype,"created",void 0),e([n({type:Number})],w.prototype,"currentTime",null),e([n({type:String})],w.prototype,"description",void 0),e([n({type:Number})],w.prototype,"duration",null),e([n({readOnly:!0})],w.prototype,"elevationSource",void 0),e([n({type:Boolean})],w.prototype,"ended",null),e([n({type:b})],w.prototype,"frame",void 0),e([n({readOnly:!0,type:Number})],w.prototype,"frameCount",void 0),e([n({type:u})],w.prototype,"fullExtent",void 0),e([n({readOnly:!0})],w.prototype,"frameHorizonPoints",null),e([n({readOnly:!0})],w.prototype,"groundControlPoints",null),e([n({type:u})],w.prototype,"initialExtent",void 0),e([n({readOnly:!0,json:{read:{source:"id"}}})],w.prototype,"layerId",void 0),e([n({type:Boolean})],w.prototype,"loop",null),e([n({readOnly:!0})],w.prototype,"metadata",null),e([n({readOnly:!0})],w.prototype,"mimeType",null),e([n({type:Boolean})],w.prototype,"muted",null),e([n({type:O})],w.prototype,"playbackInfo",void 0),e([n({type:Number})],w.prototype,"playbackRate",null),e([n({type:String})],w.prototype,"playerUrl",null),e([n({readOnly:!0})],w.prototype,"playing",null),e([n({readOnly:!0,json:{read:{source:"poster"}}})],w.prototype,"posterUrl",void 0),e([n({readOnly:!0})],w.prototype,"qualities",void 0),e([n({readOnly:!0})],w.prototype,"serviceItemId",void 0),e([n()],w.prototype,"sourceJSON",void 0),e([n({readOnly:!0})],w.prototype,"sourceQuality",void 0),e([n({readOnly:!0,json:{name:"serviceType"}})],w.prototype,"sourceType",void 0),e([n()],w.prototype,"spatialReference",void 0),e([n({readOnly:!0,type:String})],w.prototype,"state",null),e([n({readOnly:!0,type:S})],w.prototype,"telemetry",null),e([n({type:T})],w.prototype,"telemetryDisplay",void 0),e([n({readOnly:!1,json:{read:{source:"name"}}})],w.prototype,"title",void 0),e([n({readOnly:!0})],w.prototype,"type",void 0),e([n(g)],w.prototype,"url",void 0),e([n({readOnly:!0})],w.prototype,"videoElement",null),e([n({readOnly:!0})],w.prototype,"videoHeight",null),e([n({readOnly:!0,json:{read:!1}})],w.prototype,"videoLayersInfo",void 0),e([a("service","videoLayersInfo",["id","name","poster","serviceType","type"])],w.prototype,"readLayerInfosFromService",null),e([n({readOnly:!0,nonNullable:!1,json:{read:{reader:N,source:"time"}}})],w.prototype,"videoTimeExtent",void 0),e([n({readOnly:!0})],w.prototype,"videoWidth",null),e([n({readOnly:!0})],w.prototype,"waiting",null),w=e([p("esri.layers.VideoLayer")],w);const E=w;export{E as default};