Index: ogr/ogr_api.h
===================================================================
--- ogr/ogr_api.h	(révision 22312)
+++ ogr/ogr_api.h	(copie de travail)
@@ -254,6 +254,8 @@
 OGRFieldDefnH CPL_DLL OGR_FD_GetFieldDefn( OGRFeatureDefnH, int );
 int    CPL_DLL OGR_FD_GetFieldIndex( OGRFeatureDefnH, const char * );
 void   CPL_DLL OGR_FD_AddFieldDefn( OGRFeatureDefnH, OGRFieldDefnH );
+OGRErr CPL_DLL OGR_FD_DeleteFieldDefn( OGRFeatureDefnH hDefn, int iField );
+OGRErr CPL_DLL OGR_FD_ReorderFieldDefn( OGRFeatureDefnH hDefn, int iOldFieldPos, int iNewFieldPos );
 OGRwkbGeometryType CPL_DLL OGR_FD_GetGeomType( OGRFeatureDefnH );
 void   CPL_DLL OGR_FD_SetGeomType( OGRFeatureDefnH, OGRwkbGeometryType );
 int    CPL_DLL OGR_FD_IsGeometryIgnored( OGRFeatureDefnH );
@@ -355,6 +357,9 @@
 OGRErr CPL_DLL OGR_L_GetExtent( OGRLayerH, OGREnvelope *, int );
 int    CPL_DLL OGR_L_TestCapability( OGRLayerH, const char * );
 OGRErr CPL_DLL OGR_L_CreateField( OGRLayerH, OGRFieldDefnH, int );
+OGRErr CPL_DLL OGR_L_DeleteField( OGRLayerH, int iField );
+OGRErr CPL_DLL OGR_L_ReorderField( OGRLayerH, int iOldFieldPos, int iNewFieldPos );
+OGRErr CPL_DLL OGR_L_AlterFieldDefn( OGRLayerH, int iField, OGRFieldDefnH hNewFieldDefn, int nFlags );
 OGRErr CPL_DLL OGR_L_StartTransaction( OGRLayerH );
 OGRErr CPL_DLL OGR_L_CommitTransaction( OGRLayerH );
 OGRErr CPL_DLL OGR_L_RollbackTransaction( OGRLayerH );
Index: ogr/ogr_core.h
===================================================================
--- ogr/ogr_core.h	(révision 22312)
+++ ogr/ogr_core.h	(copie de travail)
@@ -220,6 +220,11 @@
 #  define DB2_V72_UNFIX_BYTE_ORDER(x) (x)
 #endif
 
+#define ALTER_NAME_FLAG            0x1
+#define ALTER_TYPE_FLAG            0x2
+#define ALTER_WIDTH_PRECISION_FLAG 0x4
+#define ALTER_ALL_FLAG             (ALTER_NAME_FLAG | ALTER_TYPE_FLAG | ALTER_WIDTH_PRECISION_FLAG)
+
 /************************************************************************/
 /*                  ogr_feature.h related definitions.                  */
 /************************************************************************/
@@ -324,6 +329,9 @@
 #define OLCFastFeatureCount    "FastFeatureCount"
 #define OLCFastGetExtent       "FastGetExtent"
 #define OLCCreateField         "CreateField"
+#define OLCDeleteField         "DeleteField"
+#define OLCReorderField        "ReorderField"
+#define OLCAlterFieldDefn      "AlterFieldDefn"
 #define OLCTransactions        "Transactions"
 #define OLCDeleteFeature       "DeleteFeature"
 #define OLCFastSetNextByIndex  "FastSetNextByIndex"
Index: ogr/ogr_feature.h
===================================================================
--- ogr/ogr_feature.h	(révision 22312)
+++ ogr/ogr_feature.h	(copie de travail)
@@ -141,6 +141,8 @@
     int         GetFieldIndex( const char * );
 
     void        AddFieldDefn( OGRFieldDefn * );
+    OGRErr      DeleteFieldDefn( int iField );
+    OGRErr      ReorderFieldDefn( int iOldFieldPos, int iNewFieldPos );
 
     OGRwkbGeometryType GetGeomType() { return eGeomType; }
     void        SetGeomType( OGRwkbGeometryType );
Index: ogr/ogrfeaturedefn.cpp
===================================================================
--- ogr/ogrfeaturedefn.cpp	(révision 22312)
+++ ogr/ogrfeaturedefn.cpp	(copie de travail)
@@ -374,6 +374,154 @@
 }
 
 /************************************************************************/
