Reading, Modifying and Writing a pmtiles file using node (preferably) #26
-
Hello, i would like to read a planet.pmtiles file add some properties, and write the result, i thought that is an easier way to add data to my pmtiles file than to generate the whole file from pbf, because all the geometry is allready present |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
There isn't a package I know of to do this in NodeJS right now. You would need to:
|
Beta Was this translation helpful? Give feedback.
-
i tried a new approach, reading from pmtiles, writing to mbtiles, it works ! the final working code :) thx for inspiration. `import fs from 'fs' import { PMTiles } from 'pmtiles' import { lngLatToTileCoord } from '@mymap/map_utilities' const pathToThisModule = fileURLToPath(import.meta.url) class FileSource { getKey() { async getBytes(offset, length) { /* const processSegment = async (sourceFilePath, destinationFilePath, segment) => { new MBTiles(destinationFilePath + '?mode=rwc', (error, mbtiles) => {
}) |
Beta Was this translation helpful? Give feedback.
i tried a new approach, reading from pmtiles, writing to mbtiles, it works !
the final working code :) thx for inspiration.
`import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import { Worker, isMainThread, parentPort, workerData } from 'worker_threads'
import { PMTiles } from 'pmtiles'
import MBTiles from '@mapbox/mbtiles'
import { VectorTile } from '@mapbox/vector-tile'
import Pbf from 'pbf'
import vtpbf from 'vt-pbf'
import { lngLatToTileCoord } from '@mymap/map_utilities'
const pathToThisModule = fileURLToPath(import.meta.url)
class FileSource {
constructor(filename) {
this.fd = fs.openSync(filename, 'r')
}
getKey() {
return ''
}
async getBytes(offset, len…