mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-03 00:45:41 +02:00
Reduce tippecanoe memory usage (#5)
* Change JSON objects to a union type to use less memory * Stop storing the string representation of JSON numbers * Restore the ability to create features with large integer attributes * Make sure large-integer feature IDs still behave as before * Add missing #include * Don't preallocate as much space for arrays and objects * Treat inability to check free disk space as a warning, not an error * Update changelog and version
This commit is contained in:
+11
-11
@@ -583,14 +583,14 @@ void handle_tasks(std::map<zxy, std::vector<std::string>> &tasks, std::vector<st
|
||||
|
||||
void handle_vector_layers(json_object *vector_layers, std::map<std::string, layermap_entry> &layermap, std::map<std::string, std::string> &attribute_descriptions) {
|
||||
if (vector_layers != NULL && vector_layers->type == JSON_ARRAY) {
|
||||
for (size_t i = 0; i < vector_layers->length; i++) {
|
||||
if (vector_layers->array[i]->type == JSON_HASH) {
|
||||
json_object *id = json_hash_get(vector_layers->array[i], "id");
|
||||
json_object *desc = json_hash_get(vector_layers->array[i], "description");
|
||||
for (size_t i = 0; i < vector_layers->value.array.length; i++) {
|
||||
if (vector_layers->value.array.array[i]->type == JSON_HASH) {
|
||||
json_object *id = json_hash_get(vector_layers->value.array.array[i], "id");
|
||||
json_object *desc = json_hash_get(vector_layers->value.array.array[i], "description");
|
||||
|
||||
if (id != NULL && desc != NULL && id->type == JSON_STRING && desc->type == JSON_STRING) {
|
||||
std::string sid = id->string;
|
||||
std::string sdesc = desc->string;
|
||||
std::string sid = id->value.string.string;
|
||||
std::string sdesc = desc->value.string.string;
|
||||
|
||||
if (sdesc.size() != 0) {
|
||||
auto f = layermap.find(sid);
|
||||
@@ -600,17 +600,17 @@ void handle_vector_layers(json_object *vector_layers, std::map<std::string, laye
|
||||
}
|
||||
}
|
||||
|
||||
json_object *fields = json_hash_get(vector_layers->array[i], "fields");
|
||||
json_object *fields = json_hash_get(vector_layers->value.array.array[i], "fields");
|
||||
if (fields != NULL && fields->type == JSON_HASH) {
|
||||
for (size_t j = 0; j < fields->length; j++) {
|
||||
if (fields->keys[j]->type == JSON_STRING && fields->values[j]->type) {
|
||||
const char *desc2 = fields->values[j]->string;
|
||||
for (size_t j = 0; j < fields->value.object.length; j++) {
|
||||
if (fields->value.object.keys[j]->type == JSON_STRING && fields->value.object.values[j]->type) {
|
||||
const char *desc2 = fields->value.object.values[j]->value.string.string;
|
||||
|
||||
if (strcmp(desc2, "Number") != 0 &&
|
||||
strcmp(desc2, "String") != 0 &&
|
||||
strcmp(desc2, "Boolean") != 0 &&
|
||||
strcmp(desc2, "Mixed") != 0) {
|
||||
attribute_descriptions.insert(std::pair<std::string, std::string>(fields->keys[j]->string, desc2));
|
||||
attribute_descriptions.insert(std::pair<std::string, std::string>(fields->value.object.keys[j]->value.string.string, desc2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user