+/*                           DeleteFieldDefn()                          */
+/************************************************************************/
+
+/**
+ * \brief Delete an existing field definition.
+ *
+ * To delete an existing field definition from a layer definition, do not use this
+ * function directly, but use OGRLayer::DeleteField() instead.
+ *
+ * This method should only be called while there are no OGRFeature
+ * objects in existance based on this OGRFeatureDefn.  The OGRFieldDefn
+ * passed in is copied, and remains the responsibility of the caller.
+ *
+ * This method is the same as the C function OGR_FD_DeleteFieldDefn().
+ *
+ * @param iField the index of the field defintion.
+ * @return OGRERR_NONE in case of success.
+ * @since OGR 1.9.0
+ */
+
+OGRErr OGRFeatureDefn::DeleteFieldDefn( int iField )
+
+{
+    if (iField < 0 || iField >= nFieldCount)
+        return OGRERR_FAILURE;
+
+    if (iField < nFieldCount - 1)
+    {
+        memmove(papoFieldDefn + iField,
+                papoFieldDefn + iField + 1,
+                (nFieldCount - 1 - iField) * sizeof(void*));
+    }
+
+    nFieldCount--;
+
+    return OGRERR_NONE;
+}
+
+/************************************************************************/
+/*                       OGR_FD_DeleteFieldDefn()                       */
+/************************************************************************/
+
+/**
+ * \brief Delete an existing field definition.
+ *
+ * To delete an existing field definition from a layer definition, do not use this
+ * function directly, but use OGR_L_DeleteField() instead.
+ *
+ * This method should only be called while there are no OGRFeature
+ * objects in existance based on this OGRFeatureDefn.  The OGRFieldDefn
+ * passed in is copied, and remains the responsibility of the caller.
+ *
+ * This method is the same as the C++ method OGRFeatureDefn::DeleteFieldDefn().
+ *
+ * @param hDefn handle to the feature definition.
+ * @param iField the index of the field defintion.
+ * @return OGRERR_NONE in case of success.
+ * @since OGR 1.9.0
+ */
+
+OGRErr OGR_FD_DeleteFieldDefn( OGRFeatureDefnH hDefn, int iField )
+
+{
+    return ((OGRFeatureDefn *) hDefn)->DeleteFieldDefn( iField );
+}
+
+/************************************************************************/
+/*                          ReorderFieldDefn()                          */
+/************************************************************************/
+
+/**
+ * \brief Reorder a field definition in the feature definition
+ *
+ * To reorder a field definition in a layer definition, do not use this
+ * function directly, but use OGR_L_ReorderField() instead.
+ *
+ * This method should only be called while there are no OGRFeature
+ * objects in existance based on this OGRFeatureDefn.  The OGRFieldDefn
+ * passed in is copied, and remains the responsibility of the caller.
+ *
+ * This method is the same as the C function OGR_FD_ReorderFieldDefn().
+ *
+ * @param iOldFieldPos previous position of the field to move.
+ * @param iNewFieldPos new position of the field to move.
+ * @return OGRERR_NONE in case of success.
+ * @since OGR 1.9.0
+ */
+
+OGRErr OGRFeatureDefn::ReorderFieldDefn( int iOldFieldPos, int iNewFieldPos )
+
+{
+    if (iOldFieldPos < 0 || iOldFieldPos >= nFieldCount)
+        return OGRERR_FAILURE;
+    if (iNewFieldPos < 0 || iNewFieldPos >= nFieldCount)
+        return OGRERR_FAILURE;
+    if (iOldFieldPos == iNewFieldPos)
+        return OGRERR_NONE;
+
+    OGRFieldDefn* poFieldDefn = papoFieldDefn[iOldFieldPos];
+    if (iOldFieldPos < iNewFieldPos)
+    {
+        /* "foo","bar","baz" (0,2) --> "bar","baz","foo" */
+        memmove(papoFieldDefn + iOldFieldPos,
+                papoFieldDefn + iOldFieldPos + 1,
+                (iNewFieldPos - iOldFieldPos) * sizeof(void*));
+    }
+    else
+    {
+        /* "foo","bar","baz" (2,0) --> "baz","foo","bar" */
+        memmove(papoFieldDefn + iNewFieldPos + 1,
+                papoFieldDefn + iNewFieldPos,
+                (iOldFieldPos - iNewFieldPos) * sizeof(void*));
+    }
+    papoFieldDefn[iNewFieldPos] = poFieldDefn;
+
+    return OGRERR_NONE;
+}
+
+/************************************************************************/
+/*                      OGR_FD_ReorderFieldDefn()                       */
+/************************************************************************/
+
+/**
+ * \brief Reorder a field definition in the feature definition
+ *
+ * To reorder a field definition in a layer definition, do not use this
+ * function directly, but use OGR_L_ReorderField() instead.
+ *
+ * This method should only be called while there are no OGRFeature
+ * objects in existance based on this OGRFeatureDefn.  The OGRFieldDefn
+ * passed in is copied, and remains the responsibility of the caller.
+ *
+ * This method is the same as the C++ method OGRFeatureDefn::ReorderFieldDefn().
+ *
+ * @param hDefn handle to the feature definition.
+ * @param iOldFieldPos previous position of the field to move.
+ * @param iNewFieldPos new position of the field to move.
+ * @return OGRERR_NONE in case of success.
+ * @since OGR 1.9.0
+ */
+
+OGRErr OGR_FD_ReorderFieldDefn( OGRFeatureDefnH hDefn, int iOldFieldPos, int iNewFieldPos )
+
+{
+    return ((OGRFeatureDefn *) hDefn)->ReorderFieldDefn( iOldFieldPos, iNewFieldPos );
+}
+
+/************************************************************************/
 /*                            GetGeomType()                             */
 /************************************************************************/
 
Index: ogr/ogrsf_frmts/ogrsf_frmts.dox
===================================================================
--- ogr/ogrsf_frmts/ogrsf_frmts.dox	(révision 22312)
+++ ogr/ogrsf_frmts/ogrsf_frmts.dox	(copie de travail)
@@ -2104,6 +2104,15 @@
  <li> <b>OLCCreateField</b> / "CreateField": TRUE if this layer can create 
 new fields on the current layer using CreateField(), otherwise FALSE.<p>
 
+ <li> <b>OLCDeleteField</b> / "DeleteField": TRUE if this layer can delete
+existing fields on the current layer using DeleteField(), otherwise FALSE.<p>
+
+ <li> <b>OLCReorderField</b> / "ReorderField": TRUE if this layer can reorder
+existing fields on the current layer using ReorderField(), otherwise FALSE.<p>
+
+ <li> <b>OLCAlterFieldDefn</b> / "AlterFieldDefn": TRUE if this layer can alter
+the definition of an existing field on the current layer using AlterFieldDefn(), otherwise FALSE.<p>
+
  <li> <b>OLCDeleteFeature</b> / "DeleteFeature": TRUE if the DeleteFeature()
 method is supported on this layer, otherwise FALSE.<p>
 
@@ -2186,6 +2195,15 @@
  <li> <b>OLCCreateField</b> / "CreateField": TRUE if this layer can create 
 new fields on the current layer using CreateField(), otherwise FALSE.<p>
 
+ <li> <b>OLCDeleteField</b> / "DeleteField": TRUE if this layer can delete
+existing fields on the current layer using DeleteField(), otherwise FALSE.<p>
+
+ <li> <b>OLCReorderField</b> / "ReorderField": TRUE if this layer can reorder
+existing fields on the current layer using ReorderField(), otherwise FALSE.<p>
+
+ <li> <b>OLCAlterFieldDefn</b> / "AlterFieldDefn": TRUE if this layer can alter
+the definition of an existing field on the current layer using AlterFieldDefn(), otherwise FALSE.<p>
+
  <li> <b>OLCDeleteFeature</b> / "DeleteFeature": TRUE if the DeleteFeature()
 method is supported on this layer, otherwise FALSE.<p>
 
@@ -2377,6 +2395,14 @@
 to reflect the new field.  Applications should never modify the OGRFeatureDefn
 used by a layer directly.
 
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCCreateField capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly.
+
 This function is the same as the C function OGR_L_CreateField().
 
 @param poField field definition to write to disk. 
@@ -2398,6 +2424,14 @@
 to reflect the new field.  Applications should never modify the OGRFeatureDefn
 used by a layer directly.
 
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCCreateField capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly.
+
  This function is the same as the C++ method OGRLayer::CreateField().
 
  @param hLayer handle to the layer to write the field definition.
