mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 16:35:40 +02:00
tippecanoe main writes pmtiles output. [#10]
* detect output format using suffix * after mbtiles is done writing, replace with pmtiles based on map/image tables. * add method to write_json for writing json sub-object.
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "jsonpull/jsonpull.h"
|
||||
#include "mbtiles.hpp"
|
||||
#include "pmtiles_file.hpp"
|
||||
#include "tile.hpp"
|
||||
#include "pool.hpp"
|
||||
#include "projection.hpp"
|
||||
@@ -1155,7 +1156,7 @@ void choose_first_zoom(long long *file_bbox, std::vector<struct reader> &readers
|
||||
}
|
||||
}
|
||||
|
||||
int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, const char *outdir, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, json_object *filter, double droprate, int buffer, const char *tmpdir, double gamma, int read_parallel, int forcetable, const char *attribution, bool uses_gamma, long long *file_bbox, const char *prefilter, const char *postfilter, const char *description, bool guess_maxzoom, std::map<std::string, int> const *attribute_types, const char *pgm, std::map<std::string, attribute_op> const *attribute_accum, std::map<std::string, std::string> const &attribute_descriptions, std::string const &commandline, int minimum_maxzoom) {
|
||||
std::pair<int, metadata> read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzoom, int basezoom, double basezoom_marker_width, sqlite3 *outdb, const char *outdir, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, json_object *filter, double droprate, int buffer, const char *tmpdir, double gamma, int read_parallel, int forcetable, const char *attribution, bool uses_gamma, long long *file_bbox, const char *prefilter, const char *postfilter, const char *description, bool guess_maxzoom, std::map<std::string, int> const *attribute_types, const char *pgm, std::map<std::string, attribute_op> const *attribute_accum, std::map<std::string, std::string> const &attribute_descriptions, std::string const &commandline, int minimum_maxzoom) {
|
||||
int ret = EXIT_SUCCESS;
|
||||
|
||||
std::vector<struct reader> readers;
|
||||
@@ -1290,6 +1291,7 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
||||
".geojson",
|
||||
".geobuf",
|
||||
".mbtiles",
|
||||
".pmtiles",
|
||||
".csv",
|
||||
".gz",
|
||||
};
|
||||
@@ -2571,7 +2573,7 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
||||
dir_write_metadata(outdir, m);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return std::make_pair(ret, m);
|
||||
}
|
||||
|
||||
static bool has_name(struct option *long_options, int *pl) {
|
||||
@@ -3471,6 +3473,10 @@ int main(int argc, char **argv) {
|
||||
if (out_mbtiles != NULL) {
|
||||
if (force) {
|
||||
unlink(out_mbtiles);
|
||||
} else {
|
||||
if (pmtiles_has_suffix(out_mbtiles)) {
|
||||
check_pmtiles(out_mbtiles, argv);
|
||||
}
|
||||
}
|
||||
|
||||
outdb = mbtiles_open(out_mbtiles, argv, forcetable);
|
||||
@@ -3503,14 +3509,20 @@ int main(int argc, char **argv) {
|
||||
|
||||
long long file_bbox[4] = {UINT_MAX, UINT_MAX, 0, 0};
|
||||
|
||||
ret = read_input(sources, name ? name : out_mbtiles ? out_mbtiles
|
||||
: out_dir,
|
||||
maxzoom, minzoom, basezoom, basezoom_marker_width, outdb, out_dir, &exclude, &include, exclude_all, filter, droprate, buffer, tmpdir, gamma, read_parallel, forcetable, attribution, gamma != 0, file_bbox, prefilter, postfilter, description, guess_maxzoom, &attribute_types, argv[0], &attribute_accum, attribute_descriptions, commandline, minimum_maxzoom);
|
||||
auto input_ret = read_input(sources, name ? name : out_mbtiles ? out_mbtiles
|
||||
: out_dir,
|
||||
maxzoom, minzoom, basezoom, basezoom_marker_width, outdb, out_dir, &exclude, &include, exclude_all, filter, droprate, buffer, tmpdir, gamma, read_parallel, forcetable, attribution, gamma != 0, file_bbox, prefilter, postfilter, description, guess_maxzoom, &attribute_types, argv[0], &attribute_accum, attribute_descriptions, commandline, minimum_maxzoom);
|
||||
|
||||
ret = std::get<0>(input_ret);
|
||||
|
||||
if (outdb != NULL) {
|
||||
mbtiles_close(outdb, argv[0]);
|
||||
}
|
||||
|
||||
if (pmtiles_has_suffix(out_mbtiles)) {
|
||||
mbtiles_map_image_to_pmtiles(out_mbtiles, std::get<1>(input_ret), prevent[P_TILE_COMPRESSION] == 0, quiet, quiet_progress);
|
||||
}
|
||||
|
||||
#ifdef MTRACE
|
||||
muntrace();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user