mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-04-09 20:11:14 +00:00
Save a few more bytes per geometry in the temporary file
by using bytes instead of ints for the drawing operations
This commit is contained in:
parent
c24cfada61
commit
241d96e57c
16
geojson.c
16
geojson.c
@ -96,6 +96,11 @@ void serialize_int(FILE *out, int n, long long *fpos, char *fname, json_pull *so
|
||||
*fpos += sizeof(int);
|
||||
}
|
||||
|
||||
void serialize_byte(FILE *out, signed char n, long long *fpos, char *fname, json_pull *source) {
|
||||
fwrite_check(&n, sizeof(signed char), 1, out, fname, source);
|
||||
*fpos += sizeof(signed char);
|
||||
}
|
||||
|
||||
void serialize_uint(FILE *out, unsigned n, long long *fpos, char *fname, json_pull *source) {
|
||||
fwrite_check(&n, sizeof(unsigned), 1, out, fname, source);
|
||||
*fpos += sizeof(unsigned);
|
||||
@ -153,7 +158,7 @@ void parse_geometry(int t, json_object *j, unsigned *bbox, long long *fpos, FILE
|
||||
}
|
||||
}
|
||||
|
||||
serialize_int(out, op, fpos, fname, source);
|
||||
serialize_byte(out, op, fpos, fname, source);
|
||||
serialize_uint(out, x, fpos, fname, source);
|
||||
serialize_uint(out, y, fpos, fname, source);
|
||||
} else {
|
||||
@ -163,7 +168,7 @@ void parse_geometry(int t, json_object *j, unsigned *bbox, long long *fpos, FILE
|
||||
|
||||
if (t == GEOM_POLYGON) {
|
||||
if (*fpos != began) {
|
||||
serialize_int(out, VT_CLOSEPATH, fpos, fname, source);
|
||||
serialize_byte(out, VT_CLOSEPATH, fpos, fname, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,6 +178,11 @@ void deserialize_int(char **f, int *n) {
|
||||
*f += sizeof(int);
|
||||
}
|
||||
|
||||
void deserialize_byte(char **f, signed char *n) {
|
||||
memcpy(n, *f, sizeof(signed char));
|
||||
*f += sizeof(signed char);
|
||||
}
|
||||
|
||||
struct pool_val *deserialize_string(char **f, struct pool *p, int type) {
|
||||
struct pool_val *ret;
|
||||
int len;
|
||||
@ -382,7 +392,7 @@ void read_json(FILE *f, char *fname, char *layername, int maxzoom, int minzoom,
|
||||
unsigned bbox[] = { UINT_MAX, UINT_MAX, 0, 0 };
|
||||
|
||||
parse_geometry(t, coordinates, bbox, &fpos, metafile, VT_MOVETO, fname, jp);
|
||||
serialize_int(metafile, VT_END, &fpos, fname, jp);
|
||||
serialize_byte(metafile, VT_END, &fpos, fname, jp);
|
||||
|
||||
char *metakey[properties->length];
|
||||
char *metaval[properties->length];
|
||||
|
@ -22,7 +22,7 @@ drawvec decode_geometry(char **meta, int z, unsigned tx, unsigned ty, int detail
|
||||
while (1) {
|
||||
draw d;
|
||||
|
||||
deserialize_int(meta, &d.op);
|
||||
deserialize_byte(meta, &d.op);
|
||||
if (d.op == VT_END) {
|
||||
break;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
struct draw {
|
||||
int op;
|
||||
signed char op;
|
||||
long long x;
|
||||
long long y;
|
||||
int necessary;
|
||||
|
Loading…
x
Reference in New Issue
Block a user