improve errors reporting in mapnik-index
This commit is contained in:
parent
ff56c86446
commit
8876d13356
2 changed files with 14 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 <typename Keys>
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue