mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-03 00:45:41 +02:00
Add --reject-null-geometry and more GeoJSON geometry validation
This commit is contained in:
@@ -103,6 +103,14 @@ void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fna
|
||||
}
|
||||
|
||||
if (t == GEOM_POLYGON) {
|
||||
if (out.size() < 3) {
|
||||
fprintf(stderr, "%s:%d: polygon must contain at least three points: ", fname, line);
|
||||
json_context(j);
|
||||
fprintf(stderr, "%s:%d: polygon must contain at least three points: ", fname, line);
|
||||
json_context(feature);
|
||||
exit(EXIT_INCORRECT_GEOMETRY);
|
||||
}
|
||||
|
||||
// Note that this is not using the correct meaning of closepath.
|
||||
//
|
||||
// We are using it here to close an entire Polygon, to distinguish
|
||||
@@ -114,6 +122,16 @@ void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fna
|
||||
|
||||
out.push_back(draw(VT_CLOSEPATH, 0, 0));
|
||||
}
|
||||
|
||||
if (t == GEOM_LINESTRING) {
|
||||
if (out.size() < 2) {
|
||||
fprintf(stderr, "%s:%d: linestring must contain at least two points: ", fname, line);
|
||||
json_context(j);
|
||||
fprintf(stderr, "%s:%d: linestring must contain at least two points: ", fname, line);
|
||||
json_context(feature);
|
||||
exit(EXIT_INCORRECT_GEOMETRY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stringify_value(json_object *value, int &type, std::string &stringified, const char *reading, int line, json_object *feature) {
|
||||
|
||||
Reference in New Issue
Block a user