Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/multi/io/wkt/read.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // Boost.Geometry (aka GGL, Generic Geometry Library) | |
2 | |
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | |
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
9 | |
10 // Use, modification and distribution is subject to the Boost Software License, | |
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
12 // http://www.boost.org/LICENSE_1_0.txt) | |
13 | |
14 #ifndef BOOST_GEOMETRY_MULTI_IO_WKT_READ_MULTI_HPP | |
15 #define BOOST_GEOMETRY_MULTI_IO_WKT_READ_MULTI_HPP | |
16 | |
17 #include <string> | |
18 | |
19 #include <boost/geometry/core/mutable_range.hpp> | |
20 #include <boost/geometry/multi/core/tags.hpp> | |
21 #include <boost/geometry/multi/core/point_type.hpp> | |
22 #include <boost/geometry/multi/geometries/concepts/check.hpp> | |
23 #include <boost/geometry/multi/io/wkt/detail/prefix.hpp> | |
24 #include <boost/geometry/io/wkt/read.hpp> | |
25 | |
26 namespace boost { namespace geometry | |
27 { | |
28 | |
29 namespace detail { namespace wkt | |
30 { | |
31 | |
32 template <typename MultiGeometry, template<typename> class Parser, typename PrefixPolicy> | |
33 struct multi_parser | |
34 { | |
35 static inline void apply(std::string const& wkt, MultiGeometry& geometry) | |
36 { | |
37 traits::clear<MultiGeometry>::apply(geometry); | |
38 | |
39 tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()")); | |
40 tokenizer::iterator it; | |
41 if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it)) | |
42 { | |
43 handle_open_parenthesis(it, tokens.end(), wkt); | |
44 | |
45 // Parse sub-geometries | |
46 while(it != tokens.end() && *it != ")") | |
47 { | |
48 traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1); | |
49 Parser | |
50 < | |
51 typename boost::range_value<MultiGeometry>::type | |
52 >::apply(it, tokens.end(), wkt, *(boost::end(geometry) - 1)); | |
53 if (it != tokens.end() && *it == ",") | |
54 { | |
55 // Skip "," after multi-element is parsed | |
56 ++it; | |
57 } | |
58 } | |
59 | |
60 handle_close_parenthesis(it, tokens.end(), wkt); | |
61 } | |
62 | |
63 check_end(it, tokens.end(), wkt); | |
64 } | |
65 }; | |
66 | |
67 template <typename P> | |
68 struct noparenthesis_point_parser | |
69 { | |
70 static inline void apply(tokenizer::iterator& it, tokenizer::iterator end, | |
71 std::string const& wkt, P& point) | |
72 { | |
73 parsing_assigner<P, 0, dimension<P>::value>::apply(it, end, point, wkt); | |
74 } | |
75 }; | |
76 | |
77 template <typename MultiGeometry, typename PrefixPolicy> | |
78 struct multi_point_parser | |
79 { | |
80 static inline void apply(std::string const& wkt, MultiGeometry& geometry) | |
81 { | |
82 traits::clear<MultiGeometry>::apply(geometry); | |
83 | |
84 tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()")); | |
85 tokenizer::iterator it; | |
86 | |
87 if (initialize<MultiGeometry>(tokens, PrefixPolicy::apply(), wkt, it)) | |
88 { | |
89 handle_open_parenthesis(it, tokens.end(), wkt); | |
90 | |
91 // If first point definition starts with "(" then parse points as (x y) | |
92 // otherwise as "x y" | |
93 bool using_brackets = (it != tokens.end() && *it == "("); | |
94 | |
95 while(it != tokens.end() && *it != ")") | |
96 { | |
97 traits::resize<MultiGeometry>::apply(geometry, boost::size(geometry) + 1); | |
98 | |
99 if (using_brackets) | |
100 { | |
101 point_parser | |
102 < | |
103 typename boost::range_value<MultiGeometry>::type | |
104 >::apply(it, tokens.end(), wkt, *(boost::end(geometry) - 1)); | |
105 } | |
106 else | |
107 { | |
108 noparenthesis_point_parser | |
109 < | |
110 typename boost::range_value<MultiGeometry>::type | |
111 >::apply(it, tokens.end(), wkt, *(boost::end(geometry) - 1)); | |
112 } | |
113 | |
114 if (it != tokens.end() && *it == ",") | |
115 { | |
116 // Skip "," after point is parsed | |
117 ++it; | |
118 } | |
119 } | |
120 | |
121 handle_close_parenthesis(it, tokens.end(), wkt); | |
122 } | |
123 | |
124 check_end(it, tokens.end(), wkt); | |
125 } | |
126 }; | |
127 | |
128 }} // namespace detail::wkt | |
129 | |
130 #ifndef DOXYGEN_NO_DISPATCH | |
131 namespace dispatch | |
132 { | |
133 | |
134 template <typename MultiGeometry> | |
135 struct read_wkt<multi_point_tag, MultiGeometry> | |
136 : detail::wkt::multi_point_parser | |
137 < | |
138 MultiGeometry, | |
139 detail::wkt::prefix_multipoint | |
140 > | |
141 {}; | |
142 | |
143 template <typename MultiGeometry> | |
144 struct read_wkt<multi_linestring_tag, MultiGeometry> | |
145 : detail::wkt::multi_parser | |
146 < | |
147 MultiGeometry, | |
148 detail::wkt::linestring_parser, | |
149 detail::wkt::prefix_multilinestring | |
150 > | |
151 {}; | |
152 | |
153 template <typename MultiGeometry> | |
154 struct read_wkt<multi_polygon_tag, MultiGeometry> | |
155 : detail::wkt::multi_parser | |
156 < | |
157 MultiGeometry, | |
158 detail::wkt::polygon_parser, | |
159 detail::wkt::prefix_multipolygon | |
160 > | |
161 {}; | |
162 | |
163 } // namespace dispatch | |
164 #endif // DOXYGEN_NO_DISPATCH | |
165 | |
166 }} // namespace boost::geometry | |
167 | |
168 #endif // BOOST_GEOMETRY_MULTI_IO_WKT_READ_MULTI_HPP |