@@ -2410,6 +2444,185 @@
 */
 
 /**
+\fn OGRErr OGRLayer::DeleteField( int iField );
+
+\brief Delete an existing field on a layer.
+
+You must use this to delete existing fields
+on a real layer. Internally the OGRFeatureDefn for the layer will be updated
+to reflect the deleted field.  Applications should never modify the OGRFeatureDefn
+used by a layer directly.
+
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCDeleteField capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly.
+
+This function is the same as the C function OGR_L_DeleteField().
+
+@param iField index of the field to delete.
+
+@return OGRERR_NONE on success.
+
+@since OGR 1.9.0
+*/
+
+/**
+
+\fn OGRErr OGR_L_DeleteField( OGRLayerH hLayer, int iField);
+
+\brief Create a new field on a layer.
+
+You must use this to delete existing fields
+on a real layer. Internally the OGRFeatureDefn for the layer will be updated
+to reflect the deleted field.  Applications should never modify the OGRFeatureDefn
+used by a layer directly.
+
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCDeleteField capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly.
+
+This function is the same as the C++ method OGRLayer::DeleteField().
+
+@param hLayer handle to the layer.
+@param iField index of the field to delete.
+
+@return OGRERR_NONE on success.
+
+@since OGR 1.9.0
+*/
+
+/**
+\fn OGRErr OGRLayer::ReorderField( int iOldFieldPos, int iNewFieldPos );
+
+\brief Reorder an existing field on a layer.
+
+You must use this to reorder existing fields
+on a real layer. Internally the OGRFeatureDefn for the layer will be updated
+to reflect the reordering of the fields.  Applications should never modify the OGRFeatureDefn
+used by a layer directly.
+
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCReorderField capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly.
+
+This function is the same as the C function OGR_L_ReorderField().
+
+@param iOldFieldPos previous position of the field to move.
+@param iNewFieldPos new position of the field to move.
+
+@return OGRERR_NONE on success.
+
+@since OGR 1.9.0
+*/
+
+/**
+
+\fn OGRErr OGR_L_ReorderField( OGRLayerH hLayer, int iOldFieldPos, int iNewFieldPos );
+
+\brief Reorder an existing field on a layer.
+
+You must use this to reorder existing fields
+on a real layer. Internally the OGRFeatureDefn for the layer will be updated
+to reflect the reordering of the fields.  Applications should never modify the OGRFeatureDefn
+used by a layer directly.
+
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCReorderField capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly.
+
+This function is the same as the C++ method OGRLayer::ReorderField().
+
+@param hLayer handle to the layer.
+@param iOldFieldPos previous position of the field to move.
+@param iNewFieldPos new position of the field to move.
+
+@return OGRERR_NONE on success.
+
+@since OGR 1.9.0
+*/
+
+/**
+\fn OGRErr OGRLayer::AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
+
+\brief Alter the definition of an existing field on a layer.
+
+You must use this to alter the definition of an existing field of a real layer.
+Internally the OGRFeatureDefn for the layer will be updated
+to reflect the altered field.  Applications should never modify the OGRFeatureDefn
+used by a layer directly.
+
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCAlterFieldDefn capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly. Some drivers might also not support
+all update flags.
+
+This function is the same as the C function OGR_L_AlterFieldDefn().
+
+@param iField index of the field whose definition must be altered.
+@param poNewFieldDefn new field definition
+@param nFlags combination of ALTER_NAME_FLAG, ALTER_TYPE_FLAG and ALTER_WIDTH_PRECISION_FLAG
+to indicate which of the name and/or type and/or width and precision fields from the new field
+definition must be taken into account.
+
+@return OGRERR_NONE on success.
+
+@since OGR 1.9.0
+*/
+
+/**
+\fn OGRErr OGR_L_AlterFieldDefn( OGRLayerH hLayer, int iField, OGRFieldDefnH hNewFieldDefn, int nFlags )
+
+\brief Alter the definition of an existing field on a layer.
+
+You must use this to alter the definition of an existing field of a real layer.
+Internally the OGRFeatureDefn for the layer will be updated
+to reflect the altered field.  Applications should never modify the OGRFeatureDefn
+used by a layer directly.
+
+This function should not be called while there are feature objects in existance that
+were obtained or created with the previous layer definition.
+
+Not all drivers support this method. You can query a layer to check if it supports it
+with the OLCAlterFieldDefn capability. Some drivers may only support this method while
+there are still no features in the layer. When it is supported, the existings features of the
+backing file/database should be updated accordingly. Some drivers might also not support
+all update flags.
+
+This function is the same as the C++ method OGRLayer::AlterFieldDefn().
+
+@param hLayer handle to the layer.
+@param iField index of the field whose definition must be altered.
+@param hNewFieldDefn new field definition
+@param nFlags combination of ALTER_NAME_FLAG, ALTER_TYPE_FLAG and ALTER_WIDTH_PRECISION_FLAG
+to indicate which of the name and/or type and/or width and precision fields from the new field
+definition must be taken into account.
+
+@return OGRERR_NONE on success.
+
+@since OGR 1.9.0
+*/
+
+/**
  \fn  void OGRLayer::GetStyleTable();
 
  \brief Returns layer style table.
Index: ogr/ogrsf_frmts/ogrsf_frmts.h
===================================================================
--- ogr/ogrsf_frmts/ogrsf_frmts.h	(révision 22312)
+++ ogr/ogrsf_frmts/ogrsf_frmts.h	(copie de travail)
@@ -95,6 +95,9 @@
 
     virtual OGRErr      CreateField( OGRFieldDefn *poField,
                                      int bApproxOK = TRUE );
+    virtual OGRErr      DeleteField( int iField );
+    virtual OGRErr      ReorderField( int iOldFieldPos, int iNewFieldPos );
+    virtual OGRErr      AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
 
     virtual OGRErr      SyncToDisk();
 
Index: ogr/ogrsf_frmts/generic/ogrlayer.cpp
===================================================================
--- ogr/ogrsf_frmts/generic/ogrlayer.cpp	(révision 22312)
+++ ogr/ogrsf_frmts/generic/ogrlayer.cpp	(copie de travail)
@@ -485,6 +485,93 @@
 }
 
 /************************************************************************/
+/*                            DeleteField()                             */
+/************************************************************************/
+
+OGRErr OGRLayer::DeleteField( int iField )
+
+{
+    (void) iField;
+
+    CPLError( CE_Failure, CPLE_NotSupported,
+              "DeleteField() not supported by this layer.\n" );
+
+    return OGRERR_UNSUPPORTED_OPERATION;
+}
+
+/************************************************************************/
+/*                         OGR_L_DeleteField()                          */
+/************************************************************************/
+
+OGRErr OGR_L_DeleteField( OGRLayerH hLayer, int iField )
+
+{
+    VALIDATE_POINTER1( hLayer, "OGR_L_DeleteField", OGRERR_INVALID_HANDLE );
+
+    return ((OGRLayer *) hLayer)->DeleteField( iField );
+}
+
+/************************************************************************/
+/*                            ReorderField()                            */
+/************************************************************************/
+
+OGRErr OGRLayer::ReorderField( int iOldFieldPos, int iNewFieldPos )
+
+{
+    (void) iOldFieldPos;
+    (void) iNewFieldPos;
+
+    CPLError( CE_Failure, CPLE_NotSupported,
+              "ReorderField() not supported by this layer.\n" );
+
+    return OGRERR_UNSUPPORTED_OPERATION;
+}
+
+/************************************************************************/
+/*                        OGR_L_ReorderField()                          */
+/************************************************************************/
+
+OGRErr OGR_L_ReorderField( OGRLayerH hLayer, int iOldFieldPos, int iNewFieldPos )
+
+{
+    VALIDATE_POINTER1( hLayer, "OGR_L_ReorderField", OGRERR_INVALID_HANDLE );
+
+    return ((OGRLayer *) hLayer)->ReorderField( iOldFieldPos, iNewFieldPos );
+}
+
+/************************************************************************/
+/*                           AlterFieldDefn()                           */
+/************************************************************************/
+
+OGRErr OGRLayer::AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn,
+                                 int nFlags )
+
+{
+    (void) iField;
+    (void) poNewFieldDefn;
+    (void) nFlags;
+
+    CPLError( CE_Failure, CPLE_NotSupported,
+              "AlterFieldDefn() not supported by this layer.\n" );
+
+    return OGRERR_UNSUPPORTED_OPERATION;
+}
+
+/************************************************************************/
+/*                        OGR_L_AlterFieldDefn()                        */
+/************************************************************************/
+
+OGRErr OGR_L_AlterFieldDefn( OGRLayerH hLayer, int iField, OGRFieldDefnH hNewFieldDefn,
+                             int nFlags )
+
+{
+    VALIDATE_POINTER1( hLayer, "OGR_L_AlterFieldDefn", OGRERR_INVALID_HANDLE );
+    VALIDATE_POINTER1( hNewFieldDefn, "OGR_L_AlterFieldDefn", OGRERR_INVALID_HANDLE );
+
+    return ((OGRLayer *) hLayer)->AlterFieldDefn( iField, (OGRFieldDefn*) hNewFieldDefn, nFlags );
+}
+
+/************************************************************************/
 /*                          StartTransaction()                          */
 /************************************************************************/
 
