Fix large features getting included multiple times at low zooms

This commit is contained in:
Eric Fischer 2014-09-23 17:18:36 -07:00
parent 8f77376b58
commit 95c2fb67b2
3 changed files with 38 additions and 2 deletions

View File

@ -129,11 +129,11 @@ int indexcmp(const void *v1, const void *v2) {
} }
} }
struct pool_val *pool(struct pool *p, char *s, int type) { struct pool_val *pool1(struct pool *p, char *s, int type, int (*compare)(const char *, const char *)) {
struct pool_val **v = &(p->vals); struct pool_val **v = &(p->vals);
while (*v != NULL) { while (*v != NULL) {
int cmp = strcmp(s, (*v)->s); int cmp = compare(s, (*v)->s);
if (cmp == 0) { if (cmp == 0) {
cmp = type - (*v)->type; cmp = type - (*v)->type;
@ -167,6 +167,27 @@ struct pool_val *pool(struct pool *p, char *s, int type) {
return *v; return *v;
} }
struct pool_val *pool(struct pool *p, char *s, int type) {
return pool1(p, s, type, strcmp);
}
int llcmp(const char *v1, const char *v2) {
long long *ll1 = (long long *) v1;
long long *ll2 = (long long *) v2;
if (*ll1 < *ll2) {
return -1;
} else if (*ll1 > *ll2) {
return 1;
} else {
return 0;
}
}
struct pool_val *pool_long_long(struct pool *p, long long *s, int type) {
return pool1(p, (char *) s, type, llcmp);
}
void pool_free(struct pool *p) { void pool_free(struct pool *p) {
while (p->head != NULL) { while (p->head != NULL) {
struct pool_val *next = p->head->next; struct pool_val *next = p->head->next;

14
tile.cc
View File

@ -145,6 +145,12 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned
values.head = NULL; values.head = NULL;
values.tail = NULL; values.tail = NULL;
struct pool dup;
dup.n = 1;
dup.vals = NULL;
dup.head = NULL;
dup.tail = NULL;
double interval = 1; double interval = 1;
double seq = 0; double seq = 0;
@ -170,6 +176,12 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned
} }
if (t == VT_POINT || draw(&meta, NULL, z, tx, ty, detail)) { if (t == VT_POINT || draw(&meta, NULL, z, tx, ty, detail)) {
struct pool_val *pv = pool_long_long(&dup, &i->fpos, 0);
if (pv->n == 0) {
continue;
}
pv->n = 0;
meta = metabase + i->fpos; meta = metabase + i->fpos;
deserialize_int(&meta, &t); deserialize_int(&meta, &t);
@ -220,6 +232,8 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned
} }
} }
pool_free(&keys); pool_free(&keys);
pool_free(&values);
pool_free(&dup);
std::string s; std::string s;
std::string compressed; std::string compressed;

1
tile.h
View File

@ -37,6 +37,7 @@ struct pool {
void deserialize_int(char **f, int *n); void deserialize_int(char **f, int *n);
struct pool_val *deserialize_string(char **f, struct pool *p, int type); struct pool_val *deserialize_string(char **f, struct pool *p, int type);
struct pool_val *pool(struct pool *p, char *s, int type); struct pool_val *pool(struct pool *p, char *s, int type);
struct pool_val *pool_long_long(struct pool *p, long long *val, int type);
void pool_free(struct pool *p); void pool_free(struct pool *p);