mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Once features can't possibly fit in a tile, stop trying (#9)
* Stop adding features to a tile if it can't possibly work * Add --integer and --fraction options to tippecanoe-decode * Carry the strategies field from tileset metadata through tile-join * Update changelog * Assign different codes to different kinds of error exits
This commit is contained in:
+18
-17
@@ -12,6 +12,7 @@
|
||||
#include "text.hpp"
|
||||
#include "geojson-loop.hpp"
|
||||
#include "milo/dtoa_milo.h"
|
||||
#include "errors.hpp"
|
||||
|
||||
int fail = EXIT_SUCCESS;
|
||||
bool wrap = false;
|
||||
@@ -198,7 +199,7 @@ void out(std::string const &s, int type, json_object *properties) {
|
||||
|
||||
if (type != buffered_type) {
|
||||
fprintf(stderr, "Error: mix of bare geometries and features\n");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,13 +210,13 @@ void join_csv(json_object *j) {
|
||||
std::string s = csv_getline(csvfile);
|
||||
if (s.size() == 0) {
|
||||
fprintf(stderr, "Couldn't get column header from CSV file\n");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_CSV);
|
||||
}
|
||||
|
||||
std::string err = check_utf8(s);
|
||||
if (err != "") {
|
||||
fprintf(stderr, "%s\n", err.c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_UTF8);
|
||||
}
|
||||
|
||||
header = csv_split(s.c_str());
|
||||
@@ -226,7 +227,7 @@ void join_csv(json_object *j) {
|
||||
|
||||
if (header.size() == 0) {
|
||||
fprintf(stderr, "No columns in CSV header \"%s\"\n", s.c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_CSV);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +260,7 @@ void join_csv(json_object *j) {
|
||||
|
||||
if (joinkey < prev_joinkey) {
|
||||
fprintf(stderr, "GeoJSON file is out of sort: \"%s\" follows \"%s\"\n", joinkey.c_str(), prev_joinkey.c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_IMPOSSIBLE);
|
||||
}
|
||||
prev_joinkey = joinkey;
|
||||
|
||||
@@ -279,7 +280,7 @@ void join_csv(json_object *j) {
|
||||
std::string err = check_utf8(s);
|
||||
if (err != "") {
|
||||
fprintf(stderr, "%s\n", err.c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_UTF8);
|
||||
}
|
||||
|
||||
fields = csv_split(s.c_str());
|
||||
@@ -290,7 +291,7 @@ void join_csv(json_object *j) {
|
||||
|
||||
if (fields.size() > 0 && fields[0] < prevkey) {
|
||||
fprintf(stderr, "CSV file is out of sort: \"%s\" follows \"%s\"\n", fields[0].c_str(), prevkey.c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_CSV);
|
||||
}
|
||||
|
||||
if (fields.size() > 0 && fields[0] >= joinkey) {
|
||||
@@ -310,7 +311,7 @@ void join_csv(json_object *j) {
|
||||
properties->value.object.values = (json_object **) realloc((void *) properties->value.object.values, (properties->value.object.length + 8 + fields.size()) * sizeof(json_object *));
|
||||
if (properties->value.object.keys == NULL || properties->value.object.values == NULL) {
|
||||
perror("realloc");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_MEMORY);
|
||||
}
|
||||
|
||||
for (size_t i = 1; i < fields.size(); i++) {
|
||||
@@ -335,7 +336,7 @@ void join_csv(json_object *j) {
|
||||
json_object *vo = (json_object *) malloc(sizeof(json_object));
|
||||
if (ko == NULL || vo == NULL) {
|
||||
perror("malloc");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_MEMORY);
|
||||
}
|
||||
|
||||
ko->type = JSON_STRING;
|
||||
@@ -345,7 +346,7 @@ void join_csv(json_object *j) {
|
||||
ko->value.string.string = strdup(k.c_str());
|
||||
if (ko->value.string.string == NULL) {
|
||||
perror("strdup");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_MEMORY);
|
||||
}
|
||||
|
||||
vo->type = attr_type;
|
||||
@@ -356,7 +357,7 @@ void join_csv(json_object *j) {
|
||||
vo->value.string.string = strdup(v.c_str());
|
||||
if (vo->value.string.string == NULL) {
|
||||
perror("strdup");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_MEMORY);
|
||||
}
|
||||
} else if (attr_type == JSON_NUMBER) {
|
||||
vo->value.number.number = atof(v.c_str());
|
||||
@@ -455,26 +456,26 @@ int main(int argc, char **argv) {
|
||||
pe = true;
|
||||
} else {
|
||||
fprintf(stderr, "%s: Unknown option for -p%s\n", argv[0], optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unexpected option -%c\n", i);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
}
|
||||
|
||||
if (extract != NULL && wrap) {
|
||||
fprintf(stderr, "%s: --wrap and --extract not supported together\n", argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_ARGS);
|
||||
}
|
||||
|
||||
if (csv != NULL) {
|
||||
csvfile = fopen(csv, "r");
|
||||
if (csvfile == NULL) {
|
||||
perror(csv);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_OPEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,7 +486,7 @@ int main(int argc, char **argv) {
|
||||
FILE *f = fopen(argv[i], "r");
|
||||
if (f == NULL) {
|
||||
perror(argv[i]);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_OPEN);
|
||||
}
|
||||
|
||||
process(f, argv[i]);
|
||||
@@ -502,7 +503,7 @@ int main(int argc, char **argv) {
|
||||
if (csvfile != NULL) {
|
||||
if (fclose(csvfile) != 0) {
|
||||
perror("close");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(EXIT_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user