diff --git a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp index 927be8f9c..e08baae18 100644 --- a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp +++ b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp @@ -42,6 +42,9 @@ namespace mapnik { namespace json { template struct extract_positions { + using boxes_type = Boxes; + using box_type = typename boxes_type::value_type::first_type; + extract_positions(Iterator start, Boxes & boxes) : start_(start), boxes_(boxes) {} @@ -50,20 +53,25 @@ struct extract_positions void operator() (T const& val) const { auto const& r = std::get<0>(val); - mapnik::box2d const& bbox = std::get<1>(val); + auto const& b = std::get<1>(val); auto offset = std::distance(start_, r.begin()); auto size = std::distance(r.begin(), r.end()); - boxes_.emplace_back(std::make_pair(bbox,std::make_pair(offset, size))); + boxes_.emplace_back(std::make_pair(box_type(b.minx(), b.miny(), b.maxx(), b.maxy()), std::make_pair(offset, size))); //boxes_.emplace_back(std::make_tuple(bbox,offset, size)); } Iterator start_; Boxes & boxes_; }; -using box_type = mapnik::box2d; +using box_type = mapnik::box2d; using boxes_type = std::vector>>; using callback_type = extract_positions; +using box_type_f = mapnik::box2d; +using boxes_type_f = std::vector>>; +using callback_type_f = extract_positions; + + namespace grammar { struct bracket_tag; @@ -90,6 +98,17 @@ using extract_bounding_boxes_reverse_context_type = phrase_parse_context_type>::type>::type>::type; +using extract_bounding_boxes_context_type_f = + x3::with_context const, + x3::with_context const, + context_type>::type>::type; + +using extract_bounding_boxes_reverse_context_type_f = + x3::with_context const, + x3::with_context const, + x3::with_context const, + phrase_parse_context_type>::type>::type>::type; + }}} #endif // MAPNIK_JSON_EXTRACT_BOUNDING_BOXES_CONFIG_HPP diff --git a/src/json/extract_bounding_boxes_x3.cpp b/src/json/extract_bounding_boxes_x3.cpp index 8aae1db1f..0c7a97d71 100644 --- a/src/json/extract_bounding_boxes_x3.cpp +++ b/src/json/extract_bounding_boxes_x3.cpp @@ -129,14 +129,15 @@ auto assign_bbox = [](auto const& ctx) auto extract_bounding_box = [](auto const& ctx) { - mapnik::box2d bbox; - calculate_bounding_box> visitor(bbox); + using box_type = typename std::decay::type; + box_type bbox; + calculate_bounding_box visitor(bbox); mapnik::util::apply_visitor(visitor, _attr(ctx)); _val(ctx) = std::move(bbox); }; -x3::rule > const coordinates_rule = "Coordinates"; -x3::rule,mapnik::box2d>> const bounding_box = "Bounding Box"; +x3::rule > const coordinates_rule = "Coordinates"; +x3::rule, mapnik::box2d>> const bounding_box = "Bounding Box"; x3::rule const feature_collection = "Feature Collection"; auto const coordinates_rule_def = lit("\"coordinates\"") >> lit(':') >> positions_rule[extract_bounding_box]; @@ -198,5 +199,5 @@ void extract_bounding_boxes(Iterator start, Iterator end, Boxes & boxes) } using base_iterator_type = char const*; template void extract_bounding_boxes(base_iterator_type, base_iterator_type, boxes_type&); - +template void extract_bounding_boxes(base_iterator_type, base_iterator_type, boxes_type_f&); }}