Add command line options for map size to mapnik-render.

This commit is contained in:
Tim Gleason 2019-05-05 12:02:47 -04:00
parent 783437f16b
commit cdcc97ac4b

View file

@ -29,6 +29,8 @@ int main (int argc,char** argv)
bool params_as_variables = false;
mapnik::logger logger;
logger.set_severity(mapnik::logger::error);
int map_width = 600;
int map_height = 400;
try
{
@ -41,6 +43,8 @@ int main (int argc,char** argv)
("xml",po::value<std::string>(),"xml map to read")
("img",po::value<std::string>(),"image to render")
("scale-factor",po::value<double>(),"scale factor for rendering")
("map-width",po::value<int>(),"map width in pixels")
("map-height",po::value<int>(),"map height in pixels")
("variables","make map parameters available as render-time variables")
;
@ -103,9 +107,17 @@ int main (int argc,char** argv)
params_as_variables = true;
}
if (vm.count("map-width")) {
map_width = vm["map-width"].as<int>();
}
if (vm.count("map-height")) {
map_height = vm["map-height"].as<int>();
}
mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
mapnik::freetype_engine::register_fonts("./fonts",true);
mapnik::Map map(600,400);
mapnik::Map map(map_width,map_height);
mapnik::load_map(map,xml_file,true);
map.zoom_all();
mapnik::image_rgba8 im(map.width(),map.height());