Skip to content
This repository
Browse code

+ allow empty arrays in "coordinates" property

  • Loading branch information...
commit 1f15012c3c331b98822f7ece7d4121f681d29659 1 parent bca033e
Artem Pavlenko authored June 12, 2012

Showing 1 changed file with 25 additions and 26 deletions. Show diff stats Hide diff stats

  1. 51  include/mapnik/json/feature_grammar.hpp
51  include/mapnik/json/feature_grammar.hpp
@@ -162,7 +162,7 @@ struct feature_grammar :
162 162
         using qi::_pass;
163 163
         using qi::eps;
164 164
         using qi::raw;
165  
-        
  165
+
166 166
         using phoenix::new_;
167 167
         using phoenix::push_back;
168 168
         using phoenix::construct;
@@ -197,7 +197,7 @@ struct feature_grammar :
197 197
         unesc_char.add
198 198
             ("\\\"", '\"') // quotation mark
199 199
             ("\\\\", '\\') // reverse solidus
200  
-            ("\\/", '/')   // solidus            
  200
+            ("\\/", '/')   // solidus
201 201
             ("\\b", '\b')  // backspace
202 202
             ("\\f", '\f')  // formfeed
203 203
             ("\\n", '\n')  // newline
@@ -207,7 +207,7 @@ struct feature_grammar :
207 207
 
208 208
         string_ %= lit('"') >> *(unesc_char | "\\u" >> hex4 | (char_ - lit('"'))) >> lit('"')
209 209
             ;
210  
-        
  210
+
211 211
         // geojson types
212 212
 
213 213
         feature_type = lit("\"type\"")
@@ -244,17 +244,17 @@ struct feature_grammar :
244 244
         //    ;
245 245
         //////////////////////////////////////////////////////////////////
246 246
 
247  
-        geometry = (lit('{')[_a = 0 ] 
  247
+        geometry = (lit('{')[_a = 0 ]
248 248
                     >> lit("\"type\"") >> lit(':') >> geometry_dispatch[_a = _1] // <---- should be Nabialek trick!
249  
-                    >> lit(',') 
  249
+                    >> lit(',')
250 250
                     >> (lit("\"coordinates\"") > lit(':') > coordinates(_r1,_a)
251  
-                        | 
252  
-                        lit("\"geometries\"") > lit(':') 
  251
+                        |
  252
+                        lit("\"geometries\"") > lit(':')
253 253
                         >> lit('[') >> geometry_collection(_r1) >> lit(']'))
254 254
                     >> lit('}'))
255 255
             | lit("null")
256 256
             ;
257  
-                
  257
+
258 258
         geometry_dispatch.add
259 259
             ("\"Point\"",1)
260 260
             ("\"LineString\"",2)
@@ -265,7 +265,7 @@ struct feature_grammar :
265 265
             ("\"GeometryCollection\"",7)
266 266
             //
267 267
             ;
268  
-        
  268
+
269 269
         coordinates = (eps(_r2 == 1) > point_coordinates(extract_geometry_(_r1)))
270 270
             | (eps(_r2 == 2) > linestring_coordinates(extract_geometry_(_r1)))
271 271
             | (eps(_r2 == 3) > polygon_coordinates(extract_geometry_(_r1)))
@@ -273,46 +273,45 @@ struct feature_grammar :
273 273
             | (eps(_r2 == 5) > multilinestring_coordinates(extract_geometry_(_r1)))
274 274
             | (eps(_r2 == 6) > multipolygon_coordinates(extract_geometry_(_r1)))
275 275
             ;
276  
-        
  276
+
277 277
         point_coordinates =  eps[ _a = new_<geometry_type>(Point) ]
278 278
             > ( point(SEG_MOVETO,_a) [push_back(_r1,_a)] | eps[cleanup_(_a)][_pass = false] )
279 279
             ;
280 280
 
281 281
         linestring_coordinates = eps[ _a = new_<geometry_type>(LineString)]
282  
-            > (points(_a) [push_back(_r1,_a)]
  282
+            > -(points(_a) [push_back(_r1,_a)]
283 283
                | eps[cleanup_(_a)][_pass = false])
284 284
             ;
285 285
 
286 286
         polygon_coordinates = eps[ _a = new_<geometry_type>(Polygon) ]
287 287
             > ((lit('[')
288  
-                > points(_a) % lit(',')
  288
+                > -(points(_a) % lit(','))
289 289
                 > lit(']')) [push_back(_r1,_a)]
290 290
                | eps[cleanup_(_a)][_pass = false])
291 291
             ;
292  
-        
293  
-        multipoint_coordinates =  lit('[') 
294  
-            > (point_coordinates(_r1) % lit(',')) 
  292
+
  293
+        multipoint_coordinates =  lit('[')
  294
+            > -(point_coordinates(_r1) % lit(','))
295 295
             > lit(']')
296 296
             ;
297  
-        
298  
-        multilinestring_coordinates =  lit('[') 
299  
-            > (linestring_coordinates(_r1) % lit(','))
  297
+
  298
+        multilinestring_coordinates =  lit('[')
  299
+            > -(linestring_coordinates(_r1) % lit(','))
300 300
             > lit(']')
301 301
             ;
302  
-        
303  
-        multipolygon_coordinates =  lit('[') 
304  
-            > (polygon_coordinates(_r1) % lit(','))
  302
+
  303
+        multipolygon_coordinates =  lit('[')
  304
+            > -(polygon_coordinates(_r1) % lit(','))
305 305
             > lit(']')
306 306
             ;
307 307
 
308 308
         geometry_collection = *geometry(_r1) >> *(lit(',') >> geometry(_r1))
309 309
             ;
310  
-        
  310
+
311 311
         // point
312  
-        point = (lit('[') > double_ > lit(',') > double_ > lit(']')) [push_vertex_(_r1,_r2,_1,_2)];
  312
+        point = lit('[') > -((double_ > lit(',') > double_)[push_vertex_(_r1,_r2,_1,_2)]) > lit(']');
313 313
         // points
314  
-        points = lit('[')[_a = SEG_MOVETO] > point (_a,_r1) % lit(',') [_a = SEG_LINETO] > lit(']');
315  
-
  314
+        points = lit('[')[_a = SEG_MOVETO] > -(point (_a,_r1) % lit(',')[_a = SEG_LINETO]) > lit(']');
316 315
         on_error<fail>
317 316
             (
318 317
                 feature
@@ -362,7 +361,7 @@ struct feature_grammar :
362 361
     qi::rule<Iterator,qi::locals<geometry_type*>,
363 362
              void(boost::ptr_vector<mapnik::geometry_type>& ),space_type> linestring_coordinates;
364 363
     qi::rule<Iterator,qi::locals<geometry_type*>,
365  
-             void(boost::ptr_vector<mapnik::geometry_type>& ),space_type> polygon_coordinates;    
  364
+             void(boost::ptr_vector<mapnik::geometry_type>& ),space_type> polygon_coordinates;
366 365
 
367 366
     qi::rule<Iterator,void(boost::ptr_vector<mapnik::geometry_type>& ),space_type> multipoint_coordinates;
368 367
     qi::rule<Iterator,void(boost::ptr_vector<mapnik::geometry_type>& ),space_type> multilinestring_coordinates;

0 notes on commit 1f15012

Please sign in to comment.
Something went wrong with that request. Please try again.