<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Even,<br><br><div>> From: even.rouault@mines-paris.org<br>> To: gdal-dev@lists.osgeo.org<br>> Subject: Re: [gdal-dev] OGRDataSource::CopyLayer<br>> Date: Tue, 28 Jan 2014 20:50:26 +0100<br>> CC: lucena_ivan@hotmail.com<br>> <br>> Le mardi 28 janvier 2014 19:52:26, Ivan Lucena a écrit :<br>> > Hi there,<br>> > <br>> > I have question/suggestion about that method. When it goes though the loop<br>> > it calls the driver's CreateField several times, depending on the number<br>> > of columns on the table. In a DBMS environment, at that point the table is<br>> > already created and the only thing the driver's CreateField() can do is to<br>> > issue some ALTER TABLE statements. But that is too time consuming. It<br>> > takes more time than to load geometry in some cases.<br>> > <br>> > Is there a way to pass the field description information to the driver and<br>> > let it decide to create the table at once with a complete description of<br>> > the fields?<br>> <br>> Ivan,<br>> <br>> No, such a method doesn't exist.<br>> <br>> One possible solution would be that the implementation of CreateLayer() and <br>> CreateField() in the driver doesn't do any SQL operation, but just save into <br>> memory the necessary elements to create the table later. The actual table <br>> creation would be deferred at the time of the first CreateFeature(), <br>> BeginTransaction(), or when the layer is destroyed.<br><br>I will try that option and see how it goes.<br><br>> Another solution would be to introduce a virtual method in OGRLayer - <br>> CreateLayerWithFields() - that could be specialized in drivers. The base <br>> implementation would just call CreateLayer() and CreateFields(). CopyLayer() <br>> and ogr2ogr would need to be retrofitted to use CreateLayerWithFields()<br><br>It looks like a very generic problem that might need a general solution in the future.<br><br>Thanks!<br><br>> <br>> Even<br>> <br>> -- <br>> Geospatial professional services<br>> http://even.rouault.free.fr/services.html<br></div>                                    </div></body>
</html>