From 8876d13356300deb4e067e242a7375aee20ccaa5 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 21 Feb 2018 16:02:12 +0100 Subject: [PATCH] improve errors reporting in `mapnik-index` --- include/mapnik/json/json_grammar_config.hpp | 5 ++++- utils/mapnik-index/process_geojson_file_x3.cpp | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/mapnik/json/json_grammar_config.hpp b/include/mapnik/json/json_grammar_config.hpp index 22395ecb0..cc23efa8d 100644 --- a/include/mapnik/json/json_grammar_config.hpp +++ b/include/mapnik/json/json_grammar_config.hpp @@ -43,7 +43,8 @@ enum well_known_names features, geometry, coordinates, - properties + properties, + geometries }; constexpr char const* wkn_to_string(well_known_names val) @@ -56,6 +57,7 @@ constexpr char const* wkn_to_string(well_known_names val) case geometry: return "geometry"; case coordinates: return "coordinates"; case properties: return "properties"; + case geometries: return "geometries"; default: return "unknown"; } } @@ -73,6 +75,7 @@ inline keys_map get_keys() ("coordinates", well_known_names::coordinates) ("properties", well_known_names::properties) ("id", well_known_names::id) + ("geometries",well_known_names::geometries) ; return keys; } diff --git a/utils/mapnik-index/process_geojson_file_x3.cpp b/utils/mapnik-index/process_geojson_file_x3.cpp index afc8d55ed..1f4487ce3 100644 --- a/utils/mapnik-index/process_geojson_file_x3.cpp +++ b/utils/mapnik-index/process_geojson_file_x3.cpp @@ -51,6 +51,11 @@ constexpr mapnik::json::well_known_names geometry_properties[] = { mapnik::json::well_known_names::type, mapnik::json::well_known_names::coordinates}; // sorted +constexpr mapnik::json::well_known_names geometry_collection_properties[] = { + mapnik::json::well_known_names::type, + mapnik::json::well_known_names::geometries}; // sorted + + template std::string join(Keys const& keys) { @@ -117,9 +122,12 @@ bool validate_geojson_feature(mapnik::json::geojson_value & value, Keys const& k { return std::get<0>(e0) < std::get<0>(e1); }); - if (!has_keys(geometry.begin(), geometry.end(), geometry_properties)) + + if (!has_keys(geometry.begin(), geometry.end(), geometry_properties) + && !has_keys(geometry.begin(), geometry.end(), geometry_collection_properties)) { - if (verbose) std::clog << "Expecting one of " << join(geometry_properties) << std::endl; + if (verbose) std::clog << "\"geometry\": xxx <-- expecting one of " << join(geometry_properties) + << " or " << join(geometry_collection_properties) << std::endl; return false; }