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:
Eric Fischer 2014-11-14 12:42:50 -08:00
parent 428be06442
commit ffe4c95376
2 changed files with 20 additions and 18 deletions

View File

@ -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
View File

@ -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);