On Jan 24, 2011, at 8:37 AM, Roel Vanhout wrote: > (cc to -users as this may be of interest to some people on that list) > > Hi, > > For the last couple of weeks I've been chipping away at making php > bindings for mapnik. After the milestones of getting mapnik to compile > on Windows/MSVC, getting a simple php extension to work in debugging > mode, wrapping some of the simpler mapnik classes and calling them > successfully from php userland scripts, I thought it time to inform a > larger audience of what I'm doing in case anyone is either also > working on this or has an interest. > > My next steps are mostly boring, just wrapping mapnik classes 1:1 to > equivalent php classes. My planning for the coming time is to focus on > getting a php version of rundemo.cpp to run and output the correct > result. I have no timeframe to full completion as this is a personal > side-project and I can only free up a few hours here and there to work > on this, at least until I find a sponsor to justify working on it for > a few days at a time. I'm keeping close to the C++ api for now so that > I don't have to spend too much time thinking about changes there. I'm > adjusting class and method names to be in line with what seems to have > emerged as the predominant naming standard in php: camelcase for > classes and camelcase with initial lower letter for method names. I'm > emulating overloaded constructors and functions too in the cases where > that's possible, it remains to be seen if that's 'natural' in php. > > Which brings me to one of the reasons to write this mail; if there is > anyone interested in using mapnik from php and has wide experience > with php, in particular with api design for php libraries, I could use > someone to brainstorm about the api with.
I have little to no experience with PHP, but I support your thinking here! > Although I consider myself > an experieced php developer, I do not have much of a 'feel' for what > is natural in api design in php, or at least not the extent I do for > C++. Are you wrapping mapnik in a C API or are you able to call directly to the C++? > I also do not have experience with the mapnik python bindings, so > I don't know the approach there; if it follows the C++ api closely or > tries to fit in with common python idioms. Ideally both, within reason. The python bindings are written using boost python, so almost purely in C++. This gives them less than a pure pythonic feel, but makes them very powerful and having very direct access to C++ classes. > So if anyone is interested > in discussing this, and/or writing documentation and test cases in > advance to flesh out the design, please let me know. > > Then secondly, a question to Dane and Artem (I think you two are the > core developers, right?): do you have thoughts on the relationship > you'd like to see between mapnik C++ and the language bindings? Great question. I've only just begun considering that because I've been working on javascript bindings: https://github.com/mapnik/node-mapnik. My sense is that there is no perfect answer, but just a balance between various considerations. Here are some bullet points: Make sure the bindings are easy to install, don't leak, and are fast before wrapping 100% of the api. Achieving the amount of coverage of the python bindings is no small task, so whatever you do, do it well. Don't invent new abstractions or change function names unless you have a good reason. Certainly tailor the bindings to the language where appropriate. > The > python version seems deeply embedded within mapnik development, is > that by design or is it for historical reasons that they're in the > same repository? Boost python makes it easy and logical to expose python bindings as mapnik was developed since we use the boost libraries thoughout. They have been used as a way to test and prototype features in C++. > As I understand it, ogcserver used to be in there as > well but was factored out, are there any plans to do the same for the > python bindings or does the way it works now work well? No, ogcserver was pure python so it makes sense to have it separate where more developers could download separately and contribute in pure python. The python bindings, being written in C++ are much easier to build at the same time as mapnik core. > The reason > that I'm asking is for the hosting of the source of these php > bindings. At the moment I have them in my own svn repo, inaccessible > for the public. There are three 'obvious' short-term (working copy) > and/or long-term (i.e., when the code is at least somewhat feature > complete) places to host them: > > 1. as a separate project, e.g. on github (as an aside, is there any > talk of mapnik moving away from svn? many of us are using git svn. there are not plans to move the central repository away from svn, partly because git svn works so well. > I have no experience with git but > it seems that with boost moving to git, svn in open source C++ land is > coming under real pressure, so I figured I'd set up a github account > to see what all the hubbub (pun not intended) is about). It seems like github would be a good spot, or somewhere public people will discover them. If they get a lot of use and are well maintained they could eventually be moved into core. > 2 .in the mapnik source tree > 3. in PECL or the php source tree > > Re: 3, I'm not sure what the policy is about acceptance into PECL or > php proper, when libraries get shipped with php itself, etc.; for a > project that size it's probably all quite bureaucratic so I'm not > considering that to be a real option for now. > > So please let me know how you feel about this. github or the like :) > > Lastly, in case there are people who could use a php version of mapnik > and want to help out, there are a bunch of tasks that are left before > this could enter even alpha stage: > - see if the code compiles on Linux and integrates easily within the > php build process. This will probably require some m4 tweaking to > instruct the php build tools, but that seems simple from what I've > seen so far. The desktop machines I have at the moment all have > Windows so this is sort of at the bottom of my own list, but I suspect > it's going to be quite important for many potential users. > - I'm writing unit tests as I go implementing classes, but there need > to be some higher-level full programs that exercise all of the code > for testing and validation. That means, writing the php code, finding > test data, making known-good results, writing tests to verify > generated output, checking (manually or with code coverage tools) that > all features are used in the examples, etc. > - the above-mentioned documentation, although some minimal form that > refers people to the C++ docs will get them there 95% of the way I > think (at least for API docs, there still needs to be some > comprehensive 'getting started' tutorial that speaks the language of > the php-only programmer). I'm noticing that not all mapnik C++ > documentation is equally complete or helpful (e.g. what the arguments > to datasource_cache and font_engine mean, but I've found many > instances where I just read the code to find out what methods or > classes do); which I understand, because I myself am not too keen on > doing something boring like that ;) but I'm just saying that anyone > offering to write detailed API documentation would be better off > spending his/her energy on the C++ sources so that there is one good > source that all language bindings could then refer to. Well, you need both right? C++ docs won't help PHP or python programmers. If you are going to do api docs they really need to leverage the best of breed tools for each language. > > Again this mail is getting way too long so I'm going to sign off here, > comments welcome. I'll try to send mail to the list when I reach more > or less important milestones; at least if there are people interested, > I don't want to spam the lists with 1000-word rambles that nobody > reads anyway ;) > > > cheers, > > roel > > > PS any news on a next mapnik hackathon? If the location is the problem > I think I can host here in Maastricht, the Netherlands: nice historic > town, centrally located in Europe within 1.5 hours of 6 major > airports. Just suggesting, and in case there is enough interest for > another one in the next 6 months or so. Ya, thanks for offering. I think there is interest just a matter of getting ourself organized :) > _______________________________________________ > Mapnik-devel mailing list > [email protected] > https://lists.berlios.de/mailman/listinfo/mapnik-devel _______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

