Added a ticket with the proposed implementation patch. Let me know how you like it.<div><br></div><div><a href="http://trac.osgeo.org/gdal/ticket/5021">http://trac.osgeo.org/gdal/ticket/5021</a></div><div><br></div><div>Best regards,</div>
<div><br></div><div>Tamas</div><div><br></div><div><br><br><div class="gmail_quote">2013/3/2 Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@mines-paris.org" target="_blank">even.rouault@mines-paris.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le vendredi 01 mars 2013 20:57:43, Tamas Szekeres a écrit :<br>
<div><div class="h5">> 2013/3/1 Even Rouault <<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>><br>
><br>
> > There's even a 4th option that doesn't require any code change. Create a<br>
> > OGR<br>
> > VRT file that renames the source fields to the truncated shapefile field<br>
> > names (or<br>
> > the reverse : creates a OGR VRT that renames the truncated shapefile<br>
> > field names<br>
> > to the original field names, since OGR VRT now supports since a few<br>
> > versions<br>
> > CreateFeature())<br>
><br>
> This may probably work, but doesn't seem to be very user friendly. Actually<br>
> I would prefer to include at least a flag to indicate that ogr2ogr should<br>
> provide mapping the fields in the same order (don't lookup field index by<br>
> name) for example:<br>
><br>
> ogr2ogr -append -f "ESRI Shapefile" -nofieldreorder destination.shp<br>
> [source]<br>
><br>
> or with the previous fieldmap approach<br>
><br>
> ogr2ogr -append -f "ESRI Shapefile" -fieldmap "default" destination.shp<br>
> [source]<br>
<br>
</div></div>I'm fine with -fieldmap. It will be just another advanced option (I'm culprit<br>
for a bunch of other options...). Perhaps "same_order" (or "identity" to be<br>
mathematically purist) instead of "default", since it's not actually the<br>
default behaviour (the default behaviour is to match the field names to build<br>
the field map). Some care should be done to check that the specified map is of<br>
the right size (number of fields of the source layer), or if<br>
"same_order"/"identity" is specified that the number of fields in the source and<br>
target layers are identical.<br>
<br>
As ogr2ogr can accept several source layers, perhaps a word of caution in the<br>
doc of the option to mention that the specified map applies to all source<br>
layers, so if they don't have the same field definition, the option might not be<br>
relevant in that case.<br>
<br>
><br>
> Best regards,<br>
><br>
> Tamas<br>
</blockquote></div><br></div>