-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream in geojson/geobuf and stream out tiles #675
Comments
My typical usage with streaming input is
or, if I want a different layer name,
There is currently no support for streaming geobuf, because The error message you are seeing is because if the attempt to memory-map the input fails, the regular JSON parser gets a chance to run on the input. This makes sense for memory-mapped JSON files vs JSON streams, but not for geobuf, so I should fix that. It would certainly be possible to do streaming output of GeoJSON or something similar, replacing the call to |
Thanks for the response! I am not sure what I did wrong originally with streaming in geojson, I'm sure I made some typo and "fixed" it when I tried with the layer json. Will use your method. Good to know on the geobuf - not a deal breaker at all for me and GeoJSON is of course usable. For streaming output I basically just want to pipe the pbf tippecanoe produces, along with its XYZ, into a different program which will directly work with the data there and finally write the output to my own database instead. So a JSON with x, y, z, and pbf would work for me. Not sure how you'd handle the tileset metadata, though. |
Maybe it would be reasonable to write out the tiles in |
|
@ericfischer Quick follow-up on this: I'm trying to use AWS Lambda to, in realtime, update a tile directory on S3 (related: #776, #741) from a Postgres database. I've created an AWS Lambda Layer ( I can foresee this approach being problematic for very large files. What I'd prefer is if there was a way to output each tile as it is generated to Example of current (not ideal) process:
|
If you just want to write each tile to stdout in a way that you can read back in from something further down the pipeline in a streaming way, the easiest thing would be to replace
For each tile it will write out a line with the zoom, x, and y coordinates, and the hex-encoded content of the tile, which you can then decode back into the tile data in your reader. Writing a |
Awesome! I'll give it a go. If i can come up with a solid solution for a fully Lambda-hosted solution, I'll make a note for future users who are hoping to go Serverless with Tippecanoe. |
@ericfischer OK, so I think I've got just about everything working except I'm trying to figure out the best way to send the hex-encoded data to S3 to create a PBF file. I'm using NodeJS's
Here's an example output array (from question 2, above, and split by
It would be amazing if we could get a new potential option, similar to -o and -e, that would stream the tiles so that they could easily be sent to a remote server. Something like |
It's not intentional that there are two hex strings in the line, so maybe there is some multithreaded locking problem going on. The format of each line is intended to just be
Do the hex strings decode to valid tiles for you? The use of sqlite is just to package the tiles into mbtiles format. If you are not using mbtiles, you could use the Tile-join also calls I agree that an |
It looks like every time I receive 2 additional hex codes (unrelated to the actual tiles). Example:
Seems to be working. I ended up converting the hex code to a buffer using Javascript's Is there an easy way to also run the metadata?
It seems to me that this would be a nice agnostic way to push to any sort of database (see #87, #751, #741, et al). Especially as the world moves increasingly towards serverless, I think that this will be an invaluable option for most. In my mind, the best format would be to output each tile as you have above (z x y hex; alternatively, hex could be a buffer) and also output the metadata. My guess is that this should be sufficient for most. For reference, here's an example of my finalized code for creating tiles in S3 using Lambda from a separate event trigger for S3. The function also uses a Lambda Layer
|
One more specific use case where If I try to recreate this on AWS Lambda, I have to choose whether to use the original output to .mbtiles or the updated code above for streaming. My ideal workflow would be:
|
@ericfischer Quick question: re solution above: How do I generate metadata? Based on my ignorant glance at the code, it looks like the metadata creation step requires a sqlite database to be created (which the above code skips). Is that correct? Any tips on a succinct way to stream the output while also creating a metadata file? |
It really should have been somewhere in Line 493 in d96b521
In this situation it writes the metadata into a temporary sqlite database, allocated here: Line 277 in d96b521
and then copies the metadata from that table into the |
Gotcha. So in order to output the metadata to a stream, I'll need to get rid of EDIT: I suppose I could also just output to the Lambda tmp folder and then copy from there as well. |
Sorry it's not clearer, but yes, getting rid of the Were you able to get straightened out whatever was causing the extra hex codes? |
I wasn't but it doesn't seem to be a problem. I was able to get my serverless workflow working (although a bit hack-y but doesn't seem to be a problem so far) which was the main goal. Thanks for the help. I'll see if I can figure out how to stream the metadata. |
Great, I hope it works! I think I'm going to go ahead and put a branch that writes to |
#789 adds the |
@stdmn |
Try the new version: arn:aws:lambda:us-east-1:003014164496:layer:Mapbox_Tippecanoe-1_34_3:9 Quick note: I've done a frankenstein and created a version that includes two new functions, tippecanoe-stream and tile-join-stream, that stream the output instead of writing to files. You can still use tippecanoe and tile-join if you want to write to files. Quick note 2: This layer works on
|
Unfortunately that version didn't work as well but I managed to run it myself. Probably you need to assign additional policies that will make it available publicly. |
In case anyone else is interested I made a Dockerfile setup for creating a Tippecanoe lambda layer here: |
Hi! Having some trouble setting up tippecanoe to do tiling without actually writing to file and I would love some assistance.
I was able to get geojson to stream with the following command:
echo '{"type":"Polygon","coordinates":[[[0,0],[0,1],[1,1],[1,0],[0,0]]]}' | tippecanoe -L'{"file":"", "layer":"test", "description":"test"}' -e test
Which didn't feel quite right, as I am basically passing in an almost empty layer json just to get it to stream. What is the intended method to accomplish this with geojson? Related to that, how would I pipe in a geobuf with the same method? When I try inserting an example base64 encoded geobuf, e.g.
CgRuYW1lGAAiHQobCgwIBBoIAAAAAgIAAAFqBwoFdGVzdDFyAgAA
into stdin then I get an error about an unexpected character, leading me to believe that it is expecting geojson. Would love some guidance on this.I also am wondering if it is possible to stream the output to stdout in some sort of structured way instead of writing to files/.mbtiles. From the documentation it looks like this may be a lot more complicated/not feasible for me to write, but if there are any known methods to do this that would be most appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: