| 66 | template <typename P> |
| 67 | struct noparenthesis_point_parser |
| 68 | { |
| 69 | static inline void apply(tokenizer::iterator& it, tokenizer::iterator end, |
| 70 | std::string const& wkt, P& point) |
| 71 | { |
| 72 | parsing_assigner<P, 0, dimension<P>::value>::apply(it, end, point, wkt); |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | template <typename MultiGeometry, typename PrefixPolicy> |
| 77 | struct multi_point_parser |
| 78 | { |
| 79 | static inline void apply(std::string const& wkt, MultiGeometry& geometry) |
| 80 | { |
| 81 | traits::clear<MultiGeometry>::apply(geometry); |
| 82 | |
| 83 | tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()")); |
| 84 | tokenizer::iterator it; |
| 85 | |
| 86 | if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it)) |
| 87 | { |
| 88 | handle_open_parenthesis(it, tokens.end(), wkt); |
| 89 | |
| 90 | // If first point definition starts with "(" then parse points as (x y) |
| 91 | // otherwise as "x y" |
| 92 | bool using_brackets = (it != tokens.end() && *it == "("); |
| 93 | |
| 94 | while(it != tokens.end() && *it != ")") |
| 95 | { |
| 96 | traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1); |
| 97 | |
| 98 | if (using_brackets) |
| 99 | { |
| 100 | point_parser |
| 101 | < |
| 102 | typename boost::range_value<MultiGeometry>::type |
| 103 | >::apply(it, tokens.end(), wkt, geometry.back()); |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | noparenthesis_point_parser |
| 108 | < |
| 109 | typename boost::range_value<MultiGeometry>::type |
| 110 | >::apply(it, tokens.end(), wkt, geometry.back()); |
| 111 | } |
| 112 | |
| 113 | if (it != tokens.end() && *it == ",") |
| 114 | { |
| 115 | // Skip "," after point is parsed |
| 116 | ++it; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | handle_close_parenthesis(it, tokens.end(), wkt); |
| 121 | } |
| 122 | |
| 123 | check_end(it, tokens.end(), wkt); |
| 124 | } |
| 125 | }; |
| 126 | |