From 252a0366e9eab2feebeaa4bc726c4bbf0ebebd78 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 11 Nov 2016 15:24:11 +0100 Subject: [PATCH] consistent usage of iterator type + cleanups --- .../mapnik-index/process_geojson_file_x3.cpp | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/utils/mapnik-index/process_geojson_file_x3.cpp b/utils/mapnik-index/process_geojson_file_x3.cpp index 44d712496..a9ac4a129 100644 --- a/utils/mapnik-index/process_geojson_file_x3.cpp +++ b/utils/mapnik-index/process_geojson_file_x3.cpp @@ -59,7 +59,7 @@ struct feature_validate_callback using box_type = mapnik::box2d; using boxes_type = std::vector>>; -//using base_iterator_type = char const*; +using base_iterator_type = char const*; //const mapnik::json::extract_bounding_box_grammar geojson_datasource_static_bbox_grammar; //const mapnik::transcoder tr("utf8"); //const mapnik::json::feature_grammar_callback> fc_grammar(tr); @@ -130,8 +130,6 @@ auto on_feature_callback = [] (auto const& ctx) namespace { auto const& geojson_value = geojson_grammar(); -//auto const& key_value_ = key_value_grammar(); -//auto const& json_string = mapnik::json::unicode_string_grammar(); } // extract bounding box from GeoJSON Feature @@ -174,7 +172,7 @@ auto extract_bounding_box = [](auto const& ctx) auto const coordinates_rule = x3::rule > {} = lit("\"coordinates\"") >> lit(':') >> positions_rule[extract_bounding_box]; -auto const bounding_box = x3::rule,mapnik::box2d>> {} +auto const bounding_box = x3::rule,mapnik::box2d>> {} = raw[lit('{')[open_bracket] >> *(eps[check_brackets] >> (lit("\"FeatureCollection\"") > eps(false) | @@ -260,8 +258,8 @@ std::pair process_geojson_file_x3(T & b { mapped_region = *memory; } - char const* start = reinterpret_cast(mapped_region->get_address()); - char const* end = start + mapped_region->get_size(); + base_iterator_type start = reinterpret_cast(mapped_region->get_address()); + base_iterator_type end = start + mapped_region->get_size(); #else mapnik::util::file file(filename); if (!file) @@ -272,14 +270,14 @@ std::pair process_geojson_file_x3(T & b std::string file_buffer; file_buffer.resize(file.size()); std::fread(&file_buffer[0], file.size(), 1, file.get()); - char const* start = file_buffer.c_str(); - char const* end = start + file_buffer.length(); + base_iterator_type start = file_buffer.c_str(); + base_iterator_type end = start + file_buffer.length(); #endif using namespace boost::spirit; using space_type = mapnik::json::grammar::space_type; auto const* itr = start; - extract_positions callback(itr, boxes); + extract_positions callback(itr, boxes); mapnik::json::grammar::keys_map keys; std::size_t bracket_counter = 0; auto feature_collection_impl = x3::with(std::ref(bracket_counter)) @@ -297,7 +295,7 @@ std::pair process_geojson_file_x3(T & b return std::make_pair(false, extent); } } - catch (x3::expectation_failure const& ex) + catch (x3::expectation_failure const& ex) { std::clog << ex.what() << std::endl; std::clog << "Expected: " << ex.which(); @@ -318,25 +316,6 @@ std::pair process_geojson_file_x3(T & b { if (!extent.valid()) extent = item.first; else extent.expand_to_include(item.first); - - if (validate_features) - { - std::clog << "FIXME" << std::endl; - return std::make_pair(false, extent); -#if 0 - base_iterator_type feat_itr = start + item.second.first; - base_iterator_type feat_end = feat_itr + item.second.second; - feature_validate_callback callback(item.first); - bool result = boost::spirit::::phrase_parse(feat_itr, feat_end, (fc_grammar) - (boost::phoenix::ref(ctx), boost::phoenix::ref(start_id), boost::phoenix::ref(callback)), - space); - if (!result || feat_itr != feat_end) - { - if (verbose) std::clog << std::string(start + item.second.first, feat_end ) << std::endl; - return std::make_pair(false, extent); - } -#endif - } } } return std::make_pair(true, extent);