mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Revert "Only do approximate attribute deduplication when writing tiles"
This reverts commit c42b34b498.
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
#include "milo/dtoa_milo.h"
|
#include "milo/dtoa_milo.h"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "serial.hpp"
|
#include "serial.hpp"
|
||||||
#include "text.hpp"
|
|
||||||
|
|
||||||
mvt_geometry::mvt_geometry(int nop, long long nx, long long ny) {
|
mvt_geometry::mvt_geometry(int nop, long long nx, long long ny) {
|
||||||
this->op = nop;
|
this->op = nop;
|
||||||
@@ -593,25 +592,41 @@ std::string mvt_value::toString() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mvt_layer::tag(mvt_feature &feature, std::string const &key, mvt_value const &value) {
|
void mvt_layer::tag(mvt_feature &feature, std::string const &key, mvt_value const &value) {
|
||||||
size_t key_hash = std::hash<std::string>()(key) % dedup.size();
|
size_t ko, vo;
|
||||||
if (dedup[key_hash] >= 0 &&
|
|
||||||
dedup[key_hash] < (ssize_t) keys.size() &&
|
|
||||||
keys[dedup[key_hash]] == key) {
|
|
||||||
} else {
|
|
||||||
dedup[key_hash] = keys.size();
|
|
||||||
keys.push_back(key);
|
|
||||||
}
|
|
||||||
feature.tags.push_back(dedup[key_hash]);
|
|
||||||
|
|
||||||
size_t value_hash = std::hash<mvt_value>()(value) % dedup.size();
|
// initialize lazily the first time anyone tags an attribute
|
||||||
if (dedup[value_hash] >= 0 &&
|
// to save the time of doing it in decode, which never actually matters.
|
||||||
dedup[value_hash] < (ssize_t) values.size() &&
|
// only tile writers actually need this.
|
||||||
values[dedup[value_hash]] == value) {
|
if (key_map.size() == 0) {
|
||||||
} else {
|
for (size_t i = 0; i < keys.size(); i++) {
|
||||||
dedup[value_hash] = values.size();
|
key_map.emplace(keys[i], i);
|
||||||
values.push_back(value);
|
}
|
||||||
|
for (size_t i = 0; i < values.size(); i++) {
|
||||||
|
value_map.emplace(values[i], i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
feature.tags.push_back(dedup[value_hash]);
|
|
||||||
|
std::unordered_map<std::string, size_t>::iterator ki = key_map.find(key);
|
||||||
|
std::unordered_map<mvt_value, size_t>::iterator vi = value_map.find(value);
|
||||||
|
|
||||||
|
if (ki == key_map.end()) {
|
||||||
|
ko = keys.size();
|
||||||
|
keys.push_back(key);
|
||||||
|
key_map.emplace(key, ko);
|
||||||
|
} else {
|
||||||
|
ko = ki->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vi == value_map.end()) {
|
||||||
|
vo = values.size();
|
||||||
|
values.push_back(value);
|
||||||
|
value_map.emplace(value, vo);
|
||||||
|
} else {
|
||||||
|
vo = vi->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
feature.tags.push_back(ko);
|
||||||
|
feature.tags.push_back(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_integer(const char *s, long long *v) {
|
bool is_integer(const char *s, long long *v) {
|
||||||
|
|||||||
@@ -174,7 +174,8 @@ struct mvt_layer {
|
|||||||
void tag(mvt_feature &feature, std::string const &key, mvt_value const &value);
|
void tag(mvt_feature &feature, std::string const &key, mvt_value const &value);
|
||||||
|
|
||||||
// For tracking the key-value constants already used in this layer
|
// For tracking the key-value constants already used in this layer
|
||||||
std::vector<ssize_t> dedup = std::vector<ssize_t>(65536, -1);
|
std::unordered_map<std::string, size_t> key_map{};
|
||||||
|
std::unordered_map<mvt_value, size_t> value_map{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mvt_tile {
|
struct mvt_tile {
|
||||||
|
|||||||
Reference in New Issue
Block a user