[Mapserver-dev] cpl utility functions

Frank Warmerdam warmerdam at pobox.com
Wed Jul 21 17:31:28 EDT 2004


Daniel Morissette wrote:
> Yewondwossen Assefa wrote:
> 
>>
>>   I need to use some utility function that are available in gdal 
>> cpl_xxx library. (In this specific case it is functions like 
>> CPLGetBasename). At the same time, It seems a bit odd to add a 
>> dependency to GDAL/OGR just to have access to a couple of functions. 
>> (in this case It is the swf module and It should normally not need 
>> gdal to work).
>>
>>   What is the general guidline for such a case ? Do we need to add the 
>> dependency ? Do I copy the functions inside mapserver utility files ?
>>
> 
> In the past we've always tried to avoid using CPL in MapServer source 
> (except in code that relies on GDAL/OGR already). What I've done when I 
> ran into those cases was either find another way to do the same thing, 
> or implement an equivalent function (or rename and copy the CPL 
> function) in mapstring.c or where it fits best.
> 
> I'm not sure it's a good idea to create a dependency on CPL, but OTOH it 
> provides several very useful utility functions that we often end up 
> having to replicate... let's see what others think.

Assefa / Daniel,

My take is similar to Daniel's.  I think that for small utility functions
from CPL, you should just replicate them into mapserver.  I would
like to suggest though that:
  o We make a map_cpl.c file with morphed code.
  o We exactly change CPL to "ms" but otherwise leave the function the
    same externally so it will be easy to use and recognise for folks who
    know CPL a bit. So CPLGetBasename() would become msGetBasename().
  o When you copy over the implementation you will of course need to
    modify the code internally to use mapserver services for memory
    allocation and various macros.  Most are pretty simple.

I was going to suggest that you dump them into maputil.c, but decided not to.
Boy is that file a hodge-podge of stuff.  Why are there lots of functions
in there not starting with ms, like getMeasureUsingPoint()?

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the mapserver-dev mailing list