Require that per-feature maxzoom and minzoom be small integers

Also fixes a place in the Makefile that accidentally still used
CFLAGS instead of CXXFLAGS
This commit is contained in:
Eric Fischer
2018-07-12 11:24:30 -07:00
parent d64ac19f11
commit d1a0e495ce
7 changed files with 156 additions and 15 deletions
+11
View File
@@ -1,5 +1,7 @@
#include "text.hpp"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/**
* Returns an empty string if `s` is valid utf8;
@@ -122,3 +124,12 @@ std::string truncate16(std::string const &s, size_t runes) {
return std::string(s, 0, lastgood - start);
}
int integer_zoom(std::string where, std::string text) {
double d = atof(text.c_str());
if (!isnormal(d) || d != floor(d) || d < 0 || d > 32) {
fprintf(stderr, "%s: Expected integer zoom level in \"tippecanoe\" GeoJSON extension, not %s\n", where.c_str(), text.c_str());
exit(EXIT_FAILURE);
}
return d;
}