Index: ogr/ogrsf_frmts/shape/shapefil.h
===================================================================
--- ogr/ogrsf_frmts/shape/shapefil.h	(révision 22312)
+++ ogr/ogrsf_frmts/shape/shapefil.h	(copie de travail)
@@ -555,6 +555,13 @@
 int	SHPAPI_CALL
       DBFDeleteField( DBFHandle hDBF, int iField );
 
+int SHPAPI_CALL
+      DBFReorderField( DBFHandle psDBF, int iOldFieldPos, int iNewFieldPos );
+
+int SHPAPI_CALL
+      DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName,
+                         char chType, int nWidth, int nDecimals );
+
 DBFFieldType SHPAPI_CALL
       DBFGetFieldInfo( DBFHandle psDBF, int iField, 
                        char * pszFieldName, int * pnWidth, int * pnDecimals );
Index: ogr/ogrsf_frmts/shape/ogrshapelayer.cpp
===================================================================
--- ogr/ogrsf_frmts/shape/ogrshapelayer.cpp	(révision 22326)
+++ ogr/ogrsf_frmts/shape/ogrshapelayer.cpp	(copie de travail)
@@ -809,7 +809,16 @@
 
     else if( EQUAL(pszCap,OLCCreateField) )
         return bUpdateAccess;
-    
+
+    else if( EQUAL(pszCap,OLCDeleteField) )
+        return bUpdateAccess;
+
+    else if( EQUAL(pszCap,OLCReorderField) )
+        return bUpdateAccess;
+
+    else if( EQUAL(pszCap,OLCAlterFieldDefn) )
+        return bUpdateAccess;
+
     else if( EQUAL(pszCap,OLCIgnoreFields) )
         return TRUE;
 
@@ -1004,6 +1013,130 @@
 }
 
 /************************************************************************/
+/*                            DeleteField()                             */
+/************************************************************************/
+
+OGRErr OGRShapeLayer::DeleteField( int iField )
+{
+    if( !bUpdateAccess )
+    {
+        CPLError( CE_Failure, CPLE_NotSupported,
+                  "Can't delete fields on a read-only shapefile layer.");
+        return OGRERR_FAILURE;
+    }
+
+    if (iField < 0 || iField >= poFeatureDefn->GetFieldCount())
+    {
+        CPLError( CE_Failure, CPLE_NotSupported,
+                  "Invalid field index");
+        return OGRERR_FAILURE;
+    }
+
+    if ( DBFDeleteField( hDBF, iField ) )
+    {
+        return poFeatureDefn->DeleteFieldDefn( iField );
+    }
+    else
+        return OGRERR_FAILURE;
+}
+
+/************************************************************************/
+/*                            ReorderField()                            */
+/************************************************************************/
+
+OGRErr OGRShapeLayer::ReorderField( int iOldFieldPos, int iNewFieldPos )
+{
+    if( !bUpdateAccess )
+    {
+        CPLError( CE_Failure, CPLE_NotSupported,
+                  "Can't reorder fields on a read-only shapefile layer.");
+        return OGRERR_FAILURE;
+    }
+
+    if (iOldFieldPos < 0 || iOldFieldPos >= poFeatureDefn->GetFieldCount())
+    {
+        CPLError( CE_Failure, CPLE_NotSupported,
+                  "Invalid field index");
+        return OGRERR_FAILURE;
+    }
+    if (iNewFieldPos < 0 || iNewFieldPos >= poFeatureDefn->GetFieldCount())
+    {
+        CPLError( CE_Failure, CPLE_NotSupported,
+                  "Invalid field index");
+        return OGRERR_FAILURE;
+    }
+
+    if ( DBFReorderField( hDBF, iOldFieldPos, iNewFieldPos ) )
+    {
+        return poFeatureDefn->ReorderFieldDefn( iOldFieldPos, iNewFieldPos );
+    }
+    else
+        return OGRERR_FAILURE;
+}
+
+/************************************************************************/
+/*                           AlterFieldDefn()                           */
+/************************************************************************/
+
+OGRErr OGRShapeLayer::AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags )
+{
+    if( !bUpdateAccess )
+    {
+        CPLError( CE_Failure, CPLE_NotSupported,
+                  "Can't alter field definition on a read-only shapefile layer.");
+        return OGRERR_FAILURE;
+    }
+
+    if (iField < 0 || iField >= poFeatureDefn->GetFieldCount())
+    {
+        CPLError( CE_Failure, CPLE_NotSupported,
+                  "Invalid field index");
+        return OGRERR_FAILURE;
+    }
+
+    OGRFieldDefn* poFieldDefn = poFeatureDefn->GetFieldDefn(iField);
+
+    if ((nFlags & ALTER_TYPE_FLAG) &&
+        poNewFieldDefn->GetType() != poFieldDefn->GetType())
+    {
+        CPLError( CE_Failure, CPLE_NotSupported, "Cannot alter field type");
+        return OGRERR_FAILURE;
+    }
+
+    char chNativeType;
+    char            szFieldName[20];
+    int             nWidth, nPrecision;
+    DBFFieldType    eDBFType;
+
+    chNativeType = DBFGetNativeFieldType( hDBF, iField );
+    eDBFType = DBFGetFieldInfo( hDBF, iField, szFieldName,
+                                &nWidth, &nPrecision );
+
+    if (nFlags & ALTER_NAME_FLAG)
+        strncpy(szFieldName, poNewFieldDefn->GetNameRef(), 10);
+    if (nFlags & ALTER_WIDTH_PRECISION_FLAG)
+    {
+        nWidth = poNewFieldDefn->GetWidth();
+        nPrecision = poNewFieldDefn->GetPrecision();
+    }
+
+    if ( DBFAlterFieldDefn( hDBF, iField, szFieldName,
+                            chNativeType, nWidth, nPrecision) )
+    {
+        if (nFlags & ALTER_NAME_FLAG)
+            poFieldDefn->SetName(szFieldName);
+        if (nFlags & ALTER_WIDTH_PRECISION_FLAG)
+        {
+            poFieldDefn->SetWidth(nWidth);
+            poFieldDefn->SetPrecision(nPrecision);
+        }
+        return OGRERR_NONE;
+    }
+    else
+        return OGRERR_FAILURE;
+}
+
+/************************************************************************/
 /*                           GetSpatialRef()                            */
 /************************************************************************/
 
