+ mapnik::value and mapnik::parameters - initial support for 64-bit integers
This commit is contained in:
parent
bf33e0eaa5
commit
855aea95e0
26 changed files with 256 additions and 207 deletions
|
@ -64,7 +64,7 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
|
|||
}
|
||||
|
||||
extract<std::string> ex0(obj);
|
||||
extract<int> ex1(obj);
|
||||
extract<mapnik::value_integer> ex1(obj);
|
||||
extract<double> ex2(obj);
|
||||
|
||||
if (ex0.check())
|
||||
|
|
|
@ -44,7 +44,7 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
|
|||
}
|
||||
|
||||
extract<std::string> ex0(obj);
|
||||
extract<int> ex1(obj);
|
||||
extract<mapnik::value_integer> ex1(obj);
|
||||
extract<double> ex2(obj);
|
||||
|
||||
if (ex0.check())
|
||||
|
|
|
@ -162,7 +162,7 @@ void export_feature()
|
|||
using mapnik::Feature;
|
||||
|
||||
// Python to mapnik::value converters
|
||||
implicitly_convertible<int,mapnik::value>();
|
||||
implicitly_convertible<mapnik::value_integer,mapnik::value>();
|
||||
implicitly_convertible<double,mapnik::value>();
|
||||
implicitly_convertible<UnicodeString,mapnik::value>();
|
||||
implicitly_convertible<bool,mapnik::value>();
|
||||
|
|
|
@ -78,7 +78,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
|
|||
std::string key = extract<std::string>(keys[i]);
|
||||
object obj = d[key];
|
||||
extract<std::string> ex0(obj);
|
||||
extract<int> ex1(obj);
|
||||
extract<mapnik::value_integer> ex1(obj);
|
||||
extract<double> ex2(obj);
|
||||
extract<UnicodeString> ex3(obj);
|
||||
|
||||
|
@ -185,7 +185,7 @@ boost::shared_ptr<mapnik::parameter> create_parameter_from_string(std::string co
|
|||
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
|
||||
}
|
||||
|
||||
boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, int value)
|
||||
boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, mapnik::value_integer value)
|
||||
{
|
||||
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace boost { namespace python {
|
|||
|
||||
struct value_converter : public boost::static_visitor<PyObject*>
|
||||
{
|
||||
PyObject * operator() (int val) const
|
||||
PyObject * operator() (mapnik::value_integer val) const
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
return ::PyLong_FromLong(val);
|
||||
|
|
|
@ -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<mapnik::value_integer>(type);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
// spirit::qi
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/phoenix.hpp>
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
|
@ -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<Iterator,std::string(), space_type> string_;
|
||||
qi::rule<Iterator,space_type> key_value;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,int,double>(),space_type> number;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,boost::long_long_type,double>(),space_type> number;
|
||||
qi::rule<Iterator,space_type> object;
|
||||
qi::rule<Iterator,space_type> array;
|
||||
qi::rule<Iterator,space_type> pairs;
|
||||
|
@ -126,7 +128,7 @@ struct feature_grammar :
|
|||
|
||||
qi::rule<Iterator,void(FeatureType &),space_type> properties;
|
||||
qi::rule<Iterator,qi::locals<std::string>, void(FeatureType &),space_type> attributes;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,int,double,std::string>(), space_type> attribute_value;
|
||||
qi::rule<Iterator,boost::variant<value_null,bool,boost::long_long_type,double,std::string>(), space_type> attribute_value;
|
||||
|
||||
phoenix::function<put_property> put_property_;
|
||||
phoenix::function<extract_geometry> extract_geometry_;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
typedef boost::variant<value_null,int,double,std::string> value_holder;
|
||||
typedef boost::variant<value_null,value_integer,value_double,std::string> value_holder;
|
||||
typedef std::pair<std::string, value_holder> parameter;
|
||||
typedef std::map<std::string, value_holder> param_map;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -106,7 +106,13 @@ struct value_null
|
|||
}
|
||||
};
|
||||
|
||||
typedef boost::variant<value_null,bool,int,double,UnicodeString> 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_null,value_bool,value_integer,value_double,value_unicode_string> 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 <typename V>
|
|||
struct add : public boost::static_visitor<V>
|
||||
{
|
||||
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 <typename R>
|
||||
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 <typename L>
|
||||
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 <typename T>
|
||||
value_type operator() (T lhs, T rhs) const
|
||||
|
@ -357,57 +408,16 @@ struct add : public boost::static_visitor<V>
|
|||
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 <typename R>
|
||||
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 <typename L>
|
||||
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 <typename T1, typename T2>
|
||||
value_type operator() (T1 const& lhs, T2 const&) const
|
||||
{
|
||||
return lhs;
|
||||
}
|
||||
|
||||
value_type operator() (value_bool lhs, value_bool rhs) const
|
||||
{
|
||||
return 0LL;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename V>
|
||||
|
@ -426,21 +436,26 @@ struct sub : public boost::static_visitor<V>
|
|||
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 <typename V>
|
||||
|
@ -458,21 +473,26 @@ struct mult : public boost::static_visitor<V>
|
|||
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 <typename V>
|
||||
|
@ -491,25 +511,25 @@ struct div: public boost::static_visitor<V>
|
|||
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<V>
|
|||
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<V>
|
|||
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<bool>
|
||||
struct to_bool : public boost::static_visitor<value_bool>
|
||||
{
|
||||
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 <typename T>
|
||||
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<std::string>
|
|||
}
|
||||
|
||||
// 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<std::string>
|
|||
}
|
||||
};
|
||||
|
||||
struct to_unicode : public boost::static_visitor<UnicodeString>
|
||||
struct to_unicode : public boost::static_visitor<value_unicode_string>
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
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>
|
||||
{
|
||||
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<std::string>
|
|||
}
|
||||
};
|
||||
|
||||
struct to_double : public boost::static_visitor<double>
|
||||
struct to_double : public boost::static_visitor<value_double>
|
||||
{
|
||||
double operator() (int val) const
|
||||
value_double operator() (value_integer val) const
|
||||
{
|
||||
return static_cast<double>(val);
|
||||
return static_cast<value_double>(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<double>
|
||||
struct to_int : public boost::static_visitor<value_integer>
|
||||
{
|
||||
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_);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -709,7 +709,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
}
|
||||
else
|
||||
{
|
||||
feature->put(fld_name,static_cast<int>(float_val));
|
||||
feature->put(fld_name,static_cast<mapnik::value_integer>(float_val));
|
||||
if (feature_count == 1)
|
||||
{
|
||||
desc_.add_descriptor(
|
||||
|
|
|
@ -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<unsigned>(nodata);
|
||||
unsigned nodata_value = static_cast<unsigned>(nodata); // FIXME: is it realy unsigned ?
|
||||
if (hasNoData)
|
||||
{
|
||||
feature->put("NODATA",static_cast<int>(nodata_value));
|
||||
feature->put("NODATA",static_cast<mapnik::value_integer>(nodata_value));
|
||||
}
|
||||
for (unsigned y = 0; y < image.height(); ++y)
|
||||
{
|
||||
|
|
|
@ -70,7 +70,7 @@ geojson_datasource::geojson_datasource(parameters const& params, bool bind)
|
|||
|
||||
struct attr_value_converter : public boost::static_visitor<mapnik::eAttributeType>
|
||||
{
|
||||
mapnik::eAttributeType operator() (int /*val*/) const
|
||||
mapnik::eAttributeType operator() (mapnik::value_integer /*val*/) const
|
||||
{
|
||||
return mapnik::Integer;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ feature_ptr ogr_featureset::next()
|
|||
{
|
||||
case OFTInteger:
|
||||
{
|
||||
feature->put( fld_name, poFeature->GetFieldAsInteger(i));
|
||||
feature->put<mapnik::value_integer>( fld_name, poFeature->GetFieldAsInteger(i));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ feature_ptr ogr_index_featureset<filterT>::next()
|
|||
{
|
||||
case OFTInteger:
|
||||
{
|
||||
feature->put(fld_name,poFeature->GetFieldAsInteger (i));
|
||||
feature->put<mapnik::value_integer>(fld_name,poFeature->GetFieldAsInteger (i));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<mapnik::value_integer>(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<mapnik::value_integer>(name, int4net(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
case 21: //int2
|
||||
{
|
||||
int val = int2net(buf);
|
||||
feature->put(name, val);
|
||||
feature->put<mapnik::value_integer>(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<mapnik::value_integer>(name, int8net(buf));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -104,7 +104,7 @@ feature_ptr sqlite_featureset::next()
|
|||
{
|
||||
case SQLITE_INTEGER:
|
||||
{
|
||||
feature->put(fld_name_str, rs_->column_integer(i));
|
||||
feature->put<mapnik::value_integer>(fld_name_str, rs_->column_integer(i));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -63,7 +63,8 @@ expression_grammar<Iterator>::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<Iterator>::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<mapnik::geometry_type_attribute>()]
|
||||
//| lit("[mapnik::geometry_type]")[_val = construct<mapnik::geometry_type_attribute>()]
|
||||
| attr [_val = construct<mapnik::attribute>( _1 ) ]
|
||||
| '(' >> expr [_val = _1 ] >> ')'
|
||||
;
|
||||
|
|
|
@ -38,7 +38,7 @@ feature_grammar<Iterator,FeatureType>::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<Iterator,FeatureType>::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<value_null>()]
|
||||
|
|
|
@ -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<int>();
|
||||
mapnik::value_integer value = paramIter->get_value<mapnik::value_integer>();
|
||||
params[name] = value;
|
||||
}
|
||||
else if (*type == "float")
|
||||
{
|
||||
is_string = false;
|
||||
double value = paramIter->get_value<double>();
|
||||
double value = paramIter->get_value<mapnik::value_double>();
|
||||
params[name] = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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("<xmlattr>.type", "int" );
|
||||
}
|
||||
|
||||
void operator () ( double val ) const
|
||||
void operator () ( mapnik::value_double val ) const
|
||||
{
|
||||
node_.put("<xmlattr>.type", "float" );
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,14 +10,14 @@ int main( int, char*[] )
|
|||
mapnik::parameters params;
|
||||
|
||||
// true
|
||||
params["bool"] = true;
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
||||
//params["bool"] = true;
|
||||
//BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
||||
|
||||
params["bool"] = "true";
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
||||
|
||||
params["bool"] = 1;
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
||||
//params["bool"] = 1;
|
||||
//BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
||||
|
||||
params["bool"] = "1";
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
||||
|
@ -32,14 +32,14 @@ int main( int, char*[] )
|
|||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == true));
|
||||
|
||||
// false
|
||||
params["bool"] = false;
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false) );
|
||||
//params["bool"] = false;
|
||||
//BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false) );
|
||||
|
||||
params["bool"] = "false";
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false) );
|
||||
|
||||
params["bool"] = 0;
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
||||
//params["bool"] = 0;
|
||||
//BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
||||
|
||||
params["bool"] = "0";
|
||||
BOOST_TEST( (params.get<mapnik::boolean>("bool") && *params.get<mapnik::boolean>("bool") == false));
|
||||
|
@ -58,7 +58,7 @@ int main( int, char*[] )
|
|||
BOOST_TEST( (params.get<std::string>("string") && *params.get<std::string>("string") == "hello") );
|
||||
|
||||
// int
|
||||
params["int"] = 1;
|
||||
params["int"] = 1LL;
|
||||
BOOST_TEST( (params.get<int>("int") && *params.get<int>("int") == 1) );
|
||||
|
||||
// double
|
||||
|
|
Loading…
Reference in a new issue