https://github.com/syncpoint/compact-cache-bundle

 

install and edit index.js file as

cmd run: 

    node index.js

will generate all tile such as 4-6.png ... in same directory, copy it to L08/

 

'use strict'
 
const bundle = require('@syncpoint/compact-cache-bundle')
 
//const file = '/Volumes/f/gis_data/tpkx/doc/tile-package-spec-master/Sample\ TPKX\ Files/Usa/tile/L01/R0000C0000.bundle'

const file = '/Volumes/f/gis_data/tpkx/tile/mgrs_tile/tile/L07/R0000C0000.bundle'

/* you don't have to use it the asynchronous way */
const fs = require('fs')
const { promisify } = require('util')
const fsOpen = promisify(fs.open)
const fsClose = promisify(fs.close)
const fsWrite = promisify(fs.write)
 
; (async () => {
let fd
try {
fd = await fsOpen(file, 'r')
 
const bundleHeader = await bundle.header(fd)
console.dir(bundleHeader)
 
const records = await bundle.tileIndex(fd)
console.dir(records)
 
const bundleOffset = bundle.offset(file)
 
/* please read ESRI's technical specification for details */
for (let r = 0; r < records.length; r++) {
let tile = await bundle.tiles(fd, records[r])
 
const absRow = bundleOffset.rowOffset + records[r].row
const absColumn = bundleOffset.columnOffset + records[r].column
/* please check the tile format upfront */
const fileName = `${absRow}-${absColumn}.png`
 
let outputFd
try {
outputFd = await fsOpen(fileName, 'w')
await fsWrite(outputFd, tile)
console.log(`created file ${fileName}`)
}
catch (error) {
console.dir(error)
}
finally {
await fsClose(outputFd)
}
}
}
catch (error) {
console.dir(error)
}
finally {
await fsClose(fd)
}
 
})()
by

Please log in or register