Index: ogr/ogrsf_frmts/shape/dbfopen.c
===================================================================
--- ogr/ogrsf_frmts/shape/dbfopen.c	(révision 22312)
+++ ogr/ogrsf_frmts/shape/dbfopen.c	(copie de travail)
@@ -802,6 +802,10 @@
     char        chFieldFill;
     SAOffset    nRecordOffset;
 
+    /* make sure that everything is written in .dbf */
+    if( !DBFFlushRecord( psDBF ) )
+        return -1;
+
 /* -------------------------------------------------------------------- */
 /*      Do some checking to ensure we can add records to this file.     */
 /* -------------------------------------------------------------------- */
@@ -1836,7 +1840,7 @@
     psDBF->nRecordLength -= nDeletedFieldSize;
 
     /* overwrite field information in header */
-    memcpy(psDBF->pszHeader + iField*32,
+    memmove(psDBF->pszHeader + iField*32,
            psDBF->pszHeader + (iField+1)*32,
            sizeof(char) * (psDBF->nFields - iField)*32);
 
@@ -1886,3 +1890,299 @@
 
     return TRUE;
 }
+
+/************************************************************************/
+/*                          DBFReorderField()                           */
+/*                                                                      */
+/*      Reorder a field in a .dbf file                                  */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFReorderField( DBFHandle psDBF, int iOldFieldPos, int iNewFieldPos )
+{
+    int nOldFieldOffset, nFieldSize, nFieldDecimals;
+    char chFieldType;
+    SAOffset nRecordOffset;
+    char* pszRecord;
+    char* pszFieldToMove;
+    int i, iRecord;
+    int nBytesToMove = 0;
+    char szFieldHeader[32];
+
+    if (iOldFieldPos < 0 || iOldFieldPos >= psDBF->nFields)
+        return FALSE;
+
+    if (iNewFieldPos < 0 || iNewFieldPos >= psDBF->nFields)
+        return FALSE;
+
+    if (iOldFieldPos == iNewFieldPos)
+        return TRUE; /* nothing to do */
+
+    /* make sure that everything is written in .dbf */
+    if( !DBFFlushRecord( psDBF ) )
+        return FALSE;
+
+    /* get information about field to be moved */
+    nOldFieldOffset = psDBF->panFieldOffset[iOldFieldPos];
+    nFieldSize = psDBF->panFieldSize[iOldFieldPos];
+    nFieldDecimals = psDBF->panFieldDecimals[iOldFieldPos];
+    chFieldType = psDBF->pachFieldType[iOldFieldPos];
+
+    /* update fields info */
+    if(iOldFieldPos < iNewFieldPos)
+    {
+        /* "foo","bar","baz" (0,2) --> "bar","baz","foo" */
+        for (i = iOldFieldPos + 1; i <= iNewFieldPos; i++)
+        {
+            nBytesToMove += psDBF->panFieldSize[i];
+            psDBF->panFieldOffset[i-1] = psDBF->panFieldOffset[i] - nFieldSize;
+            psDBF->panFieldSize[i-1] = psDBF->panFieldSize[i];
+            psDBF->panFieldDecimals[i-1] = psDBF->panFieldDecimals[i];
+            psDBF->pachFieldType[i-1] = psDBF->pachFieldType[i];
+        }
+    }
+    else
+    {
+        /* "foo","bar","baz" (2,0) --> "baz","foo","bar" */
+        for (i = iOldFieldPos - 1; i >= iNewFieldPos; i--)
+        {
+            nBytesToMove += psDBF->panFieldSize[i];
+            psDBF->panFieldOffset[i+1] = psDBF->panFieldOffset[i] + nFieldSize;
+            psDBF->panFieldSize[i+1] = psDBF->panFieldSize[i];
+            psDBF->panFieldDecimals[i+1] = psDBF->panFieldDecimals[i];
+            psDBF->pachFieldType[i+1] = psDBF->pachFieldType[i];
+        }
+    }
+
+    if (iNewFieldPos > 0)
+        psDBF->panFieldOffset[iNewFieldPos] = psDBF->panFieldOffset[iNewFieldPos-1] +
+                                              psDBF->panFieldSize[iNewFieldPos-1];
+    else
+        psDBF->panFieldOffset[iNewFieldPos] = 1;
+    psDBF->panFieldSize[iNewFieldPos] = nFieldSize;
+    psDBF->panFieldDecimals[iNewFieldPos] = nFieldDecimals;
+    psDBF->pachFieldType[iNewFieldPos] = chFieldType;
+
+    /* overwrite field information in header */
+    memcpy(szFieldHeader, psDBF->pszHeader + iOldFieldPos*32, 32);
+    if (iOldFieldPos < iNewFieldPos)
+    {
+        memmove(psDBF->pszHeader + iOldFieldPos*32,
+                psDBF->pszHeader + iOldFieldPos*32 + 32,
+                (iNewFieldPos - iOldFieldPos) * 32);
+    }
+    else
+    {
+        memmove(psDBF->pszHeader + iNewFieldPos*32 + 32,
+                psDBF->pszHeader + iNewFieldPos*32,
+                (iOldFieldPos - iNewFieldPos) * 32);
+    }
+    memcpy(psDBF->pszHeader + iNewFieldPos*32, szFieldHeader, 32);
+
+    /* we're done if we're dealing with not yet created .dbf */
+    if ( psDBF->bNoHeader && psDBF->nRecords == 0 )
+        return TRUE;
+
+    /* force update of header with new header and record length */
+    psDBF->bNoHeader = TRUE;
+    DBFUpdateHeader( psDBF );
+
+    /* alloc record */
+    pszRecord = (char *) malloc(sizeof(char) * psDBF->nRecordLength);
+    pszFieldToMove = (char *) malloc(sizeof(char) * nFieldSize);
+
+    /* shift fields in records */
+    for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++)
+    {
+        nRecordOffset =
+            psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
+
+        /* load record */
+        psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
+        psDBF->sHooks.FRead( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
+
+        memcpy(pszFieldToMove, pszRecord + nOldFieldOffset, nFieldSize);
+        if(iOldFieldPos < iNewFieldPos)
+        {
+            memmove(pszRecord + nOldFieldOffset,
+                    pszRecord + nOldFieldOffset + nFieldSize, nBytesToMove);
+        }
+        else
+        {
+            memmove(pszRecord + psDBF->panFieldOffset[iNewFieldPos] + nFieldSize,
+                    pszRecord + psDBF->panFieldOffset[iNewFieldPos], nBytesToMove);
+        }
+        memcpy(pszRecord + psDBF->panFieldOffset[iNewFieldPos], pszFieldToMove,
+               nFieldSize);
+
+        /* write record */
+        psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
+        psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
+    }
+
+    /* free record */
+    free(pszRecord);
+    free(pszFieldToMove);
+
+    return TRUE;
+}
+
+
+/************************************************************************/
+/*                          DBFAlterFieldDefn()                         */
+/*                                                                      */
+/*      Alter a field definition in a .dbf file                         */
+/************************************************************************/
+
+int SHPAPI_CALL
+DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName,
+                    char chType, int nWidth, int nDecimals )
+{
+    int   i;
+    int   iRecord;
+    int   nOffset;
+    int   nOldWidth;
+    int   nOldRecordLength;
+    int   nRecordOffset;
+    char* pszFInfo;
+
+    if (iField < 0 || iField >= psDBF->nFields)
+        return FALSE;
+
+    /* make sure that everything is written in .dbf */
+    if( !DBFFlushRecord( psDBF ) )
+        return FALSE;
+
+    nOffset = psDBF->panFieldOffset[iField];
+    nOldWidth = psDBF->panFieldSize[iField];
+    nOldRecordLength = psDBF->nRecordLength;
+
+/* -------------------------------------------------------------------- */
+/*      Do some checking to ensure we can add records to this file.     */
+/* -------------------------------------------------------------------- */
+    if( nWidth < 1 )
+        return -1;
+
+    if( nWidth > 255 )
+        nWidth = 255;
+
+/* -------------------------------------------------------------------- */
+/*      Assign the new field information fields.                        */
+/* -------------------------------------------------------------------- */
+    psDBF->panFieldSize[iField] = nWidth;
+    psDBF->panFieldDecimals[iField] = nDecimals;
+    psDBF->pachFieldType[iField] = chType;
+
+/* -------------------------------------------------------------------- */
+/*      Update the header information.                                  */
+/* -------------------------------------------------------------------- */
+    pszFInfo = psDBF->pszHeader + 32 * iField;
+
+    for( i = 0; i < 32; i++ )
+        pszFInfo[i] = '\0';
+
+    if( (int) strlen(pszFieldName) < 10 )
+        strncpy( pszFInfo, pszFieldName, strlen(pszFieldName));
+    else
+        strncpy( pszFInfo, pszFieldName, 10);
+
+    pszFInfo[11] = psDBF->pachFieldType[iField];
+
+    if( chType == 'C' )
+    {
+        pszFInfo[16] = (unsigned char) (nWidth % 256);
+        pszFInfo[17] = (unsigned char) (nWidth / 256);
+    }
+    else
+    {
+        pszFInfo[16] = (unsigned char) nWidth;
+        pszFInfo[17] = (unsigned char) nDecimals;
+    }
+
+/* -------------------------------------------------------------------- */
+/*      Update offsets                                                  */
+/* -------------------------------------------------------------------- */
+    if (nWidth != nOldWidth)
+    {
+        for (i = iField + 1; i < psDBF->nFields; i++)
+             psDBF->panFieldOffset[i] += nWidth - nOldWidth;
+        psDBF->nRecordLength += nWidth - nOldWidth;
+
+        psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord,
+                                                     psDBF->nRecordLength);
+    }
+
+    /* we're done if we're dealing with not yet created .dbf */
+    if ( psDBF->bNoHeader && psDBF->nRecords == 0 )
+        return TRUE;
+
+    /* force update of header with new header and record length */
+    psDBF->bNoHeader = TRUE;
+    DBFUpdateHeader( psDBF );
+
+    if (nWidth < nOldWidth)
+    {
+        char* pszRecord = (char *) malloc(sizeof(char) * nOldRecordLength);
+
+        /* move records to their new positions */
+        for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++)
+        {
+            nRecordOffset =
+                nOldRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
+
+            /* load record */
+            psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
+            psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp );
+
+            if (nOffset + nOldWidth < nOldRecordLength)
+            {
+                memmove( pszRecord + nOffset + nWidth,
+                         pszRecord + nOffset + nOldWidth,
+                         nOldRecordLength - (nOffset + nOldWidth));
+            }
+
+            nRecordOffset =
+                psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
+
+            /* write record */
+            psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
+            psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
+        }
+
+        free(pszRecord);
+    }
+    else if (nWidth > nOldWidth)
+    {
+        char* pszRecord = (char *) malloc(sizeof(char) * psDBF->nRecordLength);
+
+        /* move records to their new positions */
+        for (iRecord = psDBF->nRecords - 1; iRecord >= 0; iRecord--)
+        {
+            nRecordOffset =
+                nOldRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
+
+            /* load record */
+            psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
+            psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp );
+
+            if (nOffset + nOldWidth < nOldRecordLength)
+            {
+                memmove( pszRecord + nOffset + nWidth,
+                         pszRecord + nOffset + nOldWidth,
+                         nOldRecordLength - (nOffset + nOldWidth));
+            }
+            memset(pszRecord + nOffset + nOldWidth, ' ', nWidth - nOldWidth);
+
+            nRecordOffset =
+                psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
+
+            /* write record */
+            psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
+            psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
+        }
+
+        free(pszRecord);
+    }
+
+    return TRUE;
+}
Index: ogr/ogrsf_frmts/shape/ogrshape.h
===================================================================
--- ogr/ogrsf_frmts/shape/ogrshape.h	(révision 22312)
+++ ogr/ogrsf_frmts/shape/ogrshape.h	(copie de travail)
@@ -121,6 +121,9 @@
 
     virtual OGRErr      CreateField( OGRFieldDefn *poField,
                                      int bApproxOK = TRUE );
