mapnik/plugins/input/osm/render.cpp

60 lines
1.3 KiB
C++
Raw Normal View History

2008-03-01 12:49:37 +01:00
#include <mapnik/map.hpp>
#include <mapnik/layer.hpp>
2009-12-16 21:02:06 +01:00
#include <mapnik/box2d.hpp>
2008-03-01 12:49:37 +01:00
#include <mapnik/agg_renderer.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/projection.hpp>
using namespace mapnik;
#include <iostream>
#include <cmath>
using namespace std;
2008-03-06 22:04:47 +01:00
int main(int argc,char *argv[])
2008-03-01 12:49:37 +01:00
{
2008-03-06 22:04:47 +01:00
if(argc < 6)
{
std::cerr<<"Usage: render XMLfile w s e n [OSMfile]" << std::endl;
2008-03-06 22:04:47 +01:00
exit(0);
}
2008-03-01 12:49:37 +01:00
datasource_cache::instance()->register_datasources
("/usr/local/lib/mapnik/input");
freetype_engine::register_font
2008-03-06 22:04:47 +01:00
("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf");
2008-03-01 12:49:37 +01:00
Map m (800,800);
2008-03-06 22:04:47 +01:00
load_map(m,argv[1]);
if(argc>6)
2008-03-06 22:04:47 +01:00
{
parameters p;
p["type"] = "osm";
p["file"] = argv[6];
for(int count=0; count<m.layerCount(); count++)
{
parameters q = m.getLayer(count).datasource()->params();
m.getLayer(count).set_datasource(datasource_cache::instance()->
create(p));
}
2008-03-06 22:04:47 +01:00
}
2009-12-16 21:02:06 +01:00
box2d<double> bbox (atof(argv[2]),atof(argv[3]),
2008-03-06 22:04:47 +01:00
atof(argv[4]),atof(argv[5]));
2008-03-01 12:49:37 +01:00
m.zoomToBox(bbox);
2009-12-16 21:02:06 +01:00
image_32 buf (m.getWidth(), m.getHeight());
agg_renderer<image_32> r(m,buf);
2008-03-01 12:49:37 +01:00
r.apply();
2009-12-16 21:02:06 +01:00
save_to_file<image_data_32>(buf.data(),"blah.png","png");
2008-03-01 12:49:37 +01:00
return 0;
}