nik2img: make params as variables opt-in

This commit is contained in:
Dane Springmeyer 2014-11-04 17:53:50 -05:00
parent 76d5bdae8c
commit c4e4bbf350

View file

@ -115,24 +115,27 @@ int main (int argc,char** argv)
mapnik::request req(map.width(),map.height(),map.get_current_extent()); mapnik::request req(map.width(),map.height(),map.get_current_extent());
req.set_buffer_size(map.buffer_size()); req.set_buffer_size(map.buffer_size());
mapnik::attributes vars; mapnik::attributes vars;
mapnik::transcoder tr("utf-8"); if (params_as_variables)
for (auto const& param : map.get_extra_parameters())
{ {
std::string const& name = param.first.substr(1); mapnik::transcoder tr("utf-8");
if (!name.empty()) for (auto const& param : map.get_extra_parameters())
{ {
if (param.second.is<mapnik::value_integer>()) std::string const& name = param.first.substr(1);
if (!name.empty())
{ {
vars[name] = param.second.get<mapnik::value_integer>(); if (param.second.is<mapnik::value_integer>())
} {
else if (param.second.is<mapnik::value_double>()) vars[name] = param.second.get<mapnik::value_integer>();
{ }
vars[name] = param.second.get<mapnik::value_double>(); else if (param.second.is<mapnik::value_double>())
} {
else if (param.second.is<std::string>()) vars[name] = param.second.get<mapnik::value_double>();
{ }
vars[name] = tr.transcode(param.second.get<std::string>().c_str()); else if (param.second.is<std::string>())
std::clog << name << " " << param.second.get<std::string>() << "\n"; {
vars[name] = tr.transcode(param.second.get<std::string>().c_str());
std::clog << name << " " << param.second.get<std::string>() << "\n";
}
} }
} }
} }