On Thu, Jan 27, 2011 at 6:49 PM, Michal Migurski <m...@stamen.com> wrote:
> Personally, I think PHP's lurch toward object-orientedness over the past few 
> years is misguided, and I'm a big fan of the namespaceless, all-function 
> modules like GD that work by passing resources around. For mapnik, it would 
> make sense to have a single kind of resource: a map object. Everything else, 
> like rules, styles, layers, etc., could be represented with simple 
> associative arrays and plain values.

Thanks for your thoughts, Mike. Mysql has 'dual bindings' too, and
there is explicit support for it in the php extension development
code; and I agree that in some cases one makes more sense than the
other. Still, it's extra development effort, and time is the main
constraint at this time. Defining a new, procedural API would be an
extra task in itself. To take a simple example I'm not sure what the
best way to represent a color would be. The initial natural thing to
do would be have rgb components as separate arguments to functions;
making the alpha component optional like so:

mapnik_set_color($handle, 255, 0, 0);

But then how does one set the color from a css string? Would this
require overloading all functions that take a color with a string so
that you'd do

mapnik_set_color($handle, 'indigo');

Or would a color be an array with 'r', 'g', 'b' and 'a' keys? And a
function mapnik_get_color that would make the previous example work
like

mapnik_set_color($handle, mapnik_get_color('indigo'));

It's not convenient to have to do

mapnik_set_color($handle, new array('r' => 255, 'g' => 0, 'b' => 0));

And this is just a simple example, because mapnik::color is merely a
glorified struct...

Either way, if you'd like to discuss this further, maybe we could
flesh out the api design a bit, but actually implementing it will go
onto the todo list, after the 1:1 OO version is somewhat complete. For
example, could you write rundemo.cpp with the procedural php api you
envisage? That demonstrates most of the concepts I think.


cheers,

roel
_______________________________________________
Mapnik-users mailing list
Mapnik-users@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to