Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

geotiff

Package Overview
Dependencies
Maintainers
3
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geotiff - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

6

dist-node/geotiff.js
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"j27V":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.geoKeys=exports.geoKeyNames=exports.LercAddCompression=exports.LercParameters=exports.ExtraSamplesValues=exports.photometricInterpretations=exports.fieldTypes=exports.fieldTypeNames=exports.arrayFields=exports.fieldTagTypes=exports.fieldTags=exports.fieldTagNames=void 0;const 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",50674:"LercParameters"};exports.fieldTagNames=e;const o={};exports.fieldTags=o;for(const S in e)e.hasOwnProperty(S)&&(o[e[S]]=parseInt(S,10));const t={256:"SHORT",257:"SHORT",258:"SHORT",259:"SHORT",262:"SHORT",273:"LONG",274:"SHORT",277:"SHORT",278:"LONG",279:"LONG",282:"RATIONAL",283:"RATIONAL",284:"SHORT",286:"SHORT",287:"RATIONAL",296:"SHORT",305:"ASCII",306:"ASCII",338:"SHORT",339:"SHORT",513:"LONG",514:"LONG",1024:"SHORT",1025:"SHORT",2048:"SHORT",2049:"ASCII",33550:"DOUBLE",33922:"DOUBLE",34665:"LONG",34735:"SHORT",34737:"ASCII",42113:"ASCII"};exports.fieldTagTypes=t;const r=[o.BitsPerSample,o.ExtraSamples,o.SampleFormat,o.StripByteCounts,o.StripOffsets,o.StripRowCounts,o.TileByteCounts,o.TileOffsets,o.SubIFDs];exports.arrayFields=r;const i={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"};exports.fieldTypeNames=i;const s={};exports.fieldTypes=s;for(const S in i)i.hasOwnProperty(S)&&(s[i[S]]=parseInt(S,10));const a={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9};exports.photometricInterpretations=a;const n={Unspecified:0,Assocalpha:1,Unassalpha:2};exports.ExtraSamplesValues=n;const l={Version:0,AddCompression:1};exports.LercParameters=l;const p={None:0,Deflate:1};exports.LercAddCompression=p;const G={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"};exports.geoKeyNames=G;const y={};exports.geoKeys=y;for(const S in G)G.hasOwnProperty(S)&&(y[G[S]]=parseInt(S,10));
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.geoKeys=exports.geoKeyNames=exports.LercAddCompression=exports.LercParameters=exports.ExtraSamplesValues=exports.photometricInterpretations=exports.fieldTypes=exports.fieldTypeNames=exports.arrayFields=exports.fieldTagTypes=exports.fieldTags=exports.fieldTagNames=void 0;const 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",50674:"LercParameters"};exports.fieldTagNames=e;const o={};exports.fieldTags=o;for(const S in e)e.hasOwnProperty(S)&&(o[e[S]]=parseInt(S,10));const t={256:"SHORT",257:"SHORT",258:"SHORT",259:"SHORT",262:"SHORT",273:"LONG",274:"SHORT",277:"SHORT",278:"LONG",279:"LONG",282:"RATIONAL",283:"RATIONAL",284:"SHORT",286:"SHORT",287:"RATIONAL",296:"SHORT",297:"SHORT",305:"ASCII",306:"ASCII",338:"SHORT",339:"SHORT",513:"LONG",514:"LONG",1024:"SHORT",1025:"SHORT",2048:"SHORT",2049:"ASCII",3072:"SHORT",3073:"ASCII",33550:"DOUBLE",33922:"DOUBLE",34665:"LONG",34735:"SHORT",34737:"ASCII",42113:"ASCII"};exports.fieldTagTypes=t;const r=[o.BitsPerSample,o.ExtraSamples,o.SampleFormat,o.StripByteCounts,o.StripOffsets,o.StripRowCounts,o.TileByteCounts,o.TileOffsets,o.SubIFDs];exports.arrayFields=r;const i={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"};exports.fieldTypeNames=i;const s={};exports.fieldTypes=s;for(const S in i)i.hasOwnProperty(S)&&(s[i[S]]=parseInt(S,10));const a={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9};exports.photometricInterpretations=a;const n={Unspecified:0,Assocalpha:1,Unassalpha:2};exports.ExtraSamplesValues=n;const l={Version:0,AddCompression:1};exports.LercParameters=l;const p={None:0,Deflate:1};exports.LercAddCompression=p;const G={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"};exports.geoKeyNames=G;const y={};exports.geoKeys=y;for(const S in G)G.hasOwnProperty(S)&&(y[G[S]]=parseInt(S,10));
},{}],"fpBl":[function(require,module,exports) {

@@ -28,3 +28,3 @@ "use strict";function t(t,e){const{width:n,height:r}=t,o=new Uint8Array(n*r*3);let h;for(let i=0,l=0;i<t.length;++i,l+=3)h=256-t[i]/e*256,o[l]=h,o[l+1]=h,o[l+2]=h;return o}function e(t,e){const{width:n,height:r}=t,o=new Uint8Array(n*r*3);let h;for(let i=0,l=0;i<t.length;++i,l+=3)h=t[i]/e*256,o[l]=h,o[l+1]=h,o[l+2]=h;return o}function n(t,e){const{width:n,height:r}=t,o=new Uint8Array(n*r*3),h=e.length/3,i=e.length/3*2;for(let l=0,s=0;l<t.length;++l,s+=3){const n=t[l];o[s]=e[n]/65536*256,o[s+1]=e[n+h]/65536*256,o[s+2]=e[n+i]/65536*256}return o}function r(t){const{width:e,height:n}=t,r=new Uint8Array(e*n*3);for(let o=0,h=0;o<t.length;o+=4,h+=3){const e=t[o],n=t[o+1],i=t[o+2],l=t[o+3];r[h]=(255-e)/256*255*((255-l)/256),r[h+1]=(255-n)/256*255*((255-l)/256),r[h+2]=(255-i)/256*255*((255-l)/256)}return r}function o(t){const{width:e,height:n}=t,r=new Uint8ClampedArray(e*n*3);for(let o=0,h=0;o<t.length;o+=3,h+=3){const e=t[o],n=t[o+1],i=t[o+2];r[h]=e+1.402*(i-128),r[h+1]=e-.34414*(n-128)-.71414*(i-128),r[h+2]=e+1.772*(n-128)}return r}Object.defineProperty(exports,"__esModule",{value:!0}),exports.fromWhiteIsZero=t,exports.fromBlackIsZero=e,exports.fromPalette=n,exports.fromCMYK=r,exports.fromYCbCr=o,exports.fromCIELab=s;const h=.95047,i=1,l=1.08883;function s(t){const{width:e,height:n}=t,r=new Uint8Array(e*n*3);for(let o=0,s=0;o<t.length;o+=3,s+=3){let e,n,a,c=(t[o+0]+16)/116,f=(t[o+1]<<24>>24)/500+c,u=c-(t[o+2]<<24>>24)/200;e=(e=3.2406*(f=h*(f*f*f>.008856?f*f*f:(f-16/116)/7.787))+-1.5372*(c=i*(c*c*c>.008856?c*c*c:(c-16/116)/7.787))+-.4986*(u=l*(u*u*u>.008856?u*u*u:(u-16/116)/7.787)))>.0031308?1.055*e**(1/2.4)-.055:12.92*e,n=(n=-.9689*f+1.8758*c+.0415*u)>.0031308?1.055*n**(1/2.4)-.055:12.92*n,a=(a=.0557*f+-.204*c+1.057*u)>.0031308?1.055*a**(1/2.4)-.055:12.92*a,r[s]=255*Math.max(0,Math.min(1,e)),r[s+1]=255*Math.max(0,Math.min(1,n)),r[s+2]=255*Math.max(0,Math.min(1,a))}return r}

},{}],"xD7g":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlockedSource=void 0;var t=o(require("lru-cache")),e=require("./basesource"),s=require("../utils");function o(t){return t&&t.__esModule?t:{default:t}}class c{constructor(t,e,s=null){this.offset=t,this.length=e,this.data=s}get top(){return this.offset+this.length}}class r{constructor(t,e,s){this.offset=t,this.length=e,this.blockIds=s}}class i extends e.BaseSource{constructor(e,{blockSize:s=65536,cacheSize:o=100}={}){super(),this.source=e,this.blockSize=s,this.blockCache=new t.default({max:o}),this.blockRequests=new Map,this.blockIdsToFetch=new Set}get fileSize(){return this.source.fileSize}async fetch(t,e){const o=new Map,c=new Map,r=new Set;for(const{offset:s,length:n}of t){let t=s+n;const{fileSize:e}=this;null!==e&&(t=Math.min(t,e));for(let i=Math.floor(s/this.blockSize)*this.blockSize;i<t;i+=this.blockSize){const t=Math.floor(i/this.blockSize);this.blockCache.has(t)?o.set(t,this.blockCache.get(t)):this.blockRequests.has(t)?c.set(t,this.blockRequests.get(t)):this.blockIdsToFetch.has(t)?r.add(t):(this.blockIdsToFetch.add(t),r.add(t))}}await(0,s.wait)(),this.fetchBlocks(e);for(const s of r){const t=this.blockRequests.get(s),e=this.blockCache.get(s);if(t)c.set(s,t);else{if(!e)throw new Error(`Block ${s} is not in the block requests`);o.set(s,e)}}let i=await Promise.allSettled(c.values());if(i.some(t=>"rejected"===t.status)){const t=new Set;for(const[o,r]of(0,s.zip)(c.keys(),i)){const{rejected:s,reason:c}=r;s&&"AbortError"===c.name&&c.signal!==e&&(this.blockIdsToFetch.add(o),t.add(o))}if(this.blockIdsToFetch.length>0){this.fetchBlocks(e);for(const e of t){const t=this.blockRequests.get(e);if(!t)throw new Error(`Block ${e} is not in the block requests`);c.set(e,t)}i=await Promise.allSettled(Array.from(c.values()))}}if(i.some(t=>"rejected"===t.status)){if(e&&e.aborted)throw new s.AbortError("Request was aborted");throw new s.AggregateError(i.filter(t=>"rejected"===t.status).map(t=>t.reason),"Request failed")}const l=i.map(t=>t.value),h=new Map((0,s.zip)(Array.from(c.keys()),l));for(const[s,n]of o)h.set(s,n);return this.readSliceData(t,h)}fetchBlocks(t){if(this.blockIdsToFetch.size>0){const e=this.groupBlocks(this.blockIdsToFetch),s=this.source.fetch(e,t);for(let o=0;o<e.length;++o){const r=e[o];for(const e of r.blockIds){const r=(async()=>{try{const i=(await s)[o],l=e*this.blockSize,h=l-i.offset,n=Math.min(h+this.blockSize,i.data.byteLength),a=i.data.slice(h,n),f=new c(l,a.byteLength,a);return this.blockCache.set(e,f),f}catch(r){throw"AbortError"===r.name&&(r.signal=t),r}finally{this.blockRequests.delete(e)}})();this.blockRequests.set(e,r)}}this.blockIdsToFetch.clear()}}groupBlocks(t){const e=Array.from(t).sort((t,e)=>t-e);if(0===e.length)return[];let s=[],o=null;const c=[];for(const i of e)null===o||o+1===i?(s.push(i),o=i):(c.push(new r(s[0]*this.blockSize,s.length*this.blockSize,s)),s=[i],o=i);return c.push(new r(s[0]*this.blockSize,s.length*this.blockSize,s)),c}readSliceData(t,e){return t.map(t=>{const s=t.offset+t.length,o=Math.floor(t.offset/this.blockSize),c=Math.floor((t.offset+t.length)/this.blockSize),r=new ArrayBuffer(t.length),i=new Uint8Array(r);for(let l=o;l<=c;++l){const o=e.get(l),c=o.offset-t.offset,r=o.top-s;let h,n=0,a=0;c<0?n=-c:c>0&&(a=c),h=r<0?o.length-n:s-o.offset-n;const f=new Uint8Array(o.data,n,h);i.set(f,a)}return r})}}exports.BlockedSource=i;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlockedSource=void 0;var t=o(require("lru-cache")),e=require("./basesource"),s=require("../utils");function o(t){return t&&t.__esModule?t:{default:t}}class r{constructor(t,e,s=null){this.offset=t,this.length=e,this.data=s}get top(){return this.offset+this.length}}class c{constructor(t,e,s){this.offset=t,this.length=e,this.blockIds=s}}class i extends e.BaseSource{constructor(e,{blockSize:s=65536,cacheSize:o=100}={}){super(),this.source=e,this.blockSize=s,this.blockCache=new t.default({max:o}),this.blockRequests=new Map,this.blockIdsToFetch=new Set}get fileSize(){return this.source.fileSize}async fetch(t,e){const o=new Map,r=new Map,c=new Set;for(const{offset:s,length:n}of t){let t=s+n;const{fileSize:e}=this;null!==e&&(t=Math.min(t,e));for(let i=Math.floor(s/this.blockSize)*this.blockSize;i<t;i+=this.blockSize){const t=Math.floor(i/this.blockSize);this.blockCache.has(t)?o.set(t,this.blockCache.get(t)):this.blockRequests.has(t)?r.set(t,this.blockRequests.get(t)):this.blockIdsToFetch.has(t)?c.add(t):(this.blockIdsToFetch.add(t),c.add(t))}}await(0,s.wait)(),this.fetchBlocks(e);for(const s of c){const t=this.blockRequests.get(s),e=this.blockCache.get(s);if(t)r.set(s,t);else{if(!e)throw new Error(`Block ${s} is not in the block requests`);o.set(s,e)}}let i=await Promise.allSettled(Array.from(r.values()));if(i.some(t=>"rejected"===t.status)){const t=new Set;for(const[o,c]of(0,s.zip)(r.keys(),i)){const{rejected:s,reason:r}=c;s&&"AbortError"===r.name&&r.signal!==e&&(this.blockIdsToFetch.add(o),t.add(o))}if(this.blockIdsToFetch.length>0){this.fetchBlocks(e);for(const e of t){const t=this.blockRequests.get(e);if(!t)throw new Error(`Block ${e} is not in the block requests`);r.set(e,t)}i=await Promise.allSettled(Array.from(r.values()))}}if(i.some(t=>"rejected"===t.status)){if(e&&e.aborted)throw new s.AbortError("Request was aborted");throw new s.AggregateError(i.filter(t=>"rejected"===t.status).map(t=>t.reason),"Request failed")}const l=i.map(t=>t.value),h=new Map((0,s.zip)(Array.from(r.keys()),l));for(const[s,n]of o)h.set(s,n);return this.readSliceData(t,h)}fetchBlocks(t){if(this.blockIdsToFetch.size>0){const e=this.groupBlocks(this.blockIdsToFetch),s=this.source.fetch(e,t);for(let o=0;o<e.length;++o){const c=e[o];for(const e of c.blockIds){const c=(async()=>{try{const i=(await s)[o],l=e*this.blockSize,h=l-i.offset,n=Math.min(h+this.blockSize,i.data.byteLength),a=i.data.slice(h,n),f=new r(l,a.byteLength,a);return this.blockCache.set(e,f),f}catch(c){throw"AbortError"===c.name&&(c.signal=t),c}finally{this.blockRequests.delete(e)}})();this.blockRequests.set(e,c)}}this.blockIdsToFetch.clear()}}groupBlocks(t){const e=Array.from(t).sort((t,e)=>t-e);if(0===e.length)return[];let s=[],o=null;const r=[];for(const i of e)null===o||o+1===i?(s.push(i),o=i):(r.push(new c(s[0]*this.blockSize,s.length*this.blockSize,s)),s=[i],o=i);return r.push(new c(s[0]*this.blockSize,s.length*this.blockSize,s)),r}readSliceData(t,e){return t.map(t=>{const s=t.offset+t.length,o=Math.floor(t.offset/this.blockSize),r=Math.floor((t.offset+t.length)/this.blockSize),c=new ArrayBuffer(t.length),i=new Uint8Array(c);for(let l=o;l<=r;++l){const o=e.get(l),r=o.offset-t.offset,c=o.top-s;let h,n=0,a=0;r<0?n=-r:r>0&&(a=r),h=c<0?o.length-n:s-o.offset-n;const f=new Uint8Array(o.data,n,h);i.set(f,a)}return c})}}exports.BlockedSource=i;
},{"./basesource":"LzCD","../utils":"FOZT"}],"uL1U":[function(require,module,exports) {

@@ -47,3 +47,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseClient=exports.BaseResponse=void 0;class e{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(e){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}}exports.BaseResponse=e;class t{constructor(e){this.url=e}async request({headers:e,credentials:t,signal:s}={}){throw new Error("request is not implemented")}}exports.BaseClient=t;

},{"./basesource":"LzCD"}],"BGyE":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeGeotiff=p;var e=require("./globals"),t=require("./utils");const r=(0,t.invert)(e.fieldTagNames),o=(0,t.invert)(e.geoKeyNames),i={};(0,t.assign)(i,r),(0,t.assign)(i,o);const n=(0,t.invert)(e.fieldTypeNames),s=1e3,a={nextZero:(e,t)=>{let r=t;for(;0!==e[r];)r++;return r},readUshort:(e,t)=>e[t]<<8|e[t+1],readShort:(e,t)=>{const r=a.ui8;return r[0]=e[t+1],r[1]=e[t+0],a.i16[0]},readInt:(e,t)=>{const r=a.ui8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t+0],a.i32[0]},readUint:(e,t)=>{const r=a.ui8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t+0],a.ui32[0]},readASCII:(e,t,r)=>r.map(r=>String.fromCharCode(e[t+r])).join(""),readFloat:(e,r)=>{const o=a.ui8;return(0,t.times)(4,t=>{o[t]=e[r+3-t]}),a.fl32[0]},readDouble:(e,r)=>{const o=a.ui8;return(0,t.times)(8,t=>{o[t]=e[r+7-t]}),a.fl64[0]},writeUshort:(e,t,r)=>{e[t]=r>>8&255,e[t+1]=255&r},writeUint:(e,t,r)=>{e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r>>0&255},writeASCII:(e,r,o)=>{(0,t.times)(o.length,t=>{e[r+t]=o.charCodeAt(t)})},ui8:new Uint8Array(8)};a.fl64=new Float64Array(a.ui8.buffer),a.writeDouble=((e,r,o)=>{a.fl64[0]=o,(0,t.times)(8,t=>{e[r+t]=a.ui8[7-t]})});const l=(r,o,i,s)=>{let a=i;const l=Object.keys(s).filter(e=>null!=e&&"undefined"!==e);r.writeUshort(o,a,l.length);let f=(a+=2)+12*l.length+4;for(const u of l){let i=null;"number"==typeof u?i=u:"string"==typeof u&&(i=parseInt(u,10));const l=e.fieldTagTypes[i],c=n[l];if(null==l||void 0===l||void 0===l)throw new Error(`unknown type of tag: ${i}`);let h=s[u];if(void 0===h)throw new Error(`failed to get value for key ${u}`);"ASCII"===l&&"string"==typeof h&&!1===(0,t.endsWith)(h,"\0")&&(h+="\0");const m=h.length;r.writeUshort(o,a,i),a+=2,r.writeUshort(o,a,c),a+=2,r.writeUint(o,a,m);let p=[-1,1,1,2,4,8,0,0,0,0,0,0,8][c]*m,y=a+=4;p>4&&(r.writeUint(o,a,f),y=f),"ASCII"===l?r.writeASCII(o,y,h):"SHORT"===l?(0,t.times)(m,e=>{r.writeUshort(o,y+2*e,h[e])}):"LONG"===l?(0,t.times)(m,e=>{r.writeUint(o,y+4*e,h[e])}):"RATIONAL"===l?(0,t.times)(m,e=>{r.writeUint(o,y+8*e,Math.round(1e4*h[e])),r.writeUint(o,y+8*e+4,1e4)}):"DOUBLE"===l&&(0,t.times)(m,e=>{r.writeDouble(o,y+8*e,h[e])}),p>4&&(f+=p+=1&p),a+=4}return[a,f]},f=e=>{const t=new Uint8Array(1e3);let r=4;const o=a;t[0]=77,t[1]=77,t[3]=42;let i=8;if(o.writeUint(t,r,i),r+=4,e.forEach((r,n)=>{const s=l(o,t,i,r);i=s[1],n<e.length-1&&o.writeUint(t,s[0],i)}),t.slice)return t.slice(0,i).buffer;const n=new Uint8Array(i);for(let s=0;s<i;s++)n[s]=t[s];return n.buffer},u=(e,r,o,i)=>{if(null==o)throw new Error(`you passed into encodeImage a width of type ${o}`);if(null==r)throw new Error(`you passed into encodeImage a width of type ${r}`);const n={256:[r],257:[o],273:[1e3],278:[o],305:"geotiff.js"};if(i)for(const t in i)i.hasOwnProperty(t)&&(n[t]=i[t]);const s=new Uint8Array(f([n])),a=new Uint8Array(e),l=n[277],u=new Uint8Array(1e3+r*o*l);return(0,t.times)(s.length,e=>{u[e]=s[e]}),(0,t.forEach)(a,(e,t)=>{u[1e3+t]=e}),u.buffer},c=e=>{const t={};for(const r in e)"StripOffsets"!==r&&(i[r]||console.error(r,"not in name2code:",Object.keys(i)),t[i[r]]=e[r]);return t},h=e=>Array.isArray(e)?e:[e],m=[["Compression",1],["PlanarConfiguration",1],["XPosition",0],["YPosition",0],["ResolutionUnit",1],["ExtraSamples",0],["GeoAsciiParams","WGS 84\0"],["ModelTiepoint",[0,0,0,-180,90,0]],["GTModelTypeGeoKey",2],["GTRasterTypeGeoKey",1],["GeographicTypeGeoKey",4326],["GeogCitationGeoKey","WGS 84"]];function p(r,o){let n,s,a,l;"number"==typeof r[0]?(n=o.height||o.ImageLength,a=o.width||o.ImageWidth,s=r.length/(n*a),l=r):(s=r.length,n=r[0].length,a=r[0][0].length,l=[],(0,t.times)(n,e=>{(0,t.times)(a,o=>{(0,t.times)(s,t=>{l.push(r[t][e][o])})})})),o.ImageLength=n,delete o.height,o.ImageWidth=a,delete o.width,o.BitsPerSample||(o.BitsPerSample=(0,t.times)(s,()=>8)),m.forEach(e=>{const t=e[0];if(!o[t]){const r=e[1];o[t]=r}}),o.PhotometricInterpretation||(o.PhotometricInterpretation=3===o.BitsPerSample.length?2:1),o.SamplesPerPixel||(o.SamplesPerPixel=[s]),o.StripByteCounts||(o.StripByteCounts=[s*n*a]),o.ModelPixelScale||(o.ModelPixelScale=[360/a,180/n,0]),o.SampleFormat||(o.SampleFormat=(0,t.times)(s,()=>1));const f=Object.keys(o).filter(e=>(0,t.endsWith)(e,"GeoKey")).sort((e,t)=>i[e]-i[t]);if(!o.GeoKeyDirectory){const t=[1,1,0,f.length];f.forEach(r=>{const n=Number(i[r]);let s,a,l;t.push(n),"SHORT"===e.fieldTagTypes[n]?(s=1,a=0,l=o[r]):"GeogCitationGeoKey"===r?(s=o.GeoAsciiParams.length,a=Number(i.GeoAsciiParams),l=0):console.log(`[geotiff.js] couldn't get TIFFTagLocation for ${r}`),t.push(a),t.push(s),t.push(l)}),o.GeoKeyDirectory=t}for(const e in f)f.hasOwnProperty(e)&&delete o[e];["Compression","ExtraSamples","GeographicTypeGeoKey","GTModelTypeGeoKey","GTRasterTypeGeoKey","ImageLength","ImageWidth","PhotometricInterpretation","PlanarConfiguration","ResolutionUnit","SamplesPerPixel","XPosition","YPosition"].forEach(e=>{o[e]&&(o[e]=h(o[e]))});const p=c(o);return u(l,a,n,p)}
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.writeGeotiff=y;var e=require("./globals"),t=require("./utils");const r=(0,t.invert)(e.fieldTagNames),o=(0,t.invert)(e.geoKeyNames),i={};(0,t.assign)(i,r),(0,t.assign)(i,o);const n=(0,t.invert)(e.fieldTypeNames),s=1e3,a={nextZero:(e,t)=>{let r=t;for(;0!==e[r];)r++;return r},readUshort:(e,t)=>e[t]<<8|e[t+1],readShort:(e,t)=>{const r=a.ui8;return r[0]=e[t+1],r[1]=e[t+0],a.i16[0]},readInt:(e,t)=>{const r=a.ui8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t+0],a.i32[0]},readUint:(e,t)=>{const r=a.ui8;return r[0]=e[t+3],r[1]=e[t+2],r[2]=e[t+1],r[3]=e[t+0],a.ui32[0]},readASCII:(e,t,r)=>r.map(r=>String.fromCharCode(e[t+r])).join(""),readFloat:(e,r)=>{const o=a.ui8;return(0,t.times)(4,t=>{o[t]=e[r+3-t]}),a.fl32[0]},readDouble:(e,r)=>{const o=a.ui8;return(0,t.times)(8,t=>{o[t]=e[r+7-t]}),a.fl64[0]},writeUshort:(e,t,r)=>{e[t]=r>>8&255,e[t+1]=255&r},writeUint:(e,t,r)=>{e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=r>>0&255},writeASCII:(e,r,o)=>{(0,t.times)(o.length,t=>{e[r+t]=o.charCodeAt(t)})},ui8:new Uint8Array(8)};a.fl64=new Float64Array(a.ui8.buffer),a.writeDouble=((e,r,o)=>{a.fl64[0]=o,(0,t.times)(8,t=>{e[r+t]=a.ui8[7-t]})});const l=(r,o,i,s)=>{let a=i;const l=Object.keys(s).filter(e=>null!=e&&"undefined"!==e);r.writeUshort(o,a,l.length);let c=(a+=2)+12*l.length+4;for(const f of l){let i=null;"number"==typeof f?i=f:"string"==typeof f&&(i=parseInt(f,10));const l=e.fieldTagTypes[i],h=n[l];if(null==l||void 0===l||void 0===l)throw new Error(`unknown type of tag: ${i}`);let u=s[f];if(void 0===u)throw new Error(`failed to get value for key ${f}`);"ASCII"===l&&"string"==typeof u&&!1===(0,t.endsWith)(u,"\0")&&(u+="\0");const p=u.length;r.writeUshort(o,a,i),a+=2,r.writeUshort(o,a,h),a+=2,r.writeUint(o,a,p);let y=[-1,1,1,2,4,8,0,0,0,0,0,0,8][h]*p,m=a+=4;y>4&&(r.writeUint(o,a,c),m=c),"ASCII"===l?r.writeASCII(o,m,u):"SHORT"===l?(0,t.times)(p,e=>{r.writeUshort(o,m+2*e,u[e])}):"LONG"===l?(0,t.times)(p,e=>{r.writeUint(o,m+4*e,u[e])}):"RATIONAL"===l?(0,t.times)(p,e=>{r.writeUint(o,m+8*e,Math.round(1e4*u[e])),r.writeUint(o,m+8*e+4,1e4)}):"DOUBLE"===l&&(0,t.times)(p,e=>{r.writeDouble(o,m+8*e,u[e])}),y>4&&(c+=y+=1&y),a+=4}return[a,c]},c=e=>{const t=new Uint8Array(1e3);let r=4;const o=a;t[0]=77,t[1]=77,t[3]=42;let i=8;if(o.writeUint(t,r,i),r+=4,e.forEach((r,n)=>{const s=l(o,t,i,r);i=s[1],n<e.length-1&&o.writeUint(t,s[0],i)}),t.slice)return t.slice(0,i).buffer;const n=new Uint8Array(i);for(let s=0;s<i;s++)n[s]=t[s];return n.buffer},f=(e,r,o,i)=>{if(null==o)throw new Error(`you passed into encodeImage a width of type ${o}`);if(null==r)throw new Error(`you passed into encodeImage a width of type ${r}`);const n={256:[r],257:[o],273:[1e3],278:[o],305:"geotiff.js"};if(i)for(const t in i)i.hasOwnProperty(t)&&(n[t]=i[t]);const s=new Uint8Array(c([n])),a=new Uint8Array(e),l=n[277],f=new Uint8Array(1e3+r*o*l);return(0,t.times)(s.length,e=>{f[e]=s[e]}),(0,t.forEach)(a,(e,t)=>{f[1e3+t]=e}),f.buffer},h=e=>{const t={};for(const r in e)"StripOffsets"!==r&&(i[r]||console.error(r,"not in name2code:",Object.keys(i)),t[i[r]]=e[r]);return t},u=e=>Array.isArray(e)?e:[e],p=[["Compression",1],["PlanarConfiguration",1],["ExtraSamples",0]];function y(r,o){let n,s,a,l;"number"==typeof r[0]?(n=o.height||o.ImageLength,a=o.width||o.ImageWidth,s=r.length/(n*a),l=r):(s=r.length,n=r[0].length,a=r[0][0].length,l=[],(0,t.times)(n,e=>{(0,t.times)(a,o=>{(0,t.times)(s,t=>{l.push(r[t][e][o])})})})),o.ImageLength=n,delete o.height,o.ImageWidth=a,delete o.width,o.BitsPerSample||(o.BitsPerSample=(0,t.times)(s,()=>8)),p.forEach(e=>{const t=e[0];if(!o[t]){const r=e[1];o[t]=r}}),o.PhotometricInterpretation||(o.PhotometricInterpretation=3===o.BitsPerSample.length?2:1),o.SamplesPerPixel||(o.SamplesPerPixel=[s]),o.StripByteCounts||(o.StripByteCounts=[s*n*a]),o.ModelPixelScale||(o.ModelPixelScale=[360/a,180/n,0]),o.SampleFormat||(o.SampleFormat=(0,t.times)(s,()=>1)),o.hasOwnProperty("GeographicTypeGeoKey")||o.hasOwnProperty("ProjectedCSTypeGeoKey")||(o.GeographicTypeGeoKey=4326,o.ModelTiepoint=[0,0,0,-180,90,0],o.GeogCitationGeoKey="WGS 84",o.GTModelTypeGeoKey=2);const c=Object.keys(o).filter(e=>(0,t.endsWith)(e,"GeoKey")).sort((e,t)=>i[e]-i[t]);if(!o.GeoAsciiParams){let t="";c.forEach(r=>{const n=Number(i[r]);"ASCII"===e.fieldTagTypes[n]&&(t+=`${o[r].toString()}\0`)}),t.length>0&&(o.GeoAsciiParams=t)}if(!o.GeoKeyDirectory){const t=[1,1,0,c.length];c.forEach(r=>{const n=Number(i[r]);let s,a,l;t.push(n),"SHORT"===e.fieldTagTypes[n]?(s=1,a=0,l=o[r]):"GeogCitationGeoKey"===r?(s=o.GeoAsciiParams.length,a=Number(i.GeoAsciiParams),l=0):console.log(`[geotiff.js] couldn't get TIFFTagLocation for ${r}`),t.push(a),t.push(s),t.push(l)}),o.GeoKeyDirectory=t}for(const e in c)c.hasOwnProperty(e)&&delete o[e];["Compression","ExtraSamples","GeographicTypeGeoKey","GTModelTypeGeoKey","GTRasterTypeGeoKey","ImageLength","ImageWidth","Orientation","PhotometricInterpretation","ProjectedCSTypeGeoKey","PlanarConfiguration","ResolutionUnit","SamplesPerPixel","XPosition","YPosition"].forEach(e=>{o[e]&&(o[e]=u(o[e]))});const y=h(o);return f(l,a,n,y)}
},{"./globals":"j27V","./utils":"FOZT"}],"dy4f":[function(require,module,exports) {

@@ -50,0 +50,0 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setLogger=t,exports.debug=n,exports.log=o,exports.info=u,exports.warn=i,exports.error=s,exports.time=f,exports.timeEnd=c;class e{log(){}debug(){}info(){}warn(){}error(){}time(){}timeEnd(){}}let r=new e;function t(t=new e){r=t}function n(...e){return r.debug(...e)}function o(...e){return r.log(...e)}function u(...e){return r.info(...e)}function i(...e){return r.warn(...e)}function s(...e){return r.error(...e)}function f(...e){return r.time(...e)}function c(...e){return r.timeEnd(...e)}

{
"name": "geotiff",
"version": "1.0.8",
"version": "1.0.9",
"description": "GeoTIFF image decoding in JavaScript",

@@ -5,0 +5,0 @@ "repository": "https://github.com/geotiffjs/geotiff.js",

@@ -126,3 +126,3 @@ /*

if (typeof val === 'undefined') {
if (val === undefined) {
throw new Error(`failed to get value for key ${key}`);

@@ -294,12 +294,3 @@ }

['PlanarConfiguration', 1],
['XPosition', 0],
['YPosition', 0],
['ResolutionUnit', 1], // Code 1 for actual pixel count or 2 for pixels per inch.
['ExtraSamples', 0], // should this be an array??
['GeoAsciiParams', 'WGS 84\u0000'],
['ModelTiepoint', [0, 0, 0, -180, 90, 0]], // raster fits whole globe
['GTModelTypeGeoKey', 2],
['GTRasterTypeGeoKey', 1],
['GeographicTypeGeoKey', 4326],
['GeogCitationGeoKey', 'WGS 84'],
['ExtraSamples', 0],
];

@@ -378,2 +369,10 @@

// if didn't pass in projection information, assume the popular 4326 "geographic projection"
if (!metadata.hasOwnProperty('GeographicTypeGeoKey') && !metadata.hasOwnProperty('ProjectedCSTypeGeoKey')) {
metadata.GeographicTypeGeoKey = 4326;
metadata.ModelTiepoint = [0, 0, 0, -180, 90, 0]; // raster fits whole globe
metadata.GeogCitationGeoKey = 'WGS 84';
metadata.GTModelTypeGeoKey = 2;
}
const geoKeys = Object.keys(metadata)

@@ -383,2 +382,16 @@ .filter((key) => endsWith(key, 'GeoKey'))

if (!metadata.GeoAsciiParams) {
let geoAsciiParams = '';
geoKeys.forEach((name) => {
const code = Number(name2code[name]);
const tagType = fieldTagTypes[code];
if (tagType === 'ASCII') {
geoAsciiParams += `${metadata[name].toString()}\u0000`;
}
});
if (geoAsciiParams.length > 0) {
metadata.GeoAsciiParams = geoAsciiParams;
}
}
if (!metadata.GeoKeyDirectory) {

@@ -428,3 +441,5 @@ const NumberOfKeys = geoKeys.length;

'ImageWidth',
'Orientation',
'PhotometricInterpretation',
'ProjectedCSTypeGeoKey',
'PlanarConfiguration',

@@ -431,0 +446,0 @@ 'ResolutionUnit',

@@ -148,2 +148,3 @@ export const fieldTagNames = {

296: 'SHORT',
297: 'SHORT',
305: 'ASCII',

@@ -159,2 +160,4 @@ 306: 'ASCII',

2049: 'ASCII',
3072: 'SHORT',
3073: 'ASCII',
33550: 'DOUBLE',

@@ -161,0 +164,0 @@ 33922: 'DOUBLE',

@@ -119,3 +119,3 @@ import LRUCache from 'lru-cache';

// actually await all pending requests
let results = await Promise.allSettled(blockRequests.values());
let results = await Promise.allSettled(Array.from(blockRequests.values()));

@@ -122,0 +122,0 @@ // perform retries if a block was interrupted by a previous signal

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc