Open jingsam opened 8 years ago
I am currently working on a web mapping platform built with Express. A nodejs bindings would be great so that I could integrate Tippecanoe in our platform.
If you are serving tiles dynamically, you may be better off using https://github.com/mapbox/geojson-vt. Hard to say without knowing more about what you are doing.
This might be possible, although Tippecanoe is structured to operate as a program, not as a library. How are you thinking you would like to be able to use it?
@ericfischer One thought I've had before is that if Tippecanoe exposed a limited library interface for data input, maybe that would afford a way to skip the geojson parsing step, which I remember you saying is one of the main bottlenecks?
@anandthakker That would make sense. As it is the generation of the internal representation of geometries is highly tangled up with GeoJSON parsing and with the notion that there are a fixed number of parser threads, but it would be great to get that all straightened out and cleaned up.
@ericfischer Hi, saw your comment about using https://github.com/mapbox/geojson-vt, but it can't export vector tiles to MBTiles. From what I gather, only tippecanoe can do this (outside of using a desktop like software such as MapBox Studio), am I mistaken ?
@clouddie I think https://github.com/mapbox/vt-pbf should let you create vector tiles from JavaScript.
@ericfischer I agree, but it does not create mbtiles, isn't it ?
@clouddie It doesn't, but you could use https://github.com/mapbox/node-sqlite3 to create an mbtiles file and write the tiles to it.
Most of what tippecanoe does with mbtiles is mostly just sqlite insert
s of tiles into the database. The only messy part is making the vector_layers
row in the metadata
table, but that should be easier from JavaScript than it is from C++ since you can make it as a JavaScript object and stringify it instead of having to build the structure by hand. I think you should just be able to copy most of the SQL from https://github.com/mapbox/tippecanoe/blob/master/mbtiles.cpp to do exactly the same thing Tippecanoe does, but from JavaScript instead of C++.
@ericfischer Thanks for the tip, I am usually so terrified by C++ that I don't dare look at source code (hence my comment on node bindings). I will give it a go !
@ericfischer @jingsam You could just spawn a child process and manipulate the stdout for feedback etc. Assuming you have tippecanoe installed you can simply call it in a node script as such:
`var exec = require('child_process') .exec, output = "test.mbtiles", input = "test.geojson", layername ='test';
execute('tippecanoe -o '+output+' -l '+layername+' '+input+'');
function execute(command) {
var child = exec(command); child.stdout.on('data', function (data) { console.log('stdout: ' + data); //cb(data); }); child.stderr.on('data', function (data) { //console.log('stdout: ' + data); }); child.on('close', function (code) { console.log('closing code: ' + code); });
}`
This would help with wrapping tippecanoe behind a node powered web app. Like http://ogre.adc4gis.com but for tippecanoe. Sure we can spawn a child process but proper bindings would make this nicer.
Currently tippecanoe's error handling is far too reliant on exiting when an error is encountered to make it viable to use as a library instead of in its own process. Maybe someday I can get that straightened out but probably not any time soon.
This might be possible, although Tippecanoe is structured to operate as a program, not as a library. How are you thinking you would like to be able to use it? Give it JSON text and get back an mbtiles file, or are you wanting it to work on JSON objects and give access to individual tiles?