mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Extra coordinate precision; feature ordering; compression improvements
* Add an option to retain extra coordinate precision at maxzoom * Make sure not to shift away the extra detail from coordinates * Add an option to convert double-precision attributes to single * Sort attribute values in tiles to make them compress a little better * Slightly improve polygon simplification By choosing a point that would be retained after simplification to be the start/end point that always gets retained * I regret making all of these tests involve polygons * Add an option to specify the size of tiny polygons * Fix accidental requiring of argument for --single-precision * Guard against duplicate points when generating "sizes" for them * Restore the intended behavior that tiny polygons don't get simplified * Make the extra detail settable rather than always maximizing it * Revert "Improve maxzoom guessing for tightly-clustered point data sources (#4)" This reverts commitfec5e8354c. * Add an option to prevent choosing a base zoom higher than the maxzoom * Keep the drop rate high enough when the basezoom gets constrained * Revert "Revert "Improve maxzoom guessing for tightly-clustered point data sources (#4)"" This reverts commitdb6bc27d9e. * Add --order-by and --order-descending options * Accept multiple --order-by and --order-descending-by sort keys
This commit is contained in:
committed by
Erica Fischer
parent
4ea8a37611
commit
a447dfc089
@@ -296,6 +296,19 @@ bool mvt_tile::decode(std::string &message, bool &was_compressed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct sorted_value {
|
||||
std::string val;
|
||||
size_t orig;
|
||||
|
||||
bool operator<(const sorted_value &sv) const {
|
||||
if (val < sv.val) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::string mvt_tile::encode() {
|
||||
std::string data;
|
||||
|
||||
@@ -313,6 +326,8 @@ std::string mvt_tile::encode() {
|
||||
layer_writer.add_string(3, layers[i].keys[j]); /* key */
|
||||
}
|
||||
|
||||
std::vector<sorted_value> sorted_values;
|
||||
|
||||
for (size_t v = 0; v < layers[i].values.size(); v++) {
|
||||
std::string value_string;
|
||||
protozero::pbf_writer value_writer(value_string);
|
||||
@@ -340,7 +355,19 @@ std::string mvt_tile::encode() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
layer_writer.add_message(4, value_string);
|
||||
sorted_value sv;
|
||||
sv.val = value_string;
|
||||
sv.orig = v;
|
||||
sorted_values.push_back(sv);
|
||||
}
|
||||
|
||||
std::sort(sorted_values.begin(), sorted_values.end());
|
||||
std::vector<size_t> mapping;
|
||||
mapping.resize(sorted_values.size());
|
||||
|
||||
for (size_t v = 0; v < sorted_values.size(); v++) {
|
||||
mapping[sorted_values[v].orig] = v;
|
||||
layer_writer.add_message(4, sorted_values[v].val);
|
||||
}
|
||||
|
||||
for (size_t f = 0; f < layers[i].features.size(); f++) {
|
||||
@@ -348,7 +375,12 @@ std::string mvt_tile::encode() {
|
||||
protozero::pbf_writer feature_writer(feature_string);
|
||||
|
||||
feature_writer.add_enum(3, layers[i].features[f].type);
|
||||
feature_writer.add_packed_uint32(2, std::begin(layers[i].features[f].tags), std::end(layers[i].features[f].tags));
|
||||
|
||||
std::vector<unsigned> sorted_tags = layers[i].features[f].tags;
|
||||
for (size_t v = 1; v < sorted_tags.size(); v += 2) {
|
||||
sorted_tags[v] = mapping[sorted_tags[v]];
|
||||
}
|
||||
feature_writer.add_packed_uint32(2, std::begin(sorted_tags), std::end(sorted_tags));
|
||||
|
||||
if (layers[i].features[f].has_id) {
|
||||
feature_writer.add_uint64(1, layers[i].features[f].id);
|
||||
@@ -458,7 +490,7 @@ static std::string quote(std::string const &s) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::string mvt_value::toString() {
|
||||
std::string mvt_value::toString() const {
|
||||
if (type == mvt_string) {
|
||||
return quote(string_value);
|
||||
} else if (type == mvt_int) {
|
||||
|
||||
Reference in New Issue
Block a user