I'm officially working with the TerraLib mantainers (http://www.terralib.org/) to make Python bindings for it (Dave, you can count this one as another boost.python project :-). Part of the functionality of that library concerns map tiling: large geo-referenced images are sliced and the tiles are stored in a Database. Later on, you can ask the library to return the map of an area and it will reassemble the image and return it. What is the best way to pass a lump of bytes (with nulls in it) back and forth? Something that I could get as a Python String would be nice, but std::string doesn't seem null friendly... Ultimately I'll probably be feeding this lump of bytes to PIL (Python Imaging Library) to make some final tweaks to the image before publishing it on the Web (it's actually a Zope project). Any tips? -- Ideas don't stay in some minds very long because they don't like solitary confinement.
From: "Leonardo Rochael Almeida" <leo@hiper.com.br>
I'm officially working with the TerraLib mantainers (http://www.terralib.org/) to make Python bindings for it (Dave, you can count this one as another boost.python project :-).
Part of the functionality of that library concerns map tiling: large geo-referenced images are sliced and the tiles are stored in a Database. Later on, you can ask the library to return the map of an area and it will reassemble the image and return it. What is the best way to pass a lump of bytes (with nulls in it) back and forth? Something that I could get as a Python String would be nice, but std::string doesn't seem null friendly... Ultimately I'll probably be feeding this lump of bytes to PIL (Python Imaging Library) to make some final tweaks to the image before publishing it on the Web (it's actually a Zope project).
Any tips?
How about just using boost::python::str, i.e. a Python string object? You can always extract<char*>(...) from it. If you think that's too semantically loose on the Python side, you could wrap a C++ class which contains a str. ----------------------------------------------------------- David Abrahams * Boost Consulting dave@boost-consulting.com * http://www.boost-consulting.com
--- Leonardo Rochael Almeida <leo@hiper.com.br> wrote:
I'm officially working with the TerraLib mantainers (http://www.terralib.org/) to make Python bindings for it (Dave, you can count this one as another boost.python project :-).
Part of the functionality of that library concerns map tiling: large geo-referenced images are sliced and the tiles are stored in a Database. Later on, you can ask the library to return the map of an area and it will reassemble the image and return it. What is the best way to pass a lump of bytes (with nulls in it) back and forth? Something that I could get as a Python String would be nice, but std::string doesn't seem null friendly... Ultimately I'll probably be feeding this lump of bytes to PIL (Python Imaging Library) to make some final tweaks to the image before publishing it on the Web (it's actually a Zope project).
Any tips?
For prototyping you could use the "flex" type of the scitbx array family to make pickleable 2-D arryas of "char" or "signed char" or "unsigned char", whatever is most appropriate. If using the scitbx is to heavy-weight as a final solution you can later rip out what you need. To make the flex.char type: cd scitbx/array_family/boost_python cp flex_bool.cpp flex_char.cpp Replace "bool" by "char". Add this near the top of flex_char.cpp (untested): namespace scitbx { namespace boost_python { namespace pickle_single_buffered { inline char* to_string(char* start, char const& value) { *start = value; return start + 1; } template <> struct from_string<char> { from_string(const char* start) : end(start) { value = *end++; } char value; const char* end; }; }}} Add "flex_char.cpp" to the SConscript and recompile with libtbx_scons . as shown in http://cci.lbl.gov/~rwgk/scitbx/cold_start_redhat_73_csh You might have to modify the cvs checkout of boost to use the RC_1_29_0 branch if the trunk turns out to be broken. HTH, Ralf __________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com
From: "Ralf W. Grosse-Kunstleve" <rwgk@yahoo.com>
For prototyping you could use the "flex" type of the scitbx array family to make pickleable 2-D arryas of "char" or "signed char" or "unsigned char", whatever is most appropriate. If using the scitbx is to heavy-weight as a final solution you can later rip out what you need.
Ralf's idea is certainly better if you need in-place modification of your buffer's contents. Might be a better approach even if you don't. ----------------------------------------------------------- David Abrahams * Boost Consulting dave@boost-consulting.com * http://www.boost-consulting.com
participants (3)
-
David Abrahams -
Leonardo Rochael Almeida -
Ralf W. Grosse-Kunstleve