diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 5ffb7c69b..732349694 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -64,7 +64,7 @@ boost::shared_ptr create_datasource(const dict& d) } extract ex0(obj); - extract ex1(obj); + extract ex1(obj); extract ex2(obj); if (ex0.check()) diff --git a/bindings/python/mapnik_datasource_cache.cpp b/bindings/python/mapnik_datasource_cache.cpp index 50074f3af..a11525f79 100644 --- a/bindings/python/mapnik_datasource_cache.cpp +++ b/bindings/python/mapnik_datasource_cache.cpp @@ -44,7 +44,7 @@ boost::shared_ptr create_datasource(const dict& d) } extract ex0(obj); - extract ex1(obj); + extract ex1(obj); extract ex2(obj); if (ex0.check()) diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index c4d7f75b6..befe84069 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -162,7 +162,7 @@ void export_feature() using mapnik::Feature; // Python to mapnik::value converters - implicitly_convertible(); + implicitly_convertible(); implicitly_convertible(); implicitly_convertible(); implicitly_convertible(); diff --git a/bindings/python/mapnik_parameters.cpp b/bindings/python/mapnik_parameters.cpp index e90487193..08280c4da 100644 --- a/bindings/python/mapnik_parameters.cpp +++ b/bindings/python/mapnik_parameters.cpp @@ -78,7 +78,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite std::string key = extract(keys[i]); object obj = d[key]; extract ex0(obj); - extract ex1(obj); + extract ex1(obj); extract ex2(obj); extract ex3(obj); @@ -185,7 +185,7 @@ boost::shared_ptr create_parameter_from_string(std::string co return boost::make_shared(key,mapnik::value_holder(value)); } -boost::shared_ptr create_parameter_from_int(std::string const& key, int value) +boost::shared_ptr create_parameter_from_int(std::string const& key, mapnik::value_integer value) { return boost::make_shared(key,mapnik::value_holder(value)); } diff --git a/bindings/python/mapnik_value_converter.hpp b/bindings/python/mapnik_value_converter.hpp index 34b88e9de..e1a34bb0f 100644 --- a/bindings/python/mapnik_value_converter.hpp +++ b/bindings/python/mapnik_value_converter.hpp @@ -30,7 +30,7 @@ namespace boost { namespace python { struct value_converter : public boost::static_visitor { - PyObject * operator() (int val) const + PyObject * operator() (mapnik::value_integer val) const { #if PY_VERSION_HEX >= 0x03000000 return ::PyLong_FromLong(val); diff --git a/include/mapnik/attribute.hpp b/include/mapnik/attribute.hpp index 9ff0ab063..2ea821033 100644 --- a/include/mapnik/attribute.hpp +++ b/include/mapnik/attribute.hpp @@ -59,11 +59,11 @@ struct geometry_type_attribute { if (type != 0 && itr->type() != type) { - return 4; // Collection + return 4LL; // Collection } type = itr->type(); } - return type; + return static_cast(type); } }; diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index 9b010fffa..432fa9a9c 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -187,6 +187,7 @@ struct feature_generator_grammar: using boost::spirit::karma::uint_; using boost::spirit::karma::bool_; using boost::spirit::karma::int_; + using boost::spirit::karma::long_long; using boost::spirit::karma::double_; using boost::spirit::karma::_val; using boost::spirit::karma::_1; @@ -212,7 +213,7 @@ struct feature_generator_grammar: << value(phoenix::at_c<1>(_val)) ; - value = (value_null_| bool_ | int_| double_ | ustring)[_1 = value_base_(_r1)] + value = (value_null_| bool_ | long_long | double_ | ustring)[_1 = value_base_(_r1)] ; value_null_ = string[_1 = "null"] diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 13c11e836..9b41d6943 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -29,6 +29,7 @@ // spirit::qi #include +#include #include #include #include @@ -62,6 +63,7 @@ public: { return mapnik::value(val); } + mapnik::transcoder const& tr_; }; @@ -114,7 +116,7 @@ struct feature_grammar : qi::uint_parser< unsigned, 16, 4, 4 > hex4 ; qi::rule string_; qi::rule key_value; - qi::rule(),space_type> number; + qi::rule(),space_type> number; qi::rule object; qi::rule array; qi::rule pairs; @@ -126,7 +128,7 @@ struct feature_grammar : qi::rule properties; qi::rule, void(FeatureType &),space_type> attributes; - qi::rule(), space_type> attribute_value; + qi::rule(), space_type> attribute_value; phoenix::function put_property_; phoenix::function extract_geometry_; diff --git a/include/mapnik/params.hpp b/include/mapnik/params.hpp index 6f76b365d..3a3a37ce0 100644 --- a/include/mapnik/params.hpp +++ b/include/mapnik/params.hpp @@ -38,7 +38,7 @@ namespace mapnik { -typedef boost::variant value_holder; +typedef boost::variant value_holder; typedef std::pair parameter; typedef std::map param_map; diff --git a/include/mapnik/util/conversions.hpp b/include/mapnik/util/conversions.hpp index 3e4193abc..47abdabcf 100644 --- a/include/mapnik/util/conversions.hpp +++ b/include/mapnik/util/conversions.hpp @@ -47,6 +47,9 @@ namespace mapnik { namespace util { MAPNIK_DECL bool string2int(const char * value, int & result); MAPNIK_DECL bool string2int(std::string const& value, int & result); +MAPNIK_DECL bool string2longlong(const char * value, boost::long_long_type & result); +MAPNIK_DECL bool string2longlong(std::string const& value, boost::long_long_type & result); + MAPNIK_DECL bool string2double(std::string const& value, double & result); MAPNIK_DECL bool string2double(const char * value, double & result); diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index cfe807d7a..2762a3ece 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -106,7 +106,13 @@ struct value_null } }; -typedef boost::variant value_base; + +typedef boost::long_long_type value_integer; +typedef double value_double; +typedef UnicodeString value_unicode_string; +typedef bool value_bool; + +typedef boost::variant value_base; namespace impl { @@ -125,18 +131,18 @@ struct equals return lhs == rhs; } - bool operator() (int lhs, double rhs) const + bool operator() (value_integer lhs, value_double rhs) const { return lhs == rhs; } - bool operator() (double lhs, int rhs) const + bool operator() (value_double lhs, value_integer rhs) const { return (lhs == rhs)? true : false ; } - bool operator() (UnicodeString const& lhs, - UnicodeString const& rhs) const + bool operator() (value_unicode_string const& lhs, + value_unicode_string const& rhs) const { return (lhs == rhs) ? true: false; } @@ -163,18 +169,18 @@ struct not_equals return lhs != rhs; } - bool operator() (int lhs, double rhs) const + bool operator() (value_integer lhs, value_double rhs) const { return lhs != rhs; } - bool operator() (double lhs, int rhs) const + bool operator() (value_double lhs, value_integer rhs) const { return lhs != rhs; } - bool operator() (UnicodeString const& lhs, - UnicodeString const& rhs) const + bool operator() (value_unicode_string const& lhs, + value_unicode_string const& rhs) const { return (lhs != rhs)? true : false; } @@ -215,17 +221,17 @@ struct greater_than return lhs > rhs; } - bool operator() (int lhs, double rhs) const + bool operator() (value_integer lhs, value_double rhs) const { return lhs > rhs; } - bool operator() (double lhs, int rhs) const + bool operator() (value_double lhs, value_integer rhs) const { return lhs > rhs; } - bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const + bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const { return (lhs > rhs) ? true : false ; } @@ -251,17 +257,17 @@ struct greater_or_equal return lhs >= rhs; } - bool operator() (int lhs, double rhs) const + bool operator() (value_integer lhs, value_double rhs) const { return lhs >= rhs; } - bool operator() (double lhs, int rhs) const + bool operator() (value_double lhs, value_integer rhs) const { return lhs >= rhs; } - bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const + bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const { return ( lhs >= rhs ) ? true : false ; } @@ -287,18 +293,18 @@ struct less_than return lhs < rhs; } - bool operator() (int lhs, double rhs) const + bool operator() (value_integer lhs, value_double rhs) const { return lhs < rhs; } - bool operator() (double lhs, int rhs) const + bool operator() (value_double lhs, value_integer rhs) const { return lhs < rhs; } - bool operator()(UnicodeString const& lhs, - UnicodeString const& rhs ) const + bool operator()(value_unicode_string const& lhs, + value_unicode_string const& rhs ) const { return (lhs < rhs) ? true : false ; } @@ -324,18 +330,18 @@ struct less_or_equal return lhs <= rhs; } - bool operator() (int lhs, double rhs) const + bool operator() (value_integer lhs, value_double rhs) const { return lhs <= rhs; } - bool operator() (double lhs, int rhs) const + bool operator() (value_double lhs, value_integer rhs) const { return lhs <= rhs; } - bool operator()(UnicodeString const& lhs, - UnicodeString const& rhs ) const + bool operator()(value_unicode_string const& lhs, + value_unicode_string const& rhs ) const { return (lhs <= rhs) ? true : false ; } @@ -350,6 +356,51 @@ template struct add : public boost::static_visitor { typedef V value_type; + value_type operator() (value_unicode_string const& lhs , + value_unicode_string const& rhs ) const + { + return lhs + rhs; + } + + value_type operator() (value_double lhs, value_integer rhs) const + { + return lhs + rhs; + } + + value_type operator() (value_integer lhs, value_double rhs) const + { + return lhs + rhs; + } + + value_type operator() (value_unicode_string const& lhs, value_null rhs) const + { + boost::ignore_unused_variable_warning(rhs); + return lhs; + } + + value_type operator() (value_null lhs, value_unicode_string const& rhs) const + { + boost::ignore_unused_variable_warning(lhs); + return rhs; + } + + template + value_type operator() (value_unicode_string const& lhs, R const& rhs) const + { + std::string val; + if (util::to_string(val,rhs)) + return lhs + value_unicode_string(val.c_str()); + return lhs; + } + + template + value_type operator() (L const& lhs , value_unicode_string const& rhs) const + { + std::string val; + if (util::to_string(val,lhs)) + return value_unicode_string(val.c_str()) + rhs; + return rhs; + } template value_type operator() (T lhs, T rhs) const @@ -357,57 +408,16 @@ struct add : public boost::static_visitor return lhs + rhs ; } - value_type operator() (UnicodeString const& lhs , - UnicodeString const& rhs ) const - { - return lhs + rhs; - } - - value_type operator() (double lhs, int rhs) const - { - return lhs + rhs; - } - - value_type operator() (int lhs, double rhs) const - { - return lhs + rhs; - } - - value_type operator() (UnicodeString const& lhs, value_null rhs) const - { - boost::ignore_unused_variable_warning(rhs); - return lhs; - } - - value_type operator() (value_null lhs, UnicodeString const& rhs) const - { - boost::ignore_unused_variable_warning(lhs); - return rhs; - } - - template - value_type operator() (UnicodeString const& lhs, R const& rhs) const - { - std::string val; - if (util::to_string(val,rhs)) - return lhs + UnicodeString(val.c_str()); - return lhs; - } - - template - value_type operator() (L const& lhs , UnicodeString const& rhs) const - { - std::string val; - if (util::to_string(val,lhs)) - return UnicodeString(val.c_str()) + rhs; - return rhs; - } - template value_type operator() (T1 const& lhs, T2 const&) const { return lhs; } + + value_type operator() (value_bool lhs, value_bool rhs) const + { + return 0LL; + } }; template @@ -421,26 +431,31 @@ struct sub : public boost::static_visitor } template - value_type operator() (T lhs, T rhs) const + value_type operator() (T lhs, T rhs) const { return lhs - rhs ; } - value_type operator() (UnicodeString const& lhs, - UnicodeString const& ) const + value_type operator() (value_unicode_string const& lhs, + value_unicode_string const& ) const { return lhs; } - value_type operator() (double lhs, int rhs) const + value_type operator() (value_double lhs, value_integer rhs) const { return lhs - rhs; } - value_type operator() (int lhs, double rhs) const + value_type operator() (value_integer lhs, value_double rhs) const { return lhs - rhs; } + + value_type operator() (value_bool lhs, value_bool rhs) const + { + return 0LL; + } }; template @@ -458,21 +473,26 @@ struct mult : public boost::static_visitor return lhs * rhs; } - value_type operator() (UnicodeString const& lhs, - UnicodeString const& ) const + value_type operator() (value_unicode_string const& lhs, + value_unicode_string const& ) const { return lhs; } - value_type operator() (double lhs, int rhs) const + value_type operator() (value_double lhs, value_integer rhs) const { return lhs * rhs; } - value_type operator() (int lhs, double rhs) const + value_type operator() (value_integer lhs, value_double rhs) const { return lhs * rhs; } + + value_type operator() (value_bool lhs, value_bool rhs) const + { + return 0LL; + } }; template @@ -491,25 +511,25 @@ struct div: public boost::static_visitor return lhs / rhs; } - value_type operator() (bool lhs, bool rhs ) const + value_type operator() (value_bool lhs, value_bool rhs ) const { boost::ignore_unused_variable_warning(lhs); boost::ignore_unused_variable_warning(rhs); return false; } - value_type operator() (UnicodeString const& lhs, - UnicodeString const&) const + value_type operator() (value_unicode_string const& lhs, + value_unicode_string const&) const { return lhs; } - value_type operator() (double lhs, int rhs) const + value_type operator() (value_double lhs, value_integer rhs) const { return lhs / rhs; } - value_type operator() (int lhs, double rhs) const + value_type operator() (value_integer lhs, value_double rhs) const { return lhs / rhs; } @@ -531,31 +551,31 @@ struct mod: public boost::static_visitor return lhs % rhs; } - value_type operator() (UnicodeString const& lhs, - UnicodeString const&) const + value_type operator() (value_unicode_string const& lhs, + value_unicode_string const&) const { return lhs; } - value_type operator() (bool lhs, - bool rhs) const + value_type operator() (value_bool lhs, + value_bool rhs) const { boost::ignore_unused_variable_warning(lhs); boost::ignore_unused_variable_warning(rhs); return false; } - value_type operator() (double lhs, int rhs) const + value_type operator() (value_double lhs, value_integer rhs) const { return std::fmod(lhs, rhs); } - value_type operator() (int lhs, double rhs) const + value_type operator() (value_integer lhs, value_double rhs) const { return std::fmod(lhs, rhs); } - value_type operator() (double lhs, double rhs) const + value_type operator() (value_double lhs, value_double rhs) const { return std::fmod(lhs, rhs); } @@ -577,39 +597,39 @@ struct negate : public boost::static_visitor return val; } - value_type operator() (bool val) const + value_type operator() (value_bool val) const { - return val ? -1 : 0; + return val ? -1LL : 0LL; } - value_type operator() (UnicodeString const& ustr) const + value_type operator() (value_unicode_string const& ustr) const { - UnicodeString inplace(ustr); + value_unicode_string inplace(ustr); return inplace.reverse(); } }; -struct to_bool : public boost::static_visitor +struct to_bool : public boost::static_visitor { - bool operator() (bool val) const + value_bool operator() (value_bool val) const { return val; } - bool operator() (UnicodeString const& ustr) const + value_bool operator() (value_unicode_string const& ustr) const { boost::ignore_unused_variable_warning(ustr); return true; } - bool operator() (value_null const& val) const + value_bool operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); return false; } template - bool operator() (T val) const + value_bool operator() (T val) const { return val > 0 ? true : false; } @@ -626,14 +646,14 @@ struct to_string : public boost::static_visitor } // specializations - std::string operator() (UnicodeString const& val) const + std::string operator() (value_unicode_string const& val) const { std::string utf8; to_utf8(val,utf8); return utf8; } - std::string operator() (double val) const + std::string operator() (value_double val) const { std::string str; util::to_string(str, val); // TODO set precision(16) @@ -647,54 +667,54 @@ struct to_string : public boost::static_visitor } }; -struct to_unicode : public boost::static_visitor +struct to_unicode : public boost::static_visitor { template - UnicodeString operator() (T val) const + value_unicode_string operator() (T val) const { std::string str; util::to_string(str,val); - return UnicodeString(str.c_str()); + return value_unicode_string(str.c_str()); } // specializations - UnicodeString const& operator() (UnicodeString const& val) const + value_unicode_string const& operator() (value_unicode_string const& val) const { return val; } - UnicodeString operator() (double val) const + value_unicode_string operator() (value_double val) const { std::string str; util::to_string(str,val); - return UnicodeString(str.c_str()); + return value_unicode_string(str.c_str()); } - UnicodeString operator() (value_null const& val) const + value_unicode_string operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); - return UnicodeString(""); + return value_unicode_string(""); } }; struct to_expression_string : public boost::static_visitor { - std::string operator() (UnicodeString const& val) const + std::string operator() (value_unicode_string const& val) const { std::string utf8; to_utf8(val,utf8); return "'" + utf8 + "'"; } - std::string operator() (double val) const + std::string operator() (value_double val) const { std::string output; util::to_string(output,val); // TODO precision(16) return output; } - std::string operator() (bool val) const + std::string operator() (value_bool val) const { return val ? "true":"false"; } @@ -714,69 +734,71 @@ struct to_expression_string : public boost::static_visitor } }; -struct to_double : public boost::static_visitor +struct to_double : public boost::static_visitor { - double operator() (int val) const + value_double operator() (value_integer val) const { - return static_cast(val); + return static_cast(val); } - double operator() (double val) const + value_double operator() (value_double val) const { return val; } - double operator() (std::string const& val) const + value_double operator() (std::string const& val) const { - double result; + value_double result; if (util::string2double(val,result)) return result; return 0; } - double operator() (UnicodeString const& val) const + + value_double operator() (value_unicode_string const& val) const { std::string utf8; to_utf8(val,utf8); return operator()(utf8); } - double operator() (value_null const& val) const + value_double operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); return 0.0; } }; -struct to_int : public boost::static_visitor +struct to_int : public boost::static_visitor { - int operator() (int val) const + value_integer operator() (value_integer val) const { return val; } - int operator() (double val) const + value_integer operator() (value_double val) const { return rint(val); } - int operator() (std::string const& val) const + value_integer operator() (std::string const& val) const { - int result; - if (util::string2int(val,result)) + value_integer result; + if (util::string2longlong(val,result)) return result; - return 0; + return 0LL; } - int operator() (UnicodeString const& val) const + + value_integer operator() (value_unicode_string const& val) const { std::string utf8; to_utf8(val,utf8); return operator()(utf8); } - int operator() (value_null const& val) const + value_integer operator() (value_null const& val) const { boost::ignore_unused_variable_warning(val); - return 0; + return 0LL; } }; @@ -842,7 +864,7 @@ public: bool is_null() const; - bool to_bool() const + value_bool to_bool() const { return boost::apply_visitor(impl::to_bool(),base_); } @@ -857,19 +879,21 @@ public: return boost::apply_visitor(impl::to_string(),base_); } - UnicodeString to_unicode() const + value_unicode_string to_unicode() const { return boost::apply_visitor(impl::to_unicode(),base_); } - double to_double() const + value_double to_double() const { - return boost::apply_visitor(impl::to_double(),base_); + return 0.0; + //return boost::apply_visitor(impl::to_double(),base_); } - double to_int() const + value_integer to_int() const { - return boost::apply_visitor(impl::to_int(),base_); + return 0LL; + //return boost::apply_visitor(impl::to_int(),base_); } }; diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 1101108ae..a07070f32 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -467,7 +467,7 @@ void csv_datasource::parse_csv(T & stream, { csv_utils::fix_json_quoting(csv_line); } - + Tokenizer tok(csv_line, grammer); Tokenizer::iterator beg = tok.begin(); @@ -598,7 +598,7 @@ void csv_datasource::parse_csv(T & stream, MAPNIK_LOG_ERROR(csv) << s.str(); } } - } + } } else { @@ -709,7 +709,7 @@ void csv_datasource::parse_csv(T & stream, } else { - feature->put(fld_name,static_cast(float_val)); + feature->put(fld_name,static_cast(float_val)); if (feature_count == 1) { desc_.add_descriptor( diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index 08fef0f6b..9088e6a9f 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -445,10 +445,10 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q) { MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Loading colour table..."; - unsigned nodata_value = static_cast(nodata); + unsigned nodata_value = static_cast(nodata); // FIXME: is it realy unsigned ? if (hasNoData) { - feature->put("NODATA",static_cast(nodata_value)); + feature->put("NODATA",static_cast(nodata_value)); } for (unsigned y = 0; y < image.height(); ++y) { diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index a118bd088..9c51b49a7 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -70,7 +70,7 @@ geojson_datasource::geojson_datasource(parameters const& params, bool bind) struct attr_value_converter : public boost::static_visitor { - mapnik::eAttributeType operator() (int /*val*/) const + mapnik::eAttributeType operator() (mapnik::value_integer /*val*/) const { return mapnik::Integer; } @@ -110,29 +110,29 @@ void geojson_datasource::bind() const { if (is_bound_) return; - typedef std::istreambuf_iterator base_iterator_type; - + typedef std::istreambuf_iterator base_iterator_type; + std::ifstream is(file_.c_str()); - boost::spirit::multi_pass begin = + boost::spirit::multi_pass begin = boost::spirit::make_default_multi_pass(base_iterator_type(is)); - boost::spirit::multi_pass end = + boost::spirit::multi_pass end = boost::spirit::make_default_multi_pass(base_iterator_type()); - + mapnik::context_ptr ctx = boost::make_shared(); mapnik::json::feature_collection_parser > p(ctx,*tr_); bool result = p.parse(begin,end, features_); - if (!result) + if (!result) { throw mapnik::datasource_exception("geojson_datasource: Failed parse GeoJSON file '" + file_ + "'"); } - + bool first = true; std::size_t count=0; BOOST_FOREACH (mapnik::feature_ptr f, features_) { mapnik::box2d const& box = f->envelope(); - if (first) + if (first) { extent_ = box; first = false; @@ -147,7 +147,7 @@ void geojson_datasource::bind() const else { extent_.expand_to_include(box); - } + } tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++); } is_bound_ = true; @@ -160,7 +160,7 @@ const char * geojson_datasource::name() return "geojson"; } -boost::optional geojson_datasource::get_geometry_type() const +boost::optional geojson_datasource::get_geometry_type() const { boost::optional result; int multi_type = 0; @@ -182,7 +182,7 @@ boost::optional geojson_datasource::get_geometry return result; } -mapnik::datasource::datasource_t geojson_datasource::type() const +mapnik::datasource::datasource_t geojson_datasource::type() const { return type_; } @@ -203,7 +203,7 @@ mapnik::layer_descriptor geojson_datasource::get_descriptor() const mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) const { if (!is_bound_) bind(); - + // if the query box intersects our world extent then query for features mapnik::box2d const& b = q.get_bbox(); if (extent_.intersects(b)) @@ -211,7 +211,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy())); index_array_ = tree_.find(box); return boost::make_shared(features_, index_array_.begin(), index_array_.end()); - } + } // otherwise return an empty featureset pointer return mapnik::featureset_ptr(); } diff --git a/plugins/input/ogr/ogr_featureset.cpp b/plugins/input/ogr/ogr_featureset.cpp index 9b839ec66..f8b8a7ef7 100644 --- a/plugins/input/ogr/ogr_featureset.cpp +++ b/plugins/input/ogr/ogr_featureset.cpp @@ -117,7 +117,7 @@ feature_ptr ogr_featureset::next() { case OFTInteger: { - feature->put( fld_name, poFeature->GetFieldAsInteger(i)); + feature->put( fld_name, poFeature->GetFieldAsInteger(i)); break; } diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index fec9b6131..cae937afe 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -126,7 +126,7 @@ feature_ptr ogr_index_featureset::next() { case OFTInteger: { - feature->put(fld_name,poFeature->GetFieldAsInteger (i)); + feature->put(fld_name,poFeature->GetFieldAsInteger (i)); break; } diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 44e62a0b8..0b2281767 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -76,7 +76,7 @@ feature_ptr postgis_featureset::next() std::string name = rs_->getFieldName(pos); // validation happens of this type at bind() - int val; + mapnik::value_integer val; if (oid == 20) { val = int8net(buf); @@ -94,7 +94,7 @@ feature_ptr postgis_featureset::next() // TODO - extend feature class to know // that its id is also an attribute to avoid // this duplication - feature->put(name,val); + feature->put(name,val); ++pos; } else @@ -135,24 +135,19 @@ feature_ptr postgis_featureset::next() case 23: //int4 { - int val = int4net(buf); - feature->put(name, val); + feature->put(name, int4net(buf)); break; } case 21: //int2 { - int val = int2net(buf); - feature->put(name, val); + feature->put(name, int2net(buf)); break; } case 20: //int8/BigInt { - // TODO - need to support boost::uint64_t in mapnik::value - // https://github.com/mapnik/mapnik/issues/895 - int val = int8net(buf); - feature->put(name, val); + feature->put(name, int8net(buf)); break; } diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index 7ed0da535..923e215d6 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -160,7 +160,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f) { if (record_[fields_[col].offset_] == '*') { - f.put(name,0); + f.put(name,0LL); break; } if ( fields_[col].dec_>0 ) @@ -173,7 +173,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f) } else { - int val = 0; + mapnik::value_integer val = 0LL; const char *itr = record_+fields_[col].offset_; const char *end = itr + fields_[col].length_; if (qi::phrase_parse(itr,end,int_,ascii::space,val)) diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp index 43705570c..69142adfd 100644 --- a/plugins/input/sqlite/sqlite_featureset.cpp +++ b/plugins/input/sqlite/sqlite_featureset.cpp @@ -104,7 +104,7 @@ feature_ptr sqlite_featureset::next() { case SQLITE_INTEGER: { - feature->put(fld_name_str, rs_->column_integer(i)); + feature->put(fld_name_str, rs_->column_integer(i)); break; } diff --git a/src/conversions.cpp b/src/conversions.cpp index 6411388c1..549aad498 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -39,6 +39,7 @@ namespace mapnik { namespace util { using namespace boost::spirit; BOOST_SPIRIT_AUTO(qi, INTEGER, qi::int_) +BOOST_SPIRIT_AUTO(qi, LONGLONG, qi::long_long) BOOST_SPIRIT_AUTO(qi, FLOAT, qi::float_) BOOST_SPIRIT_AUTO(qi, DOUBLE, qi::double_) @@ -63,6 +64,27 @@ bool string2int(std::string const& value, int & result) return r && (str_beg == str_end); } +bool string2longlong(const char * value, boost::long_long_type & result) +{ + size_t length = strlen(value); + if (length < 1 || value == NULL) + return false; + const char *iter = value; + const char *end = value + length; + bool r = qi::phrase_parse(iter,end,LONGLONG,ascii::space,result); + return r && (iter == end); +} + +bool string2longlong(std::string const& value, boost::long_long_type & result) +{ + if (value.empty()) + return false; + std::string::const_iterator str_beg = value.begin(); + std::string::const_iterator str_end = value.end(); + bool r = qi::phrase_parse(str_beg,str_end,LONGLONG,ascii::space,result); + return r && (str_beg == str_end); +} + bool string2double(std::string const& value, double & result) { if (value.empty()) diff --git a/src/expression_grammar.cpp b/src/expression_grammar.cpp index fcc2575f8..a3b8f8588 100644 --- a/src/expression_grammar.cpp +++ b/src/expression_grammar.cpp @@ -63,7 +63,8 @@ expression_grammar::expression_grammar(mapnik::transcoder const& tr) using qi::lexeme; using qi::_val; using qi::lit; - using qi::int_; + //using qi::int_; + using qi::long_long; using qi::double_; using qi::hex; using qi::omit; @@ -138,13 +139,13 @@ expression_grammar::expression_grammar(mapnik::transcoder const& tr) ; primary_expr = strict_double [_val = _1] - | int_ [_val = _1] - | no_case[lit("true")] [_val = true] - | no_case[lit("false")] [_val = false] - | no_case[lit("null")] [_val = value_null() ] - | no_case[geom_type][_val = _1 ] + | long_long [_val = _1] + //| no_case[lit("true")] [_val = true] + //| no_case[lit("false")] [_val = false] + //| no_case[lit("null")] [_val = value_null() ] + //| no_case[geom_type][_val = _1 ] | ustring [_val = unicode_(_1) ] - | lit("[mapnik::geometry_type]")[_val = construct()] + //| lit("[mapnik::geometry_type]")[_val = construct()] | attr [_val = construct( _1 ) ] | '(' >> expr [_val = _1 ] >> ')' ; @@ -171,4 +172,4 @@ expression_grammar::expression_grammar(mapnik::transcoder const& tr) template struct mapnik::expression_grammar; -} \ No newline at end of file +} diff --git a/src/json/feature_grammar.cpp b/src/json/feature_grammar.cpp index b09a8ba70..f388d032a 100644 --- a/src/json/feature_grammar.cpp +++ b/src/json/feature_grammar.cpp @@ -38,7 +38,7 @@ feature_grammar::feature_grammar(mapnik::transcoder const& put_property_(put_property(tr)) { using qi::lit; - using qi::int_; + using qi::long_long; using qi::double_; #if BOOST_VERSION > 104200 using qi::no_skip; @@ -90,7 +90,7 @@ feature_grammar::feature_grammar(mapnik::transcoder const& #else number = strict_double #endif - | int_ + //| long_long | lit("true") [_val = true] | lit ("false") [_val = false] | lit("null")[_val = construct()] diff --git a/src/load_map.cpp b/src/load_map.cpp index ef58168ff..c48fd8299 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -369,13 +369,13 @@ void map_parser::parse_map_include(Map & map, xml_node const& include) if (*type == "int") { is_string = false; - int value = paramIter->get_value(); + mapnik::value_integer value = paramIter->get_value(); params[name] = value; } else if (*type == "float") { is_string = false; - double value = paramIter->get_value(); + double value = paramIter->get_value(); params[name] = value; } } diff --git a/src/save_map.cpp b/src/save_map.cpp index 6e22beab0..36d0caa7f 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -664,12 +664,12 @@ public: serialize_type( boost::property_tree::ptree & node): node_(node) {} - void operator () ( int val ) const + void operator () ( mapnik::value_integer val ) const { node_.put(".type", "int" ); } - void operator () ( double val ) const + void operator () ( mapnik::value_double val ) const { node_.put(".type", "float" ); } diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp index ed1b9bc08..517f897a4 100644 --- a/src/xml_tree.cpp +++ b/src/xml_tree.cpp @@ -125,7 +125,7 @@ DEFINE_NAME_TRAIT( double, "double") DEFINE_NAME_TRAIT( float, "float") DEFINE_NAME_TRAIT( unsigned, "unsigned") DEFINE_NAME_TRAIT( boolean, "boolean") -DEFINE_NAME_TRAIT( int, "integer" ) +DEFINE_NAME_TRAIT( mapnik::value_integer, "long long" ) DEFINE_NAME_TRAIT( std::string, "string" ) DEFINE_NAME_TRAIT( color, "color" ) DEFINE_NAME_TRAIT(expression_ptr, "expression_ptr" ) @@ -455,6 +455,7 @@ unsigned xml_node::line() const compile_get_opt_attr(boolean); compile_get_opt_attr(std::string); compile_get_opt_attr(unsigned); +compile_get_opt_attr(mapnik::value_integer); compile_get_opt_attr(float); compile_get_opt_attr(double); compile_get_opt_attr(color); @@ -476,7 +477,7 @@ compile_get_attr(pattern_alignment_e); compile_get_attr(line_rasterizer_e); compile_get_attr(colorizer_mode); compile_get_attr(double); -compile_get_value(int); +compile_get_value(value_integer); compile_get_value(double); compile_get_value(expression_ptr); } //ns mapnik diff --git a/tests/cpp_tests/params_test.cpp b/tests/cpp_tests/params_test.cpp index d4ae8bcd3..1399871de 100644 --- a/tests/cpp_tests/params_test.cpp +++ b/tests/cpp_tests/params_test.cpp @@ -10,14 +10,14 @@ int main( int, char*[] ) mapnik::parameters params; // true - params["bool"] = true; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + //params["bool"] = true; + //BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); params["bool"] = "true"; BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); - params["bool"] = 1; - BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); + //params["bool"] = 1; + //BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); params["bool"] = "1"; BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); @@ -32,14 +32,14 @@ int main( int, char*[] ) BOOST_TEST( (params.get("bool") && *params.get("bool") == true)); // false - params["bool"] = false; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); + //params["bool"] = false; + //BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); params["bool"] = "false"; BOOST_TEST( (params.get("bool") && *params.get("bool") == false) ); - params["bool"] = 0; - BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); + //params["bool"] = 0; + //BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); params["bool"] = "0"; BOOST_TEST( (params.get("bool") && *params.get("bool") == false)); @@ -58,7 +58,7 @@ int main( int, char*[] ) BOOST_TEST( (params.get("string") && *params.get("string") == "hello") ); // int - params["int"] = 1; + params["int"] = 1LL; BOOST_TEST( (params.get("int") && *params.get("int") == 1) ); // double