mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
v3.5.0
This commit is contained in:
parent
606c499143
commit
0b9c04a850
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,8 +1,17 @@
|
|||||||
# offline-editor-js - Changelog
|
# offline-editor-js - Changelog
|
||||||
|
|
||||||
|
## Version 3.5.0 - September 15, 2016
|
||||||
|
|
||||||
|
Possible breaking changes. Changes to database storage pattern.
|
||||||
|
|
||||||
|
**Enhancements**
|
||||||
|
* Added compression to the tiles database URL field, resulting in approximately 50% reduction in that field's size. This will make the largest difference when storing thousands of tiles.
|
||||||
|
* Closes #482 - clarify tile reporting in simple-tiles.html sample app.
|
||||||
|
* Minor doc updates.
|
||||||
|
|
||||||
## Version 3.4.0 - September 13, 2016
|
## Version 3.4.0 - September 13, 2016
|
||||||
|
|
||||||
Possible breaking changes.
|
Possible breaking changes. Changes to database storage pattern.
|
||||||
|
|
||||||
**Enhancements**
|
**Enhancements**
|
||||||
* Added base64 re-encoding to the tile database that results in a 2.7x (16/6) reduction in storage size.
|
* Added base64 re-encoding to the tile database that results in a 2.7x (16/6) reduction in storage size.
|
||||||
|
|||||||
2
dist/offline-edit-advanced-src.js
vendored
2
dist/offline-edit-advanced-src.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! esri-offline-maps - v3.4.0 - 2016-09-13
|
/*! esri-offline-maps - v3.5.0 - 2016-09-15
|
||||||
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
||||||
* Apache License*/
|
* Apache License*/
|
||||||
// Configure offline/online detection
|
// Configure offline/online detection
|
||||||
|
|||||||
2
dist/offline-edit-basic-src.js
vendored
2
dist/offline-edit-basic-src.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! esri-offline-maps - v3.4.0 - 2016-09-13
|
/*! esri-offline-maps - v3.5.0 - 2016-09-15
|
||||||
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
||||||
* Apache License*/
|
* Apache License*/
|
||||||
// Configure offline/online detection
|
// Configure offline/online detection
|
||||||
|
|||||||
51
dist/offline-tiles-advanced-min.js
vendored
51
dist/offline-tiles-advanced-min.js
vendored
@ -92,7 +92,48 @@ break
|
|||||||
case 15:d.push(String.fromCharCode(b|c)),e=0}f++}return this.decompress(d.join(""))},_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decompress:function(a){for(var b,c,d,e,f,g,h,i=[],j=1,k=a.charCodeAt(0)>>8;j<2*a.length&&(j<2*a.length-1||0===k);)j%2===0?(b=a.charCodeAt(j/2)>>8,c=255&a.charCodeAt(j/2),d=j/2+1<a.length?a.charCodeAt(j/2+1)>>8:NaN):(b=255&a.charCodeAt((j-1)/2),(j+1)/2<a.length?(c=a.charCodeAt((j+1)/2)>>8,d=255&a.charCodeAt((j+1)/2)):c=d=NaN),j+=3,e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)||j==2*a.length+1&&k?g=h=64:(isNaN(d)||j==2*a.length&&k)&&(h=64),i.push(this._keyStr.charAt(e)),i.push(this._keyStr.charAt(f)),i.push(this._keyStr.charAt(g)),i.push(this._keyStr.charAt(h))
|
case 15:d.push(String.fromCharCode(b|c)),e=0}f++}return this.decompress(d.join(""))},_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decompress:function(a){for(var b,c,d,e,f,g,h,i=[],j=1,k=a.charCodeAt(0)>>8;j<2*a.length&&(j<2*a.length-1||0===k);)j%2===0?(b=a.charCodeAt(j/2)>>8,c=255&a.charCodeAt(j/2),d=j/2+1<a.length?a.charCodeAt(j/2+1)>>8:NaN):(b=255&a.charCodeAt((j-1)/2),(j+1)/2<a.length?(c=a.charCodeAt((j+1)/2)>>8,d=255&a.charCodeAt((j+1)/2)):c=d=NaN),j+=3,e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)||j==2*a.length+1&&k?g=h=64:(isNaN(d)||j==2*a.length&&k)&&(h=64),i.push(this._keyStr.charAt(e)),i.push(this._keyStr.charAt(f)),i.push(this._keyStr.charAt(g)),i.push(this._keyStr.charAt(h))
|
||||||
return i.join("")},compress:function(a){var b,c,d,e,f,g,h,i,j=[],k=1,l=0,m=!1
|
return i.join("")},compress:function(a){var b,c,d,e,f,g,h,i,j=[],k=1,l=0,m=!1
|
||||||
for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<a.length;)f=this._keyStr.indexOf(a.charAt(l++)),g=this._keyStr.indexOf(a.charAt(l++)),h=this._keyStr.indexOf(a.charAt(l++)),i=this._keyStr.indexOf(a.charAt(l++)),c=f<<2|g>>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,k%2===0?(b=c<<8,m=!0,64!=h&&(j.push(String.fromCharCode(b|d)),m=!1),64!=i&&(b=e<<8,m=!0)):(j.push(String.fromCharCode(b|c)),m=!1,64!=h&&(b=d<<8,m=!0),64!=i&&(j.push(String.fromCharCode(b|e)),m=!1)),k+=3
|
for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<a.length;)f=this._keyStr.indexOf(a.charAt(l++)),g=this._keyStr.indexOf(a.charAt(l++)),h=this._keyStr.indexOf(a.charAt(l++)),i=this._keyStr.indexOf(a.charAt(l++)),c=f<<2|g>>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,k%2===0?(b=c<<8,m=!0,64!=h&&(j.push(String.fromCharCode(b|d)),m=!1),64!=i&&(b=e<<8,m=!0)):(j.push(String.fromCharCode(b|c)),m=!1,64!=h&&(b=d<<8,m=!0),64!=i&&(j.push(String.fromCharCode(b|e)),m=!1)),k+=3
|
||||||
return m?(j.push(String.fromCharCode(b)),j=j.join(""),j=String.fromCharCode(256|j.charCodeAt(0))+j.substring(1)):j=j.join(""),j}},O.esri.Tiles.saveAs=function(a){"use strict"
|
return m?(j.push(String.fromCharCode(b)),j=j.join(""),j=String.fromCharCode(256|j.charCodeAt(0))+j.substring(1)):j=j.join(""),j}},O.esri.Tiles.LZString=function(){function a(a,b){if(!e[a]){e[a]={}
|
||||||
|
for(var c=0;c<a.length;c++)e[a][a.charAt(c)]=c}return e[a][b]}var b=String.fromCharCode,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={},f={compressToBase64:function(a){if(null==a)return""
|
||||||
|
var b=f._compress(a,6,function(a){return c.charAt(a)})
|
||||||
|
switch(b.length%4){default:case 0:return b
|
||||||
|
case 1:return b+"==="
|
||||||
|
case 2:return b+"=="
|
||||||
|
case 3:return b+"="}},decompressFromBase64:function(b){return null==b?"":""==b?null:f._decompress(b.length,32,function(d){return a(c,b.charAt(d))})},compressToUTF16:function(a){return null==a?"":f._compress(a,15,function(a){return b(a+32)})+" "},decompressFromUTF16:function(a){return null==a?"":""==a?null:f._decompress(a.length,16384,function(b){return a.charCodeAt(b)-32})},compressToUint8Array:function(a){for(var b=f.compress(a),c=new Uint8Array(2*b.length),d=0,e=b.length;e>d;d++){var g=b.charCodeAt(d)
|
||||||
|
c[2*d]=g>>>8,c[2*d+1]=g%256}return c},decompressFromUint8Array:function(a){if(null===a||void 0===a)return f.decompress(a)
|
||||||
|
for(var c=new Array(a.length/2),d=0,e=c.length;e>d;d++)c[d]=256*a[2*d]+a[2*d+1]
|
||||||
|
var g=[]
|
||||||
|
return c.forEach(function(a){g.push(b(a))}),f.decompress(g.join(""))},compressToEncodedURIComponent:function(a){return null==a?"":f._compress(a,6,function(a){return d.charAt(a)})},decompressFromEncodedURIComponent:function(b){return null==b?"":""==b?null:(b=b.replace(/ /g,"+"),f._decompress(b.length,32,function(c){return a(d,b.charAt(c))}))},compress:function(a){return f._compress(a,16,function(a){return b(a)})},_compress:function(a,b,c){if(null==a)return""
|
||||||
|
var d,e,f,g={},h={},i="",j="",k="",l=2,m=3,n=2,o=[],p=0,q=0
|
||||||
|
for(f=0;f<a.length;f+=1)if(i=a.charAt(f),Object.prototype.hasOwnProperty.call(g,i)||(g[i]=m++,h[i]=!0),j=k+i,Object.prototype.hasOwnProperty.call(g,j))k=j
|
||||||
|
else{if(Object.prototype.hasOwnProperty.call(h,k)){if(k.charCodeAt(0)<256){for(d=0;n>d;d++)p<<=1,q==b-1?(q=0,o.push(c(p)),p=0):q++
|
||||||
|
for(e=k.charCodeAt(0),d=0;8>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}else{for(e=1,d=0;n>d;d++)p=p<<1|e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e=0
|
||||||
|
for(e=k.charCodeAt(0),d=0;16>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}l--,0==l&&(l=Math.pow(2,n),n++),delete h[k]}else for(e=g[k],d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1
|
||||||
|
l--,0==l&&(l=Math.pow(2,n),n++),g[j]=m++,k=String(i)}if(""!==k){if(Object.prototype.hasOwnProperty.call(h,k)){if(k.charCodeAt(0)<256){for(d=0;n>d;d++)p<<=1,q==b-1?(q=0,o.push(c(p)),p=0):q++
|
||||||
|
for(e=k.charCodeAt(0),d=0;8>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}else{for(e=1,d=0;n>d;d++)p=p<<1|e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e=0
|
||||||
|
for(e=k.charCodeAt(0),d=0;16>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}l--,0==l&&(l=Math.pow(2,n),n++),delete h[k]}else for(e=g[k],d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1
|
||||||
|
l--,0==l&&(l=Math.pow(2,n),n++)}for(e=2,d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1
|
||||||
|
for(;;){if(p<<=1,q==b-1){o.push(c(p))
|
||||||
|
break}q++}return o.join("")},decompress:function(a){return null==a?"":""==a?null:f._decompress(a.length,32768,function(b){return a.charCodeAt(b)})},_decompress:function(a,c,d){var e,f,g,h,i,j,k,l,m=[],n=4,o=4,p=3,q="",r=[],s={val:d(0),position:c,index:1}
|
||||||
|
for(f=0;3>f;f+=1)m[f]=f
|
||||||
|
for(h=0,j=Math.pow(2,2),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
switch(e=h){case 0:for(h=0,j=Math.pow(2,8),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
l=b(h)
|
||||||
|
break
|
||||||
|
case 1:for(h=0,j=Math.pow(2,16),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
l=b(h)
|
||||||
|
break
|
||||||
|
case 2:return""}for(m[3]=l,g=l,r.push(l);;){if(s.index>a)return""
|
||||||
|
for(h=0,j=Math.pow(2,p),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
switch(l=h){case 0:for(h=0,j=Math.pow(2,8),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
m[o++]=b(h),l=o-1,n--
|
||||||
|
break
|
||||||
|
case 1:for(h=0,j=Math.pow(2,16),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
m[o++]=b(h),l=o-1,n--
|
||||||
|
break
|
||||||
|
case 2:return r.join("")}if(0==n&&(n=Math.pow(2,p),p++),m[l])q=m[l]
|
||||||
|
else{if(l!==o)return null
|
||||||
|
q=g+g.charAt(0)}r.push(q),m[o++]=g+q.charAt(0),n--,g=q,0==n&&(n=Math.pow(2,p),p++)}}}
|
||||||
|
return f}(),O.esri.Tiles.saveAs=function(a){"use strict"
|
||||||
var b=a.document,c=function(){return a.URL||a.webkitURL||a},d=a.URL||a.webkitURL||a,e=b.createElementNS("http://www.w3.org/1999/xhtml","a"),f=!a.externalHost&&"download"in e,g=a.webkitRequestFileSystem,h=a.requestFileSystem||g||a.mozRequestFileSystem,i=function(b){(a.setImmediate||a.setTimeout)(function(){throw b},0)},j="application/octet-stream",k=0,l=[],m=function(){for(var a=l.length;a--;){var b=l[a]
|
var b=a.document,c=function(){return a.URL||a.webkitURL||a},d=a.URL||a.webkitURL||a,e=b.createElementNS("http://www.w3.org/1999/xhtml","a"),f=!a.externalHost&&"download"in e,g=a.webkitRequestFileSystem,h=a.requestFileSystem||g||a.mozRequestFileSystem,i=function(b){(a.setImmediate||a.setTimeout)(function(){throw b},0)},j="application/octet-stream",k=0,l=[],m=function(){for(var a=l.length;a--;){var b=l[a]
|
||||||
"string"==typeof b?d.revokeObjectURL(b):b.remove()}l.length=0},n=function(a,b,c){b=[].concat(b)
|
"string"==typeof b?d.revokeObjectURL(b):b.remove()}l.length=0},n=function(a,b,c){b=[].concat(b)
|
||||||
for(var d=b.length;d--;){var e=a["on"+b[d]]
|
for(var d=b.length;d--;){var e=a["on"+b[d]]
|
||||||
@ -132,16 +173,16 @@ var k=new f(parseFloat(d.initialExtent.xmin),parseFloat(d.initialExtent.ymin),pa
|
|||||||
m.origin=n,m.lods=j,b({initExtent:k,fullExtent:l,tileInfo:m,resultObj:d})})}},O.esri.Tiles.TilesStore=function(){this._db=null,this.dbName="offline_tile_store",this.objectStoreName="tilepath",this.isSupported=function(){return!(!window.indexedDB&&!window.openDatabase)},this.store=function(a,b){try{var c=this._db.transaction([this.objectStoreName],"readwrite")
|
m.origin=n,m.lods=j,b({initExtent:k,fullExtent:l,tileInfo:m,resultObj:d})})}},O.esri.Tiles.TilesStore=function(){this._db=null,this.dbName="offline_tile_store",this.objectStoreName="tilepath",this.isSupported=function(){return!(!window.indexedDB&&!window.openDatabase)},this.store=function(a,b){try{var c=this._db.transaction([this.objectStoreName],"readwrite")
|
||||||
c.oncomplete=function(){b(!0)},c.onerror=function(a){b(!1,a.target.error.message)}
|
c.oncomplete=function(){b(!0)},c.onerror=function(a){b(!1,a.target.error.message)}
|
||||||
var d=c.objectStore(this.objectStoreName)
|
var d=c.objectStore(this.objectStoreName)
|
||||||
a.img=O.esri.Tiles.Base64String.compress(a.img)
|
a.url=O.esri.Tiles.LZString.compress(a.url),a.img=O.esri.Tiles.Base64String.compress(a.img)
|
||||||
var e=d.put(a)
|
var e=d.put(a)
|
||||||
e.onsuccess=function(){}}catch(f){b(!1,f.stack)}},this.retrieve=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName),d=c.get(a)
|
e.onsuccess=function(){}}catch(f){b(!1,f.stack)}},this.retrieve=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName),d=c.get(O.esri.Tiles.LZString.compress(a))
|
||||||
d.onsuccess=function(a){var c=a.target.result
|
d.onsuccess=function(a){var c=a.target.result
|
||||||
void 0===c?b(!1,"not found"):(c.img=O.esri.Tiles.Base64String.decompress(c.img),b(!0,c))},d.onerror=function(a){b(!1,a)}}},this.deleteAll=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName).clear()
|
void 0===c?b(!1,"not found"):(c.url=O.esri.Tiles.LZString.decompress(c.url),c.img=O.esri.Tiles.Base64String.decompress(c.img),b(!0,c))},d.onerror=function(a){b(!1,a)}}},this.deleteAll=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName).clear()
|
||||||
b.onsuccess=function(){a(!0)},b.onerror=function(b){a(!1,b)}}else a(!1,null)},this["delete"]=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName)["delete"](a)
|
b.onsuccess=function(){a(!0)},b.onerror=function(b){a(!1,b)}}else a(!1,null)},this["delete"]=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName)["delete"](a)
|
||||||
c.onsuccess=function(){b(!0)},c.onerror=function(a){b(!1,a)}}else b(!1,null)},this.getAllTiles=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
c.onsuccess=function(){b(!0)},c.onerror=function(a){b(!1,a)}}else b(!1,null)},this.getAllTiles=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
||||||
b.onsuccess=function(b){var c=b.target.result
|
b.onsuccess=function(b){var c=b.target.result
|
||||||
if(c){var d=c.value.url,e=c.value.img
|
if(c){var d=c.value.url,e=c.value.img
|
||||||
a(d,e,null),c["continue"]()}else a(null,null,"end")}.bind(this),b.onerror=function(b){a(null,null,b)}}else a(null,null,"no db")},this.usedSpace=function(a){if(null!==this._db){var b={sizeBytes:0,tileCount:0},c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
d=O.esri.Tiles.LZString.decompress(d),e=O.esri.Tiles.Base64String.decompress(e),a(d,e,null),c["continue"]()}else a(null,null,"end")}.bind(this),b.onerror=function(b){a(null,null,b)}}else a(null,null,"no db")},this.usedSpace=function(a){if(null!==this._db){var b={sizeBytes:0,tileCount:0},c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
||||||
c.onsuccess=function(c){var d=c.target.result
|
c.onsuccess=function(c){var d=c.target.result
|
||||||
if(d){var e=d.value,f=JSON.stringify(e)
|
if(d){var e=d.value,f=JSON.stringify(e)
|
||||||
b.sizeBytes+=this._stringBytes(f),b.tileCount+=1,d["continue"]()}else a(b,null)}.bind(this),c.onerror=function(b){a(null,b)}}else a(null,null)},this._stringBytes=function(a){return a.length},this.init=function(a){var b=indexedDB.open(this.dbName,4)
|
b.sizeBytes+=this._stringBytes(f),b.tileCount+=1,d["continue"]()}else a(b,null)}.bind(this),c.onerror=function(b){a(null,b)}}else a(null,null)},this._stringBytes=function(a){return a.length},this.init=function(a){var b=indexedDB.open(this.dbName,4)
|
||||||
|
|||||||
503
dist/offline-tiles-advanced-src.js
vendored
503
dist/offline-tiles-advanced-src.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! esri-offline-maps - v3.4.0 - 2016-09-13
|
/*! esri-offline-maps - v3.5.0 - 2016-09-15
|
||||||
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
||||||
* Apache License*/
|
* Apache License*/
|
||||||
define([
|
define([
|
||||||
@ -954,6 +954,501 @@ O.esri.Tiles.Base64String = {
|
|||||||
|
|
||||||
/*jslint bitwise: false */
|
/*jslint bitwise: false */
|
||||||
|
|
||||||
|
// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
|
||||||
|
// This work is free. You can redistribute it and/or modify it
|
||||||
|
// under the terms of the WTFPL, Version 2
|
||||||
|
// For more information see LICENSE.txt or http://www.wtfpl.net/
|
||||||
|
//
|
||||||
|
// For more information, the home page:
|
||||||
|
// http://pieroxy.net/blog/pages/lz-string/testing.html
|
||||||
|
//
|
||||||
|
// LZ-based compression algorithm, version 1.4.4
|
||||||
|
O.esri.Tiles.LZString = (function() {
|
||||||
|
|
||||||
|
// private property
|
||||||
|
var f = String.fromCharCode;
|
||||||
|
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||||
|
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
||||||
|
var baseReverseDic = {};
|
||||||
|
|
||||||
|
function getBaseValue(alphabet, character) {
|
||||||
|
if (!baseReverseDic[alphabet]) {
|
||||||
|
baseReverseDic[alphabet] = {};
|
||||||
|
for (var i=0 ; i<alphabet.length ; i++) {
|
||||||
|
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return baseReverseDic[alphabet][character];
|
||||||
|
}
|
||||||
|
|
||||||
|
var LZString = {
|
||||||
|
compressToBase64 : function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
var res = LZString._compress(input, 6, function(a){return keyStrBase64.charAt(a);});
|
||||||
|
switch (res.length % 4) { // To produce valid Base64
|
||||||
|
default: // When could this happen ?
|
||||||
|
case 0 : return res;
|
||||||
|
case 1 : return res+"===";
|
||||||
|
case 2 : return res+"==";
|
||||||
|
case 3 : return res+"=";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
decompressFromBase64 : function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
if (input == "") return null;
|
||||||
|
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrBase64, input.charAt(index)); });
|
||||||
|
},
|
||||||
|
|
||||||
|
compressToUTF16 : function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
return LZString._compress(input, 15, function(a){return f(a+32);}) + " ";
|
||||||
|
},
|
||||||
|
|
||||||
|
decompressFromUTF16: function (compressed) {
|
||||||
|
if (compressed == null) return "";
|
||||||
|
if (compressed == "") return null;
|
||||||
|
return LZString._decompress(compressed.length, 16384, function(index) { return compressed.charCodeAt(index) - 32; });
|
||||||
|
},
|
||||||
|
|
||||||
|
//compress into uint8array (UCS-2 big endian format)
|
||||||
|
compressToUint8Array: function (uncompressed) {
|
||||||
|
var compressed = LZString.compress(uncompressed);
|
||||||
|
var buf=new Uint8Array(compressed.length*2); // 2 bytes per character
|
||||||
|
|
||||||
|
for (var i=0, TotalLen=compressed.length; i<TotalLen; i++) {
|
||||||
|
var current_value = compressed.charCodeAt(i);
|
||||||
|
buf[i*2] = current_value >>> 8;
|
||||||
|
buf[i*2+1] = current_value % 256;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
},
|
||||||
|
|
||||||
|
//decompress from uint8array (UCS-2 big endian format)
|
||||||
|
decompressFromUint8Array:function (compressed) {
|
||||||
|
if (compressed===null || compressed===undefined){
|
||||||
|
return LZString.decompress(compressed);
|
||||||
|
} else {
|
||||||
|
var buf=new Array(compressed.length/2); // 2 bytes per character
|
||||||
|
for (var i=0, TotalLen=buf.length; i<TotalLen; i++) {
|
||||||
|
buf[i]=compressed[i*2]*256+compressed[i*2+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = [];
|
||||||
|
buf.forEach(function (c) {
|
||||||
|
result.push(f(c));
|
||||||
|
});
|
||||||
|
return LZString.decompress(result.join(''));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//compress into a string that is already URI encoded
|
||||||
|
compressToEncodedURIComponent: function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
return LZString._compress(input, 6, function(a){return keyStrUriSafe.charAt(a);});
|
||||||
|
},
|
||||||
|
|
||||||
|
//decompress from an output of compressToEncodedURIComponent
|
||||||
|
decompressFromEncodedURIComponent:function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
if (input == "") return null;
|
||||||
|
input = input.replace(/ /g, "+");
|
||||||
|
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrUriSafe, input.charAt(index)); });
|
||||||
|
},
|
||||||
|
|
||||||
|
compress: function (uncompressed) {
|
||||||
|
return LZString._compress(uncompressed, 16, function(a){return f(a);});
|
||||||
|
},
|
||||||
|
_compress: function (uncompressed, bitsPerChar, getCharFromInt) {
|
||||||
|
if (uncompressed == null) return "";
|
||||||
|
var i, value,
|
||||||
|
context_dictionary= {},
|
||||||
|
context_dictionaryToCreate= {},
|
||||||
|
context_c="",
|
||||||
|
context_wc="",
|
||||||
|
context_w="",
|
||||||
|
context_enlargeIn= 2, // Compensate for the first entry which should not count
|
||||||
|
context_dictSize= 3,
|
||||||
|
context_numBits= 2,
|
||||||
|
context_data=[],
|
||||||
|
context_data_val=0,
|
||||||
|
context_data_position=0,
|
||||||
|
ii;
|
||||||
|
|
||||||
|
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
||||||
|
context_c = uncompressed.charAt(ii);
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(context_dictionary,context_c)) {
|
||||||
|
context_dictionary[context_c] = context_dictSize++;
|
||||||
|
context_dictionaryToCreate[context_c] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
context_wc = context_w + context_c;
|
||||||
|
if (Object.prototype.hasOwnProperty.call(context_dictionary,context_wc)) {
|
||||||
|
context_w = context_wc;
|
||||||
|
} else {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
||||||
|
if (context_w.charCodeAt(0)<256) {
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<8 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value = 1;
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | value;
|
||||||
|
if (context_data_position ==bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<16 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
delete context_dictionaryToCreate[context_w];
|
||||||
|
} else {
|
||||||
|
value = context_dictionary[context_w];
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
// Add wc to the dictionary.
|
||||||
|
context_dictionary[context_wc] = context_dictSize++;
|
||||||
|
context_w = String(context_c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output the code for w.
|
||||||
|
if (context_w !== "") {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
||||||
|
if (context_w.charCodeAt(0)<256) {
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<8 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value = 1;
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | value;
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<16 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
delete context_dictionaryToCreate[context_w];
|
||||||
|
} else {
|
||||||
|
value = context_dictionary[context_w];
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark the end of the stream
|
||||||
|
value = 2;
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush the last char
|
||||||
|
while (true) {
|
||||||
|
context_data_val = (context_data_val << 1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else context_data_position++;
|
||||||
|
}
|
||||||
|
return context_data.join('');
|
||||||
|
},
|
||||||
|
|
||||||
|
decompress: function (compressed) {
|
||||||
|
if (compressed == null) return "";
|
||||||
|
if (compressed == "") return null;
|
||||||
|
return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
|
||||||
|
},
|
||||||
|
|
||||||
|
_decompress: function (length, resetValue, getNextValue) {
|
||||||
|
var dictionary = [],
|
||||||
|
next,
|
||||||
|
enlargeIn = 4,
|
||||||
|
dictSize = 4,
|
||||||
|
numBits = 3,
|
||||||
|
entry = "",
|
||||||
|
result = [],
|
||||||
|
i,
|
||||||
|
w,
|
||||||
|
bits, resb, maxpower, power,
|
||||||
|
c,
|
||||||
|
data = {val:getNextValue(0), position:resetValue, index:1};
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i += 1) {
|
||||||
|
dictionary[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,2);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (next = bits) {
|
||||||
|
case 0:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,8);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
c = f(bits);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,16);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
c = f(bits);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
dictionary[3] = c;
|
||||||
|
w = c;
|
||||||
|
result.push(c);
|
||||||
|
while (true) {
|
||||||
|
if (data.index > length) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,numBits);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c = bits) {
|
||||||
|
case 0:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,8);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dictionary[dictSize++] = f(bits);
|
||||||
|
c = dictSize-1;
|
||||||
|
enlargeIn--;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,16);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
dictionary[dictSize++] = f(bits);
|
||||||
|
c = dictSize-1;
|
||||||
|
enlargeIn--;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return result.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enlargeIn == 0) {
|
||||||
|
enlargeIn = Math.pow(2, numBits);
|
||||||
|
numBits++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dictionary[c]) {
|
||||||
|
entry = dictionary[c];
|
||||||
|
} else {
|
||||||
|
if (c === dictSize) {
|
||||||
|
entry = w + w.charAt(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.push(entry);
|
||||||
|
|
||||||
|
// Add w+entry[0] to the dictionary.
|
||||||
|
dictionary[dictSize++] = w + entry.charAt(0);
|
||||||
|
enlargeIn--;
|
||||||
|
|
||||||
|
w = entry;
|
||||||
|
|
||||||
|
if (enlargeIn == 0) {
|
||||||
|
enlargeIn = Math.pow(2, numBits);
|
||||||
|
numBits++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return LZString;
|
||||||
|
})();
|
||||||
/* FileSaver.js
|
/* FileSaver.js
|
||||||
* A saveAs() FileSaver implementation.
|
* A saveAs() FileSaver implementation.
|
||||||
* 2013-10-21
|
* 2013-10-21
|
||||||
@ -1641,6 +2136,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
var objectStore = transaction.objectStore(this.objectStoreName);
|
var objectStore = transaction.objectStore(this.objectStoreName);
|
||||||
|
urlDataPair.url = O.esri.Tiles.LZString.compress(urlDataPair.url);
|
||||||
urlDataPair.img = O.esri.Tiles.Base64String.compress(urlDataPair.img);
|
urlDataPair.img = O.esri.Tiles.Base64String.compress(urlDataPair.img);
|
||||||
var request = objectStore.put(urlDataPair);
|
var request = objectStore.put(urlDataPair);
|
||||||
request.onsuccess = function()
|
request.onsuccess = function()
|
||||||
@ -1665,7 +2161,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
if(this._db !== null)
|
if(this._db !== null)
|
||||||
{
|
{
|
||||||
var objectStore = this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName);
|
var objectStore = this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName);
|
||||||
var request = objectStore.get(url);
|
var request = objectStore.get(O.esri.Tiles.LZString.compress(url));
|
||||||
request.onsuccess = function(event)
|
request.onsuccess = function(event)
|
||||||
{
|
{
|
||||||
var result = event.target.result;
|
var result = event.target.result;
|
||||||
@ -1675,6 +2171,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
result.url = O.esri.Tiles.LZString.decompress(result.url);
|
||||||
result.img = O.esri.Tiles.Base64String.decompress(result.img);
|
result.img = O.esri.Tiles.Base64String.decompress(result.img);
|
||||||
callback(true,result);
|
callback(true,result);
|
||||||
}
|
}
|
||||||
@ -1757,6 +2254,8 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
if(cursor){
|
if(cursor){
|
||||||
var url = cursor.value.url;
|
var url = cursor.value.url;
|
||||||
var img = cursor.value.img;
|
var img = cursor.value.img;
|
||||||
|
url = O.esri.Tiles.LZString.decompress(url);
|
||||||
|
img = O.esri.Tiles.Base64String.decompress(img);
|
||||||
callback(url,img,null);
|
callback(url,img,null);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
}
|
}
|
||||||
|
|||||||
51
dist/offline-tiles-basic-min.js
vendored
51
dist/offline-tiles-basic-min.js
vendored
@ -81,7 +81,48 @@ break
|
|||||||
case 15:d.push(String.fromCharCode(b|c)),e=0}f++}return this.decompress(d.join(""))},_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decompress:function(a){for(var b,c,d,e,f,g,h,i=[],j=1,k=a.charCodeAt(0)>>8;j<2*a.length&&(j<2*a.length-1||0===k);)j%2===0?(b=a.charCodeAt(j/2)>>8,c=255&a.charCodeAt(j/2),d=j/2+1<a.length?a.charCodeAt(j/2+1)>>8:NaN):(b=255&a.charCodeAt((j-1)/2),(j+1)/2<a.length?(c=a.charCodeAt((j+1)/2)>>8,d=255&a.charCodeAt((j+1)/2)):c=d=NaN),j+=3,e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)||j==2*a.length+1&&k?g=h=64:(isNaN(d)||j==2*a.length&&k)&&(h=64),i.push(this._keyStr.charAt(e)),i.push(this._keyStr.charAt(f)),i.push(this._keyStr.charAt(g)),i.push(this._keyStr.charAt(h))
|
case 15:d.push(String.fromCharCode(b|c)),e=0}f++}return this.decompress(d.join(""))},_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",decompress:function(a){for(var b,c,d,e,f,g,h,i=[],j=1,k=a.charCodeAt(0)>>8;j<2*a.length&&(j<2*a.length-1||0===k);)j%2===0?(b=a.charCodeAt(j/2)>>8,c=255&a.charCodeAt(j/2),d=j/2+1<a.length?a.charCodeAt(j/2+1)>>8:NaN):(b=255&a.charCodeAt((j-1)/2),(j+1)/2<a.length?(c=a.charCodeAt((j+1)/2)>>8,d=255&a.charCodeAt((j+1)/2)):c=d=NaN),j+=3,e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)||j==2*a.length+1&&k?g=h=64:(isNaN(d)||j==2*a.length&&k)&&(h=64),i.push(this._keyStr.charAt(e)),i.push(this._keyStr.charAt(f)),i.push(this._keyStr.charAt(g)),i.push(this._keyStr.charAt(h))
|
||||||
return i.join("")},compress:function(a){var b,c,d,e,f,g,h,i,j=[],k=1,l=0,m=!1
|
return i.join("")},compress:function(a){var b,c,d,e,f,g,h,i,j=[],k=1,l=0,m=!1
|
||||||
for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<a.length;)f=this._keyStr.indexOf(a.charAt(l++)),g=this._keyStr.indexOf(a.charAt(l++)),h=this._keyStr.indexOf(a.charAt(l++)),i=this._keyStr.indexOf(a.charAt(l++)),c=f<<2|g>>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,k%2===0?(b=c<<8,m=!0,64!=h&&(j.push(String.fromCharCode(b|d)),m=!1),64!=i&&(b=e<<8,m=!0)):(j.push(String.fromCharCode(b|c)),m=!1,64!=h&&(b=d<<8,m=!0),64!=i&&(j.push(String.fromCharCode(b|e)),m=!1)),k+=3
|
for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<a.length;)f=this._keyStr.indexOf(a.charAt(l++)),g=this._keyStr.indexOf(a.charAt(l++)),h=this._keyStr.indexOf(a.charAt(l++)),i=this._keyStr.indexOf(a.charAt(l++)),c=f<<2|g>>4,d=(15&g)<<4|h>>2,e=(3&h)<<6|i,k%2===0?(b=c<<8,m=!0,64!=h&&(j.push(String.fromCharCode(b|d)),m=!1),64!=i&&(b=e<<8,m=!0)):(j.push(String.fromCharCode(b|c)),m=!1,64!=h&&(b=d<<8,m=!0),64!=i&&(j.push(String.fromCharCode(b|e)),m=!1)),k+=3
|
||||||
return m?(j.push(String.fromCharCode(b)),j=j.join(""),j=String.fromCharCode(256|j.charCodeAt(0))+j.substring(1)):j=j.join(""),j}},O.esri.Tiles.saveAs=function(a){"use strict"
|
return m?(j.push(String.fromCharCode(b)),j=j.join(""),j=String.fromCharCode(256|j.charCodeAt(0))+j.substring(1)):j=j.join(""),j}},O.esri.Tiles.LZString=function(){function a(a,b){if(!e[a]){e[a]={}
|
||||||
|
for(var c=0;c<a.length;c++)e[a][a.charAt(c)]=c}return e[a][b]}var b=String.fromCharCode,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={},f={compressToBase64:function(a){if(null==a)return""
|
||||||
|
var b=f._compress(a,6,function(a){return c.charAt(a)})
|
||||||
|
switch(b.length%4){default:case 0:return b
|
||||||
|
case 1:return b+"==="
|
||||||
|
case 2:return b+"=="
|
||||||
|
case 3:return b+"="}},decompressFromBase64:function(b){return null==b?"":""==b?null:f._decompress(b.length,32,function(d){return a(c,b.charAt(d))})},compressToUTF16:function(a){return null==a?"":f._compress(a,15,function(a){return b(a+32)})+" "},decompressFromUTF16:function(a){return null==a?"":""==a?null:f._decompress(a.length,16384,function(b){return a.charCodeAt(b)-32})},compressToUint8Array:function(a){for(var b=f.compress(a),c=new Uint8Array(2*b.length),d=0,e=b.length;e>d;d++){var g=b.charCodeAt(d)
|
||||||
|
c[2*d]=g>>>8,c[2*d+1]=g%256}return c},decompressFromUint8Array:function(a){if(null===a||void 0===a)return f.decompress(a)
|
||||||
|
for(var c=new Array(a.length/2),d=0,e=c.length;e>d;d++)c[d]=256*a[2*d]+a[2*d+1]
|
||||||
|
var g=[]
|
||||||
|
return c.forEach(function(a){g.push(b(a))}),f.decompress(g.join(""))},compressToEncodedURIComponent:function(a){return null==a?"":f._compress(a,6,function(a){return d.charAt(a)})},decompressFromEncodedURIComponent:function(b){return null==b?"":""==b?null:(b=b.replace(/ /g,"+"),f._decompress(b.length,32,function(c){return a(d,b.charAt(c))}))},compress:function(a){return f._compress(a,16,function(a){return b(a)})},_compress:function(a,b,c){if(null==a)return""
|
||||||
|
var d,e,f,g={},h={},i="",j="",k="",l=2,m=3,n=2,o=[],p=0,q=0
|
||||||
|
for(f=0;f<a.length;f+=1)if(i=a.charAt(f),Object.prototype.hasOwnProperty.call(g,i)||(g[i]=m++,h[i]=!0),j=k+i,Object.prototype.hasOwnProperty.call(g,j))k=j
|
||||||
|
else{if(Object.prototype.hasOwnProperty.call(h,k)){if(k.charCodeAt(0)<256){for(d=0;n>d;d++)p<<=1,q==b-1?(q=0,o.push(c(p)),p=0):q++
|
||||||
|
for(e=k.charCodeAt(0),d=0;8>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}else{for(e=1,d=0;n>d;d++)p=p<<1|e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e=0
|
||||||
|
for(e=k.charCodeAt(0),d=0;16>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}l--,0==l&&(l=Math.pow(2,n),n++),delete h[k]}else for(e=g[k],d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1
|
||||||
|
l--,0==l&&(l=Math.pow(2,n),n++),g[j]=m++,k=String(i)}if(""!==k){if(Object.prototype.hasOwnProperty.call(h,k)){if(k.charCodeAt(0)<256){for(d=0;n>d;d++)p<<=1,q==b-1?(q=0,o.push(c(p)),p=0):q++
|
||||||
|
for(e=k.charCodeAt(0),d=0;8>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}else{for(e=1,d=0;n>d;d++)p=p<<1|e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e=0
|
||||||
|
for(e=k.charCodeAt(0),d=0;16>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1}l--,0==l&&(l=Math.pow(2,n),n++),delete h[k]}else for(e=g[k],d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1
|
||||||
|
l--,0==l&&(l=Math.pow(2,n),n++)}for(e=2,d=0;n>d;d++)p=p<<1|1&e,q==b-1?(q=0,o.push(c(p)),p=0):q++,e>>=1
|
||||||
|
for(;;){if(p<<=1,q==b-1){o.push(c(p))
|
||||||
|
break}q++}return o.join("")},decompress:function(a){return null==a?"":""==a?null:f._decompress(a.length,32768,function(b){return a.charCodeAt(b)})},_decompress:function(a,c,d){var e,f,g,h,i,j,k,l,m=[],n=4,o=4,p=3,q="",r=[],s={val:d(0),position:c,index:1}
|
||||||
|
for(f=0;3>f;f+=1)m[f]=f
|
||||||
|
for(h=0,j=Math.pow(2,2),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
switch(e=h){case 0:for(h=0,j=Math.pow(2,8),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
l=b(h)
|
||||||
|
break
|
||||||
|
case 1:for(h=0,j=Math.pow(2,16),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
l=b(h)
|
||||||
|
break
|
||||||
|
case 2:return""}for(m[3]=l,g=l,r.push(l);;){if(s.index>a)return""
|
||||||
|
for(h=0,j=Math.pow(2,p),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
switch(l=h){case 0:for(h=0,j=Math.pow(2,8),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
m[o++]=b(h),l=o-1,n--
|
||||||
|
break
|
||||||
|
case 1:for(h=0,j=Math.pow(2,16),k=1;k!=j;)i=s.val&s.position,s.position>>=1,0==s.position&&(s.position=c,s.val=d(s.index++)),h|=(i>0?1:0)*k,k<<=1
|
||||||
|
m[o++]=b(h),l=o-1,n--
|
||||||
|
break
|
||||||
|
case 2:return r.join("")}if(0==n&&(n=Math.pow(2,p),p++),m[l])q=m[l]
|
||||||
|
else{if(l!==o)return null
|
||||||
|
q=g+g.charAt(0)}r.push(q),m[o++]=g+q.charAt(0),n--,g=q,0==n&&(n=Math.pow(2,p),p++)}}}
|
||||||
|
return f}(),O.esri.Tiles.saveAs=function(a){"use strict"
|
||||||
var b=a.document,c=function(){return a.URL||a.webkitURL||a},d=a.URL||a.webkitURL||a,e=b.createElementNS("http://www.w3.org/1999/xhtml","a"),f=!a.externalHost&&"download"in e,g=a.webkitRequestFileSystem,h=a.requestFileSystem||g||a.mozRequestFileSystem,i=function(b){(a.setImmediate||a.setTimeout)(function(){throw b},0)},j="application/octet-stream",k=0,l=[],m=function(){for(var a=l.length;a--;){var b=l[a]
|
var b=a.document,c=function(){return a.URL||a.webkitURL||a},d=a.URL||a.webkitURL||a,e=b.createElementNS("http://www.w3.org/1999/xhtml","a"),f=!a.externalHost&&"download"in e,g=a.webkitRequestFileSystem,h=a.requestFileSystem||g||a.mozRequestFileSystem,i=function(b){(a.setImmediate||a.setTimeout)(function(){throw b},0)},j="application/octet-stream",k=0,l=[],m=function(){for(var a=l.length;a--;){var b=l[a]
|
||||||
"string"==typeof b?d.revokeObjectURL(b):b.remove()}l.length=0},n=function(a,b,c){b=[].concat(b)
|
"string"==typeof b?d.revokeObjectURL(b):b.remove()}l.length=0},n=function(a,b,c){b=[].concat(b)
|
||||||
for(var d=b.length;d--;){var e=a["on"+b[d]]
|
for(var d=b.length;d--;){var e=a["on"+b[d]]
|
||||||
@ -121,16 +162,16 @@ var k=new f(parseFloat(d.initialExtent.xmin),parseFloat(d.initialExtent.ymin),pa
|
|||||||
m.origin=n,m.lods=j,b({initExtent:k,fullExtent:l,tileInfo:m,resultObj:d})})}},O.esri.Tiles.TilesStore=function(){this._db=null,this.dbName="offline_tile_store",this.objectStoreName="tilepath",this.isSupported=function(){return!(!window.indexedDB&&!window.openDatabase)},this.store=function(a,b){try{var c=this._db.transaction([this.objectStoreName],"readwrite")
|
m.origin=n,m.lods=j,b({initExtent:k,fullExtent:l,tileInfo:m,resultObj:d})})}},O.esri.Tiles.TilesStore=function(){this._db=null,this.dbName="offline_tile_store",this.objectStoreName="tilepath",this.isSupported=function(){return!(!window.indexedDB&&!window.openDatabase)},this.store=function(a,b){try{var c=this._db.transaction([this.objectStoreName],"readwrite")
|
||||||
c.oncomplete=function(){b(!0)},c.onerror=function(a){b(!1,a.target.error.message)}
|
c.oncomplete=function(){b(!0)},c.onerror=function(a){b(!1,a.target.error.message)}
|
||||||
var d=c.objectStore(this.objectStoreName)
|
var d=c.objectStore(this.objectStoreName)
|
||||||
a.img=O.esri.Tiles.Base64String.compress(a.img)
|
a.url=O.esri.Tiles.LZString.compress(a.url),a.img=O.esri.Tiles.Base64String.compress(a.img)
|
||||||
var e=d.put(a)
|
var e=d.put(a)
|
||||||
e.onsuccess=function(){}}catch(f){b(!1,f.stack)}},this.retrieve=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName),d=c.get(a)
|
e.onsuccess=function(){}}catch(f){b(!1,f.stack)}},this.retrieve=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName),d=c.get(O.esri.Tiles.LZString.compress(a))
|
||||||
d.onsuccess=function(a){var c=a.target.result
|
d.onsuccess=function(a){var c=a.target.result
|
||||||
void 0===c?b(!1,"not found"):(c.img=O.esri.Tiles.Base64String.decompress(c.img),b(!0,c))},d.onerror=function(a){b(!1,a)}}},this.deleteAll=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName).clear()
|
void 0===c?b(!1,"not found"):(c.url=O.esri.Tiles.LZString.decompress(c.url),c.img=O.esri.Tiles.Base64String.decompress(c.img),b(!0,c))},d.onerror=function(a){b(!1,a)}}},this.deleteAll=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName).clear()
|
||||||
b.onsuccess=function(){a(!0)},b.onerror=function(b){a(!1,b)}}else a(!1,null)},this["delete"]=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName)["delete"](a)
|
b.onsuccess=function(){a(!0)},b.onerror=function(b){a(!1,b)}}else a(!1,null)},this["delete"]=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName)["delete"](a)
|
||||||
c.onsuccess=function(){b(!0)},c.onerror=function(a){b(!1,a)}}else b(!1,null)},this.getAllTiles=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
c.onsuccess=function(){b(!0)},c.onerror=function(a){b(!1,a)}}else b(!1,null)},this.getAllTiles=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
||||||
b.onsuccess=function(b){var c=b.target.result
|
b.onsuccess=function(b){var c=b.target.result
|
||||||
if(c){var d=c.value.url,e=c.value.img
|
if(c){var d=c.value.url,e=c.value.img
|
||||||
a(d,e,null),c["continue"]()}else a(null,null,"end")}.bind(this),b.onerror=function(b){a(null,null,b)}}else a(null,null,"no db")},this.usedSpace=function(a){if(null!==this._db){var b={sizeBytes:0,tileCount:0},c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
d=O.esri.Tiles.LZString.decompress(d),e=O.esri.Tiles.Base64String.decompress(e),a(d,e,null),c["continue"]()}else a(null,null,"end")}.bind(this),b.onerror=function(b){a(null,null,b)}}else a(null,null,"no db")},this.usedSpace=function(a){if(null!==this._db){var b={sizeBytes:0,tileCount:0},c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
||||||
c.onsuccess=function(c){var d=c.target.result
|
c.onsuccess=function(c){var d=c.target.result
|
||||||
if(d){var e=d.value,f=JSON.stringify(e)
|
if(d){var e=d.value,f=JSON.stringify(e)
|
||||||
b.sizeBytes+=this._stringBytes(f),b.tileCount+=1,d["continue"]()}else a(b,null)}.bind(this),c.onerror=function(b){a(null,b)}}else a(null,null)},this._stringBytes=function(a){return a.length},this.init=function(a){var b=indexedDB.open(this.dbName,4)
|
b.sizeBytes+=this._stringBytes(f),b.tileCount+=1,d["continue"]()}else a(b,null)}.bind(this),c.onerror=function(b){a(null,b)}}else a(null,null)},this._stringBytes=function(a){return a.length},this.init=function(a){var b=indexedDB.open(this.dbName,4)
|
||||||
|
|||||||
503
dist/offline-tiles-basic-src.js
vendored
503
dist/offline-tiles-basic-src.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! esri-offline-maps - v3.4.0 - 2016-09-13
|
/*! esri-offline-maps - v3.5.0 - 2016-09-15
|
||||||
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
||||||
* Apache License*/
|
* Apache License*/
|
||||||
define([
|
define([
|
||||||
@ -785,6 +785,501 @@ O.esri.Tiles.Base64String = {
|
|||||||
|
|
||||||
/*jslint bitwise: false */
|
/*jslint bitwise: false */
|
||||||
|
|
||||||
|
// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
|
||||||
|
// This work is free. You can redistribute it and/or modify it
|
||||||
|
// under the terms of the WTFPL, Version 2
|
||||||
|
// For more information see LICENSE.txt or http://www.wtfpl.net/
|
||||||
|
//
|
||||||
|
// For more information, the home page:
|
||||||
|
// http://pieroxy.net/blog/pages/lz-string/testing.html
|
||||||
|
//
|
||||||
|
// LZ-based compression algorithm, version 1.4.4
|
||||||
|
O.esri.Tiles.LZString = (function() {
|
||||||
|
|
||||||
|
// private property
|
||||||
|
var f = String.fromCharCode;
|
||||||
|
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||||
|
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
||||||
|
var baseReverseDic = {};
|
||||||
|
|
||||||
|
function getBaseValue(alphabet, character) {
|
||||||
|
if (!baseReverseDic[alphabet]) {
|
||||||
|
baseReverseDic[alphabet] = {};
|
||||||
|
for (var i=0 ; i<alphabet.length ; i++) {
|
||||||
|
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return baseReverseDic[alphabet][character];
|
||||||
|
}
|
||||||
|
|
||||||
|
var LZString = {
|
||||||
|
compressToBase64 : function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
var res = LZString._compress(input, 6, function(a){return keyStrBase64.charAt(a);});
|
||||||
|
switch (res.length % 4) { // To produce valid Base64
|
||||||
|
default: // When could this happen ?
|
||||||
|
case 0 : return res;
|
||||||
|
case 1 : return res+"===";
|
||||||
|
case 2 : return res+"==";
|
||||||
|
case 3 : return res+"=";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
decompressFromBase64 : function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
if (input == "") return null;
|
||||||
|
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrBase64, input.charAt(index)); });
|
||||||
|
},
|
||||||
|
|
||||||
|
compressToUTF16 : function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
return LZString._compress(input, 15, function(a){return f(a+32);}) + " ";
|
||||||
|
},
|
||||||
|
|
||||||
|
decompressFromUTF16: function (compressed) {
|
||||||
|
if (compressed == null) return "";
|
||||||
|
if (compressed == "") return null;
|
||||||
|
return LZString._decompress(compressed.length, 16384, function(index) { return compressed.charCodeAt(index) - 32; });
|
||||||
|
},
|
||||||
|
|
||||||
|
//compress into uint8array (UCS-2 big endian format)
|
||||||
|
compressToUint8Array: function (uncompressed) {
|
||||||
|
var compressed = LZString.compress(uncompressed);
|
||||||
|
var buf=new Uint8Array(compressed.length*2); // 2 bytes per character
|
||||||
|
|
||||||
|
for (var i=0, TotalLen=compressed.length; i<TotalLen; i++) {
|
||||||
|
var current_value = compressed.charCodeAt(i);
|
||||||
|
buf[i*2] = current_value >>> 8;
|
||||||
|
buf[i*2+1] = current_value % 256;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
},
|
||||||
|
|
||||||
|
//decompress from uint8array (UCS-2 big endian format)
|
||||||
|
decompressFromUint8Array:function (compressed) {
|
||||||
|
if (compressed===null || compressed===undefined){
|
||||||
|
return LZString.decompress(compressed);
|
||||||
|
} else {
|
||||||
|
var buf=new Array(compressed.length/2); // 2 bytes per character
|
||||||
|
for (var i=0, TotalLen=buf.length; i<TotalLen; i++) {
|
||||||
|
buf[i]=compressed[i*2]*256+compressed[i*2+1];
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = [];
|
||||||
|
buf.forEach(function (c) {
|
||||||
|
result.push(f(c));
|
||||||
|
});
|
||||||
|
return LZString.decompress(result.join(''));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//compress into a string that is already URI encoded
|
||||||
|
compressToEncodedURIComponent: function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
return LZString._compress(input, 6, function(a){return keyStrUriSafe.charAt(a);});
|
||||||
|
},
|
||||||
|
|
||||||
|
//decompress from an output of compressToEncodedURIComponent
|
||||||
|
decompressFromEncodedURIComponent:function (input) {
|
||||||
|
if (input == null) return "";
|
||||||
|
if (input == "") return null;
|
||||||
|
input = input.replace(/ /g, "+");
|
||||||
|
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrUriSafe, input.charAt(index)); });
|
||||||
|
},
|
||||||
|
|
||||||
|
compress: function (uncompressed) {
|
||||||
|
return LZString._compress(uncompressed, 16, function(a){return f(a);});
|
||||||
|
},
|
||||||
|
_compress: function (uncompressed, bitsPerChar, getCharFromInt) {
|
||||||
|
if (uncompressed == null) return "";
|
||||||
|
var i, value,
|
||||||
|
context_dictionary= {},
|
||||||
|
context_dictionaryToCreate= {},
|
||||||
|
context_c="",
|
||||||
|
context_wc="",
|
||||||
|
context_w="",
|
||||||
|
context_enlargeIn= 2, // Compensate for the first entry which should not count
|
||||||
|
context_dictSize= 3,
|
||||||
|
context_numBits= 2,
|
||||||
|
context_data=[],
|
||||||
|
context_data_val=0,
|
||||||
|
context_data_position=0,
|
||||||
|
ii;
|
||||||
|
|
||||||
|
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
||||||
|
context_c = uncompressed.charAt(ii);
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(context_dictionary,context_c)) {
|
||||||
|
context_dictionary[context_c] = context_dictSize++;
|
||||||
|
context_dictionaryToCreate[context_c] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
context_wc = context_w + context_c;
|
||||||
|
if (Object.prototype.hasOwnProperty.call(context_dictionary,context_wc)) {
|
||||||
|
context_w = context_wc;
|
||||||
|
} else {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
||||||
|
if (context_w.charCodeAt(0)<256) {
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<8 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value = 1;
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | value;
|
||||||
|
if (context_data_position ==bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<16 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
delete context_dictionaryToCreate[context_w];
|
||||||
|
} else {
|
||||||
|
value = context_dictionary[context_w];
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
// Add wc to the dictionary.
|
||||||
|
context_dictionary[context_wc] = context_dictSize++;
|
||||||
|
context_w = String(context_c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output the code for w.
|
||||||
|
if (context_w !== "") {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
||||||
|
if (context_w.charCodeAt(0)<256) {
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<8 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value = 1;
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | value;
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
value = context_w.charCodeAt(0);
|
||||||
|
for (i=0 ; i<16 ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
delete context_dictionaryToCreate[context_w];
|
||||||
|
} else {
|
||||||
|
value = context_dictionary[context_w];
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
context_enlargeIn--;
|
||||||
|
if (context_enlargeIn == 0) {
|
||||||
|
context_enlargeIn = Math.pow(2, context_numBits);
|
||||||
|
context_numBits++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark the end of the stream
|
||||||
|
value = 2;
|
||||||
|
for (i=0 ; i<context_numBits ; i++) {
|
||||||
|
context_data_val = (context_data_val << 1) | (value&1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data_position = 0;
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
context_data_val = 0;
|
||||||
|
} else {
|
||||||
|
context_data_position++;
|
||||||
|
}
|
||||||
|
value = value >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush the last char
|
||||||
|
while (true) {
|
||||||
|
context_data_val = (context_data_val << 1);
|
||||||
|
if (context_data_position == bitsPerChar-1) {
|
||||||
|
context_data.push(getCharFromInt(context_data_val));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else context_data_position++;
|
||||||
|
}
|
||||||
|
return context_data.join('');
|
||||||
|
},
|
||||||
|
|
||||||
|
decompress: function (compressed) {
|
||||||
|
if (compressed == null) return "";
|
||||||
|
if (compressed == "") return null;
|
||||||
|
return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
|
||||||
|
},
|
||||||
|
|
||||||
|
_decompress: function (length, resetValue, getNextValue) {
|
||||||
|
var dictionary = [],
|
||||||
|
next,
|
||||||
|
enlargeIn = 4,
|
||||||
|
dictSize = 4,
|
||||||
|
numBits = 3,
|
||||||
|
entry = "",
|
||||||
|
result = [],
|
||||||
|
i,
|
||||||
|
w,
|
||||||
|
bits, resb, maxpower, power,
|
||||||
|
c,
|
||||||
|
data = {val:getNextValue(0), position:resetValue, index:1};
|
||||||
|
|
||||||
|
for (i = 0; i < 3; i += 1) {
|
||||||
|
dictionary[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,2);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (next = bits) {
|
||||||
|
case 0:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,8);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
c = f(bits);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,16);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
c = f(bits);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
dictionary[3] = c;
|
||||||
|
w = c;
|
||||||
|
result.push(c);
|
||||||
|
while (true) {
|
||||||
|
if (data.index > length) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,numBits);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (c = bits) {
|
||||||
|
case 0:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,8);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dictionary[dictSize++] = f(bits);
|
||||||
|
c = dictSize-1;
|
||||||
|
enlargeIn--;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
bits = 0;
|
||||||
|
maxpower = Math.pow(2,16);
|
||||||
|
power=1;
|
||||||
|
while (power!=maxpower) {
|
||||||
|
resb = data.val & data.position;
|
||||||
|
data.position >>= 1;
|
||||||
|
if (data.position == 0) {
|
||||||
|
data.position = resetValue;
|
||||||
|
data.val = getNextValue(data.index++);
|
||||||
|
}
|
||||||
|
bits |= (resb>0 ? 1 : 0) * power;
|
||||||
|
power <<= 1;
|
||||||
|
}
|
||||||
|
dictionary[dictSize++] = f(bits);
|
||||||
|
c = dictSize-1;
|
||||||
|
enlargeIn--;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return result.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enlargeIn == 0) {
|
||||||
|
enlargeIn = Math.pow(2, numBits);
|
||||||
|
numBits++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dictionary[c]) {
|
||||||
|
entry = dictionary[c];
|
||||||
|
} else {
|
||||||
|
if (c === dictSize) {
|
||||||
|
entry = w + w.charAt(0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.push(entry);
|
||||||
|
|
||||||
|
// Add w+entry[0] to the dictionary.
|
||||||
|
dictionary[dictSize++] = w + entry.charAt(0);
|
||||||
|
enlargeIn--;
|
||||||
|
|
||||||
|
w = entry;
|
||||||
|
|
||||||
|
if (enlargeIn == 0) {
|
||||||
|
enlargeIn = Math.pow(2, numBits);
|
||||||
|
numBits++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return LZString;
|
||||||
|
})();
|
||||||
/* FileSaver.js
|
/* FileSaver.js
|
||||||
* A saveAs() FileSaver implementation.
|
* A saveAs() FileSaver implementation.
|
||||||
* 2013-10-21
|
* 2013-10-21
|
||||||
@ -1472,6 +1967,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
var objectStore = transaction.objectStore(this.objectStoreName);
|
var objectStore = transaction.objectStore(this.objectStoreName);
|
||||||
|
urlDataPair.url = O.esri.Tiles.LZString.compress(urlDataPair.url);
|
||||||
urlDataPair.img = O.esri.Tiles.Base64String.compress(urlDataPair.img);
|
urlDataPair.img = O.esri.Tiles.Base64String.compress(urlDataPair.img);
|
||||||
var request = objectStore.put(urlDataPair);
|
var request = objectStore.put(urlDataPair);
|
||||||
request.onsuccess = function()
|
request.onsuccess = function()
|
||||||
@ -1496,7 +1992,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
if(this._db !== null)
|
if(this._db !== null)
|
||||||
{
|
{
|
||||||
var objectStore = this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName);
|
var objectStore = this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName);
|
||||||
var request = objectStore.get(url);
|
var request = objectStore.get(O.esri.Tiles.LZString.compress(url));
|
||||||
request.onsuccess = function(event)
|
request.onsuccess = function(event)
|
||||||
{
|
{
|
||||||
var result = event.target.result;
|
var result = event.target.result;
|
||||||
@ -1506,6 +2002,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
result.url = O.esri.Tiles.LZString.decompress(result.url);
|
||||||
result.img = O.esri.Tiles.Base64String.decompress(result.img);
|
result.img = O.esri.Tiles.Base64String.decompress(result.img);
|
||||||
callback(true,result);
|
callback(true,result);
|
||||||
}
|
}
|
||||||
@ -1588,6 +2085,8 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
if(cursor){
|
if(cursor){
|
||||||
var url = cursor.value.url;
|
var url = cursor.value.url;
|
||||||
var img = cursor.value.img;
|
var img = cursor.value.img;
|
||||||
|
url = O.esri.Tiles.LZString.decompress(url);
|
||||||
|
img = O.esri.Tiles.Base64String.decompress(img);
|
||||||
callback(url,img,null);
|
callback(url,img,null);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
}
|
}
|
||||||
|
|||||||
8
dist/offline-tpk-min.js
vendored
8
dist/offline-tpk-min.js
vendored
@ -52,16 +52,16 @@ return 16+5*f},_getCacheFilePath:function(a,b,c,d){var e=[]
|
|||||||
return e.push(a),e.push("/"),e.push("L"),e.push(10>b?"0"+b:b),e.push("/"),e.push("R"),e.push(this._int2HexString(c)),e.push("C"),e.push(this._int2HexString(d)),e.join("")},_bytes2MBs:function(a){return(a>>>20)+"."+(2046&a)}})}),"undefined"!=typeof O?O.esri.TPK={}:(O={},O.esri={TPK:{},Tiles:{}}),O.esri.Tiles.TilesStore=function(){this._db=null,this.dbName="offline_tile_store",this.objectStoreName="tilepath",this.isSupported=function(){return!(!window.indexedDB&&!window.openDatabase)},this.store=function(a,b){try{var c=this._db.transaction([this.objectStoreName],"readwrite")
|
return e.push(a),e.push("/"),e.push("L"),e.push(10>b?"0"+b:b),e.push("/"),e.push("R"),e.push(this._int2HexString(c)),e.push("C"),e.push(this._int2HexString(d)),e.join("")},_bytes2MBs:function(a){return(a>>>20)+"."+(2046&a)}})}),"undefined"!=typeof O?O.esri.TPK={}:(O={},O.esri={TPK:{},Tiles:{}}),O.esri.Tiles.TilesStore=function(){this._db=null,this.dbName="offline_tile_store",this.objectStoreName="tilepath",this.isSupported=function(){return!(!window.indexedDB&&!window.openDatabase)},this.store=function(a,b){try{var c=this._db.transaction([this.objectStoreName],"readwrite")
|
||||||
c.oncomplete=function(){b(!0)},c.onerror=function(a){b(!1,a.target.error.message)}
|
c.oncomplete=function(){b(!0)},c.onerror=function(a){b(!1,a.target.error.message)}
|
||||||
var d=c.objectStore(this.objectStoreName)
|
var d=c.objectStore(this.objectStoreName)
|
||||||
a.img=O.esri.Tiles.Base64String.compress(a.img)
|
a.url=O.esri.Tiles.LZString.compress(a.url),a.img=O.esri.Tiles.Base64String.compress(a.img)
|
||||||
var e=d.put(a)
|
var e=d.put(a)
|
||||||
e.onsuccess=function(){}}catch(f){b(!1,f.stack)}},this.retrieve=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName),d=c.get(a)
|
e.onsuccess=function(){}}catch(f){b(!1,f.stack)}},this.retrieve=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName),d=c.get(O.esri.Tiles.LZString.compress(a))
|
||||||
d.onsuccess=function(a){var c=a.target.result
|
d.onsuccess=function(a){var c=a.target.result
|
||||||
void 0===c?b(!1,"not found"):(c.img=O.esri.Tiles.Base64String.decompress(c.img),b(!0,c))},d.onerror=function(a){b(!1,a)}}},this.deleteAll=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName).clear()
|
void 0===c?b(!1,"not found"):(c.url=O.esri.Tiles.LZString.decompress(c.url),c.img=O.esri.Tiles.Base64String.decompress(c.img),b(!0,c))},d.onerror=function(a){b(!1,a)}}},this.deleteAll=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName).clear()
|
||||||
b.onsuccess=function(){a(!0)},b.onerror=function(b){a(!1,b)}}else a(!1,null)},this["delete"]=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName)["delete"](a)
|
b.onsuccess=function(){a(!0)},b.onerror=function(b){a(!1,b)}}else a(!1,null)},this["delete"]=function(a,b){if(null!==this._db){var c=this._db.transaction([this.objectStoreName],"readwrite").objectStore(this.objectStoreName)["delete"](a)
|
||||||
c.onsuccess=function(){b(!0)},c.onerror=function(a){b(!1,a)}}else b(!1,null)},this.getAllTiles=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
c.onsuccess=function(){b(!0)},c.onerror=function(a){b(!1,a)}}else b(!1,null)},this.getAllTiles=function(a){if(null!==this._db){var b=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
||||||
b.onsuccess=function(b){var c=b.target.result
|
b.onsuccess=function(b){var c=b.target.result
|
||||||
if(c){var d=c.value.url,e=c.value.img
|
if(c){var d=c.value.url,e=c.value.img
|
||||||
a(d,e,null),c["continue"]()}else a(null,null,"end")}.bind(this),b.onerror=function(b){a(null,null,b)}}else a(null,null,"no db")},this.usedSpace=function(a){if(null!==this._db){var b={sizeBytes:0,tileCount:0},c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
d=O.esri.Tiles.LZString.decompress(d),e=O.esri.Tiles.Base64String.decompress(e),a(d,e,null),c["continue"]()}else a(null,null,"end")}.bind(this),b.onerror=function(b){a(null,null,b)}}else a(null,null,"no db")},this.usedSpace=function(a){if(null!==this._db){var b={sizeBytes:0,tileCount:0},c=this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName).openCursor()
|
||||||
c.onsuccess=function(c){var d=c.target.result
|
c.onsuccess=function(c){var d=c.target.result
|
||||||
if(d){var e=d.value,f=JSON.stringify(e)
|
if(d){var e=d.value,f=JSON.stringify(e)
|
||||||
b.sizeBytes+=this._stringBytes(f),b.tileCount+=1,d["continue"]()}else a(b,null)}.bind(this),c.onerror=function(b){a(null,b)}}else a(null,null)},this._stringBytes=function(a){return a.length},this.init=function(a){var b=indexedDB.open(this.dbName,4)
|
b.sizeBytes+=this._stringBytes(f),b.tileCount+=1,d["continue"]()}else a(b,null)}.bind(this),c.onerror=function(b){a(null,b)}}else a(null,null)},this._stringBytes=function(a){return a.length},this.init=function(a){var b=indexedDB.open(this.dbName,4)
|
||||||
|
|||||||
8
dist/offline-tpk-src.js
vendored
8
dist/offline-tpk-src.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! esri-offline-maps - v3.4.0 - 2016-09-13
|
/*! esri-offline-maps - v3.5.0 - 2016-09-15
|
||||||
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
|
||||||
* Apache License*/
|
* Apache License*/
|
||||||
/**
|
/**
|
||||||
@ -794,6 +794,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
var objectStore = transaction.objectStore(this.objectStoreName);
|
var objectStore = transaction.objectStore(this.objectStoreName);
|
||||||
|
urlDataPair.url = O.esri.Tiles.LZString.compress(urlDataPair.url);
|
||||||
urlDataPair.img = O.esri.Tiles.Base64String.compress(urlDataPair.img);
|
urlDataPair.img = O.esri.Tiles.Base64String.compress(urlDataPair.img);
|
||||||
var request = objectStore.put(urlDataPair);
|
var request = objectStore.put(urlDataPair);
|
||||||
request.onsuccess = function()
|
request.onsuccess = function()
|
||||||
@ -818,7 +819,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
if(this._db !== null)
|
if(this._db !== null)
|
||||||
{
|
{
|
||||||
var objectStore = this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName);
|
var objectStore = this._db.transaction([this.objectStoreName]).objectStore(this.objectStoreName);
|
||||||
var request = objectStore.get(url);
|
var request = objectStore.get(O.esri.Tiles.LZString.compress(url));
|
||||||
request.onsuccess = function(event)
|
request.onsuccess = function(event)
|
||||||
{
|
{
|
||||||
var result = event.target.result;
|
var result = event.target.result;
|
||||||
@ -828,6 +829,7 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
result.url = O.esri.Tiles.LZString.decompress(result.url);
|
||||||
result.img = O.esri.Tiles.Base64String.decompress(result.img);
|
result.img = O.esri.Tiles.Base64String.decompress(result.img);
|
||||||
callback(true,result);
|
callback(true,result);
|
||||||
}
|
}
|
||||||
@ -910,6 +912,8 @@ O.esri.Tiles.TilesStore = function(){
|
|||||||
if(cursor){
|
if(cursor){
|
||||||
var url = cursor.value.url;
|
var url = cursor.value.url;
|
||||||
var img = cursor.value.img;
|
var img = cursor.value.img;
|
||||||
|
url = O.esri.Tiles.LZString.decompress(url);
|
||||||
|
img = O.esri.Tiles.Base64String.decompress(img);
|
||||||
callback(url,img,null);
|
callback(url,img,null);
|
||||||
cursor.continue();
|
cursor.continue();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ Deletes all tiles stored in the indexed db database.
|
|||||||
The callback is called to indicate success (true) or failure (false,err)
|
The callback is called to indicate success (true) or failure (false,err)
|
||||||
|
|
||||||
####basemap.getOfflineUsage(callback)
|
####basemap.getOfflineUsage(callback)
|
||||||
It calculates the number of tiles that are stored in the indexed db database and the space used by them. The callback is called with an object containing the result of this calculation:
|
It calculates the number of tiles that are stored in the indexed db database and the space used by them. Because the library uses compression, the database size will be significantly smaller than the downloaded tiles size. The callback is called with an object containing the result of this calculation:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
@ -245,4 +245,6 @@ If you are using an optimized version of the ArcGIS API for JavaScript make sure
|
|||||||
|
|
||||||
Our general guideline for the amount of total storage you can use on a device is be between 50MBs and 100MBs. If you need greater storage than that you'll need to either switch to a hybrid model (e.g. PhoneGap) or use one of our native ArcGIS Runtime SDKs. The Runtime SDKs have fully supported and robust offline capabilities that go beyond what JavaScript is currently capable of.
|
Our general guideline for the amount of total storage you can use on a device is be between 50MBs and 100MBs. If you need greater storage than that you'll need to either switch to a hybrid model (e.g. PhoneGap) or use one of our native ArcGIS Runtime SDKs. The Runtime SDKs have fully supported and robust offline capabilities that go beyond what JavaScript is currently capable of.
|
||||||
|
|
||||||
|
The library helps where it can by providing 2.7x compression of the tile imagery and about 50% compression of the tile URLs.
|
||||||
|
|
||||||
Some developers have mentioned that they have stored alot more than 100MBs. How much you can store varies between devices and browsers. Every mobile operating system sets a limit on how much memory a single application can use. Since web apps are dependant on the browser, which is a web app, if it consumes too much memory the operating system will simply kill the browser. Poof and it's gone. So, web apps are dependant on a variety of things including how many other browser tabs are open, browser memory leakage especially if it's been running for a long time, other storage being used such as feature edits, the application cache and the general browser cache.
|
Some developers have mentioned that they have stored alot more than 100MBs. How much you can store varies between devices and browsers. Every mobile operating system sets a limit on how much memory a single application can use. Since web apps are dependant on the browser, which is a web app, if it consumes too much memory the operating system will simply kill the browser. Poof and it's gone. So, web apps are dependant on a variety of things including how many other browser tabs are open, browser memory leakage especially if it's been running for a long time, other storage being used such as feature edits, the application cache and the general browser cache.
|
||||||
|
|||||||
@ -134,6 +134,8 @@ The following three properties will affect the size of the TPK file. Minimizing
|
|||||||
|
|
||||||
It's a general recommended to keep the size of the local database below 75MBs, with a maximum of 100MBs for best performance. Allowing the database to grow to large can result in browser crashes and slow app performance.
|
It's a general recommended to keep the size of the local database below 75MBs, with a maximum of 100MBs for best performance. Allowing the database to grow to large can result in browser crashes and slow app performance.
|
||||||
|
|
||||||
|
The library helps where it can by providing 2.7x compression of the tile imagery and about 50% compression of the tile URLs.
|
||||||
|
|
||||||
The amount of memory allowed to the browser is dependant on many variables including the available device memory, other applications already running and the number of open browser tabs.
|
The amount of memory allowed to the browser is dependant on many variables including the available device memory, other applications already running and the number of open browser tabs.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "esri-offline-maps",
|
"name": "esri-offline-maps",
|
||||||
"version": "3.4.0",
|
"version": "3.5.0",
|
||||||
"description": "Lightweight set of libraries for working offline with map tiles and editing with ArcGIS feature services",
|
"description": "Lightweight set of libraries for working offline with map tiles and editing with ArcGIS feature services",
|
||||||
"author": "Andy Gup <agup@esri.com> (http://blog.andygup.net)",
|
"author": "Andy Gup <agup@esri.com> (http://blog.andygup.net)",
|
||||||
"license": "Apache 2.0",
|
"license": "Apache 2.0",
|
||||||
@ -15,7 +15,8 @@
|
|||||||
"offline",
|
"offline",
|
||||||
"gis",
|
"gis",
|
||||||
"maps",
|
"maps",
|
||||||
"mapping"
|
"mapping",
|
||||||
|
"tiles"
|
||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
"appHomePage": "appcache-tiles.html",
|
"appHomePage": "appcache-tiles.html",
|
||||||
"optimizedApiURL": "../samples/jsolib",
|
"optimizedApiURL": "../samples/jsolib",
|
||||||
"arcGISBaseURL": "http://js.arcgis.com/3.14",
|
"arcGISBaseURL": "http://js.arcgis.com/3.14",
|
||||||
"version": "3.4.0",
|
"version": "3.5.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "manifest generator project",
|
"description": "manifest generator project",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user