Need for msInit() and msFinish()...

Frank Warmerdam warmerdam at POBOX.COM
Mon Feb 13 12:07:09 EST 2006


Steve Lime wrote:
> I think I'd just default to calling it msCleanup if that name is already out
> there and being used (although I like msFinish better ;-) ). I don't believe
> msCleanup is being exposed to MapScript though.

Steve,

It is declared in map.h and I have confirmed that it is available
in Python mapscript as "mapscript.msCleanup()".

>> Can you avoid msInit() by having the geos interface do the initialization
>> the first time it is entered?
> 
> Tht's how the C++ interface works but that was with our own global factory.
> I don't know how to detect that the library has already been initialized. Hopefully
> repeated calls to GEOSInit() are ok.

Well, there is always the hacky:

    static int bInitialized = FALSE;

    if( !bInitialized )
    {
         GEOSInit();
         bInitialized = TRUE;
    }

at some suitable point.

>> I wonder if we are going to have any conflicts with GDAL/OGR also doing
>> GEOS init/cleanup stuff.
> 
> Where is the GDAL/OGR GEOS cleanup happening? msCleanup?

msCleanup() calls the GDAL/OGR cleanup functions which ought to call
the GEOS cleanup function, though I'm pretty sure I don't yet.

>>> Hence the need. We could hide calls in the mapfile load/free code, but there are 
>>> some cases where MapScript scripts don't need a mapfile so we'd need to expose 
>>> 'em for those cases.
> 
>> I don't think we ought to cleanup geos just because a mapfile is
>> destroyed.  And of course sometimes we use many maps in a single
>> run.
> 
> I agree. If folks got in the habit of starting each script with msInit() and ending with
> msCleanup() that would be excellent. However, that would break every MapScript
> script out there which would make this a 5.0 type change.

Sean pointed out that the python mapscript already calls msSetup()
in the Python %init block, so it is automatic for Python.  He is
setting python mapscript to register an "atexit" handler for msCleanup().
I believe this auto-setup stuff needs to be implemented custom for each
swig wrapped language to make it automatic.

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