mapnik-index - implement validatation callback by comparing bounding boxes from bbox extractor and GeoJSON feature

This commit is contained in:
artemp 2015-11-12 16:12:06 +00:00
parent 5eecf1dfae
commit 7a0688edcb
2 changed files with 13 additions and 5 deletions

View file

@ -187,7 +187,11 @@ int main (int argc, char** argv)
{
std::clog << "processing '" << filename << "' as GeoJSON\n";
auto result = mapnik::detail::process_geojson_file(boxes, filename, validate_features);
if (!result.first) continue;
if (!result.first)
{
std::clog << "Error: failed to process " << filename << std::endl;
continue;
}
extent = result.second;
}

View file

@ -44,13 +44,17 @@
namespace {
struct feature_validate_callback
{
feature_validate_callback() {}
feature_validate_callback(mapnik::box2d<double> const& box)
: box_(box) {}
void operator() (mapnik::feature_ptr const& f) const
{
auto bbox = f->envelope();
std::cerr << bbox << std::endl;
if (box_ != f->envelope())
{
throw std::runtime_error("Bounding boxes mismatch validation feature");
}
}
mapnik::box2d<double> const& box_;
};
using base_iterator_type = char const*;
@ -121,7 +125,7 @@ std::pair<bool,box2d<double>> process_geojson_file(T & boxes, std::string const&
{
base_iterator_type feat_itr = start + item.second.first;
base_iterator_type feat_end = feat_itr + item.second.second;
feature_validate_callback callback;
feature_validate_callback callback(item.first);
bool result = boost::spirit::qi::phrase_parse(feat_itr, feat_end, (fc_grammar)
(boost::phoenix::ref(ctx), boost::phoenix::ref(start_id), boost::phoenix::ref(callback)),
space);