+    virtual OGRErr      DeleteField( int iField );
+    virtual OGRErr      ReorderField( int iOldFieldPos, int iNewFieldPos );
+    virtual OGRErr      AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
 
     virtual OGRSpatialReference *GetSpatialRef();
     
Index: swig/include/ogr.i
===================================================================
--- swig/include/ogr.i	(révision 22312)
+++ swig/include/ogr.i	(copie de travail)
@@ -208,6 +208,11 @@
 
 %constant NullFID = -1;
 
+%constant ALTER_NAME_FLAG = 1;
+%constant ALTER_TYPE_FLAG = 2;
+%constant ALTER_WIDTH_PRECISION_FLAG = 4;
+%constant ALTER_ALL_FLAG = 1 + 2 + 4;
+
 %constant char *OLCRandomRead          = "RandomRead";
 %constant char *OLCSequentialWrite     = "SequentialWrite";
 %constant char *OLCRandomWrite         = "RandomWrite";
@@ -215,6 +220,9 @@
 %constant char *OLCFastFeatureCount    = "FastFeatureCount";
 %constant char *OLCFastGetExtent       = "FastGetExtent";
 %constant char *OLCCreateField         = "CreateField";
+%constant char *OLCDeleteField         = "DeleteField";
+%constant char *OLCReorderField        = "ReorderField";
+%constant char *OLCAlterFieldDefn      = "AlterFieldDefn";
 %constant char *OLCTransactions        = "Transactions";
 %constant char *OLCDeleteFeature       = "DeleteFeature";
 %constant char *OLCFastSetNextByIndex  = "FastSetNextByIndex";
