Skip to content

Instantly share code, notes, and snippets.

@rveciana
Last active May 7, 2020 17:58
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rveciana/420a33fd0963e2a6aad16da54725af36 to your computer and use it in GitHub Desktop.
raster-marching-squares and leaflet
license: mit
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(){}d.prototype={isAsync:function(){return"undefined"==typeof this.decodeBlock}},b.exports=d},{}],2:[function(a,b,c){"use strict";function d(){}var e=a("../abstractdecoder.js");d.prototype=Object.create(e.prototype),d.prototype.constructor=d,d.prototype.decodeBlockAsync=function(a,b){throw new Error("DeflateDecoder is not yet implemented.")},b.exports=d},{"../abstractdecoder.js":1}],3:[function(a,b,c){"use strict";function d(){}var e=a("../abstractdecoder.js");d.prototype=Object.create(e.prototype),d.prototype.constructor=d,d.prototype.decodeBlock=function(a){throw new Error("LZWDecoder is not yet implemented")},b.exports=d},{"../abstractdecoder.js":1}],4:[function(a,b,c){"use strict";function d(){}var e=a("../abstractdecoder.js");d.prototype=Object.create(e.prototype),d.prototype.constructor=d,d.prototype.decodeBlock=function(a){var b,c,d=new DataView(a),e=[];for(b=0;b<a.byteLength;++b){var f=d.getInt8(b);if(0>f){var g=d.getUint8(b+1);for(f=-f,c=0;f>=c;++c)e.push(g);b+=1}else{for(c=0;f>=c;++c)e.push(d.getUint8(b+c+1));b+=f+1}}return new Uint8Array(e).buffer},b.exports=d},{"../abstractdecoder.js":1}],5:[function(a,b,c){"use strict";function d(){}var e=a("../abstractdecoder.js");d.prototype=Object.create(e.prototype),d.prototype.constructor=d,d.prototype.decodeBlock=function(a){return a},b.exports=d},{"../abstractdecoder.js":1}],6:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var e=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),f=function(){function a(b){d(this,a),this._dataView=new DataView(b)}return e(a,[{key:"getUint64",value:function(a,b){var c=this.getUint32(a,b),d=this.getUint32(a+4,b);return b?c<<32|d:d<<32|c}},{key:"getInt64",value:function(a,b){var c,d;return b?(c=this.getInt32(a,b),d=this.getUint32(a+4,b),c<<32|d):(c=this.getUint32(a,b),d=this.getInt32(a+4,b),d<<32|c)}},{key:"getUint8",value:function(a,b){return this._dataView.getUint8(a,b)}},{key:"getInt8",value:function(a,b){return this._dataView.getInt8(a,b)}},{key:"getUint16",value:function(a,b){return this._dataView.getUint16(a,b)}},{key:"getInt16",value:function(a,b){return this._dataView.getInt16(a,b)}},{key:"getUint32",value:function(a,b){return this._dataView.getUint32(a,b)}},{key:"getInt32",value:function(a,b){return this._dataView.getInt32(a,b)}},{key:"getFloat32",value:function(a,b){return this._dataView.getFloat32(a,b)}},{key:"getFloat64",value:function(a,b){return this._dataView.getFloat64(a,b)}},{key:"buffer",get:function(){return this._dataView.buffer}}]),a}();b.exports=f},{}],7:[function(a,b,c){"use strict";function d(a,b){this.dataView=new g(a),b=b||{},this.cache=b.cache||!1;var c=this.dataView.getUint16(0,0);if(18761===c)this.littleEndian=!0;else{if(19789!==c)throw new TypeError("Invalid byte order value.");this.littleEndian=!1}var d=this.dataView.getUint16(2,this.littleEndian);if(42===this.dataView.getUint16(2,this.littleEndian))this.bigTiff=!1;else{if(43!==d)throw new TypeError("Invalid magic number.");this.bigTiff=!0;var e=this.dataView.getUint16(4,this.littleEndian);if(8!==e)throw new Error("Unsupported offset byte-size.")}this.fileDirectories=this.parseFileDirectories(this.getOffset(this.bigTiff?8:4))}var e=a("./globals.js"),f=a("./geotiffimage.js"),g=a("./dataview64.js"),h=e.fieldTypes,i=e.fieldTagNames,j=e.arrayFields,k=e.geoKeyNames;d.prototype={getOffset:function(a){return this.bigTiff?this.dataView.getUint64(a,this.littleEndian):this.dataView.getUint32(a,this.littleEndian)},getFieldTypeLength:function(a){switch(a){case h.BYTE:case h.ASCII:case h.SBYTE:case h.UNDEFINED:return 1;case h.SHORT:case h.SSHORT:return 2;case h.LONG:case h.SLONG:case h.FLOAT:return 4;case h.RATIONAL:case h.SRATIONAL:case h.DOUBLE:case h.LONG8:case h.SLONG8:case h.IFD8:return 8;default:throw new RangeError("Invalid field type: "+a)}},getValues:function(a,b,c){var d,e=null,f=null,g=this.getFieldTypeLength(a);switch(a){case h.BYTE:case h.ASCII:case h.UNDEFINED:e=new Uint8Array(b),f=this.dataView.getUint8;break;case h.SBYTE:e=new Int8Array(b),f=this.dataView.getInt8;break;case h.SHORT:e=new Uint16Array(b),f=this.dataView.getUint16;break;case h.SSHORT:e=new Int16Array(b),f=this.dataView.getInt16;break;case h.LONG:e=new Uint32Array(b),f=this.dataView.getUint32;break;case h.SLONG:e=new Int32Array(b),f=this.dataView.getInt32;break;case h.LONG8:case h.IFD8:e=new Array(b),f=this.dataView.getUint64;break;case h.SLONG8:e=new Array(b),f=this.dataView.getInt64;break;case h.RATIONAL:e=new Uint32Array(2*b),f=this.dataView.getUint32;break;case h.SRATIONAL:e=new Int32Array(2*b),f=this.dataView.getInt32;break;case h.FLOAT:e=new Float32Array(b),f=this.dataView.getFloat32;break;case h.DOUBLE:e=new Float64Array(b),f=this.dataView.getFloat64;break;default:throw new RangeError("Invalid field type: "+a)}if(a!==h.RATIONAL&&a!==h.SRATIONAL)for(d=0;b>d;++d)e[d]=f.call(this.dataView,c+d*g,this.littleEndian);else for(d=0;2*b>d;d+=2)e[d]=f.call(this.dataView,c+d*g,this.littleEndian),e[d+1]=f.call(this.dataView,c+(d+1)*g,this.littleEndian);return a===h.ASCII?String.fromCharCode.apply(null,e):e},getFieldValues:function(a,b,c,d){var e,f=this.getFieldTypeLength(b);if(f*c<=(this.bigTiff?8:4))e=this.getValues(b,c,d);else{var g=this.getOffset(d);e=this.getValues(b,c,g)}return 1===c&&-1===j.indexOf(a)&&b!==h.RATIONAL&&b!==h.SRATIONAL?e[0]:e},parseGeoKeyDirectory:function(a){var b=a.GeoKeyDirectory;if(!b)return null;for(var c={},d=4;d<4*b[3];d+=4){var e=k[b[d]],f=b[d+1]?i[b[d+1]]:null,g=b[d+2],h=b[d+3],j=null;if(f){if(j=a[f],"undefined"==typeof j||null===j)throw new Error("Could not get value of geoKey '"+e+"'.");"string"==typeof j?j=j.substring(h,h+g-1):j.subarray&&(j=j.subarray(h,h+g-1))}else j=h;c[e]=j}return c},parseFileDirectories:function(a){for(var b=a,c=[];0!==b;){for(var d=this.bigTiff?this.dataView.getUint64(b,this.littleEndian):this.dataView.getUint16(b,this.littleEndian),e={},f=a+(this.bigTiff?8:2),g=0;d>g;f+=this.bigTiff?20:12,++g){var h=this.dataView.getUint16(f,this.littleEndian),j=this.dataView.getUint16(f+2,this.littleEndian),k=this.bigTiff?this.dataView.getUint64(f+4,this.littleEndian):this.dataView.getUint32(f+4,this.littleEndian);e[i[h]]=this.getFieldValues(h,j,k,f+(this.bigTiff?12:8))}c.push([e,this.parseGeoKeyDirectory(e)]),b=this.getOffset(f)}return c},getImage:function(a){a=a||0;var b=this.fileDirectories[a];if(!b)throw new RangeError("Invalid image index");return new f(b[0],b[1],this.dataView,this.littleEndian,this.cache)},getImageCount:function(){return this.fileDirectories.length}},b.exports=d},{"./dataview64.js":6,"./geotiffimage.js":8,"./globals.js":9}],8:[function(a,b,c){"use strict";function d(a,b,c,d,e){this.fileDirectory=a,this.geoKeys=b,this.dataView=c,this.littleEndian=d,this.tiles=e?{}:null,this.isTiled=a.StripOffsets?!1:!0;var j=a.PlanarConfiguration;if(this.planarConfiguration="undefined"==typeof j?1:j,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");switch(this.fileDirectory.Compression){case void 0:case 1:this.decoder=new f;break;case 5:this.decoder=new g;break;case 6:throw new Error("JPEG compression not supported.");case 8:this.decoder=new h;break;case 32773:this.decoder=new i;break;default:throw new Error("Unknown compresseion method identifier: "+this.fileDirectory.Compression)}}var e=a("./globals.js"),f=a("./compression/raw.js"),g=a("./compression/lzw.js"),h=a("./compression/deflate.js"),i=a("./compression/packbits.js"),j=function(a,b,c){for(var d=0,e=b;c>e;++e)d+=a[e];return d},k=function(a,b,c){switch(a){case 1:switch(b){case 8:return new Uint8Array(c);case 16:return new Uint16Array(c);case 32:return new Uint32Array(c)}break;case 2:switch(b){case 8:return new Int8Array(c);case 16:return new Int16Array(c);case 32:return new Int32Array(c)}break;case 3:switch(b){case 32:return new Float32Array(c);case 64:return new Float64Array(c)}}throw Error("Unsupported data format/bitsPerSample")};d.prototype={getFileDirectory:function(){return this.fileDirectory},getGeoKeys:function(){return this.geoKeys},getWidth:function(){return this.fileDirectory.ImageWidth},getHeight:function(){return this.fileDirectory.ImageLength},getSamplesPerPixel:function(){return this.fileDirectory.SamplesPerPixel},getTileWidth:function(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()},getTileHeight:function(){return this.isTiled?this.fileDirectory.TileLength:this.fileDirectory.RowsPerStrip},getBytesPerPixel:function(){for(var a=0,b=0;b<this.fileDirectory.BitsPerSample.length;++b){var c=this.fileDirectory.BitsPerSample[b];if(c%8!==0)throw new Error("Sample bit-width of "+c+" is not supported.");if(c!==this.fileDirectory.BitsPerSample[0])throw new Error("Differing size of samples in a pixel are not supported.");a+=c}return a/8},getSampleByteSize:function(a){if(a>=this.fileDirectory.BitsPerSample.length)throw new RangeError("Sample index "+a+" is out of range.");var b=this.fileDirectory.BitsPerSample[a];if(b%8!==0)throw new Error("Sample bit-width of "+b+" is not supported.");return b/8},getReaderForSample:function(a){var b=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[a]:1,c=this.fileDirectory.BitsPerSample[a];switch(b){case 1:switch(c){case 8:return DataView.prototype.getUint8;case 16:return DataView.prototype.getUint16;case 32:return DataView.prototype.getUint32}break;case 2:switch(c){case 8:return DataView.prototype.getInt8;case 16:return DataView.prototype.getInt16;case 32:return DataView.prototype.getInt32}break;case 3:switch(c){case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}},getArrayForSample:function(a,b){var c=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[a]:1,d=this.fileDirectory.BitsPerSample[a];return k(c,d,b)},getDecoder:function(){return this.decoder},getTileOrStrip:function(a,b,c,d){var e,f=Math.ceil(this.getWidth()/this.getTileWidth()),g=Math.ceil(this.getHeight()/this.getTileHeight()),h=this.tiles;if(1===this.planarConfiguration?e=b*f+a:2===this.planarConfiguration&&(e=c*f*g+b*f+a),null!==h&&e in h)return d?d(null,{x:a,y:b,sample:c,data:h[e]}):h[e];var i,j;this.isTiled?(i=this.fileDirectory.TileOffsets[e],j=this.fileDirectory.TileByteCounts[e]):(i=this.fileDirectory.StripOffsets[e],j=this.fileDirectory.StripByteCounts[e]);var k=this.dataView.buffer.slice(i,i+j);if(d)return this.getDecoder().decodeBlockAsync(k,function(f,g){f||null===h||(h[e]=g),d(f,{x:a,y:b,sample:c,data:g})});var l=this.getDecoder().decodeBlock(k);return null!==h&&(h[e]=l),l},_readRasterAsync:function(a,b,c,d,e,f){function g(e,f){if(e)x=e;else for(var g=new DataView(f.data),j=f.y*k,l=f.x*i,m=(f.y+1)*k,n=(f.x+1)*i,o=(f.sample,Math.max(0,a[1]-j));o<Math.min(k,k-(m-a[3]));++o)for(var t=Math.max(0,a[0]-l);t<Math.min(i,i-(n-a[2]));++t){var u,y=(o*i+t)*q,z=s[C].call(g,y+r[C],w);d?(u=(o+j-a[1])*p*b.length+(t+l-a[0])*b.length+C,c[u]=z):(u=(o+j-a[1])*p+t+l-a[0],c[C][u]=z)}v-=1,h()}function h(){u&&0===v&&(x?f(x):e(c))}for(var i=this.getTileWidth(),k=this.getTileHeight(),l=Math.floor(a[0]/i),m=Math.ceil(a[2]/i),n=Math.floor(a[1]/k),o=Math.ceil(a[3]/k),p=(Math.ceil(this.getWidth()/i),a[2]-a[0]),q=(a[3]-a[1],this.getBytesPerPixel()),r=(this.getWidth(),[]),s=[],t=0;t<b.length;++t)1===this.planarConfiguration?r.push(j(this.fileDirectory.BitsPerSample,0,b[t])/8):r.push(0),s.push(this.getReaderForSample(b[t]));for(var u=!1,v=0,w=this.littleEndian,x=null,y=n;o>=y;++y)for(var z=l;m>=z;++z)for(var A=0;A<b.length;++A){var B=b[A];2===this.planarConfiguration&&(q=this.getSampleByteSize(B));var C=A;v+=1,this.getTileOrStrip(z,y,B,g)}u=!0,h()},_readRaster:function(a,b,c,d,e,f){try{for(var g=this.getTileWidth(),h=this.getTileHeight(),i=Math.floor(a[0]/g),k=Math.ceil(a[2]/g),l=Math.floor(a[1]/h),m=Math.ceil(a[3]/h),n=(Math.ceil(this.getWidth()/g),a[2]-a[0]),o=(a[3]-a[1],this.getBytesPerPixel()),p=(this.getWidth(),[]),q=[],r=0;r<b.length;++r)1===this.planarConfiguration?p.push(j(this.fileDirectory.BitsPerSample,0,b[r])/8):p.push(0),q.push(this.getReaderForSample(b[r]));for(var s=l;m>s;++s)for(var t=i;k>t;++t)for(var u=s*h,v=t*g,w=(s+1)*h,x=(t+1)*g,y=0;y<b.length;++y){var z=b[y];2===this.planarConfiguration&&(o=this.getSampleByteSize(z));for(var A=new DataView(this.getTileOrStrip(t,s,z)),B=Math.max(0,a[1]-u);B<Math.min(h,h-(w-a[3]));++B)for(var C=Math.max(0,a[0]-v);C<Math.min(g,g-(x-a[2]));++C){var D,E=(B*g+C)*o,F=q[y].call(A,E+p[y],this.littleEndian);d?(D=(B+u-a[1])*n*b.length+(C+v-a[0])*b.length+y,c[D]=F):(D=(B+u-a[1])*n+C+v-a[0],c[y][D]=F)}}return e(c),c}catch(G){return f(G)}},readRasters:function(){var a,b,c;switch(arguments.length){case 0:break;case 1:"function"==typeof arguments[0]?b=arguments[0]:a=arguments[0];break;case 2:"function"==typeof arguments[0]?(b=arguments[0],c=arguments[1]):(a=arguments[0],b=arguments[1]);break;case 3:a=arguments[0],b=arguments[1],c=arguments[2];break;default:throw new Error("Invalid number of arguments passed.")}a=a||{},c=c||function(a){console.error(a)};var d=a.window||[0,0,this.getWidth(),this.getHeight()],e=a.samples,f=a.interleave;if(d[0]<0||d[1]<0||d[2]>this.getWidth()||d[3]>this.getHeight())throw new Error("Select window is out of image bounds.");if(d[0]>d[2]||d[1]>d[3])throw new Error("Invalid subsets");var g,h=d[2]-d[0],i=d[3]-d[1],j=h*i;if(e){for(g=0;g<e.length;++g)if(e[g]>=this.fileDirectory.SamplesPerPixel)throw new RangeError("Invalid sample index '"+e[g]+"'.")}else for(e=[],g=0;g<this.fileDirectory.SamplesPerPixel;++g)e.push(g);var l;if(f){var m=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,n=Math.max.apply(null,this.fileDirectory.BitsPerSample);l=k(m,n,j*e.length)}else for(l=[],g=0;g<e.length;++g)l.push(this.getArrayForSample(e[g],j));var o=this.getDecoder();if(o.isAsync()){if(!b)throw new Error("No callback specified for asynchronous raster reading.");return this._readRasterAsync(d,e,l,f,b,c)}return b=b||function(){},this._readRaster(d,e,l,f,b,c)},getTiePoints:function(){if(!this.fileDirectory.ModelTiepoint)return[];for(var a=[],b=0;b<this.fileDirectory.ModelTiepoint.length;b+=6)a.push({i:this.fileDirectory.ModelTiepoint[b],j:this.fileDirectory.ModelTiepoint[b+1],k:this.fileDirectory.ModelTiepoint[b+2],x:this.fileDirectory.ModelTiepoint[b+3],y:this.fileDirectory.ModelTiepoint[b+4],z:this.fileDirectory.ModelTiepoint[b+5]});return a},getGDALMetadata:function(){var a={};if(!this.fileDirectory.GDAL_METADATA)return null;for(var b=this.fileDirectory.GDAL_METADATA,c=e.parseXml(b.substring(0,b.length-1)),d=c.evaluate("GDALMetadata/Item",c,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null),f=0;f<d.snapshotLength;++f){var g=d.snapshotItem(f);a[g.getAttribute("name")]=g.textContent}return a}},b.exports=d},{"./compression/deflate.js":2,"./compression/lzw.js":3,"./compression/packbits.js":4,"./compression/raw.js":5,"./globals.js":9}],9:[function(a,b,c){"use strict";var d,e={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams"},f={};for(d in e)f[e[d]]=parseInt(d);var g=[f.BitsPerSample,f.ExtraSamples,f.SampleFormat,f.StripByteCounts,f.StripOffsets,f.StripRowCounts,f.TileByteCounts,f.TileOffsets],h={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",16:"LONG8",17:"SLONG8",18:"IFD8"},i={};for(d in h)i[h[d]]=parseInt(d);var j={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},k={};for(d in j)k[j[d]]=parseInt(d);var l;"undefined"==typeof window?l=function(b){var c=a("xmldom").DOMParser;return(new c).parseFromString(b,"text/xml")}:"undefined"!=typeof window.DOMParser?l=function(a){return(new window.DOMParser).parseFromString(a,"text/xml")}:"undefined"!=typeof window.ActiveXObject&&new window.ActiveXObject("Microsoft.XMLDOM")&&(l=function(a){var b=new window.ActiveXObject("Microsoft.XMLDOM");return b.async="false",b.loadXML(a),b}),b.exports={fieldTags:f,fieldTagNames:e,arrayFields:g,fieldTypes:i,fieldTypeNames:h,geoKeys:k,geoKeyNames:j,parseXml:l}},{xmldom:"xmldom"}],10:[function(a,b,c){"use strict";var d=a("./geotiff.js"),e=function(a,b){var c,e,f,g;if("string"==typeof a||a instanceof String)for(c=new ArrayBuffer(2*a.length),g=new Uint16Array(c),e=0,f=a.length;f>e;++e)g[e]=a.charCodeAt(e);else{if(!(a instanceof ArrayBuffer))throw new Error("Invalid input data given.");c=a}return new d(c,b)};"undefined"!=typeof b&&"undefined"!=typeof b.exports&&(b.exports.parse=e),"undefined"!=typeof window&&(window.GeoTIFF={parse:e})},{"./geotiff.js":7}]},{},[10]);
<!DOCTYPE html>
<html>
<head>
<title>GeoJSON tutorial - Leaflet</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.2/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.0.2/dist/leaflet.js"></script>
<script src="geotiff.min.js"></script>
<script src="raster-marching-squares.min.js"></script>
<style>
#map {
width: 680px;
height: 500px;
}
</style>
</head>
<body>
<div id='map'></div>
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', 'vardah.tiff', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
var tiff = GeoTIFF.parse(this.response);
var image = tiff.getImage();
var tiffWidth = image.getWidth();
var tiffHeight = image.getHeight();
var rasters = image.readRasters();
var tiepoint = image.getTiePoints()[0];
var pixelScale = image.getFileDirectory().ModelPixelScale;
var geoTransform = [tiepoint.x, pixelScale[0], 0, tiepoint.y, 0, -1*pixelScale[1]];
var pressData = new Array(tiffHeight);
var tempData = new Array(tiffHeight);
var uData = new Array(tiffHeight);
var vData = new Array(tiffHeight);
var spdData = new Array(tiffHeight);
for (var j = 0; j<tiffHeight; j++){
pressData[j] = new Array(tiffWidth);
tempData[j] = new Array(tiffWidth);
uData[j] = new Array(tiffWidth);
vData[j] = new Array(tiffWidth);
spdData[j] = new Array(tiffWidth);
for (var i = 0; i<tiffWidth; i++){
pressData[j][i] = rasters[0][i + j*tiffWidth];
tempData[j][i] = rasters[1][i + j*tiffWidth];
uData[j][i] = rasters[2][i + j*tiffWidth];
vData[j][i] = rasters[3][i + j*tiffWidth];
spdData[j][i] = 1.943844492 * Math.sqrt(uData[j][i]*uData[j][i] + vData[j][i]*vData[j][i]);
}
}
var intervalsSpd = [0, 8, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42,
44, 46, 48, 50, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96 ];
var bandsWind = rastertools.isobands(spdData, geoTransform, intervalsSpd);
function getColor(d) {
return d > 92 ? '#643c32' :
d > 88 ? '#643c32' :
d > 84 ? '#a50000' :
d > 80 ? '#c10000' :
d > 76 ? '#e11400' :
d > 72 ? '#ff3200' :
d > 68 ? '#ff6000' :
d > 64 ? '#ffa100' :
d > 60 ? '#ffc13c' :
d > 56 ? '#ffe978' :
d > 52 ? '#c9ffbf' :
d > 50 ? '#b5fbab' :
d > 48 ? '#97f58d' :
d > 46 ? '#78f572' :
d > 44 ? '#50ef50' :
d > 42 ? '#36d33c' :
d > 40 ? '#1eb31e' :
d > 38 ? '#0ea10e' :
d > 36 ? '#e1ffff' :
d > 34 ? '#b5f1fb' :
d > 32 ? '#97d3fb' :
d > 30 ? '#78b9fb' :
d > 28 ? '#50a5f5' :
d > 26 ? '#3c97f5' :
d > 24 ? '#2883f1' :
d > 22 ? '#1e6eeb' :
d > 20 ? '#1464d3' :
d > 18 ? '#646464' :
d > 16 ? '#979797' :
d > 14 ? '#bababa' :
d > 12 ? '#d1d1d1' :
d > 8 ? '#e5e5e6' :
d > 0 ? '#ffffff' :
'#ffffff';
}
function style(feature) {
return {
fillColor: getColor(feature.properties[0].lowerValue),
weight: 2,
opacity: 1,
color: getColor(feature.properties[0].lowerValue),
dashArray: '3',
fillOpacity: 0.5
};
}
var bandsWindLayer = L.geoJson(bandsWind, {
style: style
});
var intervalsPress = [970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998,
1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024, 1026, 1028];
var isobars = rastertools.isolines(pressData, geoTransform, intervalsPress);
var isobarsLayer = L.geoJSON(isobars, {
style: {
"color": "#333",
"weight": 2,
"opacity": 0.65
}
});
//Creating the color scale https://github.com/santilland/plotty/blob/master/src/plotty.js
var cs_def = {positions:[0.0,0.030303030303,0.0606060606061,0.0909090909091,0.121212121212,0.151515151515,0.181818181818,0.212121212121,0.242424242424,0.272727272727,0.30303030303,0.333333333333,0.363636363636,0.393939393939,0.424242424242,0.454545454545,0.484848484848,0.515151515152,0.545454545455,0.575757575758,0.606060606061,0.636363636364,0.666666666667,0.69696969697,0.727272727273,0.757575757576,0.787878787879,0.818181818182,0.848484848485,0.878787878788,0.909090909091,0.939393939394,0.969696969697,1.0],
colors:["#ffffff", "#e5e5e6" , "#d1d1d1", "#bababa", "#979797", "#646464",
"#1464d3", "#1e6eeb", "#2883f1", "#3c97f5", "#50a5f5", "#78b9fb", "#97d3fb", "#b5f1fb", "#e1ffff",
"#0ea10e", "#1eb31e", "#36d33c", "#50ef50", "#78f572", "#97f58d", "#b5fbab", "#c9ffbf",
"#ffe978", "#ffc13c", "#ffa100", "#ff6000", "#ff3200", "#e11400", "#c10000", "#a50000",
"#643c32", "#785046", "#8d645a"]};
var scaleWidth = 256;
var canvasColorScale = document.createElement('canvas');
canvasColorScale.width = scaleWidth;
canvasColorScale.height = 1;
canvasColorScale.style.display = "none";
document.body.appendChild(canvasColorScale);
var contextColorScale = canvasColorScale.getContext("2d");
var gradient = contextColorScale.createLinearGradient(0, 0, scaleWidth, 1);
for (var i = 0; i < cs_def.colors.length; ++i) {
gradient.addColorStop(cs_def.positions[i], cs_def.colors[i]);
}
contextColorScale.fillStyle = gradient;
contextColorScale.fillRect(0, 0, scaleWidth, 1);
var csImageData = contextColorScale.getImageData(0, 0, scaleWidth-1, 1).data;
//Calculating the image
var width = 680,
height = 500;
var canvasRaster = document.createElement('canvas');
canvasRaster.width = width;
canvasRaster.height = height;
canvasRaster.style.display = "none";
document.body.appendChild(canvasRaster);
var contextRaster = canvasRaster.getContext("2d");
var id = contextRaster.createImageData(width,height);
var data = id.data;
var pos = 0;
var invGeoTransform = [-geoTransform[0]/geoTransform[1], 1/geoTransform[1],0,-geoTransform[3]/geoTransform[5],0,1/geoTransform[5]];
for(var j = 0; j<height; j++){
for(var i = 0; i<width; i++){
var pointCoordsX = geoTransform[0] + i*tiffWidth*geoTransform[1]/width;
var pointCoordsY = geoTransform[3] + j*tiffHeight*geoTransform[5]/height;
var px = invGeoTransform[0] + pointCoordsX * invGeoTransform[1];
var py = invGeoTransform[3] + pointCoordsY * invGeoTransform[5];
var value;
if(Math.floor(px) >= 0 && Math.ceil(px) < image.getWidth() && Math.floor(py) >= 0 && Math.ceil(py) < image.getHeight()){
var dist1 = (Math.ceil(px)-px)*(Math.ceil(py)-py);
var dist2 = (px-Math.floor(px))*(Math.ceil(py)-py);
var dist3 = (Math.ceil(px)-px)*(py-Math.floor(py));
var dist4 = (px-Math.floor(px))*(py-Math.floor(py));
if (dist1 != 0 || dist2!=0 || dist3!=0 || dist4!=0){
value = spdData[Math.floor(py)][Math.floor(px)]*dist1+
spdData[Math.floor(py)][Math.ceil(px)]*dist2 +
spdData[Math.ceil(py)][Math.floor(px)]*dist3 +
spdData[Math.ceil(py)][Math.ceil(px)]*dist4;
} else {
value = spdData[Math.floor(py)][Math.floor(px)];
}
} else {
value = -999;
}
var c = Math.round((scaleWidth-1) * ((value - 8)/88));
var alpha = 200;
if (c<0 || c > (scaleWidth-1)){
alpha = 0;
}
data[pos] = csImageData[c*4];;
data[pos+1] = csImageData[c*4+1];
data[pos+2] = csImageData[c*4+2];
data[pos+3] = alpha;
pos = pos + 4
}
}
contextRaster.putImageData( id, 0, 0);
var imageBounds = [[geoTransform[3], geoTransform[0]], [geoTransform[3] + tiffHeight*geoTransform[5], geoTransform[0] + tiffWidth*geoTransform[1]]];
var imageLayer = L.imageOverlay(canvasRaster.toDataURL(), imageBounds,{
opacity: 0.5
});
var baseLayer = L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
var map = L.map('map', {
layers: [baseLayer, bandsWindLayer]
}).setView([13, 81], 6);
L.control.layers(null, {
"Wind speed": bandsWindLayer,
"Pressure": isobarsLayer,
"Image": imageLayer
}).addTo(map);
map.on('click', function(e) {
var xTiff = (e.latlng.lng - geoTransform[0])/geoTransform[1];
var yTiff = ( e.latlng.lat - geoTransform[3])/geoTransform[5];
var temp = tempData[Math.round(yTiff)][Math.round(xTiff)];
var press = pressData[Math.round(yTiff)][Math.round(xTiff)];
var uValue = uData[Math.round(yTiff)][Math.round(xTiff)];
var vValue = vData[Math.round(yTiff)][Math.round(xTiff)];
var spd = Math.sqrt(uValue*uValue + vValue*vValue);
var dir = 270 + (Math.atan2(-vValue,uValue)*180/Math.PI);
if(dir<0){dir = dir + 360;}
if(dir>360){dir = dir - 360;}
L.popup()
.setLatLng(e.latlng)
.setContent("Wind speed: " + spd.toFixed(1) + " kt <br/>Wind dir: " + dir.toFixed(0) +"º <br/>Temp: " + temp.toFixed(1) + " C<br/>Pressure: " + press.toFixed(0) + " hPa")
.openOn(map);
});
};
xhr.send();
</script>
</body>
</html>
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.rastertools=e.rastertools||{})}(this,function(e){"use strict";function t(e,t,o){return(e-t)/(o-t)}function o(e){for(var t=[],o=e.rows,r=e.cols,h=[],l=0;l<o;l++)for(var a=0;a<r;a++)if("undefined"!=typeof e.cells[l][a]&&e.cells[l][a].edges.length>0){var f=e.cells[l][a],n=(f.cval,p(f)),i=null,c=a,b=l;null!==n&&h.push([n.p[0]+c,n.p[1]+b]);do{if(i=u(e.cells[b][c],n.x,n.y,n.o),null===i)break;if(h.push([i.p[0]+c,i.p[1]+b]),c+=i.x,b+=i.y,n=i,b<0||b>=o||c<0||c>=r||"undefined"==typeof e.cells[b][c]){c-=i.x,b-=i.y;var g=s(e,c,b,i.x,i.y,i.o);if(null===g)break;g.path.forEach(function(e){h.push(e)}),c=g.i,b=g.j,n=g}}while("undefined"!=typeof e.cells[b][c]&&e.cells[b][c].edges.length>0);t.push(h),h=[],e.cells[l][a].edges.length>0&&a--}return t}function s(e,t,o,s,r,p){for(var u=e.cells[o][t],h=u.cval_real,l=t+s,a=o+r,f=[],n=(e.rows,e.cols,!1);!n;){if("undefined"==typeof e.cells[a]||"undefined"==typeof e.cells[a][l])if(a-=r,l-=s,u=e.cells[a][l],h=u.cval_real,r===-1)if(0===p)if(h&w)f.push([l,a]),s=-1,r=0,p=0;else{if(!(h&x)){f.push([l+u.bottomright,a]),s=0,r=1,p=1,n=!0;break}f.push([l+1,a]),s=1,r=0,p=0}else{if(!(h&w)){if(h&x){f.push([l+u.bottomright,a]),s=0,r=1,p=1,n=!0;break}f.push([l+u.bottomleft,a]),s=0,r=1,p=0,n=!0;break}f.push([l,a]),s=-1,r=0,p=0}else if(1===r)if(0===p){if(!(h&k)){if(h&v){f.push([l+u.topleft,a+1]),s=0,r=-1,p=0,n=!0;break}f.push([l+u.topright,a+1]),s=0,r=-1,p=1,n=!0;break}f.push([l+1,a+1]),s=1,r=0,p=1}else h&k?(f.push([l+1,a+1]),s=1,r=0,p=1):(f.push([l+1,a+1]),s=1,r=0,p=1);else if(s===-1)if(0===p){if(!(h&v)){if(h&w){f.push([l,a+u.leftbottom]),s=1,r=0,p=0,n=!0;break}f.push([l,a+u.lefttop]),s=1,r=0,p=1,n=!0;break}f.push([l,a+1]),s=0,r=1,p=0}else{if(!(h&v)){console.log("wtf");break}f.push([l,a+1]),s=0,r=1,p=0}else{if(1!==s){console.log("we came from nowhere!");break}if(0===p){if(!(h&x)){f.push([l+1,a+u.rightbottom]),s=-1,r=0,p=0,n=!0;break}f.push([l+1,a]),s=0,r=-1,p=1}else{if(!(h&x)){if(h&k){f.push([l+1,a+u.righttop]),s=-1,r=0,p=1;break}f.push([l+1,a+u.rightbottom]),s=-1,r=0,p=0,n=!0;break}f.push([l+1,a]),s=0,r=-1,p=1}}else if(u=e.cells[a][l],h=u.cval_real,s===-1)if(0===p)if("undefined"!=typeof e.cells[a-1]&&"undefined"!=typeof e.cells[a-1][l])s=0,r=-1,p=1;else{if(!(h&w)){f.push([l+u.bottomright,a]),s=0,r=1,p=1,n=!0;break}f.push([l,a])}else{if(!(h&v)){console.log("found entry from top at "+l+","+a);break}console.log("proceeding in x-direction!")}else if(1===s){if(0===p){console.log("wtf");break}if("undefined"!=typeof e.cells[a+1]&&"undefined"!=typeof e.cells[a+1][l])s=0,r=1,p=0;else{if(!(h&k)){f.push([l+u.topleft,a+1]),s=0,r=-1,p=0,n=!0;break}f.push([l+1,a+1]),s=1,r=0,p=1}}else if(r===-1){if(1!==p){console.log("wtf");break}if("undefined"!=typeof e.cells[a][l+1])s=1,r=0,p=1;else{if(!(h&x)){f.push([l+1,a+u.righttop]),s=-1,r=0,p=1,n=!0;break}f.push([l+1,a]),s=0,r=-1,p=1}}else{if(1!==r){console.log("where did we came from???");break}if(0!==p){console.log("wtf");break}if("undefined"!=typeof e.cells[a][l-1])s=-1,r=0,p=0;else{if(!(h&v)){f.push([l,a+u.leftbottom]),s=1,r=0,p=0,n=!0;break}f.push([l,a+1]),s=0,r=1,p=0}}if(l+=s,a+=r,l===t&&a===o)break}return{path:f,i:l,j:a,x:s,y:r,o:p}}function r(e,t){delete e.edges[t];for(var o=t+1;o<e.edges.length;o++)e.edges[o-1]=e.edges[o];e.edges.pop()}function p(e){if(e.edges.length>0){var t=e.edges[e.edges.length-1],o=e.cval_real;switch(t){case 0:return o&k?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.topleft,1],x:0,y:-1,o:0};case 1:return o&x?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 2:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[e.topleft,1],x:0,y:-1,o:0};case 3:return o&w?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 4:return o&k?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};case 5:return o&x?{p:[e.topright,1],x:0,y:-1,o:1}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 6:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};case 7:return o&w?{p:[e.topright,1],x:0,y:-1,o:1}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 8:return o&x?{p:[e.bottomright],x:0,y:1,o:1}:{p:[1,e.righttop],x:-1,y:0,o:1};case 9:return o&w?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 10:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[1,e.righttop],x:-1,y:0,o:1};case 11:return o&v?{p:[1,e.righttop],x:-1,y:0,o:1}:{p:[0,e.lefttop],x:1,y:0,o:1};case 12:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 13:return o&w?{p:[1,e.rightbottom],x:-1,y:0,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 14:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[1,e.rightbottom],x:-1,y:0,o:0};case 15:return o&v?{p:[1,e.rightbottom],x:-1,y:0,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 16:return o&x?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[0,e.leftbottom],x:1,y:0,o:0};case 17:return o&v?{p:[e.bottomright,0],x:0,y:1,o:1}:{p:[0,e.lefttop],x:1,y:0,o:1};case 18:return o&w?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[e.bottomleft,0],x:0,y:1,o:0};case 19:return o&v?{p:[e.bottomleft,0],x:0,y:1,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 20:return o&v?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[0,e.leftbottom],x:1,y:0,o:0};case 21:return o&k?{p:[0,e.leftbottom],x:1,y:0,o:0}:{p:[e.topright,1],x:0,y:-1,o:1};case 22:return o&v?{p:[e.topleft,1],x:0,y:-1,o:0}:{p:[0,e.lefttop],x:1,y:0,o:1};case 23:return o&k?{p:[0,e.lefttop],x:1,y:0,o:1}:{p:[e.topright,1],x:0,y:-1,o:1};default:console.log("edge index out of range!"),console.log(e)}}return null}function u(e,t,o,s){var p,u,t,o,h,l,a,f=e.cval;switch(t){case-1:switch(s){case 0:p=U[f],h=A[f],l=G[f],a=P[f];break;default:p=R[f],h=F[f],l=O[f],a=I[f]}break;case 1:switch(s){case 0:p=Y[f],h=J[f],l=K[f],a=Q[f];break;default:p=Z[f],h=B[f],l=D[f],a=H[f]}break;default:switch(o){case-1:switch(s){case 0:p=$[f],h=N[f],l=j[f],a=C[f];break;default:p=ee[f],h=_[f],l=E[f],a=M[f]}break;case 1:switch(s){case 0:p=X[f],h=T[f],l=V[f],a=L[f];break;default:p=W[f],h=S[f],l=q[f],a=z[f]}}}if(u=e.edges.indexOf(p),"undefined"==typeof e.edges[u])return null;switch(r(e,u),f=e.cval_real,p){case 0:f&k?(t=e.topleft,o=1):(t=1,o=e.righttop);break;case 1:f&x?(t=1,o=e.rightbottom):(t=e.topleft,o=1);break;case 2:f&x?(t=e.topleft,o=1):(t=e.bottomright,o=0);break;case 3:f&w?(t=e.bottomleft,o=0):(t=e.topleft,o=1);break;case 4:f&k?(t=e.topright,o=1):(t=1,o=e.righttop);break;case 5:f&x?(t=1,o=e.rightbottom):(t=e.topright,o=1);break;case 6:f&x?(t=e.topright,o=1):(t=e.bottomright,o=0);break;case 7:f&w?(t=e.bottomleft,o=0):(t=e.topright,o=1);break;case 8:f&x?(t=1,o=e.righttop):(t=e.bottomright,o=0);break;case 9:f&w?(t=e.bottomleft,o=0):(t=1,o=e.righttop);break;case 10:f&w?(t=1,o=e.righttop):(t=0,o=e.leftbottom);break;case 11:f&v?(t=0,o=e.lefttop):(t=1,o=e.righttop);break;case 12:f&x?(t=1,o=e.rightbottom):(t=e.bottomright,o=0);break;case 13:f&w?(t=e.bottomleft,o=0):(t=1,o=e.rightbottom);break;case 14:f&w?(t=1,o=e.rightbottom):(t=0,o=e.leftbottom);break;case 15:f&v?(t=0,o=e.lefttop):(t=1,o=e.rightbottom);break;case 16:f&x?(t=0,o=e.leftbottom):(t=e.bottomright,o=0);break;case 17:f&v?(t=0,o=e.lefttop):(t=e.bottomright,o=0);break;case 18:f&w?(t=e.bottomleft,o=0):(t=0,o=e.leftbottom);break;case 19:f&v?(t=0,o=e.lefttop):(t=e.bottomleft,o=0);break;case 20:f&v?(t=0,o=e.leftbottom):(t=e.topleft,o=1);break;case 21:f&k?(t=e.topright,o=1):(t=0,o=e.leftbottom);break;case 22:f&v?(t=0,o=e.lefttop):(t=e.topleft,o=1);break;case 23:f&k?(t=e.topright,o=1):(t=0,o=e.lefttop);break;default:return console.log("edge index out of range!"),console.log(e),null}return"undefined"!=typeof t&&"undefined"!=typeof o&&"undefined"!=typeof h&&"undefined"!=typeof l&&"undefined"!=typeof a||(console.log("undefined value!"),console.log(e),console.log(t+" "+o+" "+h+" "+l+" "+a)),{p:[t,o],x:h,y:l,o:a}}function h(e,t,o){return(e-t)/(o-t)}function l(e,t){for(var o=e.length-1,s=e[0].length-1,r={rows:o,cols:s,cells:[]},p=0;p<o;++p){r.cells[p]=[];for(var u=0;u<s;++u){var l=0,a=e[p+1][u],f=e[p+1][u+1],n=e[p][u+1],i=e[p][u];if(!(isNaN(a)||isNaN(f)||isNaN(n)||isNaN(i))){l|=a>=t?8:0,l|=f>=t?4:0,l|=n>=t?2:0,l|=i>=t?1:0;var c=!1;if(5==l||10==l){var b=(a+f+n+i)/4;5==l&&b<t?(l=10,c=!0):10==l&&b<t&&(l=5,c=!0)}if(0!==l&&15!==l){var g,d,y,m;g=d=y=m=.5,1==l?(y=1-h(t,a,i),d=1-h(t,n,i)):2==l?(d=h(t,i,n),m=1-h(t,f,n)):3==l?(y=1-h(t,a,i),m=1-h(t,f,n)):4==l?(g=h(t,a,f),m=h(t,n,f)):5==l?(g=h(t,a,f),m=h(t,n,f),d=1-h(t,n,i),y=1-h(t,a,i)):6==l?(d=h(t,i,n),g=h(t,a,f)):7==l?(y=1-h(t,a,i),g=h(t,a,f)):8==l?(y=h(t,i,a),g=1-h(t,f,a)):9==l?(d=1-h(t,n,i),g=1-h(t,f,a)):10==l?(g=1-h(t,f,a),m=1-h(t,f,n),d=h(t,i,n),y=h(t,i,a)):11==l?(g=1-h(t,f,a),m=1-h(t,f,n)):12==l?(y=h(t,i,a),m=h(t,n,f)):13==l?(d=1-h(t,n,i),m=h(t,n,f)):14==l?(y=h(t,i,a),d=h(t,i,n)):console.log("Illegal cval detected: "+l),r.cells[p][u]={cval:l,flipped:c,top:g,right:m,bottom:d,left:y}}}}}return r}function a(e){return 5==e.cval||10==e.cval}function f(e){return 0===e.cval||15==e.cval}function n(e){f(e)||5==e.cval||10==e.cval||(e.cval=15)}function i(e,t){return"top"===t?[e.top,1]:"bottom"===t?[e.bottom,0]:"right"===t?[1,e.right]:"left"===t?[0,e.left]:void 0}function c(e){var t=[],o=0,s=(e.rows,e.cols,1e-7);return e.cells.forEach(function(r,p){r.forEach(function(r,u){if("undefined"!=typeof r&&!a(r)&&!f(r)){var h=b(e.cells,p,u),l=!1;if("mergeable"==h.info)for(var n=h.path[h.path.length-1][0],i=h.path[h.path.length-1][1],c=o-1;c>=0;c--)if(Math.abs(t[c][0][0]-n)<=s&&Math.abs(t[c][0][1]-i)<=s){for(var g=h.path.length-2;g>=0;--g)t[c].unshift(h.path[g]);l=!0;break}l||(t[o++]=h.path)}})}),t}function b(e,t,o){var s,r,p=e.length,u=[],h=[0,0,1,1,0,0,0,0,-1,0,1,1,-1,0,-1,0],l=[0,-1,0,0,1,1,1,1,0,-1,0,0,0,-1,0,0],a=["none","left","bottom","left","right","none","bottom","left","top","top","none","top","right","right","bottom","none"],f=["none","bottom","right","right","top","top","top","top","left","bottom","right","right","left","bottom","left","none"],c=(e[t][o],e[t][o]),b=c.cval,g=a[b],d=i(c,g);u.push([o+d[0],t+d[1]]),g=f[b],d=i(c,g),u.push([o+d[0],t+d[1]]),n(c);for(var y=o+h[b],m=t+l[b],v=b;y>=0&&m>=0&&m<p&&(y!=o||m!=t)&&(c=e[m][y],"undefined"!=typeof c);){if(b=c.cval,0===b||15===b)return{path:u,info:"mergeable"};g=f[b],s=h[b],r=l[b],5!=b&&10!=b||(5==b?c.flipped?l[v]==-1?(g="left",s=-1,r=0):(g="right",s=1,r=0):h[v]==-1&&(g="bottom",s=0,r=-1):10==b&&(c.flipped?h[v]==-1?(g="top",s=0,r=1):(g="bottom",s=0,r=-1):1==l[v]&&(g="left",s=-1,r=0))),d=i(c,g),u.push([y+d[0],m+d[1]]),n(c),y+=s,m+=r,v=b}return{path:u,info:"closed"}}var g=function(e,t,o){for(var s={type:"FeatureCollection",features:[]},r=1;r<o.length;r++){for(var p=o[r-1],u=o[r],h=d(e,t,p,u-p),l=0;l<h.length;l++)h[l].reverse();s.features.push({type:"Feature",geometry:{type:"Polygon",coordinates:h},properties:[{lowerValue:p,upperValue:u}]})}return s},d=function(e,t,o,s){if(typeof t!=typeof new Array||6!=t.length)throw new Error("GeoTransform must be a 6 elements array");for(var r=m(e,o,s),p=0;p<r.length;p++)for(var u=0;u<r[p].length;u++){var h=y(r[p][u][0],r[p][u][1],t);r[p][u][0]=h[0],r[p][u][1]=h[1]}return r},y=function(e,t,o){var s=o[0]+e*o[1]+t*o[2],r=o[3]+e*o[4]+t*o[5];return[s,r]},m=function(e,t,s,r){var p={},u={successCallback:null,progressCallback:null,verbose:!1};r=r?r:{};for(var h=Object.keys(u),l=0;l<h.length;l++){var a=h[l],f=r[a];f="undefined"!=typeof f&&null!==f?f:u[a],p[a]=f}p.verbose&&console.log("computing isobands for ["+t+":"+(t+s)+"]");var n=te(e,t,s),i=o(n);return i},v=64,k=16,x=4,w=1,N=[],j=[],C=[],_=[],E=[],M=[],F=[],O=[],I=[],A=[],G=[],P=[],T=[],V=[],L=[],S=[],q=[],z=[],B=[],D=[],H=[],J=[],K=[],Q=[];F[85]=A[85]=-1,O[85]=G[85]=0,I[85]=P[85]=1,B[85]=J[85]=1,D[85]=K[85]=0,H[85]=Q[85]=1,N[85]=_[85]=0,j[85]=E[85]=-1,C[85]=L[85]=0,S[85]=T[85]=0,q[85]=V[85]=1,M[85]=z[85]=1,J[1]=J[169]=0,K[1]=K[169]=-1,Q[1]=Q[169]=0,T[1]=T[169]=-1,V[1]=V[169]=0,L[1]=L[169]=0,A[4]=A[166]=0,G[4]=G[166]=-1,P[4]=P[166]=1,S[4]=S[166]=1,q[4]=q[166]=0,z[4]=z[166]=0,F[16]=F[154]=0,O[16]=O[154]=1,I[16]=I[154]=1,_[16]=_[154]=1,E[16]=E[154]=0,M[16]=M[154]=1,B[64]=B[106]=0,D[64]=D[106]=1,H[64]=H[106]=0,N[64]=N[106]=-1,j[64]=j[106]=0,C[64]=C[106]=1,B[2]=B[168]=0,D[2]=D[168]=-1,H[2]=H[168]=1,J[2]=J[168]=0,K[2]=K[168]=-1,Q[2]=Q[168]=0,T[2]=T[168]=-1,V[2]=V[168]=0,L[2]=L[168]=0,S[2]=S[168]=-1,q[2]=q[168]=0,z[2]=z[168]=1,F[8]=F[162]=0,O[8]=O[162]=-1,I[8]=I[162]=0,A[8]=A[162]=0,G[8]=G[162]=-1,P[8]=P[162]=1,T[8]=T[162]=1,V[8]=V[162]=0,L[8]=L[162]=1,S[8]=S[162]=1,q[8]=q[162]=0,z[8]=z[162]=0,F[32]=F[138]=0,O[32]=O[138]=1,I[32]=I[138]=1,A[32]=A[138]=0,G[32]=G[138]=1,P[32]=P[138]=0,N[32]=N[138]=1,j[32]=j[138]=0,C[32]=C[138]=0,_[32]=_[138]=1,E[32]=E[138]=0,M[32]=M[138]=1,J[128]=J[42]=0,K[128]=K[42]=1,Q[128]=Q[42]=1,B[128]=B[42]=0,D[128]=D[42]=1,H[128]=H[42]=0,N[128]=N[42]=-1,j[128]=j[42]=0,C[128]=C[42]=1,_[128]=_[42]=-1,E[128]=E[42]=0,M[128]=M[42]=0,A[5]=A[165]=-1,G[5]=G[165]=0,P[5]=P[165]=0,J[5]=J[165]=1,K[5]=K[165]=0,Q[5]=Q[165]=0,S[20]=S[150]=0,q[20]=q[150]=1,z[20]=z[150]=1,_[20]=_[150]=0,E[20]=E[150]=-1,M[20]=M[150]=1,F[80]=F[90]=-1,O[80]=O[90]=0,I[80]=I[90]=1,B[80]=B[90]=1,D[80]=D[90]=0,H[80]=H[90]=1,T[65]=T[105]=0,V[65]=V[105]=1,L[65]=L[105]=0,N[65]=N[105]=0,j[65]=j[105]=-1,C[65]=C[105]=0,F[160]=F[10]=-1,O[160]=O[10]=0,I[160]=I[10]=1,A[160]=A[10]=-1,G[160]=G[10]=0,P[160]=P[10]=0,J[160]=J[10]=1,K[160]=K[10]=0,Q[160]=Q[10]=0,B[160]=B[10]=1,D[160]=D[10]=0,H[160]=H[10]=1,S[130]=S[40]=0,q[130]=q[40]=1,z[130]=z[40]=1,T[130]=T[40]=0,V[130]=V[40]=1,L[130]=L[40]=0,N[130]=N[40]=0,j[130]=j[40]=-1,C[130]=C[40]=0,_[130]=_[40]=0,E[130]=E[40]=-1,M[130]=M[40]=1,A[37]=A[133]=0,G[37]=G[133]=1,P[37]=P[133]=1,J[37]=J[133]=0,K[37]=K[133]=1,Q[37]=Q[133]=0,N[37]=N[133]=-1,j[37]=j[133]=0,C[37]=C[133]=0,_[37]=_[133]=1,E[37]=E[133]=0,M[37]=M[133]=0,S[148]=S[22]=-1,q[148]=q[22]=0,z[148]=z[22]=0,J[148]=J[22]=0,K[148]=K[22]=-1,Q[148]=Q[22]=1,B[148]=B[22]=0,D[148]=D[22]=1,H[148]=H[22]=1,_[148]=_[22]=-1,E[148]=E[22]=0,M[148]=M[22]=1,F[82]=F[88]=0,O[82]=O[88]=-1,I[82]=I[88]=1,S[82]=S[88]=1,q[82]=q[88]=0,z[82]=z[88]=1,T[82]=T[88]=-1,V[82]=V[88]=0,L[82]=L[88]=1,B[82]=B[88]=0,D[82]=D[88]=-1,H[82]=H[88]=0,F[73]=F[97]=0,O[73]=O[97]=1,I[73]=I[97]=0,A[73]=A[97]=0,G[73]=G[97]=-1,P[73]=P[97]=0,T[73]=T[97]=1,V[73]=V[97]=0,L[73]=L[97]=0,N[73]=N[97]=1,j[73]=j[97]=0,C[73]=C[97]=1,F[145]=F[25]=0,O[145]=O[25]=-1,I[145]=I[25]=0,T[145]=T[25]=1,V[145]=V[25]=0,L[145]=L[25]=1,J[145]=J[25]=0,K[145]=K[25]=1,Q[145]=Q[25]=1,_[145]=_[25]=-1,E[145]=E[25]=0,M[145]=M[25]=0,A[70]=A[100]=0,G[70]=G[100]=1,P[70]=P[100]=0,S[70]=S[100]=-1,q[70]=q[100]=0,z[70]=z[100]=1,B[70]=B[100]=0,D[70]=D[100]=-1;H[70]=H[100]=1;N[70]=N[100]=1,j[70]=j[100]=0,C[70]=C[100]=0,A[101]=A[69]=0,G[101]=G[69]=1,P[101]=P[69]=0,N[101]=N[69]=1,j[101]=j[69]=0,C[101]=C[69]=0,J[149]=J[21]=0,K[149]=K[21]=1,Q[149]=Q[21]=1,_[149]=_[21]=-1,E[149]=E[21]=0,M[149]=M[21]=0,S[86]=S[84]=-1,q[86]=q[84]=0,z[86]=z[84]=1,B[86]=B[84]=0,D[86]=D[84]=-1,H[86]=H[84]=1,F[89]=F[81]=0,O[89]=O[81]=-1,I[89]=I[81]=0,T[89]=T[81]=1,V[89]=V[81]=0,L[89]=L[81]=1,F[96]=F[74]=0,O[96]=O[74]=1,I[96]=I[74]=0,A[96]=A[74]=-1,G[96]=G[74]=0,P[96]=P[74]=1,B[96]=B[74]=1,D[96]=D[74]=0,H[96]=H[74]=0,N[96]=N[74]=1,j[96]=j[74]=0,C[96]=C[74]=1,F[24]=F[146]=0,O[24]=O[146]=-1,I[24]=I[146]=1,S[24]=S[146]=1,q[24]=q[146]=0,z[24]=z[146]=1,T[24]=T[146]=0,V[24]=V[146]=1,L[24]=L[146]=1,_[24]=_[146]=0,E[24]=E[146]=-1,M[24]=M[146]=0,A[6]=A[164]=-1,G[6]=G[164]=0,P[6]=P[164]=1,S[6]=S[164]=-1,q[6]=q[164]=0,z[6]=z[164]=0,J[6]=J[164]=0,K[6]=K[164]=-1,Q[6]=Q[164]=1,B[6]=B[164]=1,D[6]=D[164]=0,H[6]=H[164]=0,T[129]=T[41]=0,V[129]=V[41]=1,L[129]=L[41]=1,J[129]=J[41]=0,K[129]=K[41]=1,Q[129]=Q[41]=0,N[129]=N[41]=-1,j[129]=j[41]=0,C[129]=C[41]=0,_[129]=_[41]=0,E[129]=E[41]=-1,M[129]=M[41]=0,S[66]=S[104]=0,q[66]=q[104]=1,z[66]=z[104]=0,T[66]=T[104]=-1,V[66]=V[104]=0,L[66]=L[104]=1,B[66]=B[104]=0,D[66]=D[104]=-1,H[66]=H[104]=0,N[66]=N[104]=0,j[66]=j[104]=-1,C[66]=C[104]=1,F[144]=F[26]=-1,O[144]=O[26]=0,I[144]=I[26]=0,J[144]=J[26]=1,K[144]=K[26]=0,Q[144]=Q[26]=1,B[144]=B[26]=0,D[144]=D[26]=1,H[144]=H[26]=1,_[144]=_[26]=-1,E[144]=E[26]=0,M[144]=M[26]=1,A[36]=A[134]=0,G[36]=G[134]=1,P[36]=P[134]=1,S[36]=S[134]=0,q[36]=q[134]=1,z[36]=z[134]=0,N[36]=N[134]=0,j[36]=j[134]=-1,C[36]=C[134]=1,_[36]=_[134]=1,E[36]=E[134]=0,M[36]=M[134]=0,F[9]=F[161]=-1,O[9]=O[161]=0,I[9]=I[161]=0,A[9]=A[161]=0,G[9]=G[161]=-1,P[9]=P[161]=0,T[9]=T[161]=1,V[9]=V[161]=0,L[9]=L[161]=0,J[9]=J[161]=1,K[9]=K[161]=0,Q[9]=Q[161]=1,F[136]=0,O[136]=1,I[136]=1,A[136]=0,G[136]=1,P[136]=0,S[136]=-1,q[136]=0,z[136]=1,T[136]=-1,V[136]=0,L[136]=0,J[136]=0,K[136]=-1,Q[136]=0,B[136]=0,D[136]=-1,H[136]=1,N[136]=1,j[136]=0,C[136]=0,_[136]=1,E[136]=0,M[136]=1,F[34]=0,O[34]=-1,I[34]=0,A[34]=0,G[34]=-1,P[34]=1,S[34]=1,q[34]=0,z[34]=0,T[34]=1,V[34]=0,L[34]=1,J[34]=0,K[34]=1,Q[34]=1,B[34]=0,D[34]=1,H[34]=0,N[34]=-1,j[34]=0,C[34]=1,_[34]=-1,E[34]=0,M[34]=0,F[35]=0,O[35]=1,I[35]=1,A[35]=0,G[35]=-1,P[35]=1,S[35]=1,q[35]=0,z[35]=0,T[35]=-1,V[35]=0,L[35]=0,J[35]=0,K[35]=-1,Q[35]=0,B[35]=0,D[35]=1,H[35]=0,N[35]=-1,j[35]=0,C[35]=1,_[35]=1,E[35]=0,M[35]=1,F[153]=0,O[153]=1,I[153]=1,T[153]=-1,V[153]=0;L[153]=0;J[153]=0,K[153]=-1,Q[153]=0,_[153]=1,E[153]=0,M[153]=1,A[102]=0,G[102]=-1,P[102]=1,S[102]=1,q[102]=0,z[102]=0,B[102]=0,D[102]=1,H[102]=0,N[102]=-1,j[102]=0,C[102]=1,F[155]=0,O[155]=-1,I[155]=0,T[155]=1,V[155]=0,L[155]=1,J[155]=0,K[155]=1,Q[155]=1,_[155]=-1,E[155]=0,M[155]=0,A[103]=0,G[103]=1,P[103]=0,S[103]=-1,q[103]=0,z[103]=1,B[103]=0,D[103]=-1,H[103]=1,N[103]=1,j[103]=0,C[103]=0,F[152]=0,O[152]=1,I[152]=1,S[152]=-1,q[152]=0,z[152]=1,T[152]=-1,V[152]=0,L[152]=0,J[152]=0,K[152]=-1,Q[152]=0,B[152]=0,D[152]=-1,H[152]=1,_[152]=1,E[152]=0,M[152]=1,F[156]=0,O[156]=-1,I[156]=1,S[156]=1,q[156]=0,z[156]=1,T[156]=-1,V[156]=0,L[156]=0,J[156]=0,K[156]=-1,Q[156]=0,B[156]=0,D[156]=1,H[156]=1,_[156]=-1,E[156]=0,M[156]=1,F[137]=0,O[137]=1,I[137]=1,A[137]=0,G[137]=1,P[137]=0,T[137]=-1,V[137]=0,L[137]=0,J[137]=0,K[137]=-1,Q[137]=0,N[137]=1,j[137]=0,C[137]=0,_[137]=1,E[137]=0,M[137]=1,F[139]=0,O[139]=1,I[139]=1,A[139]=0,G[139]=-1,P[139]=0,T[139]=1,V[139]=0,L[139]=0,J[139]=0,K[139]=1,Q[139]=0,N[139]=-1,j[139]=0,C[139]=0,_[139]=1,E[139]=0,M[139]=1,F[98]=0,O[98]=-1,I[98]=0,A[98]=0,G[98]=-1,P[98]=1,S[98]=1,q[98]=0,z[98]=0,T[98]=1,V[98]=0,L[98]=1,B[98]=0,D[98]=1,H[98]=0,N[98]=-1,j[98]=0,C[98]=1,F[99]=0,O[99]=1,I[99]=0,A[99]=0,G[99]=-1,P[99]=1,S[99]=1,q[99]=0,z[99]=0,T[99]=-1,V[99]=0,L[99]=1,B[99]=0,D[99]=-1,H[99]=0,N[99]=1,j[99]=0,C[99]=1,A[38]=0,G[38]=-1,P[38]=1,S[38]=1,q[38]=0,z[38]=0,J[38]=0,K[38]=1,Q[38]=1,B[38]=0,D[38]=1,H[38]=0,N[38]=-1,j[38]=0,C[38]=1,_[38]=-1,E[38]=0,M[38]=0,A[39]=0,G[39]=1,P[39]=1,S[39]=-1,q[39]=0,z[39]=0,J[39]=0,K[39]=-1,Q[39]=1,B[39]=0,D[39]=1,H[39]=0,N[39]=-1,j[39]=0,C[39]=1,_[39]=1,E[39]=0,M[39]=0;var R=[],U=[],W=[],X=[],Y=[],Z=[],$=[],ee=[];X[1]=Y[1]=18,X[169]=Y[169]=18,W[4]=U[4]=12,W[166]=U[166]=12,R[16]=ee[16]=4,R[154]=ee[154]=4,Z[64]=$[64]=22,Z[106]=$[106]=22,W[2]=Z[2]=17,X[2]=Y[2]=18,W[168]=Z[168]=17,X[168]=Y[168]=18,R[8]=X[8]=9,U[8]=W[8]=12,R[162]=X[162]=9,U[162]=W[162]=12,R[32]=ee[32]=4,U[32]=$[32]=1,R[138]=ee[138]=4,U[138]=$[138]=1,Y[128]=ee[128]=21,Z[128]=$[128]=22,Y[42]=ee[42]=21,Z[42]=$[42]=22,U[5]=Y[5]=14,U[165]=Y[165]=14,W[20]=ee[20]=6,W[150]=ee[150]=6,R[80]=Z[80]=11,R[90]=Z[90]=11,X[65]=$[65]=3,X[105]=$[105]=3,R[160]=Z[160]=11,U[160]=Y[160]=14,R[10]=Z[10]=11,U[10]=Y[10]=14,W[130]=ee[130]=6,X[130]=$[130]=3,W[40]=ee[40]=6,X[40]=$[40]=3,U[101]=$[101]=1,U[69]=$[69]=1,Y[149]=ee[149]=21,Y[21]=ee[21]=21,W[86]=Z[86]=17,W[84]=Z[84]=17,R[89]=X[89]=9,R[81]=X[81]=9,R[96]=$[96]=0,U[96]=Z[96]=15,R[74]=$[74]=0,U[74]=Z[74]=15,R[24]=W[24]=8,X[24]=ee[24]=7,R[146]=W[146]=8,X[146]=ee[146]=7,U[6]=Z[6]=15,W[6]=Y[6]=16,U[164]=Z[164]=15,W[164]=Y[164]=16,X[129]=ee[129]=7,Y[129]=$[129]=20,X[41]=ee[41]=7,Y[41]=$[41]=20,W[66]=$[66]=2,X[66]=Z[66]=19,W[104]=$[104]=2,X[104]=Z[104]=19,R[144]=Y[144]=10,Z[144]=ee[144]=23,R[26]=Y[26]=10,Z[26]=ee[26]=23,U[36]=ee[36]=5,W[36]=$[36]=2,U[134]=ee[134]=5,W[134]=$[134]=2,R[9]=Y[9]=10,U[9]=X[9]=13,R[161]=Y[161]=10,U[161]=X[161]=13,U[37]=ee[37]=5,Y[37]=$[37]=20,U[133]=ee[133]=5,Y[133]=$[133]=20,W[148]=Y[148]=16,Z[148]=ee[148]=23,W[22]=Y[22]=16,Z[22]=ee[22]=23,R[82]=W[82]=8,X[82]=Z[82]=19,R[88]=W[88]=8,X[88]=Z[88]=19,R[73]=$[73]=0,U[73]=X[73]=13,R[97]=$[97]=0,U[97]=X[97]=13,R[145]=X[145]=9,Y[145]=ee[145]=21,R[25]=X[25]=9,Y[25]=ee[25]=21,U[70]=$[70]=1,W[70]=Z[70]=17,U[100]=$[100]=1,W[100]=Z[100]=17,R[34]=X[34]=9,U[34]=W[34]=12,Y[34]=ee[34]=21,Z[34]=$[34]=22,R[136]=ee[136]=4,U[136]=$[136]=1,W[136]=Z[136]=17,X[136]=Y[136]=18,R[35]=ee[35]=4,U[35]=W[35]=12,X[35]=Y[35]=18,Z[35]=$[35]=22,R[153]=ee[153]=4,X[153]=Y[153]=18,U[102]=W[102]=12,Z[102]=$[102]=22,R[155]=X[155]=9,Y[155]=ee[155]=23,U[103]=$[103]=1,W[103]=Z[103]=17,R[152]=ee[152]=4,W[152]=Z[152]=17,X[152]=Y[152]=18,R[156]=W[156]=8,X[156]=Y[156]=18,Z[156]=ee[156]=23,R[137]=ee[137]=4,U[137]=$[137]=1,X[137]=Y[137]=18,R[139]=ee[139]=4,U[139]=X[139]=13,Y[139]=$[139]=20,R[98]=X[98]=9,U[98]=W[98]=12,Z[98]=$[98]=22,R[99]=$[99]=0,U[99]=W[99]=12,X[99]=Z[99]=19,U[38]=W[38]=12,Y[38]=ee[38]=21,Z[38]=$[38]=22,U[39]=ee[39]=5,W[39]=Y[39]=16,Z[39]=$[39]=22;var te=function(e,o,s){for(var r=e.length-1,p=e[0].length-1,u={rows:r,cols:p,cells:[]},h=o+Math.abs(s),l=0;l<r;++l){u.cells[l]=[];for(var a=0;a<p;++a){var f=0,n=e[l+1][a],i=e[l+1][a+1],c=e[l][a+1],b=e[l][a];if(!(isNaN(n)||isNaN(i)||isNaN(c)||isNaN(b))){f|=n<o?0:n>h?128:64,f|=i<o?0:i>h?32:16,f|=c<o?0:c>h?8:4,f|=b<o?0:b>h?2:1;var g=+f,d=0;if(17==f||18==f||33==f||34==f||38==f||68==f||72==f||98==f||102==f||132==f||136==f||137==f||152==f||153==f){var y=(n+i+c+b)/4;d=y>h?2:y<o?0:1,34===f?1===d?f=35:0===d&&(f=136):136===f?1===d?(f=35,d=4):0===d&&(f=34):17===f?1===d?(f=155,d=4):0===d&&(f=153):68===f?1===d?(f=103,d=4):0===d&&(f=102):153===f?1===d&&(f=155):102===f?1===d&&(f=103):152===f?d<2&&(f=156,d=1):137===f?d<2&&(f=139,d=1):98===f?d<2&&(f=99,d=1):38===f?d<2&&(f=39,d=1):18===f?d>0?(f=156,d=4):f=152:33===f?d>0?(f=139,d=4):f=137:72===f?d>0?(f=99,d=4):f=98:132===f&&(d>0?(f=39,d=4):f=38)}if(0!=f&&170!=f){var m,v,k,x,w,N,j,C;m=v=k=x=w=N=j=C=.5;var _=[];1===f?(k=1-t(o,c,b),C=1-t(o,n,b),_.push(X[f])):169===f?(k=t(h,b,c),C=t(h,b,n),_.push(X[f])):4===f?(N=1-t(o,i,c),x=t(o,b,c),_.push(U[f])):166===f?(N=t(h,c,i),x=1-t(h,c,b),_.push(U[f])):16===f?(w=t(o,c,i),v=t(o,n,i),_.push(R[f])):154===f?(w=1-t(h,i,c),v=1-t(h,i,n),_.push(R[f])):64===f?(j=t(o,b,n),m=1-t(o,i,n),_.push(Z[f])):106===f?(j=1-t(h,n,b),m=t(h,n,i),_.push(Z[f])):168===f?(x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),_.push(W[f]),_.push(X[f])):2===f?(x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),_.push(W[f]),_.push(X[f])):162===f?(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),_.push(W[f]),_.push(X[f])):8===f?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),_.push(R[f]),_.push(U[f])):138===f?(w=1-t(o,i,c),N=1-t(h,i,c),m=1-t(h,i,n),v=1-t(o,i,n),_.push(R[f]),_.push(U[f])):32===f?(w=t(h,c,i),N=t(o,c,i),m=t(o,n,i),v=t(h,n,i),_.push(R[f]),_.push(U[f])):42===f?(C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i),_.push(Y[f]),_.push(Z[f])):128===f&&(C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n),_.push(Y[f]),_.push(Z[f])),5===f?(N=1-t(o,i,c),C=1-t(o,n,b),_.push(U[f])):165===f?(N=t(h,c,i),C=t(h,b,n),_.push(U[f])):20===f?(x=t(o,b,c),v=t(o,n,i),_.push(W[f])):150===f?(x=1-t(h,c,b),v=1-t(h,i,n),_.push(W[f])):80===f?(w=t(o,c,i),j=t(o,b,n),_.push(R[f])):90===f?(w=1-t(h,i,c),j=1-t(h,n,b),_.push(R[f])):65===f?(k=1-t(o,c,b),m=1-t(o,i,n),_.push(X[f])):105===f?(k=t(h,b,c),m=t(h,n,i),_.push(X[f])):160===f?(w=t(h,c,i),N=t(o,c,i),C=t(o,b,n),j=t(h,b,n),_.push(R[f]),_.push(U[f])):10===f?(w=1-t(o,i,c),N=1-t(h,i,c),C=1-t(h,n,b),j=1-t(o,n,b),_.push(R[f]),_.push(U[f])):130===f?(x=1-t(o,c,b),k=1-t(h,c,b),m=1-t(h,i,n),v=1-t(o,i,n),_.push(W[f]),_.push(X[f])):40===f?(x=t(h,b,c),k=t(o,b,c),m=t(o,n,i),v=t(h,n,i),_.push(W[f]),_.push(X[f])):101===f?(N=t(h,c,i),m=t(h,n,i),_.push(U[f])):69===f?(N=1-t(o,i,c),m=1-t(o,i,n),_.push(U[f])):149===f?(C=t(h,b,n),v=1-t(h,i,n),_.push(Y[f])):21===f?(C=1-t(o,n,b),v=t(o,n,i),_.push(Y[f])):86===f?(x=1-t(h,c,b),j=1-t(h,n,b),_.push(W[f])):84===f?(x=t(o,b,c),j=t(o,b,n),_.push(W[f])):89===f?(w=1-t(h,i,c),k=t(h,b,c),_.push(X[f])):81===f?(w=t(o,c,i),k=1-t(o,c,b),_.push(X[f])):96===f?(w=t(h,c,i),N=t(o,c,i),j=t(o,b,n),m=t(h,n,i),_.push(R[f]),_.push(U[f])):74===f?(w=1-t(o,i,c),N=1-t(h,i,c),j=1-t(h,n,b),m=1-t(o,i,n),_.push(R[f]),_.push(U[f])):24===f?(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),v=t(o,n,i),_.push(R[f]),_.push(X[f])):146===f?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),v=1-t(h,i,n),_.push(R[f]),_.push(X[f])):6===f?(N=1-t(o,i,c),x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),_.push(U[f]),_.push(W[f])):164===f?(N=t(h,c,i),x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),_.push(U[f]),_.push(W[f])):129===f?(k=1-t(o,c,b),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n),_.push(X[f]),_.push(Y[f])):41===f?(k=t(h,b,c),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i),_.push(X[f]),_.push(Y[f])):66===f?(x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),m=1-t(o,i,n),_.push(W[f]),_.push(X[f])):104===f?(x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),m=t(h,n,i),_.push(X[f]),_.push($[f])):144===f?(w=t(o,c,i),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n),_.push(R[f]),_.push(Z[f])):26===f?(w=1-t(h,i,c),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i),_.push(R[f]),_.push(Z[f])):36===f?(N=t(h,c,i),x=t(o,b,c),m=t(o,n,i),v=t(h,n,i),_.push(U[f]),_.push(W[f])):134===f?(N=1-t(o,i,c),x=1-t(h,c,b),m=1-t(h,i,n),v=1-t(o,i,n),_.push(U[f]),_.push(W[f])):9===f?(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),C=1-t(o,n,b),_.push(R[f]),_.push(U[f])):161===f?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),C=t(h,b,n),_.push(R[f]),_.push(U[f])):37===f?(N=t(h,c,i),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i),_.push(U[f]),_.push(Y[f])):133===f?(N=1-t(o,i,c),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n),_.push(U[f]),_.push(Y[f])):148===f?(x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n),_.push(W[f]),_.push(Z[f])):22===f?(x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i),_.push(W[f]),_.push(Z[f])):82===f?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),_.push(R[f]),_.push(X[f])):88===f?(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),_.push(R[f]),_.push(X[f])):73===f?(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),m=1-t(o,i,n),_.push(R[f]),_.push(U[f])):97===f?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),m=t(h,n,i),_.push(R[f]),_.push(U[f])):145===f?(w=t(o,c,i),k=1-t(o,c,b),C=t(h,b,n),v=1-t(h,i,n),_.push(R[f]),_.push(Y[f])):25===f?(w=1-t(h,i,c),k=t(h,b,c),C=1-t(o,n,b),v=t(o,n,i),_.push(R[f]),_.push(Y[f])):70===f?(N=1-t(o,i,c),x=1-t(h,c,b),j=1-t(h,n,b),m=1-t(o,i,n),_.push(U[f]),_.push(W[f])):100===f?(N=t(h,c,i),x=t(o,b,c),j=t(o,b,n),m=t(h,n,i),_.push(U[f]),_.push(W[f])):34===f?(0===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(Y[f]),_.push(Z[f])):35===f?(4===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(X[f]),_.push(Z[f])):136===f?(0===d?(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)):(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)),_.push(R[f]),_.push(U[f]),_.push(Y[f]),_.push(Z[f])):153===f?(0===d?(w=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(X[f])):102===f?(0===d?(N=1-t(o,i,c),x=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(U[f]),_.push(Z[f])):155===f?(4===d?(w=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(Y[f])):103===f?(4===d?(N=1-t(o,i,c),x=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(U[f]),_.push(W[f])):152===f?(0===d?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(W[f]),_.push(X[f])):156===f?(4===d?(w=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),v=t(o,n,i)):(w=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),C=t(o,b,n),j=t(h,b,n),v=1-t(h,i,n)),_.push(R[f]),_.push(X[f]),_.push(Z[f])):137===f?(0===d?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)):(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)),_.push(R[f]),_.push(U[f]),_.push(X[f])):139===f?(4===d?(w=t(h,c,i),N=t(o,c,i),k=1-t(o,c,b),C=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)):(w=1-t(o,i,c),N=1-t(h,i,c),k=t(h,b,c),C=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)),_.push(R[f]),_.push(U[f]),_.push(Y[f])):98===f?(0===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(Z[f])):99===f?(4===d?(w=1-t(o,i,c),N=1-t(h,i,c),x=t(h,b,c),k=t(o,b,c),j=t(o,b,n),m=1-t(o,i,n)):(w=t(h,c,i),N=t(o,c,i),x=1-t(o,c,b),k=1-t(h,c,b),j=1-t(h,n,b),m=t(h,n,i)),_.push(R[f]),_.push(U[f]),_.push(X[f])):38===f?(0===d?(N=1-t(o,i,c),x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(U[f]),_.push(Y[f]),_.push(Z[f])):39===f?(4===d?(N=1-t(o,i,c),x=t(o,b,c),C=t(o,b,n),j=t(h,b,n),m=1-t(h,i,n),v=1-t(o,i,n)):(N=t(h,c,i),x=1-t(h,c,b),C=1-t(h,n,b),j=1-t(o,n,b),m=t(o,n,i),v=t(h,n,i)),_.push(U[f]),_.push(W[f]),_.push(Z[f])):85===f&&(w=1,N=0,x=1,k=0,C=0,j=1,m=0,v=1),(m<0||m>1||v<0||v>1||w<0||w>1||x<0||x>1||C<0||C>1||j<0||j>1)&&console.log(f+" "+g+" "+n+","+i+","+c+","+b+" "+d+" "+m+" "+v+" "+w+" "+N+" "+x+" "+k+" "+C+" "+j),u.cells[l][a]={cval:f,cval_real:g,flipped:d,topleft:m,topright:v,righttop:w,rightbottom:N,bottomright:x,bottomleft:k,leftbottom:C,lefttop:j,edges:_}}}}}return u},oe=function(e,t,o){for(var s={type:"FeatureCollection",features:[]},r=0;r<o.length;r++){var p=o[r],u=se(e,t,p);s.features.push({type:"Feature",geometry:{type:"MultiLineString",coordinates:u},properties:[{value:p}]})}return s},se=function(e,t,o){if(typeof t!=typeof new Array||6!=t.length)throw new Error("GeoTransform must be a 6 elements array");for(var s=pe(e,o),r=0;r<s.length;r++)for(var p=0;p<s[r].length;p++){var u=re(s[r][p][0],s[r][p][1],t);s[r][p][0]=u[0],s[r][p][1]=u[1]}return s},re=function(e,t,o){var s=o[0]+e*o[1]+t*o[2],r=o[3]+e*o[4]+t*o[5];return[s,r]},pe=function(e,t,o){var s={successCallback:null,progressCallback:null,verbose:!1},r={};o=o?o:{};for(var p=Object.keys(s),u=0;u<p.length;u++){var h=p[u],a=o[h];a="undefined"!=typeof a&&null!==a?a:s[h],r[h]=a}r.verbose&&console.log("computing isocontour for "+t);var f=c(l(e,t));return"function"==typeof r.successCallback&&r.successCallback(f),f};e.isoband=m,e.projectedIsoband=d,e.isobands=g,e.isoline=pe,e.projectedIsoline=se,e.isolines=oe,Object.defineProperty(e,"__esModule",{value:!0})});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment