Skip to content
This repository
Browse code

+ mapnik::value and mapnik::parameters - initial support for 64-bit i…

…ntegers
  • Loading branch information...
commit 855aea95e0c3a41db6f9d2389ec6ffff5d0d4b70 1 parent bf33e0e
Artem Pavlenko artemp authored

Showing 26 changed files with 227 additions and 178 deletions. Show diff stats Hide diff stats

  1. +1 1  bindings/python/mapnik_datasource.cpp
  2. +1 1  bindings/python/mapnik_datasource_cache.cpp
  3. +1 1  bindings/python/mapnik_feature.cpp
  4. +2 2 bindings/python/mapnik_parameters.cpp
  5. +1 1  bindings/python/mapnik_value_converter.hpp
  6. +2 2 include/mapnik/attribute.hpp
  7. +2 1  include/mapnik/json/feature_generator_grammar.hpp
  8. +4 2 include/mapnik/json/feature_grammar.hpp
  9. +1 1  include/mapnik/params.hpp
  10. +3 0  include/mapnik/util/conversions.hpp
  11. +131 107 include/mapnik/value.hpp
  12. +3 3 plugins/input/csv/csv_datasource.cpp
  13. +2 2 plugins/input/gdal/gdal_featureset.cpp
  14. +14 14 plugins/input/geojson/geojson_datasource.cpp
  15. +1 1  plugins/input/ogr/ogr_featureset.cpp
  16. +1 1  plugins/input/ogr/ogr_index_featureset.cpp
  17. +5 10 plugins/input/postgis/postgis_featureset.cpp
  18. +2 2 plugins/input/shape/dbfile.cpp
  19. +1 1  plugins/input/sqlite/sqlite_featureset.cpp
  20. +22 0 src/conversions.cpp
  21. +9 8 src/expression_grammar.cpp
  22. +2 2 src/json/feature_grammar.cpp
  23. +2 2 src/load_map.cpp
  24. +2 2 src/save_map.cpp
  25. +3 2 src/xml_tree.cpp
  26. +9 9 tests/cpp_tests/params_test.cpp
2  bindings/python/mapnik_datasource.cpp
@@ -64,7 +64,7 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
64 64 }
65 65
66 66 extract<std::string> ex0(obj);
67   - extract<int> ex1(obj);
  67 + extract<mapnik::value_integer> ex1(obj);
68 68 extract<double> ex2(obj);
69 69
70 70 if (ex0.check())
2  bindings/python/mapnik_datasource_cache.cpp
@@ -44,7 +44,7 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
44 44 }
45 45
46 46 extract<std::string> ex0(obj);
47   - extract<int> ex1(obj);
  47 + extract<mapnik::value_integer> ex1(obj);
48 48 extract<double> ex2(obj);
49 49
50 50 if (ex0.check())
2  bindings/python/mapnik_feature.cpp
@@ -162,7 +162,7 @@ void export_feature()
162 162 using mapnik::Feature;
163 163
164 164 // Python to mapnik::value converters
165   - implicitly_convertible<int,mapnik::value>();
  165 + implicitly_convertible<mapnik::value_integer,mapnik::value>();
166 166 implicitly_convertible<double,mapnik::value>();
167 167 implicitly_convertible<UnicodeString,mapnik::value>();
168 168 implicitly_convertible<bool,mapnik::value>();
4 bindings/python/mapnik_parameters.cpp
@@ -78,7 +78,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
78 78 std::string key = extract<std::string>(keys[i]);
79 79 object obj = d[key];
80 80 extract<std::string> ex0(obj);
81   - extract<int> ex1(obj);
  81 + extract<mapnik::value_integer> ex1(obj);
82 82 extract<double> ex2(obj);
83 83 extract<UnicodeString> ex3(obj);
84 84
@@ -185,7 +185,7 @@ boost::shared_ptr<mapnik::parameter> create_parameter_from_string(std::string co
185 185 return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
186 186 }
187 187
188   -boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, int value)
  188 +boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, mapnik::value_integer value)
189 189 {
190 190 return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
191 191 }
2  bindings/python/mapnik_value_converter.hpp
@@ -30,7 +30,7 @@ namespace boost { namespace python {
30 30
31 31 struct value_converter : public boost::static_visitor<PyObject*>
32 32 {
33   - PyObject * operator() (int val) const
  33 + PyObject * operator() (mapnik::value_integer val) const
34 34 {
35 35 #if PY_VERSION_HEX >= 0x03000000
36 36 return ::PyLong_FromLong(val);
4 include/mapnik/attribute.hpp
@@ -59,11 +59,11 @@ struct geometry_type_attribute
59 59 {
60 60 if (type != 0 && itr->type() != type)
61 61 {
62   - return 4; // Collection
  62 + return 4LL; // Collection
63 63 }
64 64 type = itr->type();
65 65 }
66   - return type;
  66 + return static_cast<mapnik::value_integer>(type);
67 67 }
68 68 };
69 69
3  include/mapnik/json/feature_generator_grammar.hpp
@@ -187,6 +187,7 @@ struct feature_generator_grammar:
187 187 using boost::spirit::karma::uint_;
188 188 using boost::spirit::karma::bool_;
189 189 using boost::spirit::karma::int_;
  190 + using boost::spirit::karma::long_long;
190 191 using boost::spirit::karma::double_;
191 192 using boost::spirit::karma::_val;
192 193 using boost::spirit::karma::_1;
@@ -212,7 +213,7 @@ struct feature_generator_grammar:
212 213 << value(phoenix::at_c<1>(_val))
213 214 ;
214 215
215   - value = (value_null_| bool_ | int_| double_ | ustring)[_1 = value_base_(_r1)]
  216 + value = (value_null_| bool_ | long_long | double_ | ustring)[_1 = value_base_(_r1)]
216 217 ;
217 218
218 219 value_null_ = string[_1 = "null"]
6 include/mapnik/json/feature_grammar.hpp
@@ -29,6 +29,7 @@
29 29
30 30 // spirit::qi
31 31 #include <boost/config/warning_disable.hpp>
  32 +#include <boost/cstdint.hpp>
32 33 #include <boost/spirit/include/qi.hpp>
33 34 #include <boost/spirit/include/phoenix.hpp>
34 35 #include <boost/variant/apply_visitor.hpp>
@@ -62,6 +63,7 @@ class attribute_value_visitor
62 63 {
63 64 return mapnik::value(val);
64 65 }
  66 +
65 67 mapnik::transcoder const& tr_;
66 68 };
67 69
@@ -114,7 +116,7 @@ struct feature_grammar :
114 116 qi::uint_parser< unsigned, 16, 4, 4 > hex4 ;
115 117 qi::rule<Iterator,std::string(), space_type> string_;
116 118 qi::rule<Iterator,space_type> key_value;
117   - qi::rule<Iterator,boost::variant<value_null,bool,int,double>(),space_type> number;
  119 + qi::rule<Iterator,boost::variant<value_null,bool,boost::long_long_type,double>(),space_type> number;
118 120 qi::rule<Iterator,space_type> object;
119 121 qi::rule<Iterator,space_type> array;
120 122 qi::rule<Iterator,space_type> pairs;
@@ -126,7 +128,7 @@ struct feature_grammar :
126 128
127 129 qi::rule<Iterator,void(FeatureType &),space_type> properties;
128 130 qi::rule<Iterator,qi::locals<std::string>, void(FeatureType &),space_type> attributes;
129   - qi::rule<Iterator,boost::variant<value_null,bool,int,double,std::string>(), space_type> attribute_value;
  131 + qi::rule<Iterator,boost::variant<value_null,bool,boost::long_long_type,double,std::string>(), space_type> attribute_value;
130 132
131 133 phoenix::function<put_property> put_property_;
132 134 phoenix::function<extract_geometry> extract_geometry_;
2  include/mapnik/params.hpp
@@ -38,7 +38,7 @@
38 38
39 39 namespace mapnik
40 40 {
41   -typedef boost::variant<value_null,int,double,std::string> value_holder;
  41 +typedef boost::variant<value_null,value_integer,value_double,std::string> value_holder;
42 42 typedef std::pair<std::string, value_holder> parameter;
43 43 typedef std::map<std::string, value_holder> param_map;
44 44
3  include/mapnik/util/conversions.hpp
@@ -47,6 +47,9 @@ namespace mapnik { namespace util {
47 47 MAPNIK_DECL bool string2int(const char * value, int & result);
48 48 MAPNIK_DECL bool string2int(std::string const& value, int & result);
49 49
  50 +MAPNIK_DECL bool string2longlong(const char * value, boost::long_long_type & result);
  51 +MAPNIK_DECL bool string2longlong(std::string const& value, boost::long_long_type & result);
  52 +
50 53 MAPNIK_DECL bool string2double(std::string const& value, double & result);
51 54 MAPNIK_DECL bool string2double(const char * value, double & result);
52 55
238 include/mapnik/value.hpp
@@ -106,7 +106,13 @@ struct value_null
106 106 }
107 107 };
108 108
109   -typedef boost::variant<value_null,bool,int,double,UnicodeString> value_base;
  109 +
  110 +typedef boost::long_long_type value_integer;
  111 +typedef double value_double;
  112 +typedef UnicodeString value_unicode_string;
  113 +typedef bool value_bool;
  114 +
  115 +typedef boost::variant<value_null,value_bool,value_integer,value_double,value_unicode_string> value_base;
110 116
111 117 namespace impl {
112 118
@@ -125,18 +131,18 @@ struct equals
125 131 return lhs == rhs;
126 132 }
127 133
128   - bool operator() (int lhs, double rhs) const
  134 + bool operator() (value_integer lhs, value_double rhs) const
129 135 {
130 136 return lhs == rhs;
131 137 }
132 138
133   - bool operator() (double lhs, int rhs) const
  139 + bool operator() (value_double lhs, value_integer rhs) const
134 140 {
135 141 return (lhs == rhs)? true : false ;
136 142 }
137 143
138   - bool operator() (UnicodeString const& lhs,
139   - UnicodeString const& rhs) const
  144 + bool operator() (value_unicode_string const& lhs,
  145 + value_unicode_string const& rhs) const
140 146 {
141 147 return (lhs == rhs) ? true: false;
142 148 }
@@ -163,18 +169,18 @@ struct not_equals
163 169 return lhs != rhs;
164 170 }
165 171
166   - bool operator() (int lhs, double rhs) const
  172 + bool operator() (value_integer lhs, value_double rhs) const
167 173 {
168 174 return lhs != rhs;
169 175 }
170 176
171   - bool operator() (double lhs, int rhs) const
  177 + bool operator() (value_double lhs, value_integer rhs) const
172 178 {
173 179 return lhs != rhs;
174 180 }
175 181
176   - bool operator() (UnicodeString const& lhs,
177   - UnicodeString const& rhs) const
  182 + bool operator() (value_unicode_string const& lhs,
  183 + value_unicode_string const& rhs) const
178 184 {
179 185 return (lhs != rhs)? true : false;
180 186 }
@@ -215,17 +221,17 @@ struct greater_than
215 221 return lhs > rhs;
216 222 }
217 223
218   - bool operator() (int lhs, double rhs) const
  224 + bool operator() (value_integer lhs, value_double rhs) const
219 225 {
220 226 return lhs > rhs;
221 227 }
222 228
223   - bool operator() (double lhs, int rhs) const
  229 + bool operator() (value_double lhs, value_integer rhs) const
224 230 {
225 231 return lhs > rhs;
226 232 }
227 233
228   - bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const
  234 + bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const
229 235 {
230 236 return (lhs > rhs) ? true : false ;
231 237 }
@@ -251,17 +257,17 @@ struct greater_or_equal
251 257 return lhs >= rhs;
252 258 }
253 259
254   - bool operator() (int lhs, double rhs) const
  260 + bool operator() (value_integer lhs, value_double rhs) const
255 261 {
256 262 return lhs >= rhs;
257 263 }
258 264
259   - bool operator() (double lhs, int rhs) const
  265 + bool operator() (value_double lhs, value_integer rhs) const
260 266 {
261 267 return lhs >= rhs;
262 268 }
263 269
264   - bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const
  270 + bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const
265 271 {
266 272 return ( lhs >= rhs ) ? true : false ;
267 273 }
@@ -287,18 +293,18 @@ struct less_than
287 293 return lhs < rhs;
288 294 }
289 295
290   - bool operator() (int lhs, double rhs) const
  296 + bool operator() (value_integer lhs, value_double rhs) const
291 297 {
292 298 return lhs < rhs;
293 299 }
294 300
295   - bool operator() (double lhs, int rhs) const
  301 + bool operator() (value_double lhs, value_integer rhs) const
296 302 {
297 303 return lhs < rhs;
298 304 }
299 305
300   - bool operator()(UnicodeString const& lhs,
301   - UnicodeString const& rhs ) const
  306 + bool operator()(value_unicode_string const& lhs,
  307 + value_unicode_string const& rhs ) const
302 308 {
303 309 return (lhs < rhs) ? true : false ;
304 310 }
@@ -324,18 +330,18 @@ struct less_or_equal
324 330 return lhs <= rhs;
325 331 }
326 332
327   - bool operator() (int lhs, double rhs) const
  333 + bool operator() (value_integer lhs, value_double rhs) const
328 334 {
329 335 return lhs <= rhs;
330 336 }
331 337
332   - bool operator() (double lhs, int rhs) const
  338 + bool operator() (value_double lhs, value_integer rhs) const
333 339 {
334 340 return lhs <= rhs;
335 341 }
336 342
337   - bool operator()(UnicodeString const& lhs,
338   - UnicodeString const& rhs ) const
  343 + bool operator()(value_unicode_string const& lhs,
  344 + value_unicode_string const& rhs ) const
339 345 {
340 346 return (lhs <= rhs) ? true : false ;
341 347 }
@@ -350,64 +356,68 @@ template <typename V>
350 356 struct add : public boost::static_visitor<V>
351 357 {
352 358 typedef V value_type;
353   -
354   - template <typename T>
355   - value_type operator() (T lhs, T rhs) const
356   - {
357   - return lhs + rhs ;
358   - }
359   -
360   - value_type operator() (UnicodeString const& lhs ,
361   - UnicodeString const& rhs ) const
  359 + value_type operator() (value_unicode_string const& lhs ,
  360 + value_unicode_string const& rhs ) const
362 361 {
363 362 return lhs + rhs;
364 363 }
365 364
366   - value_type operator() (double lhs, int rhs) const
  365 + value_type operator() (value_double lhs, value_integer rhs) const
367 366 {
368 367 return lhs + rhs;
369 368 }
370 369
371   - value_type operator() (int lhs, double rhs) const
  370 + value_type operator() (value_integer lhs, value_double rhs) const
372 371 {
373 372 return lhs + rhs;
374 373 }
375 374
376   - value_type operator() (UnicodeString const& lhs, value_null rhs) const
  375 + value_type operator() (value_unicode_string const& lhs, value_null rhs) const
377 376 {
378 377 boost::ignore_unused_variable_warning(rhs);
379 378 return lhs;
380 379 }
381 380
382   - value_type operator() (value_null lhs, UnicodeString const& rhs) const
  381 + value_type operator() (value_null lhs, value_unicode_string const& rhs) const
383 382 {
384 383 boost::ignore_unused_variable_warning(lhs);
385 384 return rhs;
386 385 }
387 386
388 387 template <typename R>
389   - value_type operator() (UnicodeString const& lhs, R const& rhs) const
  388 + value_type operator() (value_unicode_string const& lhs, R const& rhs) const
390 389 {
391 390 std::string val;
392 391 if (util::to_string(val,rhs))
393   - return lhs + UnicodeString(val.c_str());
  392 + return lhs + value_unicode_string(val.c_str());
394 393 return lhs;
395 394 }
396 395
397 396 template <typename L>
398   - value_type operator() (L const& lhs , UnicodeString const& rhs) const
  397 + value_type operator() (L const& lhs , value_unicode_string const& rhs) const
399 398 {
400 399 std::string val;
401 400 if (util::to_string(val,lhs))
402   - return UnicodeString(val.c_str()) + rhs;
  401 + return value_unicode_string(val.c_str()) + rhs;
403 402 return rhs;
404 403 }
405 404
  405 + template <typename T>
  406 + value_type operator() (T lhs, T rhs) const
  407 + {
  408 + return lhs + rhs ;
  409 + }
  410 +
406 411 template <typename T1, typename T2>
407 412 value_type operator() (T1 const& lhs, T2 const&) const
408 413 {
409 414 return lhs;
410 415 }
  416 +
  417 + value_type operator() (value_bool lhs, value_bool rhs) const
  418 + {
  419 + return 0LL;
  420 + }
411 421 };
412 422
413 423 template <typename V>
@@ -421,26 +431,31 @@ struct sub : public boost::static_visitor<V>
421 431 }
422 432
423 433 template <typename T>
424   - value_type operator() (T lhs, T rhs) const
  434 + value_type operator() (T lhs, T rhs) const
425 435 {
426 436 return lhs - rhs ;
427 437 }
428 438
429   - value_type operator() (UnicodeString const& lhs,
430   - UnicodeString const& ) const
  439 + value_type operator() (value_unicode_string const& lhs,
  440 + value_unicode_string const& ) const
431 441 {
432 442 return lhs;
433 443 }
434 444
435   - value_type operator() (double lhs, int rhs) const
  445 + value_type operator() (value_double lhs, value_integer rhs) const
436 446 {
437 447 return lhs - rhs;
438 448 }
439 449
440   - value_type operator() (int lhs, double rhs) const
  450 + value_type operator() (value_integer lhs, value_double rhs) const
441 451 {
442 452 return lhs - rhs;
443 453 }
  454 +
  455 + value_type operator() (value_bool lhs, value_bool rhs) const
  456 + {
  457 + return 0LL;
  458 + }
444 459 };
445 460
446 461 template <typename V>
@@ -458,21 +473,26 @@ struct mult : public boost::static_visitor<V>
458 473 return lhs * rhs;
459 474 }
460 475
461   - value_type operator() (UnicodeString const& lhs,
462   - UnicodeString const& ) const
  476 + value_type operator() (value_unicode_string const& lhs,
  477 + value_unicode_string const& ) const
463 478 {
464 479 return lhs;
465 480 }
466 481
467   - value_type operator() (double lhs, int rhs) const
  482 + value_type operator() (value_double lhs, value_integer rhs) const
468 483 {
469 484 return lhs * rhs;
470 485 }
471 486
472   - value_type operator() (int lhs, double rhs) const
  487 + value_type operator() (value_integer lhs, value_double rhs) const
473 488 {
474 489 return lhs * rhs;
475 490 }
  491 +
  492 + value_type operator() (value_bool lhs, value_bool rhs) const
  493 + {
  494 + return 0LL;
  495 + }
476 496 };
477 497
478 498 template <typename V>
@@ -491,25 +511,25 @@ struct div: public boost::static_visitor<V>
491 511 return lhs / rhs;
492 512 }
493 513
494   - value_type operator() (bool lhs, bool rhs ) const
  514 + value_type operator() (value_bool lhs, value_bool rhs ) const
495 515 {
496 516 boost::ignore_unused_variable_warning(lhs);
497 517 boost::ignore_unused_variable_warning(rhs);
498 518 return false;
499 519 }
500 520
501   - value_type operator() (UnicodeString const& lhs,
502   - UnicodeString const&) const
  521 + value_type operator() (value_unicode_string const& lhs,
  522 + value_unicode_string const&) const
503 523 {
504 524 return lhs;
505 525 }
506 526
507   - value_type operator() (double lhs, int rhs) const
  527 + value_type operator() (value_double lhs, value_integer rhs) const
508 528 {
509 529 return lhs / rhs;
510 530 }
511 531
512   - value_type operator() (int lhs, double rhs) const
  532 + value_type operator() (value_integer lhs, value_double rhs) const
513 533 {
514 534 return lhs / rhs;
515 535 }
@@ -531,31 +551,31 @@ struct mod: public boost::static_visitor<V>
531 551 return lhs % rhs;
532 552 }
533 553
534   - value_type operator() (UnicodeString const& lhs,
535   - UnicodeString const&) const
  554 + value_type operator() (value_unicode_string const& lhs,
  555 + value_unicode_string const&) const
536 556 {
537 557 return lhs;
538 558 }
539 559
540   - value_type operator() (bool lhs,
541   - bool rhs) const
  560 + value_type operator() (value_bool lhs,
  561 + value_bool rhs) const
542 562 {
543 563 boost::ignore_unused_variable_warning(lhs);
544 564 boost::ignore_unused_variable_warning(rhs);
545 565 return false;
546 566 }
547 567
548   - value_type operator() (double lhs, int rhs) const
  568 + value_type operator() (value_double lhs, value_integer rhs) const
549 569 {
550 570 return std::fmod(lhs, rhs);
551 571 }
552 572
553   - value_type operator() (int lhs, double rhs) const
  573 + value_type operator() (value_integer lhs, value_double rhs) const
554 574 {
555 575 return std::fmod(lhs, rhs);
556 576 }
557 577
558   - value_type operator() (double lhs, double rhs) const
  578 + value_type operator() (value_double lhs, value_double rhs) const
559 579 {
560 580 return std::fmod(lhs, rhs);
561 581 }
@@ -577,39 +597,39 @@ struct negate : public boost::static_visitor<V>
577 597 return val;
578 598 }
579 599
580   - value_type operator() (bool val) const
  600 + value_type operator() (value_bool val) const
581 601 {
582   - return val ? -1 : 0;
  602 + return val ? -1LL : 0LL;
583 603 }
584 604
585   - value_type operator() (UnicodeString const& ustr) const
  605 + value_type operator() (value_unicode_string const& ustr) const
586 606 {
587   - UnicodeString inplace(ustr);
  607 + value_unicode_string inplace(ustr);
588 608 return inplace.reverse();
589 609 }
590 610 };
591 611
592   -struct to_bool : public boost::static_visitor<bool>
  612 +struct to_bool : public boost::static_visitor<value_bool>
593 613 {
594   - bool operator() (bool val) const
  614 + value_bool operator() (value_bool val) const
595 615 {
596 616 return val;
597 617 }
598 618
599   - bool operator() (UnicodeString const& ustr) const
  619 + value_bool operator() (value_unicode_string const& ustr) const
600 620 {
601 621 boost::ignore_unused_variable_warning(ustr);
602 622 return true;
603 623 }
604 624
605   - bool operator() (value_null const& val) const
  625 + value_bool operator() (value_null const& val) const
606 626 {
607 627 boost::ignore_unused_variable_warning(val);
608 628 return false;
609 629 }
610 630
611 631 template <typename T>
612   - bool operator() (T val) const
  632 + value_bool operator() (T val) const
613 633 {
614 634 return val > 0 ? true : false;
615 635 }
@@ -626,14 +646,14 @@ struct to_string : public boost::static_visitor<std::string>
626 646 }
627 647
628 648 // specializations
629   - std::string operator() (UnicodeString const& val) const
  649 + std::string operator() (value_unicode_string const& val) const
630 650 {
631 651 std::string utf8;
632 652 to_utf8(val,utf8);
633 653 return utf8;
634 654 }
635 655
636   - std::string operator() (double val) const
  656 + std::string operator() (value_double val) const
637 657 {
638 658 std::string str;
639 659 util::to_string(str, val); // TODO set precision(16)
@@ -647,54 +667,54 @@ struct to_string : public boost::static_visitor<std::string>
647 667 }
648 668 };
649 669
650   -struct to_unicode : public boost::static_visitor<UnicodeString>
  670 +struct to_unicode : public boost::static_visitor<value_unicode_string>
651 671 {
652 672
653 673 template <typename T>
654   - UnicodeString operator() (T val) const
  674 + value_unicode_string operator() (T val) const
655 675 {
656 676 std::string str;
657 677 util::to_string(str,val);
658   - return UnicodeString(str.c_str());
  678 + return value_unicode_string(str.c_str());
659 679 }
660 680
661 681 // specializations
662   - UnicodeString const& operator() (UnicodeString const& val) const
  682 + value_unicode_string const& operator() (value_unicode_string const& val) const
663 683 {
664 684 return val;
665 685 }
666 686
667   - UnicodeString operator() (double val) const
  687 + value_unicode_string operator() (value_double val) const
668 688 {
669 689 std::string str;
670 690 util::to_string(str,val);
671   - return UnicodeString(str.c_str());
  691 + return value_unicode_string(str.c_str());
672 692 }
673 693
674   - UnicodeString operator() (value_null const& val) const
  694 + value_unicode_string operator() (value_null const& val) const
675 695 {
676 696 boost::ignore_unused_variable_warning(val);
677   - return UnicodeString("");
  697 + return value_unicode_string("");
678 698 }
679 699 };
680 700
681 701 struct to_expression_string : public boost::static_visitor<std::string>
682 702 {
683   - std::string operator() (UnicodeString const& val) const
  703 + std::string operator() (value_unicode_string const& val) const
684 704 {
685 705 std::string utf8;
686 706 to_utf8(val,utf8);
687 707 return "'" + utf8 + "'";
688 708 }
689 709
690   - std::string operator() (double val) const
  710 + std::string operator() (value_double val) const
691 711 {
692 712 std::string output;
693 713 util::to_string(output,val); // TODO precision(16)
694 714 return output;
695 715 }
696 716
697   - std::string operator() (bool val) const
  717 + std::string operator() (value_bool val) const
698 718 {
699 719 return val ? "true":"false";
700 720 }
@@ -714,69 +734,71 @@ struct to_expression_string : public boost::static_visitor<std::string>
714 734 }
715 735 };
716 736
717   -struct to_double : public boost::static_visitor<double>
  737 +struct to_double : public boost::static_visitor<value_double>
718 738 {
719   - double operator() (int val) const
  739 + value_double operator() (value_integer val) const
720 740 {
721   - return static_cast<double>(val);
  741 + return static_cast<value_double>(val);
722 742 }
723 743
724   - double operator() (double val) const
  744 + value_double operator() (value_double val) const
725 745 {
726 746 return val;
727 747 }
728 748
729   - double operator() (std::string const& val) const
  749 + value_double operator() (std::string const& val) const
730 750 {
731   - double result;
  751 + value_double result;
732 752 if (util::string2double(val,result))
733 753 return result;
734 754 return 0;
735 755 }
736   - double operator() (UnicodeString const& val) const
  756 +
  757 + value_double operator() (value_unicode_string const& val) const
737 758 {
738 759 std::string utf8;
739 760 to_utf8(val,utf8);
740 761 return operator()(utf8);
741 762 }
742 763
743   - double operator() (value_null const& val) const
  764 + value_double operator() (value_null const& val) const
744 765 {
745 766 boost::ignore_unused_variable_warning(val);
746 767 return 0.0;
747 768 }
748 769 };
749 770
750   -struct to_int : public boost::static_visitor<double>
  771 +struct to_int : public boost::static_visitor<value_integer>
751 772 {
752   - int operator() (int val) const
  773 + value_integer operator() (value_integer val) const
753 774 {
754 775 return val;
755 776 }
756 777
757   - int operator() (double val) const
  778 + value_integer operator() (value_double val) const
758 779 {
759 780 return rint(val);
760 781 }
761 782
762   - int operator() (std::string const& val) const
  783 + value_integer operator() (std::string const& val) const
763 784 {
764   - int result;
765   - if (util::string2int(val,result))
  785 + value_integer result;
  786 + if (util::string2longlong(val,result))
766 787 return result;
767   - return 0;
  788 + return 0LL;
768 789 }
769   - int operator() (UnicodeString const& val) const
  790 +
  791 + value_integer operator() (value_unicode_string const& val) const
770 792 {
771 793 std::string utf8;
772 794 to_utf8(val,utf8);
773 795 return operator()(utf8);
774 796 }
775 797
776   - int operator() (value_null const& val) const
  798 + value_integer operator() (value_null const& val) const
777 799 {
778 800 boost::ignore_unused_variable_warning(val);
779   - return 0;
  801 + return 0LL;
780 802 }
781 803 };
782 804
@@ -842,7 +864,7 @@ class value
842 864
843 865 bool is_null() const;
844 866
845   - bool to_bool() const
  867 + value_bool to_bool() const
846 868 {
847 869 return boost::apply_visitor(impl::to_bool(),base_);
848 870 }
@@ -857,19 +879,21 @@ class value
857 879 return boost::apply_visitor(impl::to_string(),base_);
858 880 }
859 881
860   - UnicodeString to_unicode() const
  882 + value_unicode_string to_unicode() const
861 883 {
862 884 return boost::apply_visitor(impl::to_unicode(),base_);
863 885 }
864 886
865   - double to_double() const
  887 + value_double to_double() const
866 888 {
867   - return boost::apply_visitor(impl::to_double(),base_);
  889 + return 0.0;
  890 + //return boost::apply_visitor(impl::to_double(),base_);
868 891 }
869 892
870   - double to_int() const
  893 + value_integer to_int() const
871 894 {
872   - return boost::apply_visitor(impl::to_int(),base_);
  895 + return 0LL;
  896 + //return boost::apply_visitor(impl::to_int(),base_);
873 897 }
874 898
875 899 };
6 plugins/input/csv/csv_datasource.cpp
@@ -467,7 +467,7 @@ void csv_datasource::parse_csv(T & stream,
467 467 {
468 468 csv_utils::fix_json_quoting(csv_line);
469 469 }
470   -
  470 +
471 471 Tokenizer tok(csv_line, grammer);
472 472 Tokenizer::iterator beg = tok.begin();
473 473
@@ -598,7 +598,7 @@ void csv_datasource::parse_csv(T & stream,
598 598 MAPNIK_LOG_ERROR(csv) << s.str();
599 599 }
600 600 }
601   - }
  601 + }
602 602 }
603 603 else
604 604 {
@@ -709,7 +709,7 @@ void csv_datasource::parse_csv(T & stream,
709 709 }
710 710 else
711 711 {
712   - feature->put(fld_name,static_cast<int>(float_val));
  712 + feature->put(fld_name,static_cast<mapnik::value_integer>(float_val));
713 713 if (feature_count == 1)
714 714 {
715 715 desc_.add_descriptor(
4 plugins/input/gdal/gdal_featureset.cpp
@@ -445,10 +445,10 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
445 445 {
446 446 MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Loading colour table...";
447 447
448   - unsigned nodata_value = static_cast<unsigned>(nodata);
  448 + unsigned nodata_value = static_cast<unsigned>(nodata); // FIXME: is it realy unsigned ?
449 449 if (hasNoData)
450 450 {
451   - feature->put("NODATA",static_cast<int>(nodata_value));
  451 + feature->put("NODATA",static_cast<mapnik::value_integer>(nodata_value));
452 452 }
453 453 for (unsigned y = 0; y < image.height(); ++y)
454 454 {
28 plugins/input/geojson/geojson_datasource.cpp
@@ -70,7 +70,7 @@ geojson_datasource::geojson_datasource(parameters const& params, bool bind)
70 70
71 71 struct attr_value_converter : public boost::static_visitor<mapnik::eAttributeType>
72 72 {
73   - mapnik::eAttributeType operator() (int /*val*/) const
  73 + mapnik::eAttributeType operator() (mapnik::value_integer /*val*/) const
74 74 {
75 75 return mapnik::Integer;
76 76 }
@@ -110,29 +110,29 @@ void geojson_datasource::bind() const
110 110 {
111 111 if (is_bound_) return;
112 112
113   - typedef std::istreambuf_iterator<char> base_iterator_type;
114   -
  113 + typedef std::istreambuf_iterator<char> base_iterator_type;
  114 +
115 115 std::ifstream is(file_.c_str());
116   - boost::spirit::multi_pass<base_iterator_type> begin =
  116 + boost::spirit::multi_pass<base_iterator_type> begin =
117 117 boost::spirit::make_default_multi_pass(base_iterator_type(is));
118 118
119   - boost::spirit::multi_pass<base_iterator_type> end =
  119 + boost::spirit::multi_pass<base_iterator_type> end =
120 120 boost::spirit::make_default_multi_pass(base_iterator_type());
121   -
  121 +
122 122 mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
123 123 mapnik::json::feature_collection_parser<boost::spirit::multi_pass<base_iterator_type> > p(ctx,*tr_);
124 124 bool result = p.parse(begin,end, features_);
125   - if (!result)
  125 + if (!result)
126 126 {
127 127 throw mapnik::datasource_exception("geojson_datasource: Failed parse GeoJSON file '" + file_ + "'");
128 128 }
129   -
  129 +
130 130 bool first = true;
131 131 std::size_t count=0;
132 132 BOOST_FOREACH (mapnik::feature_ptr f, features_)
133 133 {
134 134 mapnik::box2d<double> const& box = f->envelope();
135   - if (first)
  135 + if (first)
136 136 {
137 137 extent_ = box;
138 138 first = false;
@@ -147,7 +147,7 @@ void geojson_datasource::bind() const
147 147 else
148 148 {
149 149 extent_.expand_to_include(box);
150   - }
  150 + }
151 151 tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++);
152 152 }
153 153 is_bound_ = true;
@@ -160,7 +160,7 @@ const char * geojson_datasource::name()
160 160 return "geojson";
161 161 }
162 162
163   -boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry_type() const
  163 +boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry_type() const
164 164 {
165 165 boost::optional<mapnik::datasource::geometry_t> result;
166 166 int multi_type = 0;
@@ -182,7 +182,7 @@ boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry
182 182 return result;
183 183 }
184 184
185   -mapnik::datasource::datasource_t geojson_datasource::type() const
  185 +mapnik::datasource::datasource_t geojson_datasource::type() const
186 186 {
187 187 return type_;
188 188 }
@@ -203,7 +203,7 @@ mapnik::layer_descriptor geojson_datasource::get_descriptor() const
203 203 mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) const
204 204 {
205 205 if (!is_bound_) bind();
206   -
  206 +
207 207 // if the query box intersects our world extent then query for features
208 208 mapnik::box2d<double> const& b = q.get_bbox();
209 209 if (extent_.intersects(b))
@@ -211,7 +211,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
211 211 box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy()));
212 212 index_array_ = tree_.find(box);
213 213 return boost::make_shared<geojson_featureset>(features_, index_array_.begin(), index_array_.end());
214   - }
  214 + }
215 215 // otherwise return an empty featureset pointer
216 216 return mapnik::featureset_ptr();
217 217 }
2  plugins/input/ogr/ogr_featureset.cpp
@@ -117,7 +117,7 @@ feature_ptr ogr_featureset::next()
117 117 {
118 118 case OFTInteger:
119 119 {
120   - feature->put( fld_name, poFeature->GetFieldAsInteger(i));
  120 + feature->put<mapnik::value_integer>( fld_name, poFeature->GetFieldAsInteger(i));
121 121 break;
122 122 }
123 123
2  plugins/input/ogr/ogr_index_featureset.cpp
@@ -126,7 +126,7 @@ feature_ptr ogr_index_featureset<filterT>::next()
126 126 {
127 127 case OFTInteger:
128 128 {
129   - feature->put(fld_name,poFeature->GetFieldAsInteger (i));
  129 + feature->put<mapnik::value_integer>(fld_name,poFeature->GetFieldAsInteger (i));
130 130 break;
131 131 }
132 132
15 plugins/input/postgis/postgis_featureset.cpp
@@ -76,7 +76,7 @@ feature_ptr postgis_featureset::next()
76 76 std::string name = rs_->getFieldName(pos);
77 77
78 78 // validation happens of this type at bind()
79   - int val;
  79 + mapnik::value_integer val;
80 80 if (oid == 20)
81 81 {
82 82 val = int8net(buf);
@@ -94,7 +94,7 @@ feature_ptr postgis_featureset::next()
94 94 // TODO - extend feature class to know
95 95 // that its id is also an attribute to avoid
96 96 // this duplication
97   - feature->put(name,val);
  97 + feature->put<mapnik::value_integer>(name,val);
98 98 ++pos;
99 99 }
100 100 else
@@ -135,24 +135,19 @@ feature_ptr postgis_featureset::next()
135 135
136 136 case 23: //int4
137 137 {
138   - int val = int4net(buf);
139   - feature->put(name, val);
  138 + feature->put<mapnik::value_integer>(name, int4net(buf));
140 139 break;
141 140 }
142 141
143 142 case 21: //int2
144 143 {
145   - int val = int2net(buf);
146   - feature->put(name, val);
  144 + feature->put<mapnik::value_integer>(name, int2net(buf));
147 145 break;
148 146 }
149 147
150 148 case 20: //int8/BigInt
151 149 {
152   - // TODO - need to support boost::uint64_t in mapnik::value
153   - // https://github.com/mapnik/mapnik/issues/895
154   - int val = int8net(buf);
155   - feature->put(name, val);
  150 + feature->put<mapnik::value_integer>(name, int8net(buf));
156 151 break;
157 152 }
158 153
4 plugins/input/shape/dbfile.cpp
@@ -160,7 +160,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f)
160 160 {
161 161 if (record_[fields_[col].offset_] == '*')
162 162 {
163   - f.put(name,0);
  163 + f.put(name,0LL);
164 164 break;
165 165 }
166 166 if ( fields_[col].dec_>0 )
@@ -173,7 +173,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f)
173 173 }
174 174 else
175 175 {
176   - int val = 0;
  176 + mapnik::value_integer val = 0LL;
177 177 const char *itr = record_+fields_[col].offset_;
178 178 const char *end = itr + fields_[col].length_;
179 179 if (qi::phrase_parse(itr,end,int_,ascii::space,val))
2  plugins/input/sqlite/sqlite_featureset.cpp
@@ -104,7 +104,7 @@ feature_ptr sqlite_featureset::next()
104 104 {
105 105 case SQLITE_INTEGER:
106 106 {
107   - feature->put(fld_name_str, rs_->column_integer(i));
  107 + feature->put<mapnik::value_integer>(fld_name_str, rs_->column_integer(i));
108 108 break;
109 109 }
110 110
22 src/conversions.cpp
@@ -39,6 +39,7 @@ namespace mapnik { namespace util {
39 39 using namespace boost::spirit;
40 40
41 41 BOOST_SPIRIT_AUTO(qi, INTEGER, qi::int_)
  42 +BOOST_SPIRIT_AUTO(qi, LONGLONG, qi::long_long)
42 43 BOOST_SPIRIT_AUTO(qi, FLOAT, qi::float_)
43 44 BOOST_SPIRIT_AUTO(qi, DOUBLE, qi::double_)
44 45
@@ -63,6 +64,27 @@ bool string2int(std::string const& value, int & result)
63 64 return r && (str_beg == str_end);
64 65 }
65 66
  67 +bool string2longlong(const char * value, boost::long_long_type & result)
  68 +{
  69 + size_t length = strlen(value);
  70 + if (length < 1 || value == NULL)
  71 + return false;
  72 + const char *iter = value;
  73 + const char *end = value + length;
  74 + bool r = qi::phrase_parse(iter,end,LONGLONG,ascii::space,result);
  75 + return r && (iter == end);
  76 +}
  77 +
  78 +bool string2longlong(std::string const& value, boost::long_long_type & result)
  79 +{
  80 + if (value.empty())
  81 + return false;
  82 + std::string::const_iterator str_beg = value.begin();
  83 + std::string::const_iterator str_end = value.end();
  84 + bool r = qi::phrase_parse(str_beg,str_end,LONGLONG,ascii::space,result);
  85 + return r && (str_beg == str_end);
  86 +}
  87 +
66 88 bool string2double(std::string const& value, double & result)
67 89 {
68 90 if (value.empty())
17 src/expression_grammar.cpp
@@ -63,7 +63,8 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
63 63 using qi::lexeme;
64 64 using qi::_val;
65 65 using qi::lit;
66   - using qi::int_;
  66 + //using qi::int_;
  67 + using qi::long_long;
67 68 using qi::double_;
68 69 using qi::hex;
69 70 using qi::omit;
@@ -138,13 +139,13 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
138 139 ;
139 140
140 141 primary_expr = strict_double [_val = _1]
141   - | int_ [_val = _1]
142   - | no_case[lit("true")] [_val = true]
143   - | no_case[lit("false")] [_val = false]
144   - | no_case[lit("null")] [_val = value_null() ]
145   - | no_case[geom_type][_val = _1 ]
  142 + | long_long [_val = _1]
  143 + //| no_case[lit("true")] [_val = true]
  144 + //| no_case[lit("false")] [_val = false]
  145 + //| no_case[lit("null")] [_val = value_null() ]
  146 + //| no_case[geom_type][_val = _1 ]
146 147 | ustring [_val = unicode_(_1) ]
147   - | lit("[mapnik::geometry_type]")[_val = construct<mapnik::geometry_type_attribute>()]
  148 + //| lit("[mapnik::geometry_type]")[_val = construct<mapnik::geometry_type_attribute>()]
148 149 | attr [_val = construct<mapnik::attribute>( _1 ) ]
149 150 | '(' >> expr [_val = _1 ] >> ')'
150 151 ;
@@ -171,4 +172,4 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
171 172
172 173 template struct mapnik::expression_grammar<std::string::const_iterator>;
173 174
174   -}
  175 +}
4 src/json/feature_grammar.cpp
@@ -38,7 +38,7 @@ feature_grammar<Iterator,FeatureType>::feature_grammar(mapnik::transcoder const&
38 38 put_property_(put_property(tr))
39 39 {
40 40 using qi::lit;
41   - using qi::int_;
  41 + using qi::long_long;
42 42 using qi::double_;
43 43 #if BOOST_VERSION > 104200
44 44 using qi::no_skip;
@@ -90,7 +90,7 @@ feature_grammar<Iterator,FeatureType>::feature_grammar(mapnik::transcoder const&
90 90 #else
91 91 number = strict_double
92 92 #endif
93   - | int_
  93 + //| long_long
94 94 | lit("true") [_val = true]
95 95 | lit ("false") [_val = false]
96 96 | lit("null")[_val = construct<value_null>()]
4 src/load_map.cpp
@@ -369,13 +369,13 @@ void map_parser::parse_map_include(Map & map, xml_node const& include)
369 369 if (*type == "int")
370 370 {
371 371 is_string = false;
372   - int value = paramIter->get_value<int>();
  372 + mapnik::value_integer value = paramIter->get_value<mapnik::value_integer>();
373 373 params[name] = value;
374 374 }