mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-31 16:00:36 +00:00
Restore old code for uniform instead of random dot-dropping
From ffe4c953760d8fd
This commit is contained in:
parent
572df8ad39
commit
558a7a412c
13
geojson.c
13
geojson.c
@ -194,7 +194,7 @@ struct pool_val *deserialize_string(char **f, struct pool *p, int type) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void traverse_zooms(int geomfd[4], off_t geom_size[4], char *metabase, unsigned *file_bbox, struct pool *file_keys, unsigned *midx, unsigned *midy, const char *layername, int maxzoom, int minzoom, sqlite3 *outdb, double droprate, int buffer, const char *fname, struct json_pull *jp, const char *tmpdir) {
|
||||
void traverse_zooms(int geomfd[4], off_t geom_size[4], char *metabase, unsigned *file_bbox, struct pool *file_keys, unsigned *midx, unsigned *midy, const char *layername, int maxzoom, int minzoom, sqlite3 *outdb, double droprate, int buffer, const char *fname, struct json_pull *jp, const char *tmpdir, double gamma) {
|
||||
int i;
|
||||
for (i = 0; i <= maxzoom; i++) {
|
||||
long long most = 0;
|
||||
@ -255,7 +255,7 @@ void traverse_zooms(int geomfd[4], off_t geom_size[4], char *metabase, unsigned
|
||||
|
||||
// fprintf(stderr, "%d/%u/%u\n", z, x, y);
|
||||
|
||||
long long len = write_tile(&geom, metabase, file_bbox, z, x, y, z == maxzoom ? full_detail : low_detail, maxzoom, file_keys, layername, outdb, droprate, buffer, fname, jp, sub, minzoom, maxzoom, todo, geomstart, along);
|
||||
long long len = write_tile(&geom, metabase, file_bbox, z, x, y, z == maxzoom ? full_detail : low_detail, maxzoom, file_keys, layername, outdb, droprate, buffer, fname, jp, sub, minzoom, maxzoom, todo, geomstart, along, gamma);
|
||||
|
||||
if (z == maxzoom && len > most) {
|
||||
*midx = x;
|
||||
@ -356,7 +356,7 @@ static void merge(struct merge *merges, int nmerges, unsigned char *map, FILE *f
|
||||
}
|
||||
}
|
||||
|
||||
void read_json(FILE *f, const char *fname, const char *layername, int maxzoom, int minzoom, sqlite3 *outdb, struct pool *exclude, struct pool *include, int exclude_all, double droprate, int buffer, const char *tmpdir) {
|
||||
void read_json(FILE *f, const char *fname, const char *layername, int maxzoom, int minzoom, sqlite3 *outdb, struct pool *exclude, struct pool *include, int exclude_all, double droprate, int buffer, const char *tmpdir, double gamma) {
|
||||
char metaname[strlen(tmpdir) + strlen("/meta.XXXXXXXX") + 1];
|
||||
char geomname[strlen(tmpdir) + strlen("/geom.XXXXXXXX") + 1];
|
||||
char indexname[strlen(tmpdir) + strlen("/index.XXXXXXXX") + 1];
|
||||
@ -833,7 +833,7 @@ void read_json(FILE *f, const char *fname, const char *layername, int maxzoom, i
|
||||
|
||||
fprintf(stderr, "%lld features, %lld bytes of geometry, %lld bytes of metadata\n", seq, (long long) geomst.st_size, (long long) metast.st_size);
|
||||
|
||||
traverse_zooms(fd, size, meta, file_bbox, &file_keys, &midx, &midy, layername, maxzoom, minzoom, outdb, droprate, buffer, fname, jp, tmpdir);
|
||||
traverse_zooms(fd, size, meta, file_bbox, &file_keys, &midx, &midy, layername, maxzoom, minzoom, outdb, droprate, buffer, fname, jp, tmpdir, gamma);
|
||||
|
||||
if (munmap(meta, metast.st_size) != 0) {
|
||||
perror("munmap meta");
|
||||
@ -884,6 +884,7 @@ int main(int argc, char **argv) {
|
||||
int minzoom = 0;
|
||||
int force = 0;
|
||||
double droprate = 2.5;
|
||||
double gamma = 1;
|
||||
int buffer = 5;
|
||||
const char *tmpdir = "/tmp";
|
||||
|
||||
@ -982,7 +983,7 @@ int main(int argc, char **argv) {
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "%s: %s: %s\n", argv[0], argv[i], strerror(errno));
|
||||
} else {
|
||||
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, outdb, &exclude, &include, exclude_all, droprate, buffer, tmpdir);
|
||||
read_json(f, name ? name : argv[i], layer, maxzoom, minzoom, outdb, &exclude, &include, exclude_all, droprate, buffer, tmpdir, gamma);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
@ -990,7 +991,7 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "%s: Only accepts one input file\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
read_json(stdin, name ? name : outdir, layer, maxzoom, minzoom, outdb, &exclude, &include, exclude_all, droprate, buffer, tmpdir);
|
||||
read_json(stdin, name ? name : outdir, layer, maxzoom, minzoom, outdb, &exclude, &include, exclude_all, droprate, buffer, tmpdir, gamma);
|
||||
}
|
||||
|
||||
mbtiles_close(outdb, argv);
|
||||
|
24
tile.cc
24
tile.cc
@ -342,7 +342,7 @@ void evaluate(std::vector<coalesce> &features, char *metabase, struct pool *file
|
||||
pool_free(&keys);
|
||||
}
|
||||
|
||||
long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along) {
|
||||
long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along, double gamma) {
|
||||
int line_detail;
|
||||
static bool evaluated = false;
|
||||
double oprogress = 0;
|
||||
@ -361,6 +361,12 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u
|
||||
//long long along = 0;
|
||||
double accum_area = 0;
|
||||
|
||||
double interval = 0;
|
||||
double seq = 0;
|
||||
if (z < basezoom) {
|
||||
interval = exp(log(droprate) * (basezoom - z));
|
||||
}
|
||||
|
||||
std::vector<coalesce> features;
|
||||
|
||||
int within[4] = { 0 };
|
||||
@ -475,11 +481,23 @@ long long write_tile(char **geoms, char *metabase, unsigned *file_bbox, int z, u
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((t == VT_LINE && z + line_detail <= feature_minzoom) ||
|
||||
(t == VT_POINT && z < feature_minzoom)) {
|
||||
if (t == VT_LINE && z + line_detail <= feature_minzoom) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t == VT_POINT && z < feature_minzoom && gamma == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t == VT_POINT && gamma != 0) {
|
||||
seq++;
|
||||
if (seq >= 0) {
|
||||
seq -= interval;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
bool reduced = false;
|
||||
if (t == VT_POLYGON) {
|
||||
geom = reduce_tiny_poly(geom, z, line_detail, &reduced, &accum_area);
|
||||
|
2
tile.h
2
tile.h
@ -26,4 +26,4 @@ void deserialize_uint(char **f, unsigned *n);
|
||||
void deserialize_byte(char **f, signed char *n);
|
||||
struct pool_val *deserialize_string(char **f, struct pool *p, int type);
|
||||
|
||||
long long write_tile(char **geom, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, struct json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along);
|
||||
long long write_tile(char **geom, char *metabase, unsigned *file_bbox, int z, unsigned x, unsigned y, int detail, int basezoom, struct pool *file_keys, const char *layername, sqlite3 *outdb, double droprate, int buffer, const char *fname, struct json_pull *jp, FILE *geomfile[4], int file_minzoom, int file_maxzoom, double todo, char *geomstart, long long along, double gamma);
|
||||
|
Loading…
x
Reference in New Issue
Block a user