@@ -242,6 +250,9 @@
 #define OLCFastFeatureCount    "FastFeatureCount"
 #define OLCFastGetExtent       "FastGetExtent"
 #define OLCCreateField         "CreateField"
+#define OLCDeleteField         "DeleteField"
+#define OLCReorderField        "ReorderField"
+#define OLCAlterFieldDefn      "AlterFieldDefn"
 #define OLCTransactions        "Transactions"
 #define OLCDeleteFeature       "DeleteFeature"
 #define OLCFastSetNextByIndex  "FastSetNextByIndex"
@@ -633,7 +644,24 @@
     return OGR_L_CreateField(self, field_def, approx_ok);
   }
 %clear OGRFieldDefnShadow *field_def;
-  
+
+  OGRErr DeleteField(int iField)
+  {
+    return OGR_L_DeleteField(self, iField);
+  }
+
+  OGRErr ReorderField(int iOldFieldPos, int iNewFieldPos)
+  {
+    return OGR_L_ReorderField(self, iOldFieldPos, iNewFieldPos);
+  }
+
+%apply Pointer NONNULL {OGRFieldDefnShadow *field_def};
+  OGRErr AlterFieldDefn(int iField, OGRFieldDefnShadow* field_def, int nFlags)
+  {
+    return OGR_L_AlterFieldDefn(self, iField, field_def, nFlags);
+  }
+%clear OGRFieldDefnShadow *field_def;
+
   OGRErr StartTransaction() {
     return OGR_L_StartTransaction(self);
   }
Index: swig/python/extensions/ogr_wrap.cpp
===================================================================
--- swig/python/extensions/ogr_wrap.cpp	(révision 22312)
+++ swig/python/extensions/ogr_wrap.cpp	(copie de travail)
@@ -3469,6 +3469,15 @@
 SWIGINTERN OGRErr OGRLayerShadow_CreateField(OGRLayerShadow *self,OGRFieldDefnShadow *field_def,int approx_ok=1){
     return OGR_L_CreateField(self, field_def, approx_ok);
   }
+SWIGINTERN OGRErr OGRLayerShadow_DeleteField(OGRLayerShadow *self,int iField){
+    return OGR_L_DeleteField(self, iField);
+  }
+SWIGINTERN OGRErr OGRLayerShadow_ReorderField(OGRLayerShadow *self,int iOldFieldPos,int iNewFieldPos){
+    return OGR_L_ReorderField(self, iOldFieldPos, iNewFieldPos);
+  }
+SWIGINTERN OGRErr OGRLayerShadow_AlterFieldDefn(OGRLayerShadow *self,int iField,OGRFieldDefnShadow *field_def,int nFlags){
+    return OGR_L_AlterFieldDefn(self, iField, field_def, nFlags);
+  }
 SWIGINTERN OGRErr OGRLayerShadow_StartTransaction(OGRLayerShadow *self){
     return OGR_L_StartTransaction(self);
   }
@@ -6704,6 +6713,212 @@
 }
 
 
+SWIGINTERN PyObject *_wrap_Layer_DeleteField(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ;
+  int arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  OGRErr result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:Layer_DeleteField",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_DeleteField" "', argument " "1"" of type '" "OGRLayerShadow *""'"); 
+  }
+  arg1 = reinterpret_cast< OGRLayerShadow * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_DeleteField" "', argument " "2"" of type '" "int""'");
+  } 
+  arg2 = static_cast< int >(val2);
+  {
+    if ( bUseExceptions ) {
+      CPLErrorReset();
+    }
+    result = (OGRErr)OGRLayerShadow_DeleteField(arg1,arg2);
+    if ( bUseExceptions ) {
+      CPLErr eclass = CPLGetLastErrorType();
+      if ( eclass == CE_Failure || eclass == CE_Fatal ) {
+        SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
+      }
+    }
+  }
+  {
+    /* %typemap(out) OGRErr */
+    if ( result != 0 && bUseExceptions) {
+      PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) );
+      SWIG_fail;
+    }
+  }
+  {
+    /* %typemap(ret) OGRErr */
+    if (resultobj == Py_None ) {
+      Py_DECREF(resultobj);
+      resultobj = 0;
+    }
+    if (resultobj == 0) {
+      resultobj = PyInt_FromLong( result );
+    }
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Layer_ReorderField(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ;
+  int arg2 ;
+  int arg3 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  int val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  OGRErr result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOO:Layer_ReorderField",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_ReorderField" "', argument " "1"" of type '" "OGRLayerShadow *""'"); 
+  }
+  arg1 = reinterpret_cast< OGRLayerShadow * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_ReorderField" "', argument " "2"" of type '" "int""'");
+  } 
+  arg2 = static_cast< int >(val2);
+  ecode3 = SWIG_AsVal_int(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Layer_ReorderField" "', argument " "3"" of type '" "int""'");
+  } 
+  arg3 = static_cast< int >(val3);
+  {
+    if ( bUseExceptions ) {
+      CPLErrorReset();
+    }
+    result = (OGRErr)OGRLayerShadow_ReorderField(arg1,arg2,arg3);
+    if ( bUseExceptions ) {
+      CPLErr eclass = CPLGetLastErrorType();
+      if ( eclass == CE_Failure || eclass == CE_Fatal ) {
+        SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
+      }
+    }
+  }
+  {
+    /* %typemap(out) OGRErr */
+    if ( result != 0 && bUseExceptions) {
+      PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) );
+      SWIG_fail;
+    }
+  }
+  {
+    /* %typemap(ret) OGRErr */
+    if (resultobj == Py_None ) {
+      Py_DECREF(resultobj);
+      resultobj = 0;
+    }
+    if (resultobj == 0) {
+      resultobj = PyInt_FromLong( result );
+    }
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Layer_AlterFieldDefn(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ;
+  int arg2 ;
+  OGRFieldDefnShadow *arg3 = (OGRFieldDefnShadow *) 0 ;
+  int arg4 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
+  int val4 ;
+  int ecode4 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
+  OGRErr result;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:Layer_AlterFieldDefn",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_OGRLayerShadow, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Layer_AlterFieldDefn" "', argument " "1"" of type '" "OGRLayerShadow *""'"); 
+  }
+  arg1 = reinterpret_cast< OGRLayerShadow * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Layer_AlterFieldDefn" "', argument " "2"" of type '" "int""'");
+  } 
+  arg2 = static_cast< int >(val2);
+  res3 = SWIG_ConvertPtr(obj2, &argp3,SWIGTYPE_p_OGRFieldDefnShadow, 0 |  0 );
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Layer_AlterFieldDefn" "', argument " "3"" of type '" "OGRFieldDefnShadow *""'"); 
+  }
+  arg3 = reinterpret_cast< OGRFieldDefnShadow * >(argp3);
+  ecode4 = SWIG_AsVal_int(obj3, &val4);
+  if (!SWIG_IsOK(ecode4)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Layer_AlterFieldDefn" "', argument " "4"" of type '" "int""'");
+  } 
+  arg4 = static_cast< int >(val4);
+  {
+    if (!arg3) {
+      SWIG_exception(SWIG_ValueError,"Received a NULL pointer.");
+    }
+  }
+  {
+    if ( bUseExceptions ) {
+      CPLErrorReset();
+    }
+    result = (OGRErr)OGRLayerShadow_AlterFieldDefn(arg1,arg2,arg3,arg4);
+    if ( bUseExceptions ) {
+      CPLErr eclass = CPLGetLastErrorType();
+      if ( eclass == CE_Failure || eclass == CE_Fatal ) {
+        SWIG_exception( SWIG_RuntimeError, CPLGetLastErrorMsg() );
+      }
+    }
+  }
+  {
+    /* %typemap(out) OGRErr */
+    if ( result != 0 && bUseExceptions) {
+      PyErr_SetString( PyExc_RuntimeError, OGRErrMessages(result) );
+      SWIG_fail;
+    }
+  }
+  {
+    /* %typemap(ret) OGRErr */
+    if (resultobj == Py_None ) {
+      Py_DECREF(resultobj);
+      resultobj = 0;
+    }
+    if (resultobj == 0) {
+      resultobj = PyInt_FromLong( result );
+    }
+  }
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_Layer_StartTransaction(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   OGRLayerShadow *arg1 = (OGRLayerShadow *) 0 ;
@@ -16753,6 +16968,9 @@
 		"\n"
 		"OGRERR_NONE on success. \n"
 		""},
