use mapnik::util namespace for conversions

This commit is contained in:
Artem Pavlenko 2012-03-23 11:01:18 +00:00
parent e9940c6add
commit 242385f16d
6 changed files with 21 additions and 22 deletions

View file

@ -20,15 +20,15 @@
*
*****************************************************************************/
#ifndef MAPNIK_CONVERSIONS_UTIL_HPP
#define MAPNIK_CONVERSIONS_UTIL_HPP
#ifndef MAPNIK_UTIL_CONVERSIONS_HPP
#define MAPNIK_UTIL_CONVERSIONS_HPP
// mapnik
// stl
#include <string>
namespace mapnik { namespace conversions {
namespace mapnik { namespace util {
bool string2int(const char * value, int & result);
bool string2int(std::string const& value, int & result);
@ -39,7 +39,6 @@ namespace mapnik { namespace conversions {
bool string2float(std::string const& value, float & result);
bool string2float(const char * value, float & result);
}
}
}}
#endif // MAPNIK_CONVERSIONS_UTIL_HPP
#endif // MAPNIK_UTIL_CONVERSIONS_HPP

View file

@ -175,7 +175,7 @@ void postgis_datasource::bind() const
if (srid_c != NULL)
{
int result;
if (mapnik::conversions::string2int(srid_c,result))
if (mapnik::util::string2int(srid_c,result))
srid_ = result;
}
}
@ -205,7 +205,7 @@ void postgis_datasource::bind() const
if (srid_c != NULL)
{
int result;
if (mapnik::conversions::string2int(srid_c,result))
if (mapnik::util::string2int(srid_c,result))
srid_ = result;
}
}
@ -685,10 +685,10 @@ box2d<double> postgis_datasource::envelope() const
double loy;
double hix;
double hiy;
if (mapnik::conversions::string2double(rs->getValue(0),lox) &&
mapnik::conversions::string2double(rs->getValue(1),loy) &&
mapnik::conversions::string2double(rs->getValue(2),hix) &&
mapnik::conversions::string2double(rs->getValue(3),hiy))
if (mapnik::util::string2double(rs->getValue(0),lox) &&
mapnik::util::string2double(rs->getValue(1),loy) &&
mapnik::util::string2double(rs->getValue(2),hix) &&
mapnik::util::string2double(rs->getValue(3),hiy))
{
extent_.init(lox,loy,hix,hiy);
extent_initialized_ = true;

View file

@ -162,7 +162,7 @@ feature_ptr postgis_featureset::next()
{
std::string str = mapnik::sql_utils::numeric2string(buf);
double val;
if (mapnik::conversions::string2double(str,val))
if (mapnik::util::string2double(str,val))
feature->put(name,val);
}
else

View file

@ -31,7 +31,7 @@
BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
namespace mapnik { namespace conversions {
namespace mapnik { namespace util {
using namespace boost::spirit;

View file

@ -158,7 +158,7 @@ void handle_png_options(std::string const& type,
if (*colors < 0)
throw ImageWriterException("invalid color parameter: unavailable for true color images");
if (!mapnik::conversions::string2int(t.substr(2),*colors) || *colors < 0 || *colors > 256)
if (!mapnik::util::string2int(t.substr(2),*colors) || *colors < 0 || *colors > 256)
throw ImageWriterException("invalid color parameter: " + t.substr(2));
}
else if (boost::algorithm::starts_with(t, "t="))
@ -166,14 +166,14 @@ void handle_png_options(std::string const& type,
if (*colors < 0)
throw ImageWriterException("invalid trans_mode parameter: unavailable for true color images");
if (!mapnik::conversions::string2int(t.substr(2),*trans_mode) || *trans_mode < 0 || *trans_mode > 2)
if (!mapnik::util::string2int(t.substr(2),*trans_mode) || *trans_mode < 0 || *trans_mode > 2)
throw ImageWriterException("invalid trans_mode parameter: " + t.substr(2));
}
else if (boost::algorithm::starts_with(t, "g="))
{
if (*colors < 0)
throw ImageWriterException("invalid gamma parameter: unavailable for true color images");
if (!mapnik::conversions::string2double(t.substr(2),*gamma) || *gamma < 0)
if (!mapnik::util::string2double(t.substr(2),*gamma) || *gamma < 0)
{
throw ImageWriterException("invalid gamma parameter: " + t.substr(2));
}
@ -186,7 +186,7 @@ void handle_png_options(std::string const& type,
#define Z_BEST_COMPRESSION 9
#define Z_DEFAULT_COMPRESSION (-1)
*/
if (!mapnik::conversions::string2int(t.substr(2),*compression)
if (!mapnik::util::string2int(t.substr(2),*compression)
|| *compression < Z_DEFAULT_COMPRESSION
|| *compression > Z_BEST_COMPRESSION)
{
@ -317,7 +317,7 @@ void save_to_stream(T const& image,
std::string const& val = t.substr(4);
if (!val.empty())
{
if (!mapnik::conversions::string2int(val,quality) || quality < 0 || quality > 100)
if (!mapnik::util::string2int(val,quality) || quality < 0 || quality > 100)
{
throw ImageWriterException("invalid jpeg quality: '" + val + "'");
}

View file

@ -54,7 +54,7 @@ template <>
inline boost::optional<int> fast_cast(xml_tree const& tree, std::string const& value)
{
int result;
if (mapnik::conversions::string2int(value, result))
if (mapnik::util::string2int(value, result))
return boost::optional<int>(result);
return boost::optional<int>();
}
@ -63,7 +63,7 @@ template <>
inline boost::optional<double> fast_cast(xml_tree const& tree, std::string const& value)
{
double result;
if (mapnik::conversions::string2double(value, result))
if (mapnik::util::string2double(value, result))
return boost::optional<double>(result);
return boost::optional<double>();
}
@ -72,7 +72,7 @@ template <>
inline boost::optional<float> fast_cast(xml_tree const& tree, std::string const& value)
{
float result;
if (mapnik::conversions::string2float(value, result))
if (mapnik::util::string2float(value, result))
return boost::optional<float>(result);
return boost::optional<float>();
}