mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-06 02:15:41 +02:00
Tile-join had not been compressing its tiles.
This commit is contained in:
+8
-2
@@ -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) {
|
void handle(std::string message, int z, unsigned x, unsigned y, int describe, std::set<std::string> const &to_decode) {
|
||||||
int within = 0;
|
int within = 0;
|
||||||
mvt_tile tile;
|
mvt_tile tile;
|
||||||
|
bool was_compressed;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!tile.decode(message)) {
|
if (!tile.decode(message, was_compressed)) {
|
||||||
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", z, x, y);
|
fprintf(stderr, "Couldn't parse tile %d/%u/%u\n", z, x, y);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,12 @@ void handle(std::string message, int z, unsigned x, unsigned y, int describe, st
|
|||||||
printf("{ \"type\": \"FeatureCollection\"");
|
printf("{ \"type\": \"FeatureCollection\"");
|
||||||
|
|
||||||
if (describe) {
|
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) {
|
if (projection != projections) {
|
||||||
printf(", \"crs\": { \"type\": \"name\", \"properties\": { \"name\": ");
|
printf(", \"crs\": { \"type\": \"name\", \"properties\": { \"name\": ");
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ int compress(std::string const &input, std::string &output) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mvt_tile::decode(std::string &message) {
|
bool mvt_tile::decode(std::string &message, bool &was_compressed) {
|
||||||
layers.clear();
|
layers.clear();
|
||||||
std::string src;
|
std::string src;
|
||||||
|
|
||||||
@@ -87,8 +87,10 @@ bool mvt_tile::decode(std::string &message) {
|
|||||||
std::string uncompressed;
|
std::string uncompressed;
|
||||||
decompress(message, uncompressed);
|
decompress(message, uncompressed);
|
||||||
src = uncompressed;
|
src = uncompressed;
|
||||||
|
was_compressed = true;
|
||||||
} else {
|
} else {
|
||||||
src = message;
|
src = message;
|
||||||
|
was_compressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protozero::pbf_reader reader(src);
|
protozero::pbf_reader reader(src);
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ struct mvt_tile {
|
|||||||
std::vector<mvt_layer> layers;
|
std::vector<mvt_layer> layers;
|
||||||
|
|
||||||
std::string encode();
|
std::string encode();
|
||||||
bool decode(std::string &message);
|
bool decode(std::string &message, bool &was_compressed);
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_compressed(std::string const &data);
|
bool is_compressed(std::string const &data);
|
||||||
|
|||||||
+5
-2
@@ -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) {
|
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;
|
mvt_tile tile;
|
||||||
int features_added = 0;
|
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);
|
fprintf(stderr, "Couldn't decompress tile %d/%u/%u\n", z, x, y);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@@ -402,7 +403,9 @@ void *join_worker(void *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (anything) {
|
if (anything) {
|
||||||
std::string compressed = tile.encode();
|
std::string pbf = tile.encode();
|
||||||
|
std::string compressed;
|
||||||
|
compress(pbf, compressed);
|
||||||
|
|
||||||
if (!pk && compressed.size() > 500000) {
|
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());
|
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());
|
||||||
|
|||||||
Reference in New Issue
Block a user