mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Shave a few bytes off temporary files by using more unsigned integers
This commit is contained in:
+17
-17
@@ -212,9 +212,9 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long
|
||||
layer |= sf->has_tippecanoe_minzoom << FLAG_MINZOOM;
|
||||
layer |= sf->has_tippecanoe_maxzoom << FLAG_MAXZOOM;
|
||||
|
||||
serialize_long_long(geomfile, layer, geompos, fname);
|
||||
serialize_ulong_long(geomfile, layer, geompos, fname);
|
||||
if (sf->seq != 0) {
|
||||
serialize_long_long(geomfile, sf->seq, geompos, fname);
|
||||
serialize_ulong_long(geomfile, sf->seq, geompos, fname);
|
||||
}
|
||||
if (sf->has_tippecanoe_minzoom) {
|
||||
serialize_int(geomfile, sf->tippecanoe_minzoom, geompos, fname);
|
||||
@@ -226,7 +226,7 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long
|
||||
serialize_ulong_long(geomfile, sf->id, geompos, fname);
|
||||
}
|
||||
|
||||
serialize_int(geomfile, sf->segment, geompos, fname);
|
||||
serialize_uint(geomfile, sf->segment, geompos, fname);
|
||||
|
||||
write_geometry(sf->geometry, geompos, geomfile, fname, wx, wy);
|
||||
serialize_byte(geomfile, VT_END, geompos, fname);
|
||||
@@ -237,14 +237,14 @@ void serialize_feature(FILE *geomfile, serial_feature *sf, std::atomic<long long
|
||||
serialize_ulong_long(geomfile, sf->label_point, geompos, fname);
|
||||
}
|
||||
if (sf->extent != 0) {
|
||||
serialize_long_long(geomfile, sf->extent, geompos, fname);
|
||||
serialize_ulong_long(geomfile, sf->extent, geompos, fname);
|
||||
}
|
||||
|
||||
serialize_long_long(geomfile, sf->keys.size(), geompos, fname);
|
||||
serialize_ulong_long(geomfile, sf->keys.size(), geompos, fname);
|
||||
|
||||
for (size_t i = 0; i < sf->keys.size(); i++) {
|
||||
serialize_long_long(geomfile, sf->keys[i], geompos, fname);
|
||||
serialize_long_long(geomfile, sf->values[i], geompos, fname);
|
||||
serialize_ulong_long(geomfile, sf->keys[i], geompos, fname);
|
||||
serialize_ulong_long(geomfile, sf->values[i], geompos, fname);
|
||||
}
|
||||
|
||||
if (include_minzoom) {
|
||||
@@ -260,11 +260,11 @@ serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_
|
||||
return sf;
|
||||
}
|
||||
|
||||
deserialize_long_long_io(geoms, &sf.layer, geompos_in);
|
||||
deserialize_ulong_long_io(geoms, &sf.layer, geompos_in);
|
||||
|
||||
sf.seq = 0;
|
||||
if (sf.layer & (1 << FLAG_SEQ)) {
|
||||
deserialize_long_long_io(geoms, &sf.seq, geompos_in);
|
||||
deserialize_ulong_long_io(geoms, &sf.seq, geompos_in);
|
||||
}
|
||||
|
||||
sf.tippecanoe_minzoom = -1;
|
||||
@@ -282,7 +282,7 @@ serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_
|
||||
deserialize_ulong_long_io(geoms, &sf.id, geompos_in);
|
||||
}
|
||||
|
||||
deserialize_int_io(geoms, &sf.segment, geompos_in);
|
||||
deserialize_uint_io(geoms, &sf.segment, geompos_in);
|
||||
|
||||
sf.index = 0;
|
||||
sf.label_point = 0;
|
||||
@@ -296,18 +296,18 @@ serial_feature deserialize_feature(FILE *geoms, std::atomic<long long> *geompos_
|
||||
deserialize_ulong_long_io(geoms, &sf.label_point, geompos_in);
|
||||
}
|
||||
if (sf.layer & (1 << FLAG_EXTENT)) {
|
||||
deserialize_long_long_io(geoms, &sf.extent, geompos_in);
|
||||
deserialize_ulong_long_io(geoms, &sf.extent, geompos_in);
|
||||
}
|
||||
|
||||
sf.layer >>= FLAG_LAYER;
|
||||
|
||||
long long count;
|
||||
deserialize_long_long_io(geoms, &count, geompos_in);
|
||||
unsigned long long count;
|
||||
deserialize_ulong_long_io(geoms, &count, geompos_in);
|
||||
|
||||
for (long long i = 0; i < count; i++) {
|
||||
long long k, v;
|
||||
deserialize_long_long_io(geoms, &k, geompos_in);
|
||||
deserialize_long_long_io(geoms, &v, geompos_in);
|
||||
for (unsigned long long i = 0; i < count; i++) {
|
||||
unsigned long long k, v;
|
||||
deserialize_ulong_long_io(geoms, &k, geompos_in);
|
||||
deserialize_ulong_long_io(geoms, &v, geompos_in);
|
||||
sf.keys.push_back(k);
|
||||
sf.values.push_back(v);
|
||||
}
|
||||
|
||||
+6
-6
@@ -38,9 +38,9 @@ struct serial_val {
|
||||
};
|
||||
|
||||
struct serial_feature {
|
||||
long long layer = 0;
|
||||
int segment = 0;
|
||||
long long seq = 0;
|
||||
unsigned long long layer = 0;
|
||||
unsigned int segment = 0;
|
||||
unsigned long long seq = 0;
|
||||
|
||||
signed char t = 0;
|
||||
signed char feature_minzoom = 0;
|
||||
@@ -57,10 +57,10 @@ struct serial_feature {
|
||||
drawvec geometry = drawvec();
|
||||
unsigned long long index = 0;
|
||||
unsigned long long label_point = 0;
|
||||
long long extent = 0;
|
||||
unsigned long long extent = 0;
|
||||
|
||||
std::vector<long long> keys{};
|
||||
std::vector<long long> values{};
|
||||
std::vector<unsigned long long> keys{};
|
||||
std::vector<unsigned long long> values{};
|
||||
|
||||
// XXX This isn't serialized. Should it be here?
|
||||
long long bbox[4] = {0, 0, 0, 0};
|
||||
|
||||
@@ -79,13 +79,13 @@ bool draws_something(drawvec &geom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static int metacmp(const std::vector<long long> &keys1, const std::vector<long long> &values1, char *stringpool1, const std::vector<long long> &keys2, const std::vector<long long> &values2, char *stringpool2);
|
||||
static int metacmp(const std::vector<unsigned long long> &keys1, const std::vector<unsigned long long> &values1, char *stringpool1, const std::vector<unsigned long long> &keys2, const std::vector<unsigned long long> &values2, char *stringpool2);
|
||||
int coalindexcmp(const struct coalesce *c1, const struct coalesce *c2);
|
||||
|
||||
struct coalesce {
|
||||
char *stringpool = NULL;
|
||||
std::vector<long long> keys = std::vector<long long>();
|
||||
std::vector<long long> values = std::vector<long long>();
|
||||
std::vector<unsigned long long> keys;
|
||||
std::vector<unsigned long long> values;
|
||||
std::vector<std::string> full_keys = std::vector<std::string>();
|
||||
std::vector<serial_val> full_values = std::vector<serial_val>();
|
||||
drawvec geom = drawvec();
|
||||
@@ -201,7 +201,7 @@ mvt_value retrieve_string(long long off, const char *stringpool, int *otype) {
|
||||
return stringified_to_mvt_value(type, s);
|
||||
}
|
||||
|
||||
void decode_meta(std::vector<long long> const &metakeys, std::vector<long long> const &metavals, char *stringpool, mvt_layer &layer, mvt_feature &feature) {
|
||||
void decode_meta(std::vector<unsigned long long> const &metakeys, std::vector<unsigned long long> const &metavals, char *stringpool, mvt_layer &layer, mvt_feature &feature) {
|
||||
size_t i;
|
||||
for (i = 0; i < metakeys.size(); i++) {
|
||||
int otype;
|
||||
@@ -212,7 +212,7 @@ void decode_meta(std::vector<long long> const &metakeys, std::vector<long long>
|
||||
}
|
||||
}
|
||||
|
||||
static int metacmp(const std::vector<long long> &keys1, const std::vector<long long> &values1, char *stringpool1, const std::vector<long long> &keys2, const std::vector<long long> &values2, char *stringpool2) {
|
||||
static int metacmp(const std::vector<unsigned long long> &keys1, const std::vector<unsigned long long> &values1, char *stringpool1, const std::vector<unsigned long long> &keys2, const std::vector<unsigned long long> &values2, char *stringpool2) {
|
||||
size_t i;
|
||||
for (i = 0; i < keys1.size() && i < keys2.size(); i++) {
|
||||
mvt_value key1 = retrieve_string(keys1[i], stringpool1, NULL);
|
||||
@@ -258,8 +258,8 @@ static mvt_value find_attribute_value(const struct coalesce *c1, std::string key
|
||||
return v;
|
||||
}
|
||||
|
||||
const std::vector<long long> &keys1 = c1->keys;
|
||||
const std::vector<long long> &values1 = c1->values;
|
||||
const std::vector<unsigned long long> &keys1 = c1->keys;
|
||||
const std::vector<unsigned long long> &values1 = c1->values;
|
||||
const char *stringpool1 = c1->stringpool;
|
||||
|
||||
for (size_t i = 0; i < keys1.size(); i++) {
|
||||
@@ -324,7 +324,7 @@ struct ordercmp {
|
||||
}
|
||||
} ordercmp;
|
||||
|
||||
void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, unsigned tx, unsigned ty, int buffer, int *within, std::atomic<long long> *geompos, FILE **geomfile, const char *fname, signed char t, int layer, 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, std::vector<long long> &metakeys, std::vector<long long> &metavals, bool has_id, unsigned long long id, unsigned long long index, unsigned long long label_point, long long extent) {
|
||||
void rewrite(drawvec &geom, int z, int nextzoom, int maxzoom, long long *bbox, unsigned tx, unsigned ty, int buffer, int *within, std::atomic<long long> *geompos, FILE **geomfile, const char *fname, signed char t, int layer, signed char feature_minzoom, int child_shards, int max_zoom_increment, unsigned long long seq, int tippecanoe_minzoom, int tippecanoe_maxzoom, int segment, unsigned *initial_x, unsigned *initial_y, std::vector<unsigned long long> &metakeys, std::vector<unsigned long long> &metavals, bool has_id, unsigned long long id, unsigned long long index, unsigned long long label_point, unsigned long long extent) {
|
||||
if (geom.size() > 0 && (nextzoom <= maxzoom || additional[A_EXTEND_ZOOMS])) {
|
||||
int xo, yo;
|
||||
int span = 1 << (nextzoom - z);
|
||||
@@ -435,12 +435,12 @@ struct accum_state {
|
||||
};
|
||||
|
||||
struct partial {
|
||||
std::vector<drawvec> geoms = std::vector<drawvec>();
|
||||
std::vector<long long> keys = std::vector<long long>();
|
||||
std::vector<long long> values = std::vector<long long>();
|
||||
std::vector<std::string> full_keys = std::vector<std::string>();
|
||||
std::vector<serial_val> full_values = std::vector<serial_val>();
|
||||
std::vector<ssize_t> arc_polygon = std::vector<ssize_t>();
|
||||
std::vector<drawvec> geoms;
|
||||
std::vector<unsigned long long> keys;
|
||||
std::vector<unsigned long long> values;
|
||||
std::vector<std::string> full_keys;
|
||||
std::vector<serial_val> full_values;
|
||||
std::vector<ssize_t> arc_polygon;
|
||||
long long layer = 0;
|
||||
long long original_seq = 0;
|
||||
unsigned long long index = 0;
|
||||
@@ -1273,7 +1273,7 @@ unsigned long long choose_mingap(std::vector<unsigned long long> const &indices,
|
||||
return top;
|
||||
}
|
||||
|
||||
long long choose_minextent(std::vector<long long> &extents, double f) {
|
||||
unsigned long long choose_minextent(std::vector<unsigned long long> &extents, double f) {
|
||||
std::sort(extents.begin(), extents.end());
|
||||
return extents[(extents.size() - 1) * (1 - f)];
|
||||
}
|
||||
@@ -1894,7 +1894,7 @@ long long write_tile(FILE *geoms, std::atomic<long long> *geompos_in, char *stri
|
||||
std::map<std::string, std::vector<coalesce>> layers;
|
||||
|
||||
std::vector<unsigned long long> indices;
|
||||
std::vector<long long> extents;
|
||||
std::vector<unsigned long long> extents;
|
||||
size_t extents_increment = 1;
|
||||
|
||||
double coalesced_area = 0;
|
||||
|
||||
Reference in New Issue
Block a user