[Gdal-dev] OGR Close Datasource?

Ari Jolma ari.jolma at tkk.fi
Wed Sep 21 05:32:48 EDT 2005


Charlie Savage wrote:

> Wondering if it would make sense to introduce the concept of "closing" a
> datasource to the OGR API as a distinct thing from "destroying" a data
> source object?
>
> I bring this up because I run into a problem with a test script in Ruby:


What is the problem you run into? When I run this test code with Perl 
bindings, the delete data source -method deletes the datasource (the 
directory on hard disk) in both cases, whether datasource object still 
exists or is deleted.

However, the datasource object seems at least somewhat operational after 
the DeleteDataSource, it reports its name for example without an error.

Ari

>
> 1.  Create temporary csv data source
> 2.  Do some stuff to it
> 3.  At the end of the test, delete the temporary data source
>
> Pseudo code:
>
> driver = Ogr.get_driver_by_name('CSV')
> ds_name = "tempds"
> ds = driver.open(ds_name)
> ...
> ds = nil
> GC.start     <- Try to gc the ds object here
> driver.delete_data_source(ds_name)  <- Delete the data source
>
> Before deleting the temporary data source, the ds object must be
> destroyed (because it has the temporary data source open).  This means
> that the test is reliant on the garbage collector deleting the ds
> object.  Depending on the dynamic language, this may or may not work.
>
> Thus it would be handy to have a "close" method on a datasource.  The
> one gottcha I see is that once you've closed a datasource you can't use
> it anymore.  Also, you would need to make sure the destructor of the
> object doesn't try to close the datasource a second time.
>
> Charlie
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev



-- 
Prof. Ari Jolma
Kartografia ja Geoinformatiikka / Cartography and Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




More information about the Gdal-dev mailing list