GeoJSON - backport positions grammar changes from master, fixes #3609
This commit is contained in:
parent
ab206321b5
commit
6cb3bce2d7
4 changed files with 20 additions and 23 deletions
|
@ -51,7 +51,7 @@ struct extract_bounding_box_grammar :
|
||||||
qi::rule<Iterator, qi::locals<Iterator>, void(boxes_type&), space_type> features;
|
qi::rule<Iterator, qi::locals<Iterator>, void(boxes_type&), space_type> features;
|
||||||
qi::rule<Iterator, qi::locals<int, box_type>, void(boxes_type&, Iterator const&), space_type> feature;
|
qi::rule<Iterator, qi::locals<int, box_type>, void(boxes_type&, Iterator const&), space_type> feature;
|
||||||
qi::rule<Iterator, qi::locals<box_type>, box_type(), space_type> coords;
|
qi::rule<Iterator, qi::locals<box_type>, box_type(), space_type> coords;
|
||||||
qi::rule<Iterator, boost::optional<position_type>(), space_type> pos;
|
qi::rule<Iterator, position_type(), space_type> pos;
|
||||||
qi::rule<Iterator, void(box_type&), space_type> ring;
|
qi::rule<Iterator, void(box_type&), space_type> ring;
|
||||||
qi::rule<Iterator, void(box_type&), space_type> rings;
|
qi::rule<Iterator, void(box_type&), space_type> rings;
|
||||||
qi::rule<Iterator, void(box_type&), space_type> rings_array;
|
qi::rule<Iterator, void(box_type&), space_type> rings_array;
|
||||||
|
|
|
@ -42,18 +42,15 @@ struct calculate_bounding_box_impl
|
||||||
template <typename T0, typename T1>
|
template <typename T0, typename T1>
|
||||||
result_type operator() (T0 & bbox, T1 const& pos) const
|
result_type operator() (T0 & bbox, T1 const& pos) const
|
||||||
{
|
{
|
||||||
if (pos)
|
typename T0::value_type x = pos.x;
|
||||||
|
typename T0::value_type y = pos.y;
|
||||||
|
if (!bbox.valid())
|
||||||
{
|
{
|
||||||
typename T0::value_type x = pos->x;
|
bbox.init(x, y);
|
||||||
typename T0::value_type y = pos->y;
|
}
|
||||||
if (!bbox.valid())
|
else
|
||||||
{
|
{
|
||||||
bbox.init(x, y);
|
bbox.expand_to_include(x, y);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bbox.expand_to_include(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -132,16 +129,16 @@ extract_bounding_box_grammar<Iterator, Boxes, ErrorHandler>::extract_bounding_bo
|
||||||
>> lit(':') >> (rings_array(_a) | rings (_a) | ring(_a) | pos[calculate_bounding_box(_a,_1)])[_val = _a]
|
>> lit(':') >> (rings_array(_a) | rings (_a) | ring(_a) | pos[calculate_bounding_box(_a,_1)])[_val = _a]
|
||||||
;
|
;
|
||||||
|
|
||||||
pos = lit('[') > -(double_ > lit(',') > double_) > omit[*(lit(',') > double_)] > lit(']')
|
pos = lit('[') > double_ > lit(',') > double_ > omit[*(lit(',') > double_)] > lit(']')
|
||||||
;
|
;
|
||||||
|
|
||||||
ring = lit('[') >> pos[calculate_bounding_box(_r1,_1)] % lit(',') > lit(']')
|
ring = lit('[') >> -(pos[calculate_bounding_box(_r1,_1)] % lit(',')) >> lit(']')
|
||||||
;
|
;
|
||||||
|
|
||||||
rings = lit('[') >> ring(_r1) % lit(',') > lit(']')
|
rings = lit('[') >> (ring(_r1) % lit(',') > lit(']'))
|
||||||
;
|
;
|
||||||
|
|
||||||
rings_array = lit('[') >> rings(_r1) % lit(',') > lit(']')
|
rings_array = lit('[') >> (rings(_r1) % lit(',') > lit(']'))
|
||||||
;
|
;
|
||||||
|
|
||||||
coords.name("Coordinates");
|
coords.name("Coordinates");
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct positions_grammar :
|
||||||
{
|
{
|
||||||
positions_grammar(ErrorHandler & error_handler);
|
positions_grammar(ErrorHandler & error_handler);
|
||||||
qi::rule<Iterator, coordinates(),space_type> coords;
|
qi::rule<Iterator, coordinates(),space_type> coords;
|
||||||
qi::rule<Iterator, boost::optional<position>(), space_type> pos;
|
qi::rule<Iterator, position(), space_type> pos;
|
||||||
qi::rule<Iterator, positions(), space_type> ring;
|
qi::rule<Iterator, positions(), space_type> ring;
|
||||||
qi::rule<Iterator, std::vector<positions>(), space_type> rings;
|
qi::rule<Iterator, std::vector<positions>(), space_type> rings;
|
||||||
qi::rule<Iterator, std::vector<std::vector<positions> >(), space_type> rings_array;
|
qi::rule<Iterator, std::vector<std::vector<positions> >(), space_type> rings_array;
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct set_position_impl
|
||||||
template <typename T0,typename T1>
|
template <typename T0,typename T1>
|
||||||
result_type operator() (T0 & coords, T1 const& pos) const
|
result_type operator() (T0 & coords, T1 const& pos) const
|
||||||
{
|
{
|
||||||
if (pos) coords = *pos;
|
coords = pos;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ struct push_position_impl
|
||||||
template <typename T0, typename T1>
|
template <typename T0, typename T1>
|
||||||
result_type operator() (T0 & coords, T1 const& pos) const
|
result_type operator() (T0 & coords, T1 const& pos) const
|
||||||
{
|
{
|
||||||
if (pos) coords.emplace_back(*pos);
|
coords.emplace_back(pos);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -75,13 +75,13 @@ positions_grammar<Iterator, ErrorHandler>::positions_grammar(ErrorHandler & erro
|
||||||
|
|
||||||
coords = rings_array[_val = _1] | rings [_val = _1] | ring[_val = _1] | pos[set_position(_val,_1)]
|
coords = rings_array[_val = _1] | rings [_val = _1] | ring[_val = _1] | pos[set_position(_val,_1)]
|
||||||
;
|
;
|
||||||
pos = lit('[') > -(double_ > lit(',') > double_) > omit[*(lit(',') > double_)] > lit(']')
|
pos = lit('[') > double_ > lit(',') > double_ > omit[*(lit(',') > double_)] > lit(']')
|
||||||
;
|
;
|
||||||
ring = lit('[') >> pos[push_position(_val,_1)] % lit(',') > lit(']')
|
ring = lit('[') >> -(pos[push_position(_val,_1)] % lit(',')) >> lit(']')
|
||||||
;
|
;
|
||||||
rings = lit('[') >> ring % lit(',') > lit(']')
|
rings = lit('[') >> (ring % lit(',') > lit(']'))
|
||||||
;
|
;
|
||||||
rings_array = lit('[') >> rings % lit(',') > lit(']')
|
rings_array = lit('[') >> (rings % lit(',') > lit(']'))
|
||||||
;
|
;
|
||||||
coords.name("Coordinates");
|
coords.name("Coordinates");
|
||||||
pos.name("Position");
|
pos.name("Position");
|
||||||
|
|
Loading…
Reference in a new issue