Quick reject by bounding box of linear features too small to draw

This commit is contained in:
Eric Fischer 2014-11-12 15:57:45 -08:00
parent 2b6ad9968f
commit 5595a087c7
3 changed files with 20 additions and 2 deletions

View File

@ -445,6 +445,18 @@ 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;
int minzoom = 0;
if (mb_geometry[t] == VT_LINE) {
for (minzoom = 0; minzoom < 31; minzoom++) {
unsigned mask = 1 << (32 - (minzoom + 1));
if (((bbox[0] & mask) != (bbox[2] & mask)) ||
((bbox[1] & mask) != (bbox[3] & mask))) {
break;
}
}
}
/* XXX do proper overlap instead of whole bounding box */
if (z == 0) {
struct index ix;
@ -452,6 +464,7 @@ void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom,
ix.fpos = start;
ix.type = mb_geometry[t];
ix.maxzoom = z;
ix.minzoom = minzoom;
fwrite_check(&ix, sizeof(struct index), 1, indexfile, fname, jp);
} else {
int pass;
@ -497,6 +510,7 @@ void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom,
ix.type = mb_geometry[t];
ix.maxzoom = z;
ix.candup = (instances > 1);
ix.minzoom = minzoom;
fwrite_check(&ix, sizeof(struct index), 1, indexfile, fname, jp);
}
}

View File

@ -371,6 +371,9 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
if (z > i->maxzoom) {
continue;
}
if (z + line_detail <= i->minzoom) {
continue;
}
if (i->candup) {
if (dup.count(i->fpos) != 0) {

5
tile.h
View File

@ -20,8 +20,9 @@ struct pool_val *deserialize_string(char **f, struct pool *p, int type);
struct index {
unsigned long long index;
long long fpos : 48;
int maxzoom : 8;
long long fpos : 44;
int maxzoom : 6;
int minzoom : 6;
int type : 7;
int candup : 1;
};