diff --git a/CHANGELOG.md b/CHANGELOG.md index 20286a02..c84e1ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.15.2 + +* Change tile hash function to fnv1a +* Report JSON object context on the same line as the error message + ## 2.15.1 * Correct mbtiles inserts to use text instead of blob diff --git a/geojson-loop.cpp b/geojson-loop.cpp index 150166ec..ab0cd9db 100644 --- a/geojson-loop.cpp +++ b/geojson-loop.cpp @@ -32,7 +32,7 @@ static void json_context(json_object *j) { sprintf(s + 497, "..."); } - fprintf(stderr, "In JSON object %s\n", s); + fprintf(stderr, "in JSON object %s\n", s); free(s); // stringify } @@ -45,9 +45,11 @@ void parse_json(json_feature_action *jfa, json_pull *jp) { json_object *j = json_read(jp); if (j == NULL) { if (jp->error != NULL) { - fprintf(stderr, "%s:%d: %s\n", jfa->fname.c_str(), jp->line, jp->error); + fprintf(stderr, "%s:%d: %s: ", jfa->fname.c_str(), jp->line, jp->error); if (jp->root != NULL) { json_context(jp->root); + } else { + fprintf(stderr, "\n"); } } @@ -140,7 +142,7 @@ void parse_json(json_feature_action *jfa, json_pull *jp) { json_object *geometry = json_hash_get(j, "geometry"); if (geometry == NULL) { - fprintf(stderr, "%s:%d: feature with no geometry\n", jfa->fname.c_str(), jp->line); + fprintf(stderr, "%s:%d: feature with no geometry: ", jfa->fname.c_str(), jp->line); json_context(j); json_free(j); continue; @@ -148,7 +150,7 @@ void parse_json(json_feature_action *jfa, json_pull *jp) { json_object *properties = json_hash_get(j, "properties"); if (properties == NULL || (properties->type != JSON_HASH && properties->type != JSON_NULL)) { - fprintf(stderr, "%s:%d: feature without properties hash\n", jfa->fname.c_str(), jp->line); + fprintf(stderr, "%s:%d: feature without properties hash: ", jfa->fname.c_str(), jp->line); json_context(j); json_free(j); continue; diff --git a/geojson.cpp b/geojson.cpp index cbe4b2c6..16ef9457 100644 --- a/geojson.cpp +++ b/geojson.cpp @@ -46,7 +46,7 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom if (geometry_type == NULL) { static int warned = 0; if (!warned) { - fprintf(stderr, "%s:%d: null geometry (additional not reported)\n", sst->fname, sst->line); + fprintf(stderr, "%s:%d: null geometry (additional not reported): ", sst->fname, sst->line); json_context(feature); warned = 1; } @@ -55,14 +55,14 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom } if (geometry_type->type != JSON_STRING) { - fprintf(stderr, "%s:%d: geometry type is not a string\n", sst->fname, sst->line); + fprintf(stderr, "%s:%d: geometry type is not a string: ", sst->fname, sst->line); json_context(feature); return 0; } json_object *coordinates = json_hash_get(geometry, "coordinates"); if (coordinates == NULL || coordinates->type != JSON_ARRAY) { - fprintf(stderr, "%s:%d: feature without coordinates array\n", sst->fname, sst->line); + fprintf(stderr, "%s:%d: feature without coordinates array: ", sst->fname, sst->line); json_context(feature); return 0; } @@ -74,7 +74,7 @@ int serialize_geojson_feature(struct serialization_state *sst, json_object *geom } } if (t >= GEOM_TYPES) { - fprintf(stderr, "%s:%d: Can't handle geometry type %s\n", sst->fname, sst->line, geometry_type->value.string.string); + fprintf(stderr, "%s:%d: Can't handle geometry type %s: ", sst->fname, sst->line, geometry_type->value.string.string); json_context(feature); return 0; } diff --git a/plugin.cpp b/plugin.cpp index ebb24889..158ea3f7 100644 --- a/plugin.cpp +++ b/plugin.cpp @@ -99,9 +99,11 @@ std::vector parse_layers(int fd, int z, unsigned x, unsigned y, std:: json_object *j = json_read(jp); if (j == NULL) { if (jp->error != NULL) { - fprintf(stderr, "Filter output:%d: %s\n", jp->line, jp->error); + fprintf(stderr, "Filter output:%d: %s: ", jp->line, jp->error); if (jp->root != NULL) { json_context(jp->root); + } else { + fprintf(stderr, "\n"); } exit(EXIT_JSON); } @@ -120,7 +122,7 @@ std::vector parse_layers(int fd, int z, unsigned x, unsigned y, std:: json_object *geometry = json_hash_get(j, "geometry"); if (geometry == NULL) { - fprintf(stderr, "Filter output:%d: filtered feature with no geometry\n", jp->line); + fprintf(stderr, "Filter output:%d: filtered feature with no geometry: ", jp->line); json_context(j); json_free(j); exit(EXIT_JSON); @@ -128,7 +130,7 @@ std::vector parse_layers(int fd, int z, unsigned x, unsigned y, std:: json_object *properties = json_hash_get(j, "properties"); if (properties == NULL || (properties->type != JSON_HASH && properties->type != JSON_NULL)) { - fprintf(stderr, "Filter output:%d: feature without properties hash\n", jp->line); + fprintf(stderr, "Filter output:%d: feature without properties hash: ", jp->line); json_context(j); json_free(j); exit(EXIT_JSON); @@ -136,20 +138,20 @@ std::vector parse_layers(int fd, int z, unsigned x, unsigned y, std:: json_object *geometry_type = json_hash_get(geometry, "type"); if (geometry_type == NULL) { - fprintf(stderr, "Filter output:%d: null geometry (additional not reported)\n", jp->line); + fprintf(stderr, "Filter output:%d: null geometry (additional not reported): ", jp->line); json_context(j); exit(EXIT_JSON); } if (geometry_type->type != JSON_STRING) { - fprintf(stderr, "Filter output:%d: geometry type is not a string\n", jp->line); + fprintf(stderr, "Filter output:%d: geometry type is not a string: ", jp->line); json_context(j); exit(EXIT_JSON); } json_object *coordinates = json_hash_get(geometry, "coordinates"); if (coordinates == NULL || coordinates->type != JSON_ARRAY) { - fprintf(stderr, "Filter output:%d: feature without coordinates array\n", jp->line); + fprintf(stderr, "Filter output:%d: feature without coordinates array: ", jp->line); json_context(j); exit(EXIT_JSON); } @@ -161,7 +163,7 @@ std::vector parse_layers(int fd, int z, unsigned x, unsigned y, std:: } } if (t >= GEOM_TYPES) { - fprintf(stderr, "Filter output:%d: Can't handle geometry type %s\n", jp->line, geometry_type->value.string.string); + fprintf(stderr, "Filter output:%d: Can't handle geometry type %s: ", jp->line, geometry_type->value.string.string); json_context(j); exit(EXIT_JSON); } @@ -306,9 +308,11 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: json_object *j = json_read(jp); if (j == NULL) { if (jp->error != NULL) { - fprintf(stderr, "Filter output:%d: %s\n", jp->line, jp->error); + fprintf(stderr, "Filter output:%d: %s: ", jp->line, jp->error); if (jp->root != NULL) { json_context(jp->root); + } else { + fprintf(stderr, "\n"); } exit(EXIT_JSON); } @@ -328,7 +332,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: json_object *geometry = json_hash_get(j, "geometry"); if (geometry == NULL) { - fprintf(stderr, "Filter output:%d: filtered feature with no geometry\n", jp->line); + fprintf(stderr, "Filter output:%d: filtered feature with no geometry: ", jp->line); json_context(j); json_free(j); exit(EXIT_JSON); @@ -336,7 +340,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: json_object *properties = json_hash_get(j, "properties"); if (properties == NULL || (properties->type != JSON_HASH && properties->type != JSON_NULL)) { - fprintf(stderr, "Filter output:%d: feature without properties hash\n", jp->line); + fprintf(stderr, "Filter output:%d: feature without properties hash: ", jp->line); json_context(j); json_free(j); exit(EXIT_JSON); @@ -344,20 +348,20 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: json_object *geometry_type = json_hash_get(geometry, "type"); if (geometry_type == NULL) { - fprintf(stderr, "Filter output:%d: null geometry (additional not reported)\n", jp->line); + fprintf(stderr, "Filter output:%d: null geometry (additional not reported): ", jp->line); json_context(j); exit(EXIT_JSON); } if (geometry_type->type != JSON_STRING) { - fprintf(stderr, "Filter output:%d: geometry type is not a string\n", jp->line); + fprintf(stderr, "Filter output:%d: geometry type is not a string: ", jp->line); json_context(j); exit(EXIT_JSON); } json_object *coordinates = json_hash_get(geometry, "coordinates"); if (coordinates == NULL || coordinates->type != JSON_ARRAY) { - fprintf(stderr, "Filter output:%d: feature without coordinates array\n", jp->line); + fprintf(stderr, "Filter output:%d: feature without coordinates array: ", jp->line); json_context(j); exit(EXIT_JSON); } @@ -369,7 +373,7 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std:: } } if (t >= GEOM_TYPES) { - fprintf(stderr, "Filter output:%d: Can't handle geometry type %s\n", jp->line, geometry_type->value.string.string); + fprintf(stderr, "Filter output:%d: Can't handle geometry type %s: ", jp->line, geometry_type->value.string.string); json_context(j); exit(EXIT_JSON); } diff --git a/read_json.cpp b/read_json.cpp index 8e856017..460fcb26 100644 --- a/read_json.cpp +++ b/read_json.cpp @@ -48,13 +48,13 @@ void json_context(json_object *j) { sprintf(s + 497, "..."); } - fprintf(stderr, "In JSON object %s\n", s); + fprintf(stderr, "in JSON object %s\n", s); free(s); // stringify } void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fname, int line, json_object *feature) { if (j == NULL || j->type != JSON_ARRAY) { - fprintf(stderr, "%s:%d: expected array for type %d\n", fname, line, t); + fprintf(stderr, "%s:%d: expected array for geometry type %d: ", fname, line, t); json_context(feature); return; } @@ -84,8 +84,9 @@ void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fna static int warned = 0; if (!warned) { - fprintf(stderr, "%s:%d: ignoring dimensions beyond two\n", fname, line); + fprintf(stderr, "%s:%d: ignoring dimensions beyond two: ", fname, line); json_context(j); + fprintf(stderr, "%s:%d: ignoring dimensions beyond two: ", fname, line); json_context(feature); warned = 1; } @@ -93,8 +94,9 @@ void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fna out.push_back(draw(op, x, y)); } else { - fprintf(stderr, "%s:%d: malformed point\n", fname, line); + fprintf(stderr, "%s:%d: malformed point: ", fname, line); json_context(j); + fprintf(stderr, "%s:%d: malformed point: ", fname, line); json_context(feature); exit(EXIT_JSON); } @@ -146,7 +148,7 @@ void stringify_value(json_object *value, int &type, std::string &stringified, co stringified = val; std::string err = check_utf8(val); if (err != "") { - fprintf(stderr, "%s:%d: %s\n", reading, line, err.c_str()); + fprintf(stderr, "%s:%d: %s: ", reading, line, err.c_str()); json_context(feature); exit(EXIT_UTF8); } diff --git a/version.hpp b/version.hpp index 9b4fc0d1..a85bd4f5 100644 --- a/version.hpp +++ b/version.hpp @@ -1,6 +1,6 @@ #ifndef VERSION_HPP #define VERSION_HPP -#define VERSION "v2.15.1" +#define VERSION "v2.15.2" #endif