expose the painted boolean on images and grids to allow api users to know if any features were processed and likely rendered

This commit is contained in:
Dane Springmeyer 2011-09-14 19:31:57 +00:00
parent e6cb8eb8b3
commit 256937bd4e
2 changed files with 13 additions and 0 deletions

View file

@ -35,6 +35,11 @@ using namespace boost::python;
// help compiler see template definitions // help compiler see template definitions
static dict (*encode)( mapnik::grid const&, std::string, bool, unsigned int) = mapnik::grid_encode; static dict (*encode)( mapnik::grid const&, std::string, bool, unsigned int) = mapnik::grid_encode;
bool painted(mapnik::grid const& grid)
{
return grid.painted();
}
void export_grid() void export_grid()
{ {
class_<mapnik::grid,boost::shared_ptr<mapnik::grid> >( class_<mapnik::grid,boost::shared_ptr<mapnik::grid> >(
@ -44,6 +49,7 @@ void export_grid()
( arg("width"),arg("height"),arg("key")="__id__",arg("resolution")=1 ), ( arg("width"),arg("height"),arg("key")="__id__",arg("resolution")=1 ),
"Create a mapnik.Grid object\n" "Create a mapnik.Grid object\n"
)) ))
.def("painted",&painted)
.def("width",&mapnik::grid::width) .def("width",&mapnik::grid::width)
.def("height",&mapnik::grid::height) .def("height",&mapnik::grid::height)
.def("view",&mapnik::grid::get_view) .def("view",&mapnik::grid::get_view)

View file

@ -118,6 +118,11 @@ void save_to_file3(mapnik::image_32 const& im, std::string const& filename, std:
save_to_file(im,filename,type,pal); save_to_file(im,filename,type,pal);
} }
bool painted(mapnik::image_32 const& im)
{
return im.painted();
}
boost::shared_ptr<image_32> open_from_file(std::string const& filename) boost::shared_ptr<image_32> open_from_file(std::string const& filename)
{ {
@ -195,6 +200,7 @@ void export_image()
.def("width",&image_32::width) .def("width",&image_32::width)
.def("height",&image_32::height) .def("height",&image_32::height)
.def("view",&image_32::get_view) .def("view",&image_32::get_view)
.def("painted",&painted)
.add_property("background",make_function .add_property("background",make_function
(&image_32::get_background,return_value_policy<copy_const_reference>()), (&image_32::get_background,return_value_policy<copy_const_reference>()),
&image_32::set_background, "The background color of the image.") &image_32::set_background, "The background color of the image.")
@ -204,6 +210,7 @@ void export_image()
.def("blend",&blend) .def("blend",&blend)
.def("composite",&composite) .def("composite",&composite)
//TODO(haoyu) The method name 'tostring' might be confusing since they actually return bytes in Python 3 //TODO(haoyu) The method name 'tostring' might be confusing since they actually return bytes in Python 3
.def("tostring",&tostring1) .def("tostring",&tostring1)
.def("tostring",&tostring2) .def("tostring",&tostring2)
.def("tostring",&tostring3) .def("tostring",&tostring3)