+	 { (char *)"Layer_DeleteField", _wrap_Layer_DeleteField, METH_VARARGS, (char *)"Layer_DeleteField(Layer self, int iField) -> OGRErr"},
+	 { (char *)"Layer_ReorderField", _wrap_Layer_ReorderField, METH_VARARGS, (char *)"Layer_ReorderField(Layer self, int iOldFieldPos, int iNewFieldPos) -> OGRErr"},
+	 { (char *)"Layer_AlterFieldDefn", _wrap_Layer_AlterFieldDefn, METH_VARARGS, (char *)"Layer_AlterFieldDefn(Layer self, int iField, FieldDefn field_def, int nFlags) -> OGRErr"},
 	 { (char *)"Layer_StartTransaction", _wrap_Layer_StartTransaction, METH_VARARGS, (char *)"\n"
 		"Layer_StartTransaction(Layer self) -> OGRErr\n"
 		"\n"
@@ -19838,6 +20056,10 @@
   SWIG_Python_SetConstant(d, "wkbXDR",SWIG_From_int(static_cast< int >(0)));
   SWIG_Python_SetConstant(d, "wkbNDR",SWIG_From_int(static_cast< int >(1)));
   SWIG_Python_SetConstant(d, "NullFID",SWIG_From_int(static_cast< int >(-1)));
+  SWIG_Python_SetConstant(d, "ALTER_NAME_FLAG",SWIG_From_int(static_cast< int >(1)));
+  SWIG_Python_SetConstant(d, "ALTER_TYPE_FLAG",SWIG_From_int(static_cast< int >(2)));
+  SWIG_Python_SetConstant(d, "ALTER_WIDTH_PRECISION_FLAG",SWIG_From_int(static_cast< int >(4)));
+  SWIG_Python_SetConstant(d, "ALTER_ALL_FLAG",SWIG_From_int(static_cast< int >(1+2+4)));
   SWIG_Python_SetConstant(d, "OLCRandomRead",SWIG_FromCharPtr("RandomRead"));
   SWIG_Python_SetConstant(d, "OLCSequentialWrite",SWIG_FromCharPtr("SequentialWrite"));
   SWIG_Python_SetConstant(d, "OLCRandomWrite",SWIG_FromCharPtr("RandomWrite"));
@@ -19845,6 +20067,9 @@
   SWIG_Python_SetConstant(d, "OLCFastFeatureCount",SWIG_FromCharPtr("FastFeatureCount"));
   SWIG_Python_SetConstant(d, "OLCFastGetExtent",SWIG_FromCharPtr("FastGetExtent"));
   SWIG_Python_SetConstant(d, "OLCCreateField",SWIG_FromCharPtr("CreateField"));
+  SWIG_Python_SetConstant(d, "OLCDeleteField",SWIG_FromCharPtr("DeleteField"));
+  SWIG_Python_SetConstant(d, "OLCReorderField",SWIG_FromCharPtr("ReorderField"));
+  SWIG_Python_SetConstant(d, "OLCAlterFieldDefn",SWIG_FromCharPtr("AlterFieldDefn"));
   SWIG_Python_SetConstant(d, "OLCTransactions",SWIG_FromCharPtr("Transactions"));
   SWIG_Python_SetConstant(d, "OLCDeleteFeature",SWIG_FromCharPtr("DeleteFeature"));
   SWIG_Python_SetConstant(d, "OLCFastSetNextByIndex",SWIG_FromCharPtr("FastSetNextByIndex"));
Index: swig/python/osgeo/ogr.py
===================================================================
--- swig/python/osgeo/ogr.py	(révision 22312)
+++ swig/python/osgeo/ogr.py	(copie de travail)
@@ -103,6 +103,10 @@
 wkbXDR = _ogr.wkbXDR
 wkbNDR = _ogr.wkbNDR
 NullFID = _ogr.NullFID
+ALTER_NAME_FLAG = _ogr.ALTER_NAME_FLAG
+ALTER_TYPE_FLAG = _ogr.ALTER_TYPE_FLAG
+ALTER_WIDTH_PRECISION_FLAG = _ogr.ALTER_WIDTH_PRECISION_FLAG
+ALTER_ALL_FLAG = _ogr.ALTER_ALL_FLAG
 OLCRandomRead = _ogr.OLCRandomRead
 OLCSequentialWrite = _ogr.OLCSequentialWrite
 OLCRandomWrite = _ogr.OLCRandomWrite
@@ -110,6 +114,9 @@
 OLCFastFeatureCount = _ogr.OLCFastFeatureCount
 OLCFastGetExtent = _ogr.OLCFastGetExtent
 OLCCreateField = _ogr.OLCCreateField
+OLCDeleteField = _ogr.OLCDeleteField
+OLCReorderField = _ogr.OLCReorderField
+OLCAlterFieldDefn = _ogr.OLCAlterFieldDefn
 OLCTransactions = _ogr.OLCTransactions
 OLCDeleteFeature = _ogr.OLCDeleteFeature
 OLCFastSetNextByIndex = _ogr.OLCFastSetNextByIndex
@@ -1510,6 +1517,18 @@
         """
         return _ogr.Layer_CreateField(self, *args, **kwargs)
 
+    def DeleteField(self, *args):
+        """DeleteField(self, int iField) -> OGRErr"""
+        return _ogr.Layer_DeleteField(self, *args)
+
+    def ReorderField(self, *args):
+        """ReorderField(self, int iOldFieldPos, int iNewFieldPos) -> OGRErr"""
+        return _ogr.Layer_ReorderField(self, *args)
+
+    def AlterFieldDefn(self, *args):
+        """AlterFieldDefn(self, int iField, FieldDefn field_def, int nFlags) -> OGRErr"""
+        return _ogr.Layer_AlterFieldDefn(self, *args)
+
     def StartTransaction(self, *args):
         """
         StartTransaction(self) -> OGRErr
