Make feature ordering cooperate with --retain-points-multiplier (#188)

* Make feature ordering cooperate with --retain-points-multiplier

* Forgot to check in the actual code changes???

* Sort within each multiplier cluster as well as between clusters

* Correct description of behavior in changelog

* Drag original feature sequence along in megatiles for post-filter sort

* Plumb the preserve-input-order flag through overzoom

* Sort in overzoom if requested

* Use within-tile input sequence numbers, not global sequence numbers

* Documentation

* Reverse direction of search to prevent accidental skipping

* Add some comments about converting between attribute representations
This commit is contained in:
Erica Fischer
2024-01-21 12:09:05 -08:00
committed by GitHub
parent 5d92a17193
commit 679a0d62f2
23 changed files with 41781 additions and 41134 deletions
+46
View File
@@ -14,6 +14,7 @@
#include "protozero/pbf_writer.hpp"
#include "milo/dtoa_milo.h"
#include "errors.hpp"
#include "serial.hpp"
mvt_geometry::mvt_geometry(int nop, long long nx, long long ny) {
this->op = nop;
@@ -620,6 +621,11 @@ bool is_unsigned_integer(const char *s, unsigned long long *v) {
return 1;
}
// This converts a serial_val-style attribute value to an mvt_value
// to store in a tile. If the value is numeric, it tries to choose
// the type (int, uint, sint, float, or double) that will give the
// smallest representation in the tile without losing precision,
// regardless of how the value was represented in the original source.
mvt_value stringified_to_mvt_value(int type, const char *s) {
mvt_value tv;
@@ -675,3 +681,43 @@ mvt_value stringified_to_mvt_value(int type, const char *s) {
return tv;
}
// This converts a mvt_value attribute value from a tile back into
// a serial_val for more convenient parsing and comparison without
// having to handle all of the vector tile numeric types separately.
// All numeric types are given the type mvt_double in the serial_val
// whether the actual value is integer or floating point.
serial_val mvt_value_to_serial_val(mvt_value const &v) {
serial_val sv;
if (v.type == mvt_string) {
sv.type = mvt_string;
sv.s = v.string_value;
} else if (v.type == mvt_float) {
sv.type = mvt_double;
sv.s = milo::dtoa_milo(v.numeric_value.float_value);
} else if (v.type == mvt_double) {
sv.type = mvt_double;
sv.s = milo::dtoa_milo(v.numeric_value.double_value);
} else if (v.type == mvt_int) {
sv.type = mvt_double;
sv.s = std::to_string(v.numeric_value.int_value);
} else if (v.type == mvt_uint) {
sv.type = mvt_double;
sv.s = std::to_string(v.numeric_value.uint_value);
} else if (v.type == mvt_sint) {
sv.type = mvt_double;
sv.s = std::to_string(v.numeric_value.sint_value);
} else if (v.type == mvt_bool) {
sv.type = mvt_bool;
sv.s = v.numeric_value.bool_value ? "true" : "false";
} else if (v.type == mvt_null) {
sv.type = mvt_null;
sv.s = "null";
} else {
fprintf(stderr, "unhandled mvt_type %d\n", v.type);
exit(EXIT_IMPOSSIBLE);
}
return sv;
}