mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-01-22 04:18:01 +00:00
Add the ability to inline metadata with geometry
This commit is contained in:
parent
f920c05c75
commit
3655a54d22
54
geojson.cpp
54
geojson.cpp
@ -153,7 +153,7 @@ void parse_geometry(int t, json_object *j, long long *bbox, long long *fpos, FIL
|
||||
}
|
||||
}
|
||||
|
||||
int serialize_geometry(json_object *geometry, json_object *properties, const char *reading, int line, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, const char *fname, int basezoom, int layer, double droprate, long long *file_bbox, json_object *tippecanoe, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers, std::set<type_and_string> *file_keys) {
|
||||
int serialize_geometry(json_object *geometry, json_object *properties, const char *reading, int line, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, const char *fname, int basezoom, int layer, double droprate, long long *file_bbox, json_object *tippecanoe, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers, std::set<type_and_string> *file_keys, int maxzoom) {
|
||||
json_object *geometry_type = json_hash_get(geometry, "type");
|
||||
if (geometry_type == NULL) {
|
||||
static int warned = 0;
|
||||
@ -208,7 +208,7 @@ int serialize_geometry(json_object *geometry, json_object *properties, const cha
|
||||
}
|
||||
}
|
||||
|
||||
long long bbox[] = {UINT_MAX, UINT_MAX, 0, 0};
|
||||
long long bbox[] = {LLONG_MAX, LLONG_MAX, LLONG_MIN, LLONG_MIN};
|
||||
|
||||
int nprop = 0;
|
||||
if (properties != NULL && properties->type == JSON_HASH) {
|
||||
@ -269,15 +269,6 @@ int serialize_geometry(json_object *geometry, json_object *properties, const cha
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < m; i++) {
|
||||
serialize_long_long(metafile, addpool(poolfile, treefile, metakey[i], VT_STRING), metapos, fname);
|
||||
serialize_long_long(metafile, addpool(poolfile, treefile, metaval[i], metatype[i]), metapos, fname);
|
||||
|
||||
if (mustfree[i]) {
|
||||
free((void *) metaval[i]);
|
||||
}
|
||||
}
|
||||
|
||||
long long geomstart = *geompos;
|
||||
|
||||
serialize_byte(geomfile, mb_geometry[t], geompos, fname);
|
||||
@ -292,12 +283,39 @@ int serialize_geometry(json_object *geometry, json_object *properties, const cha
|
||||
}
|
||||
|
||||
serialize_int(geomfile, segment, geompos, fname);
|
||||
serialize_long_long(geomfile, metastart, geompos, fname);
|
||||
serialize_int(geomfile, m, geompos, fname);
|
||||
long long wx = *initial_x, wy = *initial_y;
|
||||
parse_geometry(t, coordinates, bbox, geompos, geomfile, VT_MOVETO, fname, line, &wx, &wy, initialized, initial_x, initial_y);
|
||||
serialize_byte(geomfile, VT_END, geompos, fname);
|
||||
|
||||
bool inline_meta = true;
|
||||
// Don't inline metadata for features that will span several tiles at maxzoom
|
||||
if (bbox[2] - bbox[0] > (2LL << (32 - maxzoom)) || bbox[3] - bbox[1] > (2LL << (32 - maxzoom))) {
|
||||
inline_meta = false;
|
||||
}
|
||||
|
||||
serialize_int(geomfile, m, geompos, fname);
|
||||
if (inline_meta) {
|
||||
serialize_long_long(geomfile, -1, geompos, fname);
|
||||
|
||||
for (i = 0; i < m; i++) {
|
||||
serialize_long_long(geomfile, addpool(poolfile, treefile, metakey[i], VT_STRING), geompos, fname);
|
||||
serialize_long_long(geomfile, addpool(poolfile, treefile, metaval[i], metatype[i]), geompos, fname);
|
||||
}
|
||||
} else {
|
||||
serialize_long_long(geomfile, metastart, geompos, fname);
|
||||
|
||||
for (i = 0; i < m; i++) {
|
||||
serialize_long_long(metafile, addpool(poolfile, treefile, metakey[i], VT_STRING), metapos, fname);
|
||||
serialize_long_long(metafile, addpool(poolfile, treefile, metaval[i], metatype[i]), metapos, fname);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < m; i++) {
|
||||
if (mustfree[i]) {
|
||||
free((void *) metaval[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that feature_minzoom for lines is the dimension
|
||||
* of the geometry in world coordinates, but
|
||||
@ -366,7 +384,7 @@ int serialize_geometry(json_object *geometry, json_object *properties, const cha
|
||||
return 1;
|
||||
}
|
||||
|
||||
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers, std::set<type_and_string> *file_keys) {
|
||||
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers, std::set<type_and_string> *file_keys, int maxzoom) {
|
||||
long long found_hashes = 0;
|
||||
long long found_features = 0;
|
||||
long long found_geometries = 0;
|
||||
@ -431,7 +449,7 @@ void parse_json(json_pull *jp, const char *reading, volatile long long *layer_se
|
||||
}
|
||||
found_geometries++;
|
||||
|
||||
serialize_geometry(j, NULL, reading, jp->line, layer_seq, progress_seq, metapos, geompos, indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, basezoom, layer, droprate, file_bbox, NULL, segment, initialized, initial_x, initial_y, readers, file_keys);
|
||||
serialize_geometry(j, NULL, reading, jp->line, layer_seq, progress_seq, metapos, geompos, indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, basezoom, layer, droprate, file_bbox, NULL, segment, initialized, initial_x, initial_y, readers, file_keys, maxzoom);
|
||||
json_free(j);
|
||||
continue;
|
||||
}
|
||||
@ -466,10 +484,10 @@ void parse_json(json_pull *jp, const char *reading, volatile long long *layer_se
|
||||
if (geometries != NULL) {
|
||||
size_t g;
|
||||
for (g = 0; g < geometries->length; g++) {
|
||||
serialize_geometry(geometries->array[g], properties, reading, jp->line, layer_seq, progress_seq, metapos, geompos, indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, basezoom, layer, droprate, file_bbox, tippecanoe, segment, initialized, initial_x, initial_y, readers, file_keys);
|
||||
serialize_geometry(geometries->array[g], properties, reading, jp->line, layer_seq, progress_seq, metapos, geompos, indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, basezoom, layer, droprate, file_bbox, tippecanoe, segment, initialized, initial_x, initial_y, readers, file_keys, maxzoom);
|
||||
}
|
||||
} else {
|
||||
serialize_geometry(geometry, properties, reading, jp->line, layer_seq, progress_seq, metapos, geompos, indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, basezoom, layer, droprate, file_bbox, tippecanoe, segment, initialized, initial_x, initial_y, readers, file_keys);
|
||||
serialize_geometry(geometry, properties, reading, jp->line, layer_seq, progress_seq, metapos, geompos, indexpos, exclude, include, exclude_all, metafile, geomfile, indexfile, poolfile, treefile, fname, basezoom, layer, droprate, file_bbox, tippecanoe, segment, initialized, initial_x, initial_y, readers, file_keys, maxzoom);
|
||||
}
|
||||
|
||||
json_free(j);
|
||||
@ -481,7 +499,7 @@ void parse_json(json_pull *jp, const char *reading, volatile long long *layer_se
|
||||
void *run_parse_json(void *v) {
|
||||
struct parse_json_args *pja = (struct parse_json_args *) v;
|
||||
|
||||
parse_json(pja->jp, pja->reading, pja->layer_seq, pja->progress_seq, pja->metapos, pja->geompos, pja->indexpos, pja->exclude, pja->include, pja->exclude_all, pja->metafile, pja->geomfile, pja->indexfile, pja->poolfile, pja->treefile, pja->fname, pja->basezoom, pja->layer, pja->droprate, pja->file_bbox, pja->segment, pja->initialized, pja->initial_x, pja->initial_y, pja->readers, pja->file_keys);
|
||||
parse_json(pja->jp, pja->reading, pja->layer_seq, pja->progress_seq, pja->metapos, pja->geompos, pja->indexpos, pja->exclude, pja->include, pja->exclude_all, pja->metafile, pja->geomfile, pja->indexfile, pja->poolfile, pja->treefile, pja->fname, pja->basezoom, pja->layer, pja->droprate, pja->file_bbox, pja->segment, pja->initialized, pja->initial_x, pja->initial_y, pja->readers, pja->file_keys, pja->maxzoom);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -25,8 +25,9 @@ struct parse_json_args {
|
||||
unsigned *initial_y;
|
||||
struct reader *readers;
|
||||
std::set<type_and_string> *file_keys;
|
||||
int maxzoom;
|
||||
};
|
||||
|
||||
struct json_pull *json_begin_map(char *map, long long len);
|
||||
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers, std::set<type_and_string> *file_keys);
|
||||
void parse_json(json_pull *jp, const char *reading, volatile long long *layer_seq, volatile long long *progress_seq, long long *metapos, long long *geompos, long long *indexpos, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, FILE *metafile, FILE *geomfile, FILE *indexfile, struct memfile *poolfile, struct memfile *treefile, char *fname, int basezoom, int layer, double droprate, long long *file_bbox, int segment, int *initialized, unsigned *initial_x, unsigned *initial_y, struct reader *readers, std::set<type_and_string> *file_keys, int maxzoom);
|
||||
void *run_parse_json(void *v);
|
||||
|
9
main.cpp
9
main.cpp
@ -298,7 +298,7 @@ void *run_sort(void *v) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, struct reader *reader, volatile long long *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, char *fname, int basezoom, int source, int nlayers, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y, std::set<type_and_string> *file_keys) {
|
||||
void do_read_parallel(char *map, long long len, long long initial_offset, const char *reading, struct reader *reader, volatile long long *progress_seq, std::set<std::string> *exclude, std::set<std::string> *include, int exclude_all, char *fname, int basezoom, int source, int nlayers, double droprate, int *initialized, unsigned *initial_x, unsigned *initial_y, std::set<type_and_string> *file_keys, int maxzoom) {
|
||||
long long segs[CPUS + 1];
|
||||
segs[0] = 0;
|
||||
segs[CPUS] = len;
|
||||
@ -354,6 +354,7 @@ void do_read_parallel(char *map, long long len, long long initial_offset, const
|
||||
pja[i].initial_y = &initial_y[i];
|
||||
pja[i].readers = reader;
|
||||
pja[i].file_keys = &file_subkeys[i];
|
||||
pja[i].maxzoom = maxzoom;
|
||||
|
||||
if (pthread_create(&pthreads[i], NULL, run_parse_json, &pja[i]) != 0) {
|
||||
perror("pthread_create");
|
||||
@ -422,7 +423,7 @@ void *run_read_parallel(void *v) {
|
||||
}
|
||||
madvise(map, a->len, MADV_RANDOM); // sequential, but from several pointers at once
|
||||
|
||||
do_read_parallel(map, a->len, a->offset, a->reading, a->reader, a->progress_seq, a->exclude, a->include, a->exclude_all, a->fname, a->basezoom, a->source, a->nlayers, a->droprate, a->initialized, a->initial_x, a->initial_y, a->file_keys);
|
||||
do_read_parallel(map, a->len, a->offset, a->reading, a->reader, a->progress_seq, a->exclude, a->include, a->exclude_all, a->fname, a->basezoom, a->source, a->nlayers, a->droprate, a->initialized, a->initial_x, a->initial_y, a->file_keys, a->maxzoom);
|
||||
|
||||
madvise(map, a->len, MADV_DONTNEED);
|
||||
if (munmap(map, a->len) != 0) {
|
||||
@ -1015,7 +1016,7 @@ int read_input(std::vector<source> &sources, char *fname, const char *layername,
|
||||
}
|
||||
|
||||
if (map != NULL && map != MAP_FAILED) {
|
||||
do_read_parallel(map, st.st_size - off, overall_offset, reading.c_str(), reader, &progress_seq, exclude, include, exclude_all, fname, basezoom, source, nlayers, droprate, initialized, initial_x, initial_y, &file_keys[source < nlayers ? source : 0]);
|
||||
do_read_parallel(map, st.st_size - off, overall_offset, reading.c_str(), reader, &progress_seq, exclude, include, exclude_all, fname, basezoom, source, nlayers, droprate, initialized, initial_x, initial_y, &file_keys[source < nlayers ? source : 0], maxzoom);
|
||||
overall_offset += st.st_size - off;
|
||||
checkdisk(reader, CPUS);
|
||||
|
||||
@ -1131,7 +1132,7 @@ int read_input(std::vector<source> &sources, char *fname, const char *layername,
|
||||
|
||||
long long layer_seq = overall_offset;
|
||||
json_pull *jp = json_begin_file(fp);
|
||||
parse_json(jp, reading.c_str(), &layer_seq, &progress_seq, &reader[0].metapos, &reader[0].geompos, &reader[0].indexpos, exclude, include, exclude_all, reader[0].metafile, reader[0].geomfile, reader[0].indexfile, reader[0].poolfile, reader[0].treefile, fname, basezoom, source < nlayers ? source : 0, droprate, reader[0].file_bbox, 0, &initialized[0], &initial_x[0], &initial_y[0], reader, &file_keys[source < nlayers ? source : 0]);
|
||||
parse_json(jp, reading.c_str(), &layer_seq, &progress_seq, &reader[0].metapos, &reader[0].geompos, &reader[0].indexpos, exclude, include, exclude_all, reader[0].metafile, reader[0].geomfile, reader[0].indexfile, reader[0].poolfile, reader[0].treefile, fname, basezoom, source < nlayers ? source : 0, droprate, reader[0].file_bbox, 0, &initialized[0], &initial_x[0], &initial_y[0], reader, &file_keys[source < nlayers ? source : 0], maxzoom);
|
||||
json_end(jp);
|
||||
overall_offset = layer_seq;
|
||||
checkdisk(reader, CPUS);
|
||||
|
88
tile.cpp
88
tile.cpp
@ -57,7 +57,7 @@ bool draws_something(drawvec &geom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int metacmp(int m1, char **meta1, char *stringpool1, int m2, char **meta2, char *stringpool2);
|
||||
int metacmp(int m1, const std::vector<long long> &keys1, const std::vector<long long> &values1, char *stringpool1, int m2, const std::vector<long long> &keys2, const std::vector<long long> &values2, char *stringpool2);
|
||||
int coalindexcmp(const struct coalesce *c1, const struct coalesce *c2);
|
||||
static int is_integer(const char *s, long long *v);
|
||||
|
||||
@ -71,6 +71,8 @@ struct coalesce {
|
||||
unsigned long long index2;
|
||||
bool coalesced;
|
||||
long long original_seq;
|
||||
std::vector<long long> keys;
|
||||
std::vector<long long> values;
|
||||
|
||||
bool operator<(const coalesce &o) const {
|
||||
int cmp = coalindexcmp(this, &o);
|
||||
@ -97,10 +99,7 @@ int coalcmp(const void *v1, const void *v2) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
char *m1 = c1->meta;
|
||||
char *m2 = c2->meta;
|
||||
|
||||
return metacmp(c1->m, &m1, c1->stringpool, c2->m, &m2, c2->stringpool);
|
||||
return metacmp(c1->m, c1->keys, c1->values, c1->stringpool, c2->m, c2->keys, c2->values, c2->stringpool);
|
||||
}
|
||||
|
||||
int coalindexcmp(const struct coalesce *c1, const struct coalesce *c2) {
|
||||
@ -123,10 +122,7 @@ int coalindexcmp(const struct coalesce *c1, const struct coalesce *c2) {
|
||||
return cmp;
|
||||
}
|
||||
|
||||
mvt_value retrieve_string(char **f, char *stringpool, int *otype) {
|
||||
long long off;
|
||||
deserialize_long_long(f, &off);
|
||||
|
||||
mvt_value retrieve_string(long long off, char *stringpool, int *otype) {
|
||||
int type = stringpool[off];
|
||||
char *s = stringpool + off + 1;
|
||||
|
||||
@ -160,18 +156,18 @@ mvt_value retrieve_string(char **f, char *stringpool, int *otype) {
|
||||
return tv;
|
||||
}
|
||||
|
||||
void decode_meta(int m, char **meta, char *stringpool, mvt_layer &layer, mvt_feature &feature) {
|
||||
void decode_meta(int m, std::vector<long long> &metakeys, std::vector<long long> &metavals, char *stringpool, mvt_layer &layer, mvt_feature &feature) {
|
||||
int i;
|
||||
for (i = 0; i < m; i++) {
|
||||
int otype;
|
||||
mvt_value key = retrieve_string(meta, stringpool, NULL);
|
||||
mvt_value value = retrieve_string(meta, stringpool, &otype);
|
||||
mvt_value key = retrieve_string(metakeys[i], stringpool, NULL);
|
||||
mvt_value value = retrieve_string(metavals[i], stringpool, &otype);
|
||||
|
||||
layer.tag(feature, key.string_value, value);
|
||||
}
|
||||
}
|
||||
|
||||
int metacmp(int m1, char **meta1, char *stringpool1, int m2, char **meta2, char *stringpool2) {
|
||||
int metacmp(int m1, const std::vector<long long> &keys1, const std::vector<long long> &values1, char *stringpool1, int m2, const std::vector<long long> &keys2, const std::vector<long long> &values2, char *stringpool2) {
|
||||
// XXX
|
||||
// Ideally this would make identical features compare the same lexically
|
||||
// even if their attributes were declared in different orders in different instances.
|
||||
@ -179,8 +175,8 @@ int metacmp(int m1, char **meta1, char *stringpool1, int m2, char **meta2, char
|
||||
|
||||
int i;
|
||||
for (i = 0; i < m1 && i < m2; i++) {
|
||||
mvt_value key1 = retrieve_string(meta1, stringpool1, NULL);
|
||||
mvt_value key2 = retrieve_string(meta2, stringpool2, NULL);
|
||||
mvt_value key1 = retrieve_string(keys1[i], stringpool1, NULL);
|
||||
mvt_value key2 = retrieve_string(keys2[i], stringpool2, NULL);
|
||||
|
||||
if (key1.string_value < key2.string_value) {
|
||||
return -1;
|
||||
@ -188,13 +184,11 @@ int metacmp(int m1, char **meta1, char *stringpool1, int m2, char **meta2, char
|
||||
return 1;
|
||||
}
|
||||
|
||||
long long off1;
|
||||
deserialize_long_long(meta1, &off1);
|
||||
long long off1 = values1[i];
|
||||
int type1 = stringpool1[off1];
|
||||
char *s1 = stringpool1 + off1 + 1;
|
||||
|
||||
long long off2;
|
||||
deserialize_long_long(meta2, &off2);
|
||||
long long off2 = values2[i];
|
||||
int type2 = stringpool2[off2];
|
||||
char *s2 = stringpool2 + off2 + 1;
|
||||
|
||||
@ -265,7 +259,7 @@ struct sll {
|
||||
}
|
||||
};
|
||||
|
||||
void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, unsigned tx, unsigned ty, int buffer, int line_detail, int *within, long long *geompos, FILE **geomfile, const char *fname, signed char t, int layer, long long metastart, signed char feature_minzoom, int child_shards, int max_zoom_increment, long long seq, int tippecanoe_minzoom, int tippecanoe_maxzoom, int segment, unsigned *initial_x, unsigned *initial_y, int m) {
|
||||
void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, unsigned tx, unsigned ty, int buffer, int line_detail, int *within, long long *geompos, FILE **geomfile, const char *fname, signed char t, int layer, long long metastart, signed char feature_minzoom, int child_shards, int max_zoom_increment, long long seq, int tippecanoe_minzoom, int tippecanoe_maxzoom, int segment, unsigned *initial_x, unsigned *initial_y, int m, std::vector<long long> &metakeys, std::vector <long long> &metavals) {
|
||||
if (geom.size() > 0 && nextzoom <= maxzoom) {
|
||||
int xo, yo;
|
||||
int span = 1 << (nextzoom - z);
|
||||
@ -347,8 +341,6 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u
|
||||
serialize_int(geomfile[j], tippecanoe_maxzoom, geompos, fname);
|
||||
}
|
||||
serialize_int(geomfile[j], segment, &geompos[j], fname);
|
||||
serialize_long_long(geomfile[j], metastart, &geompos[j], fname);
|
||||
serialize_int(geomfile[j], m, &geompos[j], fname);
|
||||
long long wx = initial_x[segment], wy = initial_y[segment];
|
||||
|
||||
for (size_t u = 0; u < geom.size(); u++) {
|
||||
@ -363,6 +355,16 @@ void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, u
|
||||
}
|
||||
|
||||
serialize_byte(geomfile[j], VT_END, &geompos[j], fname);
|
||||
|
||||
serialize_int(geomfile[j], m, &geompos[j], fname);
|
||||
serialize_long_long(geomfile[j], metastart, &geompos[j], fname);
|
||||
if (metastart < 0) {
|
||||
for (int i = 0; i < m; i++) {
|
||||
serialize_long_long(geomfile[j], metakeys[i], &geompos[j], fname);
|
||||
serialize_long_long(geomfile[j], metavals[i], &geompos[j], fname);
|
||||
}
|
||||
}
|
||||
|
||||
serialize_byte(geomfile[j], feature_minzoom, &geompos[j], fname);
|
||||
}
|
||||
}
|
||||
@ -386,6 +388,8 @@ struct partial {
|
||||
int *prevent;
|
||||
int *additional;
|
||||
int maxzoom;
|
||||
std::vector<long long> keys;
|
||||
std::vector<long long> values;
|
||||
};
|
||||
|
||||
struct partial_arg {
|
||||
@ -649,15 +653,37 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
int segment;
|
||||
deserialize_int_io(geoms, &segment, geompos_in);
|
||||
|
||||
long long metastart;
|
||||
int m;
|
||||
deserialize_long_long_io(geoms, &metastart, geompos_in);
|
||||
deserialize_int_io(geoms, &m, geompos_in);
|
||||
char *meta = metabase + metastart + meta_off[segment];
|
||||
long long bbox[4];
|
||||
|
||||
drawvec geom = decode_geometry(geoms, geompos_in, z, tx, ty, line_detail, bbox, initial_x[segment], initial_y[segment]);
|
||||
|
||||
long long metastart;
|
||||
int m;
|
||||
deserialize_int_io(geoms, &m, geompos_in);
|
||||
deserialize_long_long_io(geoms, &metastart, geompos_in);
|
||||
char *meta = NULL;
|
||||
std::vector<long long> metakeys, metavals;
|
||||
|
||||
if (metastart >= 0) {
|
||||
meta = metabase + metastart + meta_off[segment];
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
long long k, v;
|
||||
deserialize_long_long(&meta, &k);
|
||||
deserialize_long_long(&meta, &v);
|
||||
metakeys.push_back(k);
|
||||
metavals.push_back(v);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < m; i++) {
|
||||
long long k, v;
|
||||
deserialize_long_long_io(geoms, &k, geompos_in);
|
||||
deserialize_long_long_io(geoms, &v, geompos_in);
|
||||
metakeys.push_back(k);
|
||||
metavals.push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
signed char feature_minzoom;
|
||||
deserialize_byte_io(geoms, &feature_minzoom, geompos_in);
|
||||
|
||||
@ -752,7 +778,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
}
|
||||
|
||||
if (line_detail == detail && fraction == 1) { /* only write out the next zoom once, even if we retry */
|
||||
rewrite(geom, z, nextzoom, maxzoom, bbox, tx, ty, buffer, line_detail, within, geompos, geomfile, fname, t, layer, metastart, feature_minzoom, child_shards, max_zoom_increment, original_seq, tippecanoe_minzoom, tippecanoe_maxzoom, segment, initial_x, initial_y, m);
|
||||
rewrite(geom, z, nextzoom, maxzoom, bbox, tx, ty, buffer, line_detail, within, geompos, geomfile, fname, t, layer, metastart, feature_minzoom, child_shards, max_zoom_increment, original_seq, tippecanoe_minzoom, tippecanoe_maxzoom, segment, initial_x, initial_y, m, metakeys, metavals);
|
||||
}
|
||||
|
||||
if (z < minzoom) {
|
||||
@ -818,6 +844,8 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
p.prevent = prevent;
|
||||
p.additional = additional;
|
||||
p.maxzoom = maxzoom;
|
||||
p.keys = metakeys;
|
||||
p.values = metavals;
|
||||
partials.push_back(p);
|
||||
}
|
||||
}
|
||||
@ -876,6 +904,8 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
c.m = partials[i].m;
|
||||
c.meta = partials[i].meta;
|
||||
c.stringpool = stringpool + pool_off[partials[i].segment];
|
||||
c.keys = partials[i].keys;
|
||||
c.values = partials[i].values;
|
||||
|
||||
features[layer].push_back(c);
|
||||
}
|
||||
@ -967,7 +997,7 @@ long long write_tile(FILE *geoms, long long *geompos_in, char *metabase, char *s
|
||||
feature.geometry = to_feature(features[k][x].geom);
|
||||
count += features[k][x].geom.size();
|
||||
|
||||
decode_meta(features[k][x].m, &features[k][x].meta, features[k][x].stringpool, layer, feature);
|
||||
decode_meta(features[k][x].m, features[k][x].keys, features[k][x].values, features[k][x].stringpool, layer, feature);
|
||||
layer.features.push_back(feature);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user