+ use BOOST_PYTHON_FUNCTION_OVERLOADS to reflect
render(...) overloads
This commit is contained in:
parent
d39ed1d364
commit
e634c06c17
1 changed files with 21 additions and 45 deletions
|
@ -80,28 +80,12 @@ void export_glyph_symbolizer();
|
||||||
static Pycairo_CAPI_t *Pycairo_CAPI;
|
static Pycairo_CAPI_t *Pycairo_CAPI;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void render(const mapnik::Map& map,mapnik::image_32& image, unsigned offset_x = 0, unsigned offset_y = 0)
|
void render(const mapnik::Map& map,mapnik::image_32& image, double scale_factor = 1.0 , unsigned offset_x = 0u , unsigned offset_y = 0u)
|
||||||
{
|
{
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mapnik::agg_renderer<mapnik::image_32> ren(map,image,offset_x, offset_y);
|
mapnik::agg_renderer<mapnik::image_32> ren(map,image,scale_factor,offset_x, offset_y);
|
||||||
ren.apply();
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
Py_BLOCK_THREADS
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
Py_END_ALLOW_THREADS
|
|
||||||
}
|
|
||||||
|
|
||||||
void render2(const mapnik::Map& map,mapnik::image_32& image)
|
|
||||||
{
|
|
||||||
Py_BEGIN_ALLOW_THREADS
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mapnik::agg_renderer<mapnik::image_32> ren(map,image);
|
|
||||||
ren.apply();
|
ren.apply();
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
@ -191,7 +175,7 @@ void render_tile_to_file(const mapnik::Map& map,
|
||||||
const std::string& format)
|
const std::string& format)
|
||||||
{
|
{
|
||||||
mapnik::image_32 image(width,height);
|
mapnik::image_32 image(width,height);
|
||||||
render(map,image,offset_x, offset_y);
|
render(map,image,1.0,offset_x, offset_y);
|
||||||
mapnik::save_to_file(image.data(),file,format);
|
mapnik::save_to_file(image.data(),file,format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,6 +284,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_overloads, load_map, 2, 3);
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_string_overloads, load_map_string, 2, 4);
|
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_string_overloads, load_map_string, 2, 4);
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_overloads, save_map, 2, 3);
|
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_overloads, save_map, 2, 3);
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string, 1, 2);
|
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string, 1, 2);
|
||||||
|
BOOST_PYTHON_FUNCTION_OVERLOADS(render_overloads, render, 2, 5);
|
||||||
|
|
||||||
BOOST_PYTHON_MODULE(_mapnik2)
|
BOOST_PYTHON_MODULE(_mapnik2)
|
||||||
{
|
{
|
||||||
|
@ -385,7 +370,7 @@ BOOST_PYTHON_MODULE(_mapnik2)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
def("render",&render,
|
def("render", &render, render_overloads(
|
||||||
"\n"
|
"\n"
|
||||||
"Render Map to an AGG image_32 using offsets\n"
|
"Render Map to an AGG image_32 using offsets\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -394,22 +379,13 @@ BOOST_PYTHON_MODULE(_mapnik2)
|
||||||
">>> m = Map(256,256)\n"
|
">>> m = Map(256,256)\n"
|
||||||
">>> load_map(m,'mapfile.xml')\n"
|
">>> load_map(m,'mapfile.xml')\n"
|
||||||
">>> im = Image(m.width,m.height)\n"
|
">>> im = Image(m.width,m.height)\n"
|
||||||
">>> render(m,im,1,1)\n"
|
">>> scale_factor=2.0\n"
|
||||||
"\n"
|
">>> offset = [100,50]\n"
|
||||||
);
|
|
||||||
|
|
||||||
def("render",&render2,
|
|
||||||
"\n"
|
|
||||||
"Render Map to an AGG image_32\n"
|
|
||||||
"\n"
|
|
||||||
"Usage:\n"
|
|
||||||
">>> from mapnik import Map, Image, render, load_map\n"
|
|
||||||
">>> m = Map(256,256)\n"
|
|
||||||
">>> load_map(m,'mapfile.xml')\n"
|
|
||||||
">>> im = Image(m.width,m.height)\n"
|
|
||||||
">>> render(m,im)\n"
|
">>> render(m,im)\n"
|
||||||
|
">>> render(m,im,scale_factor)\n"
|
||||||
|
">>> render(m,im,scale_factor,offset[0],offset[1])\n"
|
||||||
"\n"
|
"\n"
|
||||||
);
|
));
|
||||||
|
|
||||||
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
||||||
def("render",&render3,
|
def("render",&render3,
|
||||||
|
|
Loading…
Reference in a new issue