mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-13 15:56:36 +00:00
Calculate point dropping during encoding instead of tiling
so it is consistent across tile boundaries, and so every point that exists at zoom x always also exists at zoom x+1.
This commit is contained in:
parent
428be06442
commit
ffe4c95376
16
geojson.c
16
geojson.c
@ -445,6 +445,16 @@ void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom,
|
||||
unsigned cx = bbox[0] / 2 + bbox[2] / 2;
|
||||
unsigned cy = bbox[1] / 2 + bbox[3] / 2;
|
||||
|
||||
/*
|
||||
* Note that minzoom for lines is the dimension
|
||||
* of the geometry in world coordinates, but
|
||||
* for points is the lowest zoom level (in tiles,
|
||||
* not in pixels) at which it should be drawn.
|
||||
*
|
||||
* So a line that is too small for, say, z8
|
||||
* will have minzoom of 18 (if tile detail is 10),
|
||||
* not 8.
|
||||
*/
|
||||
int minzoom = 0;
|
||||
if (mb_geometry[t] == VT_LINE) {
|
||||
for (minzoom = 0; minzoom < 31; minzoom++) {
|
||||
@ -455,6 +465,12 @@ void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom,
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (mb_geometry[t] == VT_POINT) {
|
||||
double r = ((double) rand()) / RAND_MAX;
|
||||
if (r == 0) {
|
||||
r = .00000001;
|
||||
}
|
||||
minzoom = maxzoom - floor(log(r) / - log(droprate));
|
||||
}
|
||||
|
||||
/* XXX do proper overlap instead of whole bounding box */
|
||||
|
22
tile.cc
22
tile.cc
@ -354,24 +354,21 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
||||
pool_init(&values, 0);
|
||||
std::set<long long> dup;
|
||||
|
||||
double interval = 1;
|
||||
double seq = 0;
|
||||
long long count = 0;
|
||||
//long long along = 0;
|
||||
double accum_area = 0;
|
||||
|
||||
if (z < basezoom) {
|
||||
interval = exp(log(droprate) * (basezoom - z));
|
||||
}
|
||||
|
||||
std::vector<coalesce> features;
|
||||
|
||||
struct index *i;
|
||||
for (i = start; i < end; i++) {
|
||||
int t = i->type;
|
||||
|
||||
if (z > i->maxzoom) {
|
||||
continue;
|
||||
}
|
||||
if (z + line_detail <= i->minzoom) {
|
||||
if ((t == VT_LINE && z + line_detail <= i->minzoom) ||
|
||||
(t == VT_POINT && z < i->minzoom)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -382,17 +379,6 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
||||
dup.insert(i->fpos);
|
||||
}
|
||||
|
||||
int t = i->type;
|
||||
if (t == VT_POINT) {
|
||||
seq++;
|
||||
|
||||
if (seq >= 0) {
|
||||
seq -= interval;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
char *meta = metabase + i->fpos;
|
||||
drawvec geom = decode_geometry(&meta, z, tx, ty, line_detail);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user