mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
Tiles are smaller if coalesced features are sorted geographically
This commit is contained in:
parent
a08e57357a
commit
98b0cb5e3f
22
tile.cc
22
tile.cc
@ -444,6 +444,8 @@ struct coalesce {
|
|||||||
|
|
||||||
int nmeta;
|
int nmeta;
|
||||||
int *meta;
|
int *meta;
|
||||||
|
|
||||||
|
unsigned long long index;
|
||||||
};
|
};
|
||||||
|
|
||||||
int coalcmp(const void *v1, const void *v2) {
|
int coalcmp(const void *v1, const void *v2) {
|
||||||
@ -467,6 +469,23 @@ int coalcmp(const void *v1, const void *v2) {
|
|||||||
return c1->nmeta - c2->nmeta;
|
return c1->nmeta - c2->nmeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int coalindexcmp(const void *v1, const void *v2) {
|
||||||
|
int cmp = coalcmp(v1, v2);
|
||||||
|
|
||||||
|
if (cmp == 0) {
|
||||||
|
const struct coalesce *c1 = (const struct coalesce *) v1;
|
||||||
|
const struct coalesce *c2 = (const struct coalesce *) v2;
|
||||||
|
|
||||||
|
if (c1->index < c2->index) {
|
||||||
|
return -1;
|
||||||
|
} else if (c1->index > c2->index) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmp;
|
||||||
|
}
|
||||||
|
|
||||||
long long write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, char *layername, sqlite3 *outdb) {
|
long long write_tile(struct index *start, struct index *end, char *metabase, unsigned *file_bbox, int z, unsigned tx, unsigned ty, int detail, int basezoom, struct pool *file_keys, char *layername, sqlite3 *outdb) {
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
|
||||||
@ -546,6 +565,7 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
|||||||
pv->n = 0;
|
pv->n = 0;
|
||||||
|
|
||||||
features[nfeatures].type = t;
|
features[nfeatures].type = t;
|
||||||
|
features[nfeatures].index = i->index;
|
||||||
|
|
||||||
features[nfeatures].ngeom = len;
|
features[nfeatures].ngeom = len;
|
||||||
features[nfeatures].geom = (struct draw *) malloc(len * sizeof(struct draw));
|
features[nfeatures].geom = (struct draw *) malloc(len * sizeof(struct draw));
|
||||||
@ -575,7 +595,7 @@ long long write_tile(struct index *start, struct index *end, char *metabase, uns
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(features, nfeatures, sizeof(struct coalesce), coalcmp);
|
qsort(features, nfeatures, sizeof(struct coalesce), coalindexcmp);
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
int out = 0;
|
int out = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user