Permalink
Browse files

expose a get_pixel method on mapnik::grid (for testing purposes)

  • Loading branch information...
1 parent 7621124 commit c29c18e8dfe153566e314118ad185812e14301ba Dane Springmeyer committed Jun 6, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 bindings/python/mapnik_grid.cpp
@@ -39,6 +39,18 @@ bool painted(mapnik::grid const& grid)
return grid.painted();
}
+int get_pixel(mapnik::grid const& grid, int x, int y)
+{
+ if (x < grid.width() && y < grid.height())
+ {
+ mapnik::grid::value_type const * row = grid.getRow(y);
+ mapnik::grid::value_type const pixel = row[x];
+ return pixel;
+ }
+ PyErr_SetString(PyExc_IndexError, "invalid x,y for grid dimensions");
+ boost::python::throw_error_already_set();
+}
+
void export_grid()
{
class_<mapnik::grid,boost::shared_ptr<mapnik::grid> >(
@@ -52,6 +64,7 @@ void export_grid()
.def("width",&mapnik::grid::width)
.def("height",&mapnik::grid::height)
.def("view",&mapnik::grid::get_view)
+ .def("get_pixel",&get_pixel)
.def("encode",encode,
( boost::python::arg("encoding")="utf", boost::python::arg("features")=true,boost::python::arg("resolution")=4 ),
"Encode the grid as as optimized json\n"

0 comments on commit c29c18e

Please sign in to comment.