joto/osmium — pull request #51 by MaZderMind (2012-05-30 14:31:41+00:00)
Title: Simpler Interface for Multipolygon-Handlers

Hi Jochen,

while writing a simple App which should be able to process Multipolygons as Areas I found myself copying a lot boilerplate-code from the osmium_toogr2 example. I could imagine that this could really be barrier for developers who are not familar with the problems of the internal data structures of osm.

Such programmers want the osmium library to "just give me the damn areas" and if I think about it, I want the library to do that, too.

So I rewrote the osmium_toogr2 app to use a new MultipolygonAdapter which provides a really easy way to write a program, capable of two-pass processing. It does this by abstracting all the storage, assembling, cfw-handling into a higher level class.

One Problem I faced was the Multipolygon-Handler taking a function-pointer for callbacks, which does not work for object-methods. Therefor I extended this Handler to support boost::function which enables the handler to take a object-method as callback. Atm. the old-style function pointers are still supported, but If you'd be ready to break the interface I'd vote for only supporting boost::function, because it also works for pointer to a classic C-Methods.

I'd love to get a statement about the interface outlined in
https://github.com/MaZderMind/osmium/blob/mp_handler/examples/osmium_toogr2.cpp

And if you support this way, i'll go on, clean up and document the code.