mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 16:35:40 +02:00
* Add an option to extend zooms if still dropping, but with a limit * At least when to overzoom, even if not actually doing it yet * Refactor to give tile-join access to overzoom() * Didn't work, but *might* have worked * OK, it did something now * Ah, there's the bug! * Hook up pmtiles and dirtiles as overzooming sources * Add command line option to enable or disable overzooming * Add (currently broken) test of overzooming in tile-join * Slightly more abstraction for the tile-join readers * Factor out duplicated code * Move construction into a constructor * More changing accessors to methods * Reduce magic * Start tracking a list of the tiles at maxzoom * I think it worked? * Add missing #include * Fix sequence of overzoomed tiles (Y sorts backwards for TMS) * Don't spend memory on overzooming when we aren't going to use it * Diff rather than cmp, in the hope of figuring out this broken test * Keep full coordinate precision if we might extend zooms * Try a slightly different byte limit * Make drop-densest more consistent across tile boundaries * Also affects this test * Does it behave any differently if it can extend forever? * I think the discrepancy is a thread-safety problem here * Revert "Does it behave any differently if it can extend forever?" This reverts commit0dff0a0acc. * Lost this change to the test * This time for sure! * Revert "Also affects this test" This reverts commitcd1f7c2e78. * Revert "Make drop-densest more consistent across tile boundaries" This reverts commit563f7d2bc2. * Revert "Try a slightly different byte limit" This reverts commit2e271213d6. * Add some more explanatory comments * Amend the join-test to detect my current bug * Allow overzooming to complete the zoom if it ever starts * Forgot to correct the test * Update changelog and version * Cleanups from code review * Remove version number from fixture to fix test
100 lines
1.9 KiB
C++
100 lines
1.9 KiB
C++
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <getopt.h>
|
|
#include <string>
|
|
#include <set>
|
|
#include "errors.hpp"
|
|
#include "mvt.hpp"
|
|
#include "geometry.hpp"
|
|
|
|
extern char *optarg;
|
|
extern int optind;
|
|
|
|
int detail = 12; // tippecanoe-style: mvt extent == 1 << detail
|
|
int buffer = 5; // tippecanoe-style: mvt buffer == extent * buffer / 256;
|
|
|
|
std::set<std::string> keep;
|
|
|
|
void usage(char **argv) {
|
|
fprintf(stderr, "Usage: %s -o newtile.pbf.gz tile.pbf.gz oz/ox/oy nz/nx/ny\n", argv[0]);
|
|
fprintf(stderr, "to create tile nz/nx/ny from tile oz/ox/oy\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
int i;
|
|
const char *outfile = NULL;
|
|
|
|
while ((i = getopt(argc, argv, "y:o:d:b:")) != -1) {
|
|
switch (i) {
|
|
case 'y':
|
|
keep.insert(optarg);
|
|
break;
|
|
|
|
case 'o':
|
|
outfile = optarg;
|
|
break;
|
|
|
|
case 'd':
|
|
detail = atoi(optarg);
|
|
break;
|
|
|
|
case 'b':
|
|
buffer = atoi(optarg);
|
|
break;
|
|
|
|
default:
|
|
usage(argv);
|
|
}
|
|
}
|
|
|
|
if (argc - optind != 3) {
|
|
usage(argv);
|
|
}
|
|
|
|
if (outfile == NULL) {
|
|
usage(argv);
|
|
}
|
|
|
|
const char *infile = argv[optind + 0];
|
|
|
|
int oz, ox, oy;
|
|
if (sscanf(argv[optind + 1], "%d/%d/%d", &oz, &ox, &oy) != 3) {
|
|
fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 1]);
|
|
usage(argv);
|
|
}
|
|
|
|
int nz, nx, ny;
|
|
if (sscanf(argv[optind + 2], "%d/%d/%d", &nz, &nx, &ny) != 3) {
|
|
fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 2]);
|
|
usage(argv);
|
|
}
|
|
|
|
std::string tile;
|
|
char buf[1000];
|
|
int len;
|
|
|
|
FILE *f = fopen(infile, "rb");
|
|
if (f == NULL) {
|
|
perror(infile);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
while ((len = fread(buf, sizeof(char), 1000, f)) > 0) {
|
|
tile.append(std::string(buf, len));
|
|
}
|
|
fclose(f);
|
|
|
|
f = fopen(outfile, "wb");
|
|
if (f == NULL) {
|
|
perror(outfile);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
std::string out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep);
|
|
fwrite(out.c_str(), sizeof(char), out.size(), f);
|
|
fclose(f);
|
|
|
|
return 0;
|
|
}
|