Created
November 5, 2020 05:01
-
-
Save mk30/92e25b20cf84a857b361831f1cb8ac3f to your computer and use it in GitHub Desktop.
georender-pack examples for files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var xhr = require('xhr') | |
| var decode = require('../decode.js') | |
| var buffers = [] | |
| xhr.get('./alexbufarr', function(err, resp) { //input filename is hardcoded here | |
| resp.body.split('\n').forEach(function(line){ | |
| if (line.length != 0){ | |
| buffers.push(Buffer.from(line, 'base64')) | |
| } | |
| else return | |
| }) | |
| console.log(decode(buffers)) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //sample usage: node encode-file.js alexandria.pbf > alexlabelbuf3 | |
| var fs = require('fs') | |
| var through = require('through2') | |
| var parseOSM = require('osm-pbf-parser') | |
| var georenderPack = require('../encode.js') | |
| var osm = parseOSM() | |
| var allItems = {} | |
| var itemsRefsObject = {} | |
| fs.createReadStream(process.argv[2]) | |
| .pipe(osm) | |
| .pipe(through.obj(write, end)) | |
| function write (items, enc, next) { | |
| items.forEach(function (item) { | |
| if (item.type === 'node') { | |
| allItems[item.id] = item | |
| } | |
| else if (item.type === 'way') { | |
| allItems[item.id] = item | |
| item.refs.forEach(function (ref) { | |
| if (!itemsRefsObject[ref]) itemsRefsObject[ref] = allItems[ref] | |
| else return | |
| }) | |
| } | |
| }) | |
| next() | |
| } | |
| function end (next) { | |
| Object.values(allItems).forEach(function (item) { | |
| //console.log(georenderPack(item, itemsRefsObject).toString('hex')) | |
| console.log(georenderPack(item, itemsRefsObject).toString('base64')) | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment