[gdal-dev] OGRDataSource::CopyLayer

Even Rouault even.rouault at mines-paris.org
Tue Jan 28 11:50:26 PST 2014


Le mardi 28 janvier 2014 19:52:26, Ivan Lucena a écrit :
> Hi there,
> 
> I have question/suggestion about that method. When it goes though the loop
> it calls the driver's CreateField several times, depending on the number
> of columns on the table. In a DBMS environment, at that point the table is
> already created and the only thing the driver's CreateField() can do is to
> issue some ALTER TABLE statements. But that is too time consuming. It
> takes more time than to load geometry in some cases.
> 
> Is there a way to pass the field description information to the driver and
> let it decide to create the table at once with a complete description of
> the fields?

Ivan,

No, such a method doesn't exist.

One possible solution would be that the implementation of CreateLayer() and 
CreateField() in the driver doesn't do any SQL operation, but just save into 
memory the necessary elements to create the table later. The actual table 
creation would be deferred at the time of the first CreateFeature(), 
BeginTransaction(), or when the layer is destroyed.

Another solution would be to introduce a virtual method in OGRLayer - 
CreateLayerWithFields() - that could be specialized in drivers. The base 
implementation would just call CreateLayer() and CreateFields(). CopyLayer() 
and ogr2ogr would need to be retrofitted to use CreateLayerWithFields()

Even

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list