mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-01 08:47:57 +00:00
Tile-join had not been compressing its tiles.
This commit is contained in:
parent
685e1a4360
commit
30d54ff50d
10
decode.cpp
10
decode.cpp
@ -54,9 +54,10 @@ struct lonlat {
|
||||
void handle(std::string message, int z, unsigned x, unsigned y, int describe, std::set<std::string> const &to_decode) {
|
||||
int within = 0;
|
||||
mvt_tile tile;
|
||||
bool was_compressed;
|
||||
|
||||
try {
|
||||
if (!tile.decode(message)) {
|
||||
if (!tile.decode(message, was_compressed)) {
|
||||
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", z, x, y);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -68,7 +69,12 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe, st
|
||||
printf("{ \"type\": \"FeatureCollection\"");
|
||||
|
||||
if (describe) {
|
||||
printf(", \"properties\": { \"zoom\": %d, \"x\": %d, \"y\": %d }", z, x, y);
|
||||
printf(", \"properties\": { \"zoom\": %d, \"x\": %d, \"y\": %d", z, x, y);
|
||||
if (!was_compressed) {
|
||||
printf(", \"compressed\": false");
|
||||
}
|
||||
|
||||
printf(" }");
|
||||
|
||||
if (projection != projections) {
|
||||
printf(", \"crs\": { \"type\": \"name\", \"properties\": { \"name\": ");
|
||||
|
4
mvt.cpp
4
mvt.cpp
@ -79,7 +79,7 @@ int compress(std::string const &input, std::string &output) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool mvt_tile::decode(std::string &message) {
|
||||
bool mvt_tile::decode(std::string &message, bool &was_compressed) {
|
||||
layers.clear();
|
||||
std::string src;
|
||||
|
||||
@ -87,8 +87,10 @@ bool mvt_tile::decode(std::string &message) {
|
||||
std::string uncompressed;
|
||||
decompress(message, uncompressed);
|
||||
src = uncompressed;
|
||||
was_compressed = true;
|
||||
} else {
|
||||
src = message;
|
||||
was_compressed = false;
|
||||
}
|
||||
|
||||
protozero::pbf_reader reader(src);
|
||||
|
2
mvt.hpp
2
mvt.hpp
@ -91,7 +91,7 @@ struct mvt_tile {
|
||||
std::vector<mvt_layer> layers;
|
||||
|
||||
std::string encode();
|
||||
bool decode(std::string &message);
|
||||
bool decode(std::string &message, bool &was_compressed);
|
||||
};
|
||||
|
||||
bool is_compressed(std::string const &data);
|
||||
|
@ -32,8 +32,9 @@ struct stats {
|
||||
void handle(std::string message, int z, unsigned x, unsigned y, std::map<std::string, layermap_entry> &layermap, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, std::set<std::string> &exclude, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, int ifmatched, mvt_tile &outtile) {
|
||||
mvt_tile tile;
|
||||
int features_added = 0;
|
||||
bool was_compressed;
|
||||
|
||||
if (!tile.decode(message)) {
|
||||
if (!tile.decode(message, was_compressed)) {
|
||||
fprintf(stderr, "Couldn't decompress tile %d/%u/%u\n", z, x, y);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -402,7 +403,9 @@ void *join_worker(void *v) {
|
||||
}
|
||||
|
||||
if (anything) {
|
||||
std::string compressed = tile.encode();
|
||||
std::string pbf = tile.encode();
|
||||
std::string compressed;
|
||||
compress(pbf, compressed);
|
||||
|
||||
if (!pk && compressed.size() > 500000) {
|
||||
fprintf(stderr, "Tile %lld/%lld/%lld size is %lld, >500000. Skipping this tile\n.", ai->first.z, ai->first.x, ai->first.y, (long long) compressed.size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user