Changes between Version 4 and Version 5 of rfc35_deletereorderalterfielddefn
- Timestamp:
- May 8, 2011, 10:17:06 AM (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
rfc35_deletereorderalterfielddefn
v4 v5 25 25 {{{ 26 26 virtual OGRErr DeleteField( int iField ); 27 virtual OGRErr ReorderField ( int iOldFieldPos, int iNewFieldPos);27 virtual OGRErr ReorderFields( int* panNewOrder ); 28 28 virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags ); 29 30 /* non virtual : conveniency wrapper for ReorderFields() */ 31 OGRErr ReorderField( int iOldFieldPos, int iNewFieldPos ); 29 32 }}} 30 33 … … 42 45 used by a layer directly. 43 46 44 This functionshould not be called while there are feature objects in existance that47 This method should not be called while there are feature objects in existance that 45 48 were obtained or created with the previous layer definition. 46 49 … … 60 63 61 64 /** 62 \fn OGRErr OGRLayer::ReorderField ( int iOldFieldPos, int iNewFieldPos);63 64 \brief Reorder a n existing field ona layer.65 \fn OGRErr OGRLayer::ReorderFields( int* panNewOrder ); 66 67 \brief Reorder all the fields of a layer. 65 68 66 69 You must use this to reorder existing fields … … 69 72 used by a layer directly. 70 73 71 This function should not be called while there are feature objects in existance that 72 were obtained or created with the previous layer definition. 73 74 Not all drivers support this method. You can query a layer to check if it supports it 75 with the OLCReorderField capability. Some drivers may only support this method while 74 This method should not be called while there are feature objects in existance that 75 were obtained or created with the previous layer definition. 76 77 For each field definition initially at position i, its new position 78 will be panNewOrder[i]. 79 80 For example, let suppose the fields were "0","1","2","3","4" initially. 81 ReorderFields([0,3,1,2,4]) will reorder them as "0","2","3","1","4". 82 83 Not all drivers support this method. You can query a layer to check if it supports it 84 with the OLCReorderFields capability. Some drivers may only support this method while 76 85 there are still no features in the layer. When it is supported, the existings features of the 77 86 backing file/database should be updated accordingly. 78 87 88 This function is the same as the C function OGR_L_ReorderFields(). 89 90 @param panNewOrder an array of GetLayerDefn()->GetFieldCount() elements which 91 is a permutation of [0, GetLayerDefn()->GetFieldCount()-1]. 92 93 @return OGRERR_NONE on success. 94 95 @since OGR 1.9.0 96 */ 97 98 /** 99 \fn OGRErr OGRLayer::ReorderField( int iOldFieldPos, int iNewFieldPos ); 100 101 \brief Reorder an existing field on a layer. 102 103 This method is a conveniency wrapper of ReorderFields() dedicated to move a single field. 104 105 You must use this to reorder existing fields 106 on a real layer. Internally the OGRFeatureDefn for the layer will be updated 107 to reflect the reordering of the fields. Applications should never modify the OGRFeatureDefn 108 used by a layer directly. 109 110 This method should not be called while there are feature objects in existance that 111 were obtained or created with the previous layer definition. 112 113 The field definition that was at initial position iOldFieldPos will be moved at 114 position iNewFieldPos, and elements between will be shuffled accordingly. 115 116 For example, let suppose the fields were "0","1","2","3","4" initially. 117 ReorderField(1, 3) will reorder them as "0","2","3","1","4". 118 119 Not all drivers support this method. You can query a layer to check if it supports it 120 with the OLCReorderFields capability. Some drivers may only support this method while 121 there are still no features in the layer. When it is supported, the existings features of the 122 backing file/database should be updated accordingly. 123 79 124 This function is the same as the C function OGR_L_ReorderField(). 80 125 81 @param iOldFieldPos previous position of the field to move. 82 @param iNewFieldPos new position of the field to move. 126 @param iOldFieldPos previous position of the field to move. Must be in the range [0,GetFieldCount()-1]. 127 @param iNewFieldPos new position of the field to move. Must be in the range [0,GetFieldCount()-1]. 83 128 84 129 @return OGRERR_NONE on success. … … 97 142 used by a layer directly. 98 143 99 This functionshould not be called while there are feature objects in existance that144 This method should not be called while there are feature objects in existance that 100 145 were obtained or created with the previous layer definition. 101 146 … … 125 170 existing fields on the current layer using DeleteField(), otherwise FALSE. 126 171 127 OLCReorderField / "ReorderField": TRUE if this layer can reorder128 existing fields on the current layer using ReorderField() , otherwise FALSE.172 OLCReorderFields / "ReorderFields": TRUE if this layer can reorder 173 existing fields on the current layer using ReorderField() or ReorderFields(), otherwise FALSE. 129 174 130 175 OLCAlterFieldDefn / "AlterFieldDefn": TRUE if this layer can alter … … 136 181 {{{ 137 182 OGRErr CPL_DLL OGR_L_DeleteField( OGRLayerH, int iField ); 183 OGRErr CPL_DLL OGR_L_ReorderFields( OGRLayerH, int* panNewOrder ); 138 184 OGRErr CPL_DLL OGR_L_ReorderField( OGRLayerH, int iOldFieldPos, int iNewFieldPos ); 139 185 OGRErr CPL_DLL OGR_L_AlterFieldDefn( OGRLayerH, int iField, OGRFieldDefnH hNewFieldDefn, int nFlags ); … … 143 189 {{{ 144 190 OGRErr DeleteFieldDefn( int iField ); 145 OGRErr ReorderFieldDefn( int iOldFieldPos, int iNewFieldPos ); 146 }}} 191 OGRErr ReorderFieldDefns( int* panNewOrder ); 192 }}} 193 194 A OGRErr OGRCheckPermutation(int* panPermutation, int nSize) function is added to ogrutils.cpp to 195 check that the array is a permutation of [0,nSize-1]. It is used by OGRFeatureDefn::ReorderFieldDefns() 196 and can be used by all drivers implementing OGRLayer::ReorderFields() to validate the panNewOrder argument. 147 197 148 198 == Compatibility Issues == … … 152 202 == Changed drivers == 153 203 154 The shapefile driver will implement DeleteField(), ReorderField () and AlterFieldDefn(). Shapelib will be155 extended with DBFReorderField () and DBFAlterFieldDefn().204 The shapefile driver will implement DeleteField(), ReorderFields() and AlterFieldDefn(). Shapelib will be 205 extended with DBFReorderFields() and DBFAlterFieldDefn(). 156 206 157 207 Note: The implementation of AlterFieldDefn() in the Shapefile driver does not currently support altering … … 166 216 == SWIG bindings == 167 217 168 DeleteField(), ReorderField() and AlterFieldDefn() will be mapped to SWIG.218 DeleteField(), ReorderField(), ReorderFields() and AlterFieldDefn() will be mapped to SWIG. 169 219 170 220 == Test Suite == … … 177 227 Implementation will be done by Even Rouault in GDAL/OGR trunk. Changes in Shapelib will need to be 178 228 pushed into upstream CVS by a Shapelib committer. The proposed implementation is attached as 179 a patch in ticket #2671 ([http://trac.osgeo.org/gdal/attachment/ticket/2671/rfc35 .patch rfc35.patch]).229 a patch in ticket #2671 ([http://trac.osgeo.org/gdal/attachment/ticket/2671/rfc35_v2.patch rfc35_v2.patch]).