mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Work in progress on inverse spatial ordering
This commit is contained in:
@@ -3211,6 +3211,7 @@ int main(int argc, char **argv) {
|
||||
{"order-descending-by", required_argument, 0, '~'},
|
||||
{"order-smallest-first", no_argument, 0, '~'},
|
||||
{"order-largest-first", no_argument, 0, '~'},
|
||||
{"order-spatial-inverse", no_argument, 0, '~'},
|
||||
|
||||
{"Adding calculated attributes", 0, 0, 0},
|
||||
{"calculate-feature-density", no_argument, &additional[A_CALCULATE_FEATURE_DENSITY], 1},
|
||||
@@ -3357,6 +3358,9 @@ int main(int argc, char **argv) {
|
||||
} else if (strcmp(opt, "order-largest-first") == 0) {
|
||||
order_by.push_back(order_field(ORDER_BY_SIZE, true));
|
||||
order_by_size = true;
|
||||
} else if (strcmp(opt, "order-spatial-inverse") == 0) {
|
||||
order_by.push_back(order_field(ORDER_SPATIAL, false));
|
||||
order_by.push_back(order_field(ORDER_BY_FEATURE_MINZOOM, false));
|
||||
} else if (strcmp(opt, "simplification-at-maximum-zoom") == 0) {
|
||||
maxzoom_simplification = atof_require(optarg, "Mazoom simplification");
|
||||
if (maxzoom_simplification <= 0) {
|
||||
|
||||
@@ -79,6 +79,9 @@ extern std::vector<order_field> order_by;
|
||||
#define ORDER_BY_SIZE "\200size"
|
||||
extern bool order_by_size;
|
||||
|
||||
#define ORDER_SPATIAL "\200spatial"
|
||||
#define ORDER_BY_FEATURE_MINZOOM "\200feature_minzoom"
|
||||
|
||||
int mkstemp_cloexec(char *name);
|
||||
FILE *fopen_oflag(const char *name, const char *mode, int oflag);
|
||||
bool progress_time();
|
||||
|
||||
@@ -729,11 +729,14 @@ int serialize_feature(struct serialization_state *sst, serial_feature &sf) {
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (additional[A_DROP_DENSEST_AS_NEEDED] || additional[A_COALESCE_DENSEST_AS_NEEDED] || additional[A_CLUSTER_DENSEST_AS_NEEDED] || additional[A_CALCULATE_FEATURE_DENSITY] || additional[A_DROP_SMALLEST_AS_NEEDED] || additional[A_COALESCE_SMALLEST_AS_NEEDED] || additional[A_INCREASE_GAMMA_AS_NEEDED] || additional[A_GENERATE_POLYGON_LABEL_POINTS] || sst->uses_gamma || cluster_distance != 0) {
|
||||
sf.index = bbox_index;
|
||||
} else {
|
||||
sf.index = 0;
|
||||
}
|
||||
#endif
|
||||
sf.index = bbox_index;
|
||||
|
||||
if (sst->layermap->count(sf.layername) == 0) {
|
||||
sst->layermap->insert(std::pair<std::string, layermap_entry>(sf.layername, layermap_entry(sst->layermap->size())));
|
||||
|
||||
@@ -100,6 +100,7 @@ struct coalesce {
|
||||
bool has_id = false;
|
||||
unsigned long long id = 0;
|
||||
long long extent = 0;
|
||||
signed char feature_minzoom = 0;
|
||||
|
||||
bool operator<(const coalesce &o) const {
|
||||
int cmp = coalindexcmp(this, &o);
|
||||
@@ -253,6 +254,15 @@ static int metacmp(const std::vector<long long> &keys1, const std::vector<long l
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long long flop(unsigned long long v) {
|
||||
unsigned long long out = 0;
|
||||
for (size_t i = 0; i < 64; i++) {
|
||||
out |= ((v >> i) & 1) << (63 - i);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static mvt_value find_attribute_value(const struct coalesce *c1, std::string key) {
|
||||
if (key == ORDER_BY_SIZE) {
|
||||
mvt_value v;
|
||||
@@ -260,6 +270,18 @@ static mvt_value find_attribute_value(const struct coalesce *c1, std::string key
|
||||
v.numeric_value.double_value = c1->extent;
|
||||
return v;
|
||||
}
|
||||
if (key == ORDER_SPATIAL) {
|
||||
mvt_value v;
|
||||
v.type = mvt_uint;
|
||||
v.numeric_value.uint_value = flop(c1->index);
|
||||
return v;
|
||||
}
|
||||
if (key == ORDER_BY_FEATURE_MINZOOM) {
|
||||
mvt_value v;
|
||||
v.type = mvt_double;
|
||||
v.numeric_value.double_value = c1->feature_minzoom;
|
||||
return v;
|
||||
}
|
||||
|
||||
const std::vector<long long> &keys1 = c1->keys;
|
||||
const std::vector<long long> &values1 = c1->values;
|
||||
@@ -467,6 +489,7 @@ struct partial {
|
||||
double spacing = 0;
|
||||
double simplification = 0;
|
||||
signed char t = 0;
|
||||
signed char feature_minzoom = 0;
|
||||
unsigned long long id = 0;
|
||||
bool has_id = 0;
|
||||
ssize_t renamed = 0;
|
||||
@@ -2266,6 +2289,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
p.renamed = -1;
|
||||
p.extent = sf.extent;
|
||||
p.clustered = 0;
|
||||
p.feature_minzoom = sf.feature_minzoom;
|
||||
|
||||
if (line_detail == detail && extra_detail >= 0 && z == maxzoom) {
|
||||
p.extra_detail = extra_detail;
|
||||
@@ -2312,6 +2336,21 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
for (size_t i = 0; i < partials.size(); i++) {
|
||||
partial &p = partials[i];
|
||||
|
||||
{
|
||||
std::string layername = (*layer_unmaps)[p.segment][p.layer];
|
||||
|
||||
serial_val sv, sv2;
|
||||
p.full_keys.push_back("inverse_index");
|
||||
sv.type = mvt_double;
|
||||
sv.s = std::to_string(flop(p.index));
|
||||
p.full_values.push_back(sv);
|
||||
|
||||
p.full_keys.push_back("feature_minzoom");
|
||||
sv2.type = mvt_double;
|
||||
sv2.s = std::to_string(p.feature_minzoom);
|
||||
p.full_values.push_back(sv2);
|
||||
}
|
||||
|
||||
if (p.clustered > 0) {
|
||||
std::string layername = (*layer_unmaps)[p.segment][p.layer];
|
||||
serial_val sv, sv2, sv3, sv4;
|
||||
@@ -2456,6 +2495,7 @@ long long write_tile(decompressor *geoms, std::atomic<long long> *geompos_in, ch
|
||||
c.id = partials[i].id;
|
||||
c.has_id = partials[i].has_id;
|
||||
c.extent = partials[i].extent;
|
||||
c.feature_minzoom = partials[i].feature_minzoom;
|
||||
|
||||
// printf("segment %d layer %lld is %s\n", partials[i].segment, partials[i].layer, (*layer_unmaps)[partials[i].segment][partials[i].layer].c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user