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.
20 lines
8.9 KiB
20 lines
8.9 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("../../../chunks/tslib.es6 ../../../geometry ../../../Map ../../../core/Error ../../../core/Evented ../../../core/Logger ../../../core/mathUtils ../../../core/maybe ../../../core/promiseUtils ../../../core/reactiveUtils ../../../core/accessorSupport/decorators/property ../../../core/has ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../../geometry/geometryEngine ../../../layers/GraphicsLayer ../../../layers/ImageryTileLayer ../../../layers/support/RasterFunction ../../../layers/support/rasterFunctionConstants ../../../layers/support/TileInfo ../../../views/MapView ../../../views/2d/viewpointUtils ../utils ../../../geometry/SpatialReference ../../../geometry/Polygon ../../../geometry/Point".split(" "), |
|
function(f,e,F,z,G,H,y,I,J,l,h,T,U,K,u,L,M,N,A,O,P,Q,v,R,w,S){e=class extends G.EventedAccessor{constructor(c){super(c);this._imageChanged=!1;this._loadController=this._image=this._panConstraint=null;this._overlays=new L;this._map=new F;this.autoLoad=!1;this.clickAction="none";this.imageSource=this.error=null;this.imageRotation=0;this.state="ready";this._cancelLoadWithController=()=>{this._loadController?.abort();this._loadController=null};this._createImageHandles=()=>{this.removeHandles("enhancements-handle"); |
|
this.addHandles(l.watch(()=>[this.brightness,this.contrast,this.sharpness],([a,b,d])=>{this.image?.loaded&&(this.image.effect=`contrast(${10*(b+10)}%) brightness(${10*(a+10)}%)`,this.sharpenImage(this.image,d))},l.syncAndInitial))};this._createPanConstraint=()=>{const {image:a,imageRenderer:b}=this,d=g=>{if(!(a&&b&&g.targetGeometry&&a.serviceRasterInfo))return g;var {extent:m}=a.serviceRasterInfo;const {constraints:q,rotation:k,width:n,height:r}=b;var {extent:p}=u.rotate(w.fromExtent(m),k);const {width:B, |
|
height:C}=p;m=g.targetGeometry.clone();const D=q.scaleToZoom(g.scale);var t=1/2**D;const E=n/r;let x=t*B;t*=C;D&&(B/n>C/r?t=x/E:x=t*E);p=p.clone();p.xmin+=x/2;p.xmax-=x/2;p.ymin+=t/2;p.ymax-=t/2;g.targetGeometry=u.nearestCoordinate(p,m).coordinate;this.state="image-loaded";return g};return{constrain:d,applyPanConstraint:d}};this._createResizeHandles=a=>{a.removeHandles("resize");a.addHandles(l.watch(()=>{if(this.imageRenderer.ready){var {extent:b}=a.serviceRasterInfo,{width:d,height:g,rotation:m}= |
|
this.imageRenderer;({extent:b}=u.rotate(w.fromExtent(b),m));var {width:q,height:k}=b;return Math.max(q/d,k/g)}},b=>{if(this.imageRenderer&&null!=b){var {constraints:d,scale:g,spatialReference:m}=this.imageRenderer,q=d.minScale,k=Q.getResolutionToScaleFactor(m),n=.25*k;k=b*=k;for(var r=[];k>n;)r.push(k),k/=2;r.push(k);({lods:n}=O.create({scales:r}));d.set({minScale:b,lods:n});this._imageChanged?(this.imageRenderer.scale=b,this._imageChanged=!1):this.imageRenderer.scale=1E-6>=Math.abs(g-q)?b:g}},l.syncAndInitial), |
|
"resize")};this._loadImageInternal=(a,b={})=>{this.clearImage();this.error=null;this._imageChanged=!0;this.state="image-loading";const d="string"===typeof a,g=d?void 0:a.datasetFormat,m=d?a:a.url,{customParameters:q,options:k}=b;this._image=new M({ioConfig:{skipExtensions:["aux.xml","jgw"],skipMapInfo:!0,datasetFormat:g},url:m,customParameters:q});this._image.when(n=>{this._updatePanConstraint();this._createResizeHandles(n);this._map.add(n);this.state="image-loaded"},n=>{J.isAbortError(n)?this.state= |
|
"image-load-aborted":(this.state="image-load-error",this.error=n,H.getLogger(this).error(`error occurred while loading image ${d?a:JSON.stringify(a)}`,n),this.imageSource=null)});return this._image.load(k)};this._loadWithController=()=>{this._cancelLoadWithController();this._loadController=new AbortController;this.loadImage(this._loadController)};this._updatePanConstraint=()=>{this._panConstraint&&this.imageRenderer.constraints.customConstraints.remove(this._panConstraint);this._panConstraint=this._createPanConstraint(); |
|
this.imageRenderer.constraints.customConstraints.add(this._panConstraint)};this.addGraphic=(a,b)=>{this._overlays.graphics.add(a,b)};this.addManyGraphics=a=>{this._overlays.addMany(a)};this.clearGraphics=()=>{this._overlays.graphics.removeAll()};this.clearImage=()=>{this.image&&(this._map.layers.remove(this.image),this._image=I.destroyMaybe(this._image))};this.loadImage=a=>{const {customParameters:b,imageSource:d}=this;return d?this._loadImageInternal(d,{customParameters:b,options:a}):v.logAndThrow(this.declaredClass, |
|
new z(v.getMissingPropertyErrorName("image-viewer"),v.getMissingPropertyErrorMessage("ImageViewerViewModel","imageSource")))};this.removeGraphic=a=>{this._overlays.remove(a)};this.removeManyGraphics=a=>{this._overlays.removeMany(a)};this._imageRenderer=new P({constraints:{snapToZoom:!0,rotationEnabled:!1},map:this._map,popupEnabled:!1,spatialReference:R.WebMercator,ui:{components:["zoom"]}})}initialize(){this.state="initialized";this.addHandles([l.watch(()=>this.imageSource,c=>{c&&this.autoLoad&& |
|
this._loadWithController()},l.syncAndInitial),l.watch(()=>this.image?.loaded,()=>{this._createImageHandles()}),l.watch(()=>this.imageRotation,()=>{this._rotateImage()}),l.watch(()=>this.imageRenderer.map,(c,a)=>{a?.layers.remove(this._overlays);c?.layers.add(this._overlays)},l.initial),l.watch(()=>this.imageRenderer.map.allLayers.length,c=>{c&&this.imageRenderer.map.layers.reorder(this._overlays,c-1)},l.syncAndInitial),l.watch(()=>this.clickAction,c=>{this.removeHandles("click-handle");"none"!==c&& |
|
this.addHandles(this.imageRenderer.on("click",a=>{if(this.image?.loaded&&this.imageRenderer.ready)switch(c){case "emit":a.stopPropagation();this.emit("click",a);break;case "hittest":a.stopPropagation();a.async(async()=>{const m=await this.imageRenderer.hitTest(a.screenPoint,{include:this._overlays});this.emit("hittest-response",m)});break;case "pixel-location":if(a.stopPropagation(),this.image?.serviceRasterInfo&&a.mapPoint){var {extent:b,pixelSize:d}=this.image.serviceRasterInfo,g=new S({x:(a.mapPoint.x- |
|
b.xmin)*d.x,y:(b.ymax-a.mapPoint.y)*d.y,spatialReference:b.spatialReference});this.emit("pixel-location",g)}else this.emit("pixel-location",null)}}))},l.syncAndInitial)])}get brightness(){return this._get("brightness")??0}set brightness(c){this._set("brightness",y.clamp(c,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(c){this._set("contrast",y.clamp(c,-10,10))}get image(){return this._image}get imagePointsInView(){const {extent:c,ready:a}=this.imageRenderer;var b=this.imageRotation, |
|
d=this.image?.fullExtent;const g=this.image?.serviceRasterInfo,m=!0===this._imageRenderer.allLayerViews.find(({layer:q})=>q===this.image)?.attached;if(!(a&&c&&d&&g&&m))return null;b=u.rotate(w.fromExtent(c),b);d=w.fromExtent(d);d=u.intersect(b,d);({rings:d}=d);return d.flat().map(([q,k])=>({x:(q-g.extent.xmin)*g.pixelSize.x,y:(g.extent.ymax-k)*g.pixelSize.y}))}get imageSize(){const {image:c}=this;if(!c?.raster)return null;const {width:a,height:b}=c.raster.rasterInfo;return[a,b]}get imageRenderer(){return this._imageRenderer}get imageView(){return this.imageRenderer.allLayerViews.find(c=> |
|
c.layer===this.image)}get sharpness(){return this._get("sharpness")??0}set sharpness(c){this._set("sharpness",y.clamp(c,0,1))}_rotateImage(){this.imageRenderer.constraints.rotationEnabled=!0;this.imageRenderer.rotation=this.imageRotation;this.imageRenderer.constraints.rotationEnabled=!1}sharpenImage(c,a){a?(a=new N({functionName:"Convolution",functionArguments:{type:A.convolutionKernel.userDefined,cols:3,rows:3,kernel:[0,-1*a,0,-1*a,4*a+1,-1*a,0,-1*a,0],convolutionType:A.convolutionKernel.userDefined}}), |
|
c.rasterFunction=a):c.rasterFunction=null}};f.__decorate([h.property()],e.prototype,"_image",void 0);f.__decorate([h.property()],e.prototype,"_imageRenderer",void 0);f.__decorate([h.property()],e.prototype,"_loadController",void 0);f.__decorate([h.property()],e.prototype,"_overlays",void 0);f.__decorate([h.property()],e.prototype,"_map",void 0);f.__decorate([h.property({type:Boolean})],e.prototype,"autoLoad",void 0);f.__decorate([h.property({type:Number})],e.prototype,"brightness",null);f.__decorate([h.property()], |
|
e.prototype,"clickAction",void 0);f.__decorate([h.property({type:Number})],e.prototype,"contrast",null);f.__decorate([h.property({type:Object})],e.prototype,"customParameters",void 0);f.__decorate([h.property({type:z})],e.prototype,"error",void 0);f.__decorate([h.property({readOnly:!0})],e.prototype,"image",null);f.__decorate([h.property({readOnly:!0})],e.prototype,"imagePointsInView",null);f.__decorate([h.property({readOnly:!0})],e.prototype,"imageSize",null);f.__decorate([h.property({cast:v.castImageSource})], |
|
e.prototype,"imageSource",void 0);f.__decorate([h.property({readOnly:!0})],e.prototype,"imageRenderer",null);f.__decorate([h.property({type:Number})],e.prototype,"imageRotation",void 0);f.__decorate([h.property()],e.prototype,"imageView",null);f.__decorate([h.property({type:Number})],e.prototype,"sharpness",null);f.__decorate([h.property()],e.prototype,"state",void 0);return e=f.__decorate([K.subclass("esri.widgets.OrientedImageryViewer.components.ImageViewerViewModel")],e)}); |