-
-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add support for simple file output streams: CSV, JSON, protobuf #639
Conversation
6226783
to
d4cc04e
Compare
https://github.com/onthegomap/planetiler/actions/runs/5952929664 ℹ️ Base Logs a8e432d
ℹ️ This Branch Logs fbb6ab5
|
4a763e0
to
c221551
Compare
The primary use case for writing tile data to files using simple formats, is to provide a simple plugin system. By using named pipes data can be transformed and processed directly - e.g. to push to s3 or to store in a DB, without any intermediate file. This - depending on the use-case - also allows concurrent writing to multiple files. note: JSON entries are separated by newline, and protobuf messages are length-delimited.
c221551
to
5d7bebe
Compare
to allow to disable tile compression if some usecase doesn't requrie it
and run "standard" planetiler test for the new formats
4e519dc
to
e8e08c2
Compare
- generate the list of formats for which append/tile_write_threads is allowed, dynamically - centralize parsing & description for "escaped strings" ('\n', ' ', ...) and explain how to pass as query param - make CSV line separator/ending configurable
base64, hex (0001), hex_prefix_start (\x0001), hex_prefix_each (\x00\x01) hex(_prefix_start) allows a simple import into PostgreSQL, and should be useful for other scenarios as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! I think that we'd still eventually want to add native support for more popular output formats (s3/file/postgres) as that will most likely end up having the best performance (and support reads/copying between formats), but I do like having the ability to support any kind of output format using this technique!
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchiveWriter.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchiveWriter.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/ReadableTileArchive.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchiveConfig.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchiveMetadata.java
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WriteableJsonStreamArchive.java
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WriteableJsonStreamArchive.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WriteableProtoStreamArchive.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/Planetiler.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WriteableProtoStreamArchive.java
Outdated
Show resolved
Hide resolved
...and store/use that info in mbtiles, pmtiles, json, proto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good! A few mostly minor comments.
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WriteableProtoStreamArchive.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchiveConfig.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WriteableProtoStreamArchive.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WritableStreamArchive.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/test/java/com/onthegomap/planetiler/pmtiles/PmtilesTest.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchiveWriter.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/mbtiles/Mbtiles.java
Show resolved
Hide resolved
planetiler-core/src/test/java/com/onthegomap/planetiler/stream/StreamArchiveUtilsTest.java
Outdated
Show resolved
Hide resolved
...iler-core/src/test/java/com/onthegomap/planetiler/stream/WriteableJsonStreamArchiveTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I ran this locally and noticed 2 minor things, after that looks good to merge.
planetiler-core/src/main/java/com/onthegomap/planetiler/stream/WriteableCsvArchive.java
Outdated
Show resolved
Hide resolved
planetiler-core/src/main/java/com/onthegomap/planetiler/archive/TileArchives.java
Outdated
Show resolved
Hide resolved
091cfcf
to
da9b304
Compare
I think I addressed everything now |
Kudos, SonarCloud Quality Gate passed! |
Looks great! Thanks for adding this. |
The primary use case for writing tile data to files using simple formats, is to provide a simple plugin mechanism. By using named pipes data can be transformed and processed directly - e.g. to upload to s3 or to store in a DB, without any intermediate file (mbtiles/pmtiles).
This - depending on the use-case - also allows concurrent writing to separate files. I left a few questions in
TileArchiveWriter
about what needs to be done to handle that there.Formats
JSON
entries are separated by newline (can be changed via config), and the output of non-tile entries can be suppressed
CSV
the value separator can be changed, and no meta data is output in that format
protobuf
protobuf-message are length-delimited
in Java the messages can be read from the file/pipe as follows:
Use cases
s3
A very simple example to push tiles directly to s3 could look likes this:
mkfifo /tmp/data/output.csv ./s3-upload < /tmp/data/output.csv java -Xmx1g -jar planetiler.jar --download --area=monaco --append --output=/tmp/data/output.csv
with
s3-upload
being something like this:Parallel:
DB
MySQL
PostgreSQL
This is related to: