mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-23 18:40:17 +00:00
Fix large features getting included multiple times at low zooms
This commit is contained in:
parent
8f77376b58
commit
95c2fb67b2
25
geojson.c
25
geojson.c
@ -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);
|
||||
|
||||
while (*v != NULL) {
|
||||
int cmp = strcmp(s, (*v)->s);
|
||||
int cmp = compare(s, (*v)->s);
|
||||
|
||||
if (cmp == 0) {
|
||||
cmp = type - (*v)->type;
|
||||
@ -167,6 +167,27 @@ struct pool_val *pool(struct pool *p, char *s, int type) {
|
||||
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) {
|
||||
while (p->head != NULL) {
|
||||
struct pool_val *next = p->head->next;
|
||||
|
14
tile.cc
14
tile.cc
@ -145,6 +145,12 @@ void write_tile(struct index *start, struct index *end, char *metabase, unsigned
|
||||
values.head = NULL;
|
||||
values.tail = NULL;
|
||||
|
||||
struct pool dup;
|
||||
dup.n = 1;
|
||||
dup.vals = NULL;
|
||||
dup.head = NULL;
|
||||
dup.tail = NULL;
|
||||
|
||||
double interval = 1;
|
||||
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)) {
|
||||
struct pool_val *pv = pool_long_long(&dup, &i->fpos, 0);
|
||||
if (pv->n == 0) {
|
||||
continue;
|
||||
}
|
||||
pv->n = 0;
|
||||
|
||||
meta = metabase + i->fpos;
|
||||
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(&values);
|
||||
pool_free(&dup);
|
||||
|
||||
std::string s;
|
||||
std::string compressed;
|
||||
|
1
tile.h
1
tile.h
@ -37,6 +37,7 @@ struct pool {
|
||||
void deserialize_int(char **f, int *n);
|
||||
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_long_long(struct pool *p, long long *val, int type);
|
||||
void pool_free(struct pool *p);
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user