// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/layers/WCSLayer","dojo/_base/declare dojo/_base/lang dojo/_base/connect dojo/_base/Deferred dojo/when dojo/io-query dojo/has ../kernel ../request ../deferredUtils ./BaseRasterLayer ./WCSConnection ./Raster ./rasterFormats/ImageCanvasDecoder ./pixelFilters/StretchFilter ../geometry/Extent ../geometry ../graphic".split(" "),function(y,m,z,t,F,G,H,I,J,x,r,K,A,L,M,B,v,N){var C=function(a,d){var b;for(b=0;b<a.length;b++)if(d(a[b]))return b;return-1},O=function(a,d){var b;for(b=0;b<a.length;b++)if(d(a[b]))return a[b]},
u=function(a,d,b){var c;if(b)for(c=0;c<a.length;c++){if(a[c][b].toLowerCase()===d.toLowerCase())return a[c]}else for(c=0;c<a.length;c++)if(a[c].toLowerCase()===d.toLowerCase())return a[c]},E={parse:function(a){var d={isMultiPart:!0,data:null},b=this._getMultiPartHeader(a);b?(d.isMultiPart=!0,d.data=this._getParts(a.data,b)):(d.isMultiPart=!1,d.data=a.data);return d},_getParts:function(a,d){var b=0,c=0,e=b=0,f=[],g=[],k=[],h=[],p,q;p="--"+d.boundary;q="--"+d.boundary+"\n";for(var w="\n--"+d.boundary+
"--",l=[10],D=[13,10],b=0;b<p.length;b++)g.push(p.charCodeAt(b));for(b=0;b<q.length;b++)k.push(q.charCodeAt(b));for(b=0;b<w.length;b++)h.push(w.charCodeAt(b));p=p.length;k=new Uint8Array(a);q=Math.min(1E4,k.length);for(b=0;b<q;b++)k[b]===g[e]?e===p-1?(e=0,c&&f.push(this._parsePart(k.subarray(c,b+1-p),d)),k[b+1]===l[0]?b+=1:k[b+1]===D[0]&&k[b+2]===D[1]&&(b+=2),c=b+1):e++:e=0;for(b=k.length-h.length-2;b<k.length;b++)if(k[b]===h[e])if(e===h.length-1){e=0;b=b-h.length+1;f.push(this._parsePart(k.subarray(c,
b),d));break}else e++;else e=0;return f},_getMultiPartHeader:function(a){var d,b,c=a.getHeader("Content-Type").split(";");if("multipart/related"===c[0]||"multipart/mixed"===c[0])for(d={boundary:"",start:"",type:""},a=1;a<c.length;a++)b=c[a].split("\x3d"),d[b[0].trim()]=b[1].trim().slice(1,b[1].length-1);return d},_parsePart:function(a,d){var b=String.fromCharCode.apply(null,a.subarray(0,Math.min(300,a.length))).split("\n"),c=0,e=0,f,g=Math.min(b.length,7);f={contentType:null,contentDescription:null,
contentTransferEncoding:null,contentID:null,contentDisposition:null,contentData:null,contentLocation:null};for(var k,h,c=0;c<g;c++)if(4>b[c].length)e=e+b[c].length+1;else if("content"===b[c].slice(0,7).toLowerCase()){if(e=e+b[c].length+1,-1!==b[c].indexOf(":")&&(k=b[c].substring(0,b[c].indexOf(":")).trim(),h=b[c].substring(b[c].indexOf(":")+1).trim(),k))switch(k.toLowerCase()){case "content-type":f.contentType=h;break;case "content-description":f.contentDescription=h;break;case "content-transfer-encoding":f.contentTransferEncoding=
h;break;case "content-id":f.contentID=h;break;case "content-disposition":f.contentDisposition=h;break;case "content-location":f.contentLocation=h}}else if(f.contentDisposition&&4<=b[c].length&&-1<f.contentType.toLowerCase().indexOf("image")){b=new ArrayBuffer(a.length-e);c=new Uint8Array(b);c.set(a.subarray(e,a.length));f.contentData=b;break}else if((""===d.start||f.contentID===d.start)&&f.contentType)if(-1<f.contentType.indexOf("text")){f.contentData=String.fromCharCode.apply(null,a.subarray(e,a.length));
break}else f.contentData=a.subarray(e,a.length);return f}};r=y([r],{declaredClass:"esri.layers.WCSLayer",format:null,interpolation:null,bandIds:null,optionalParameters:null,multidimensionalDefinition:null,projectedFullExtent:null,wcsConnection:null,version:null,coverageId:null,coverageDescription:null,extent:null,timeInfo:null,pixelType:null,_projectedResolution:null,_WEB_MERCATOR:[102100,3857,102113,900913],_REVERSED_LAT_LONG_RANGES:[[4001,4999],[2044,2045],[2081,2083],[2085,2086],[2093,2093],[2096,
2098],[2105,2132],[2169,2170],[2176,2180],[2193,2193],[2200,2200],[2206,2212],[2319,2319],[2320,2462],[2523,2549],[2551,2735],[2738,2758],[2935,2941],[2953,2953],[3006,3030],[3034,3035],[3058,3059],[3068,3068],[3114,3118],[3126,3138],[3300,3301],[3328,3335],[3346,3346],[3350,3352],[3366,3366],[3416,3416],[20004,20032],[20064,20092],[21413,21423],[21473,21483],[21896,21899],[22171,22177],[22181,22187],[22191,22197],[25884,25884],[27205,27232],[27391,27398],[27492,27492],[28402,28432],[28462,28492],
[30161,30179],[30800,30800],[31251,31259],[31275,31279],[31281,31290],[31466,31700]],_pivotServerGridOrigin110:!1,constructor:function(a,d){this._pixelValueReadPromise=this._rasterReadPromise=null},_initialize:function(a,d){this._params={};y.safeMixin(this,d);this.optionalParameters=this.optionalParameters||{};this.bandIds=this.bandIds||null;var b=this.url.indexOf("?");-1<b&&b<=this.url.length-1&&(this.optionalParameters=m.mixin(this.optionalParameters,G.queryToObject(this.url.substring(b+1,this.url.length))),
this.url=this.url.substring(0,b));this.coverageId=this.coverageId||this.coverage||this.identifiers||this.optionalParameters.coverage||this.optionalParameters.coverageId||this.optionalParameters.identifiers;b=m.mixin({},{version:this.version,token:this.token,coverageId:this.coverageId},this.optionalParameters);b=this.wcsConnection||(new K(this.url,b))._connectPromise;F(b,m.hitch(this,this._initialized),this._errorHandler)},_initialized:function(a){var d;this.wcsConnection=a;this.version=this.version||
a.version;this.coverageId=this.coverageId||a.coverages[0].id;var b=u(a.coverages,this.coverageId,"id");this.coverageDescription=b;this.coverageDescription.supportedInterpolations=this.coverageDescription.supportedInterpolations||a.supportedInterpolations;this.extent=this.extent||b.extent;this.timeInfo=b.timeInfo;!this.bandIds&&this.coverageDescription.bandInfo&&(this.bandIds=Object.keys(this.coverageDescription.bandInfo).map(function(a){return parseInt(a,10)}));if((void 0===this.format||null===this.format||
""===this.format||"tiff"===this.format)&&b.supportedFormats)for(d=0;d<b.supportedFormats.length;d++)if(-1<b.supportedFormats[d].toLowerCase().indexOf("tiff")){this.format=b.supportedFormats[d];break}this.format=this.format||"image/tiff";this._findCredential();(this.credential&&this.credential.ssl||a&&a._ssl)&&this._useSSL();this._params.token=this._getToken();this.loaded=!0;this.onLoad(this);if(a=this._loadCallback)delete this._loadCallback,a(this)},onRasterReadComplete:function(){},setInfoTemplate:function(a){this.infoTemplate=
a},identify:function(a){var d=new t;this._identifyPixelValue(a).then(m.hitch(this,function(a){var b=[];if((this.infoTemplate&&this.infoTemplate.info&&this.infoTemplate.info.layerOptions&&this.infoTemplate.info.layerOptions.hasOwnProperty("showNoDataRecords")?this.infoTemplate.info.layerOptions.showNoDataRecords:1)||"NoData"!==a.value){var e=new N;e.setInfoTemplate(this.infoTemplate);e._layer=this;e.geometry=this.projectedFullExtent;e.attributes={ObjectId:0,"Raster.ServicePixelValue":a.pixelValues.map(function(a){return a.toString()})};
b.push(e)}d.resolve(b)}),m.hitch(this,function(a){d.reject(a)}));return d.promise},setUseMapTime:function(a,d){this.useMapTime=a;this._toggleTime();!d&&this._map&&this.refresh(!0)},_setMap:function(a,d){a.extent?(this.projectedFullExtent=(this.projectedFullExtent=this.projectedFullExtent||this._convertExtentToMap(this.coverageDescription.lonLatEnvelope,a.extent.spatialReference,1E-4))||this._convertExtentToMap(this.coverageDescription.extent,a.extent.spatialReference,1E-4),this._projectedResolution=
this._projectedResolution||{x:(this.projectedFullExtent.xmax-this.projectedFullExtent.xmin)/this.coverageDescription.columns,y:(this.projectedFullExtent.ymax-this.projectedFullExtent.ymin)/this.coverageDescription.rows}):this.projectedFullExtent=this.projectedFullExtent||this.coverageDescription.extent;return this.inherited(arguments)},_convertExtentToNative:function(a){if(!a)return null;var d=null,b=this.coverageDescription.lonLatEnvelope.spatialReference.wkid,c=a.spatialReference.wkid;b===c||-1<
this._WEB_MERCATOR.indexOf(b)&&-1<this._WEB_MERCATOR.indexOf(c)?d=a:4326===b&&-1<this._WEB_MERCATOR.indexOf(c)?d=v.webMercatorUtils.webMercatorToGeographic(a):4326===c&&-1<this._WEB_MERCATOR.indexOf(b)&&(d=v.webMercatorUtils.geographicToWebMercator(a));return d},_convertExtentToMap:function(a,d,b){if(!a)return null;var c=null;d=d?d.wkid:this._map.extent.spatialReference.wkid;var e=a.spatialReference.wkid;d===e||-1<this._WEB_MERCATOR.indexOf(d)&&-1<this._WEB_MERCATOR.indexOf(e)?c=a:4326===d&&-1<this._WEB_MERCATOR.indexOf(e)?
c=v.webMercatorUtils.webMercatorToGeographic(a):4326===e&&-1<this._WEB_MERCATOR.indexOf(d)&&(c=v.webMercatorUtils.geographicToWebMercator(a));c&&c.spatialReference.wkid&&-1<this._WEB_MERCATOR.indexOf(c.spatialReference.wkid)&&(c.spatialReference.wkid=3857);if(b&&c&&c.spatialReference.wkid)if(3857===c.spatialReference.wkid)c.xmin+=b,c.ymin+=b,c.xmax-=b,c.ymax-=b;else if(4326===c.spatialReference.wkid||180>=Math.abs(c.xmin)&&180>=Math.abs(c.xmax))a=1/111111,c.xmin+=b*a,c.ymin+=b*a,c.xmax-=b*a,c.ymax-=
b*a;return c},_constructGetCoverageParams:function(a,d,b,c){var e=this.projectedFullExtent;if(a.xmax<=e.xmin||a.xmin>=e.xmax||a.ymax<=e.ymin||a.ymin>=e.ymax)return null;var f=new B(a);f.xmin=Math.max(f.xmin,e.xmin);f.xmax=Math.min(f.xmax,e.xmax);f.ymin=Math.max(f.ymin,e.ymin);f.ymax=Math.min(f.ymax,e.ymax);var g=this._params;m.mixin(g,{extent:f,width:Math.round((f.xmax-f.xmin)/(a.xmax-a.xmin)*d),height:Math.round((f.ymax-f.ymin)/(a.ymax-a.ymin)*b),crs:"EPSG:"+e.spatialReference.wkid,epsgNSCRS:"urn:ogc:def:crs:EPSG::"+
e.spatialReference.wkid,coverageId:this.coverageId,format:this.format,interpolation:this.interpolation});c&&m.mixin(g,c);g.multidimensionalDefinition||(g.multidimensionalDefinition=this.multidimensionalDefinition);g.interpolation||(this.interpolation?g.interpolation=this.interpolation:this.coverageDescription.supportedInterpolations&&0<this.coverageDescription.supportedInterpolations.length&&(g.interpolation=this.coverageDescription.supportedInterpolations[0]));a=["nearest neighbor","bilinear","bicubic"];
d=["nearest","linear","cubic"];b=["nearest-neighbor","linear","cubic"];if(0===g.interpolation||1===g.interpolation||2===g.interpolation)"1.0.0"===this.version?g.interpolation=a[g.interpolation]:"1.1.0"===this.version||"1.1.1"===this.version||"1.1.2"===this.version?g.interpolation=d[g.interpolation]:"2.0.1"===this.version&&(g.interpolation="http://www.opengis.net/def/interpolation/OGC/1/"+b[g.interpolation]);this.bandIds&&(g.bandIds=this.bandIds.map(m.hitch(this,function(a){return this.coverageDescription.bandInfo[a]})));
!g.time&&this.coverageDescription.timeInfo&&"2.0.1"!==this.version&&(g.time=this.coverageDescription.timeInfo.timeExtent.endTime.toISOString());return g},_requestData:function(a,d,b){this._rasterReadPromise&&this._rasterReadPromise.cancel();var c=this._constructGetCoverageParams(a,d,b);if(c){var e=this,f=new A("");this._requestExtent=c.extent;var g;this._useBrowserDecoding()&&(a=new L({ctx:this._context}),g=m.hitch(a,"decode"));var k=new t(x._dfdCanceller);k._pendingDfd=this._getCoverage(c);var h,
p,q,w=this._requestExtent;k._pendingDfd.then(function(a){a=E.parse(a);if("1.0.0"===e.version)a=a.data;else if(a.isMultiPart)q=C(a.data,function(a){return null!=a.contentType&&-1<a.contentType.toLowerCase().indexOf("image")}),q=-1===q?a.data.length-1:q,a=a.data[q].contentData;else{p=Error("not a valid multipart coverage response");e._resolve([p],null,m.hitch(e,e._requestDataErrorHandler),k,!0);return}f.decode(a,{width:c.width,height:c.height,planes:null,pixelType:"UNKNOWN",decodeFunc:g}).then(function(a){e.pixelType=
e.pixelType||a.pixelType;if(!e.pixelFilter){var b=e._getDefaultFilter();e.pixelFilter=b.filter;e._pixelFilterArgs=b}h={pixelBlock:a,extent:w};e._resolve([h],"onRasterReadComplete",m.hitch(e,e._requestDataHandler),k,!1)},function(a){e._resolve([a],null,m.hitch(e,e._requestDataErrorHandler),k,!0)})},function(a){e._resolve([a],null,m.hitch(e,e._requestDataErrorHandler),k,!0)});this._rasterReadPromise=k.promise}else this.clear()},_requestDataHandler:function(a){this._rasterReadPromise&&this._rasterReadPromise.isCanceled()||
(this.originalPixelData=a,this.hasDataChanged=!0,this._setPixelData(a))},_setPixelData:function(a){a=this._clonePixelData(a);this.pixelFilter&&this.pixelFilter(a);this.pixelData=a;this._rasterReadPromise&&this._rasterReadPromise.isCanceled()||(this._drawPixelData(),this._rasterReadPromise=null)},_useBrowserDecoding:function(){var a=this._requestExtent,d=this._map.width,b=this._map.height,c=this.getCurrentResolution();return Math.round((a.xmax-a.xmin)/c.x)===d&&Math.round((a.ymax-a.ymin)/c.y)===b&&
(void 0===this.pixelFilter||null===this.pixelFilter)&&("jpeg"===this.format.toLowerCase()||"jpg"===this.format.toLowerCase()||-1<this.format.toLowerCase().indexOf("png"))},_clonePixelData:function(a){if(null===a||void 0===a)return a;var d={};a.extent&&(d.extent=m.clone(a.extent));a=a.pixelBlock;if(null===a||void 0===a)return d;d.pixelBlock=a.clone();return d},_resolve:function(a,d,b,c,e){d&&this[d].apply(this,a);b&&b.apply(null,a);c&&x._resDfd(c,a,e)},_getDefaultFilter:function(){var a=0;"U8"!==this.pixelType&&
(a=6);return new M({stretchType:a,min:0,max:255,dRA:!0,minPercent:.2,maxPercent:.2,useGamma:!1})},_getCoverage:function(a){var d=this.version,b=this.coverageDescription,c,e=function(a){return a.toISOString()},f=m.hitch(this,function(){c={request:"GetCoverage",service:"WCS",version:d,coverage:a.coverageId,format:a.format||"GEOTIFF",crs:a.crs,bbox:a.extent.xmin+","+a.extent.ymin+","+a.extent.xmax+","+a.extent.ymax,width:a.width,height:a.height,time:a.time,interpolation:a.interpolation,band:a.bandIds?
a.bandIds.join(","):null}}),g=m.hitch(this,function(){var p,f=this.coverageDescription.nativeCoverageDescription.domain.spatialDomain,g=f.origin.x<=f.envelope.xmin&&f.origin.y<=f.envelope.ymin;p=this._pivotServerGridOrigin110&&g?[(a.extent.xmax-a.extent.xmin)/a.width,(a.extent.ymax-a.extent.ymin)/a.height]:[(a.extent.xmax-a.extent.xmin)/a.width,(a.extent.ymin-a.extent.ymax)/a.height];var l=O(b.nativeCoverageDescription.range,function(a){return a.axis.some(function(a){return"band"===a.identifier.toLowerCase()})}),
h,k,n,f=l&&a.interpolation&&a.bandIds?l.identifier+":"+a.interpolation+"["+l.axis[0].identifier+"["+a.bandIds.join(",")+"]]":null;if(a.multidimensionalDefinition)for(h=0;h<a.multidimensionalDefinition.length;h++)if(n=a.multidimensionalDefinition[h].values,0<n.length)if(-1<a.multidimensionalDefinition[h].dimensionName.toLowerCase().indexOf("time"))n=n.map(e).join(","),a.time=n;else if(l=u(b.nativeCoverageDescription.range,a.multidimensionalDefinition[h].variableName,"identifier"))if(a.interpolation||
(a.interpolation=l.supportedInterpolations[0]),k=u(l.axis,a.multidimensionalDefinition[h].dimensionName,"identifier"))n=n.join(","),f=l.identifier+":"+a.interpolation+"["+k.identifier+"["+n+"]]";l=this._pivotServerGridOrigin110&&g?[a.extent.xmin,a.extent.ymin]:[a.extent.xmin,a.extent.ymax];this.coverageDescription._useEPSGAxis&&this._useLatLong(a.extent.spatialReference.wkid)?(g=a.extent.ymin+","+a.extent.xmin+","+a.extent.ymax+","+a.extent.xmax+","+a.epsgNSCRS,l=l[1]+","+l[0],p=p[1]+","+p[0]):(g=
a.extent.xmin+","+a.extent.ymin+","+a.extent.xmax+","+a.extent.ymax+","+a.epsgNSCRS,l=l[0]+","+l[1],p=p[0]+","+p[1]);c={request:"GetCoverage",service:"WCS",version:d,identifier:a.coverageId,format:a.format||"image/tiff",crs:a.crs,boundingbox:g,GridBaseCRS:a.epsgNSCRS,GridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",GridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",GridOrigin:l,GridOffsets:p,time:a.time,rangeSubset:f}}),k=m.hitch(this,function(){var f=[],g,h,l=b.nativeCoverageDescription.domainSet.axisLabels;
"x"===l[0].toLowerCase()||"x"===l[1].toLowerCase()?(f.push("x,http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.xmin+","+a.extent.xmax+")"),f.push("y,http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.ymin+","+a.extent.ymax+")"),g="x",h="y"):-1<l[0].toLowerCase().indexOf("lat")||-1<l[0].toLowerCase().indexOf("north")?(f.push(l[1]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.xmin+","+a.extent.xmax+
")"),f.push(l[0]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.ymin+","+a.extent.ymax+")"),g=l[1],h=l[0]):-1<l[0].toLowerCase().indexOf("lon")||-1<l[0].toLowerCase().indexOf("east")?(f.push(l[0]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.xmin+","+a.extent.xmax+")"),f.push(l[1]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.ymin+","+a.extent.ymax+")"),g=l[0],h=l[1]):this._useLatLong(a.extent.spatialReference.wkid)?
(f.push(l[1]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.xmin+","+a.extent.xmax+")"),f.push(l[0]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.ymin+","+a.extent.ymax+")"),g=l[1],h=l[0]):(f.push(l[0]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.xmin+","+a.extent.xmax+")"),f.push(l[1]+",http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid+"("+a.extent.ymin+","+
a.extent.ymax+")"),g=l[0],h=l[1]);2<l.length&&(f.push(l[2]+",http://www.opengis.net(2014/04/08 00:00:00)"),f.push(l[3]+",http://www.opengis.net(0)"));var k=null,m,n,r=[],t=[];if(a.multidimensionalDefinition){for(k=0;k<b.nativeCoverageDescription.rangeType.length;k++)t=t.concat(b.nativeCoverageDescription.rangeType[k].map(function(a){return a.name}));for(k=0;k<a.multidimensionalDefinition.length;k++)m=u(l,a.multidimensionalDefinition[k].dimensionName),n=u(t,a.multidimensionalDefinition[k].variableName),
-1===r.indexOf(n)&&r.push(n),m&&(n=a.multidimensionalDefinition[k].values,0<n.length&&(n[0]instanceof Array&&(n=n[0]),n=-1<m.toLowerCase().indexOf("time")?n.map(e).join(","):n.join(","),-1===C(f,function(a){return 0===a.indexOf(m)})&&f.push(m+",http://www.opengis.net("+n+")")));k=0<r.length?r.join(","):null}l="http://www.opengis.net/def/crs/EPSG/0/"+a.extent.spatialReference.wkid;f=f.join("\x26subset\x3d");c={request:"GetCoverage",service:"WCS",version:d,coverageId:a.coverageId,rangesubset:k,interpolation:a.interpolation,
scaleSize:g+"("+a.width+"),"+h+"("+a.height+")",subset:f,extension:null,format:a.format||"image/tiff",outputcrs:l}});switch(d){case "1.0.0":f();break;case "1.1.0":case "1.1.1":case "1.1.2":g();break;case "2.0.1":k()}m.mixin(c,this.optionalParameters);a.token&&(c.token=a.token);var h=this.wcsConnection.onlineResources.getCoverage||this.url;-1===h.indexOf("?")&&(h+="?");Object.keys(c).forEach(function(a){void 0!==c[a]&&null!==c[a]&&(h+=a,h+="\x3d",h+=c[a],h+="\x26")});h=h.substring(0,h.length-1);return J({url:h,
handleAs:"arraybuffer"},{returnFullResponse:!0})},_identifyPixelValue:function(a){var d=new t,b={objectId:0,name:"Pixel",value:null,location:a,pixelValues:null};this._pixelValueReadPromise&&this._pixelValueReadPromise.cancel();var c=this.projectedFullExtent,e=this._projectedResolution,f=c.xmin+Math.floor((a.x-c.xmin)/e.x)*e.x,c=c.ymin+Math.floor((a.y-c.ymin)/e.y)*e.y,g=new B;g.spatialReference=a.spatialReference;g.xmin=f;g.ymin=c;g.xmax=f+2*e.x;g.ymax=c+2*e.y;var k=this._constructGetCoverageParams(g,
2,2),h=this;if(!k)return d.resolve(b),h._pixelValueReadPromise=null,d;var m=new A(""),q;a=new t(x._dfdCanceller);a._pendingDfd=this._getCoverage(k);a._pendingDfd.then(function(a){a=E.parse(a);if("1.0.0"===h.version)a=a.data;else if(a.isMultiPart)a=a.data[a.data.length-1].contentData;else{q=Error("not a valid multipart coverage response");d.reject(q);h._pixelValueReadPromise=null;return}m.decode(a,{width:k.width,height:k.height,planes:null,pixelType:"UNKNOWN"}).then(function(a){a&&a.pixels&&(!a.mask||
a.mask[0]?a.pixels&&(b.pixelValues=a.pixels.map(function(a){return a[0]}),b.value=b.pixelValues.join(" ")):(b.value="NoData",b.pixelValues=[NaN]));d.resolve(b);h._pixelValueReadPromise=null},function(a){d.reject(a);h._pixelValueReadPromise=null})},function(a){d.reject(a);h._pixelValueReadPromise=null});return this._pixelValueReadPromise=d.promise},_useLatLong:function(a){if(!a)return!1;var d,b,c;for(b=0;b<this._REVERSED_LAT_LONG_RANGES.length;b++)if(c=this._REVERSED_LAT_LONG_RANGES[b],a>=c[0]&&a<=
c[1]){d=!0;break}return d},_toggleTime:function(){var a=this._map;this.timeInfo&&this.useMapTime&&a&&!this.suspended?(this._timeConnect||(this._timeConnect=z.connect(a,"onTimeExtentChange",this,this._onTimeExtentChangeHandler)),this._setTime(a.timeExtent)):(z.disconnect(this._timeConnect),this._timeConnect=null,this._setTime(null))},_setTime:function(a){var d;this._params&&(a?(d=[],a.startTime&&d.push(a.startTime.toISOString()),a.endTime&&d.push(a.endTime.toISOString()),this._params.time=d.join(",")):
this._params.time=null)},_onTimeExtentChangeHandler:function(a){this.suspended||(this._setTime(a),this.refresh(!0))}});m.mixin(r,{INTERPOLATION_NEARESTNEIGHBOR:0,INTERPOLATION_BILINEAR:1,INTERPOLATION_CUBICCONVOLUTION:2});H("extend-esri")&&m.setObject("layers.WCSLayer",r,I);return r});