LCOV - code coverage report
Current view: directory - ogr - ogrfeature.cpp (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 780 618 79.2 %
Date: 2010-01-09 Functions: 79 66 83.5 %

       1                 : /******************************************************************************
       2                 :  * $Id: ogrfeature.cpp 18479 2010-01-08 22:35:20Z rouault $
       3                 :  * 
       4                 :  * Project:  OpenGIS Simple Features Reference Implementation
       5                 :  * Purpose:  The OGRFeature class implementation. 
       6                 :  * Author:   Frank Warmerdam, warmerda@home.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 1999,  Les Technologies SoftMap Inc.
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  *
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  *
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      22                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #include "ogr_feature.h"
      31                 : #include "ogr_api.h"
      32                 : #include "ogr_p.h"
      33                 : 
      34                 : CPL_CVSID("$Id: ogrfeature.cpp 18479 2010-01-08 22:35:20Z rouault $");
      35                 : 
      36                 : /************************************************************************/
      37                 : /*                             OGRFeature()                             */
      38                 : /************************************************************************/
      39                 : 
      40                 : /**
      41                 :  * \brief Constructor
      42                 :  *
      43                 :  * Note that the OGRFeature will increment the reference count of it's
      44                 :  * defining OGRFeatureDefn.  Destruction of the OGRFeatureDefn before
      45                 :  * destruction of all OGRFeatures that depend on it is likely to result in
      46                 :  * a crash. 
      47                 :  *
      48                 :  * This method is the same as the C function OGR_F_Create().
      49                 :  *
      50                 :  * @param poDefnIn feature class (layer) definition to which the feature will
      51                 :  * adhere.
      52                 :  */
      53                 : 
      54           69906 : OGRFeature::OGRFeature( OGRFeatureDefn * poDefnIn )
      55                 : 
      56                 : {
      57           69906 :     m_pszStyleString = NULL;
      58           69906 :     m_poStyleTable = NULL;
      59           69906 :     m_pszTmpFieldValue = NULL;
      60           69906 :     poDefnIn->Reference();
      61           69906 :     poDefn = poDefnIn;
      62                 : 
      63           69906 :     nFID = OGRNullFID;
      64                 :     
      65           69906 :     poGeometry = NULL;
      66                 : 
      67                 :     // we should likely be initializing from the defaults, but this will
      68                 :     // usually be a waste. 
      69                 :     pauFields = (OGRField *) CPLCalloc( poDefn->GetFieldCount(),
      70           69906 :                                         sizeof(OGRField) );
      71                 : 
      72          614238 :     for( int i = 0; i < poDefn->GetFieldCount(); i++ )
      73                 :     {
      74          544332 :         pauFields[i].Set.nMarker1 = OGRUnsetMarker;
      75          544332 :         pauFields[i].Set.nMarker2 = OGRUnsetMarker;
      76                 :     }
      77           69906 : }
      78                 : 
      79                 : /************************************************************************/
      80                 : /*                            OGR_F_Create()                            */
      81                 : /************************************************************************/
      82                 : /**
      83                 :  * \brief Feature factory.
      84                 :  *
      85                 :  * Note that the OGRFeature will increment the reference count of it's
      86                 :  * defining OGRFeatureDefn.  Destruction of the OGRFeatureDefn before
      87                 :  * destruction of all OGRFeatures that depend on it is likely to result in
      88                 :  * a crash. 
      89                 :  *
      90                 :  * This function is the same as the C++ method OGRFeature::OGRFeature().
      91                 :  * 
      92                 :  * @param hDefn handle to the feature class (layer) definition to 
      93                 :  * which the feature will adhere.
      94                 :  * 
      95                 :  * @return an handle to the new feature object with null fields and 
      96                 :  * no geometry.
      97                 :  */
      98                 : 
      99           17241 : OGRFeatureH OGR_F_Create( OGRFeatureDefnH hDefn )
     100                 : 
     101                 : {
     102           17241 :     VALIDATE_POINTER1( hDefn, "OGR_F_Create", NULL );
     103                 : 
     104           17241 :     return (OGRFeatureH) new OGRFeature( (OGRFeatureDefn *) hDefn );
     105                 : }
     106                 : 
     107                 : /************************************************************************/
     108                 : /*                            ~OGRFeature()                             */
     109                 : /************************************************************************/
     110                 : 
     111          139682 : OGRFeature::~OGRFeature()
     112                 : 
     113                 : {
     114           69906 :     if( poGeometry != NULL )
     115           53304 :         delete poGeometry;
     116                 : 
     117          614255 :     for( int i = 0; i < poDefn->GetFieldCount(); i++ )
     118                 :     {
     119          544349 :         OGRFieldDefn    *poFDefn = poDefn->GetFieldDefn(i);
     120                 :         
     121          544349 :         if( !IsFieldSet(i) )
     122          308414 :             continue;
     123                 :     
     124          235935 :         switch( poFDefn->GetType() )
     125                 :         {
     126                 :           case OFTString:
     127           68174 :             if( pauFields[i].String != NULL )
     128           68174 :                 VSIFree( pauFields[i].String );
     129           68174 :             break;
     130                 : 
     131                 :           case OFTBinary:
     132              34 :             if( pauFields[i].Binary.paData != NULL )
     133              34 :                 VSIFree( pauFields[i].Binary.paData );
     134              34 :             break;
     135                 : 
     136                 :           case OFTStringList:
     137              97 :             CSLDestroy( pauFields[i].StringList.paList );
     138              97 :             break;
     139                 : 
     140                 :           case OFTIntegerList:
     141                 :           case OFTRealList:
     142           45686 :             CPLFree( pauFields[i].IntegerList.paList );
     143                 :             break;
     144                 : 
     145                 :           default:
     146                 :             // should add support for wide strings.
     147                 :             break;
     148                 :         }
     149                 :     }
     150                 :     
     151           69906 :     poDefn->Release();
     152                 : 
     153           69906 :     CPLFree( pauFields );
     154           69906 :     CPLFree(m_pszStyleString);
     155           69906 :     CPLFree(m_pszTmpFieldValue);
     156          139682 : }
     157                 : 
     158                 : /************************************************************************/
     159                 : /*                           OGR_F_Destroy()                            */
     160                 : /************************************************************************/
     161                 : /**
     162                 :  * \brief Destroy feature
     163                 :  *
     164                 :  * The feature is deleted, but within the context of the GDAL/OGR heap.
     165                 :  * This is necessary when higher level applications use GDAL/OGR from a 
     166                 :  * DLL and they want to delete a feature created within the DLL.  If the
     167                 :  * delete is done in the calling application the memory will be freed onto
     168                 :  * the application heap which is inappropriate. 
     169                 :  *
     170                 :  * This function is the same as the C++ method OGRFeature::DestroyFeature().
     171                 :  * 
     172                 :  * @param hFeat handle to the feature to destroy.
     173                 :  */
     174                 : 
     175           20666 : void OGR_F_Destroy( OGRFeatureH hFeat )
     176                 : 
     177                 : {
     178           20666 :     delete (OGRFeature *) hFeat;
     179           20666 : }
     180                 : 
     181                 : /************************************************************************/
     182                 : /*                           CreateFeature()                            */
     183                 : /************************************************************************/
     184                 : 
     185                 : /**
     186                 :  * \brief Feature factory.
     187                 :  *
     188                 :  * This is essentially a feature factory, useful for               
     189                 :  * applications creating features but wanting to ensure they       
     190                 :  * are created out of the OGR/GDAL heap.                           
     191                 :  * 
     192                 :  * This method is the same as the C function OGR_F_Create().
     193                 :  *
     194                 :  * @param poDefn Feature definition defining schema.
     195                 :  * 
     196                 :  * @return new feature object with null fields and no geometry.  May be
     197                 :  * deleted with delete. 
     198                 :  */
     199                 : 
     200             183 : OGRFeature *OGRFeature::CreateFeature( OGRFeatureDefn *poDefn )
     201                 : 
     202                 : {
     203             183 :     return new OGRFeature( poDefn );
     204                 : }
     205                 : 
     206                 : /************************************************************************/
     207                 : /*                           DestroyFeature()                           */
     208                 : /************************************************************************/
     209                 : 
     210                 : /**
     211                 :  * \brief Destroy feature
     212                 :  *
     213                 :  * The feature is deleted, but within the context of the GDAL/OGR heap.
     214                 :  * This is necessary when higher level applications use GDAL/OGR from a 
     215                 :  * DLL and they want to delete a feature created within the DLL.  If the
     216                 :  * delete is done in the calling application the memory will be freed onto
     217                 :  * the application heap which is inappropriate. 
     218                 :  *
     219                 :  * This method is the same as the C function OGR_F_Destroy().
     220                 :  * 
     221                 :  * @param poFeature the feature to delete.
     222                 :  */
     223                 : 
     224           15077 : void OGRFeature::DestroyFeature( OGRFeature *poFeature )
     225                 : 
     226                 : {
     227           15077 :     delete poFeature;
     228           15077 : }
     229                 : 
     230                 : /************************************************************************/
     231                 : /*                             GetDefnRef()                             */
     232                 : /************************************************************************/
     233                 : 
     234                 : /**
     235                 :  * \fn OGRFeatureDefn *OGRFeature::GetDefnRef();
     236                 :  *
     237                 :  * \brief Fetch feature definition.
     238                 :  *
     239                 :  * This method is the same as the C function OGR_F_GetDefnRef().
     240                 :  *
     241                 :  * @return a reference to the feature definition object.
     242                 :  */
     243                 : 
     244                 : /************************************************************************/
     245                 : /*                          OGR_F_GetDefnRef()                          */
     246                 : /************************************************************************/
     247                 : 
     248                 : /**
     249                 :  * \brief Fetch feature definition.
     250                 :  *
     251                 :  * This function is the same as the C++ method OGRFeature::GetDefnRef().
     252                 :  *
     253                 :  * @param hFeat handle to the feature to get the feature definition from.
     254                 :  *
     255                 :  * @return an handle to the feature definition object on which feature
     256                 :  * depends.
     257                 :  */
     258                 : 
     259               0 : OGRFeatureDefnH OGR_F_GetDefnRef( OGRFeatureH hFeat )
     260                 : 
     261                 : {
     262               0 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetDefnRef", NULL );
     263                 : 
     264               0 :     return (OGRFeatureDefnH) ((OGRFeature *) hFeat)->GetDefnRef();
     265                 : }
     266                 : 
     267                 : /************************************************************************/
     268                 : /*                        SetGeometryDirectly()                         */
     269                 : /************************************************************************/
     270                 : 
     271                 : /**
     272                 :  * \brief Set feature geometry.
     273                 :  *
     274                 :  * This method updates the features geometry, and operate exactly as
     275                 :  * SetGeometry(), except that this method assumes ownership of the
     276                 :  * passed geometry.
     277                 :  *
     278                 :  * This method is the same as the C function OGR_F_SetGeometryDirectly().
     279                 :  *
     280                 :  * @param poGeomIn new geometry to apply to feature. Passing NULL value here
     281                 :  * is correct and it will result in deallocation of currently assigned geometry
     282                 :  * without assigning new one.
     283                 :  *
     284                 :  * @return OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if
     285                 :  * the geometry type is illegal for the OGRFeatureDefn (checking not yet
     286                 :  * implemented). 
     287                 :  */ 
     288                 : 
     289           37884 : OGRErr OGRFeature::SetGeometryDirectly( OGRGeometry * poGeomIn )
     290                 : 
     291                 : {
     292           37884 :     delete poGeometry;
     293           37884 :     poGeometry = poGeomIn;
     294                 : 
     295                 :     // I should be verifying that the geometry matches the defn's type.
     296                 :     
     297           37884 :     return OGRERR_NONE;
     298                 : }
     299                 : 
     300                 : /************************************************************************/
     301                 : /*                     OGR_F_SetGeometryDirectly()                      */
     302                 : /************************************************************************/
     303                 : 
     304                 : /**
     305                 :  * \brief Set feature geometry.
     306                 :  *
     307                 :  * This function updates the features geometry, and operate exactly as
     308                 :  * SetGeometry(), except that this function assumes ownership of the
     309                 :  * passed geometry.
     310                 :  *
     311                 :  * This function is the same as the C++ method 
     312                 :  * OGRFeature::SetGeometryDirectly.
     313                 :  *
     314                 :  * @param hFeat handle to the feature on which to apply the geometry.
     315                 :  * @param hGeom handle to the new geometry to apply to feature.
     316                 :  *
     317                 :  * @return OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if
     318                 :  * the geometry type is illegal for the OGRFeatureDefn (checking not yet
     319                 :  * implemented). 
     320                 :  */ 
     321                 : 
     322             459 : OGRErr OGR_F_SetGeometryDirectly( OGRFeatureH hFeat, OGRGeometryH hGeom )
     323                 : 
     324                 : {
     325             459 :     VALIDATE_POINTER1( hFeat, "OGR_F_SetGeometryDirectly", CE_Failure );
     326                 : 
     327             459 :     return ((OGRFeature *) hFeat)->SetGeometryDirectly((OGRGeometry *) hGeom);
     328                 : }
     329                 : 
     330                 : /************************************************************************/
     331                 : /*                            SetGeometry()                             */
     332                 : /************************************************************************/
     333                 : 
     334                 : /**
     335                 :  * \brief Set feature geometry.
     336                 :  *
     337                 :  * This method updates the features geometry, and operate exactly as
     338                 :  * SetGeometryDirectly(), except that this method does not assume ownership
     339                 :  * of the passed geometry, but instead makes a copy of it. 
     340                 :  *
     341                 :  * This method is the same as the C function OGR_F_SetGeometry().
     342                 :  *
     343                 :  * @param poGeomIn new geometry to apply to feature. Passing NULL value here
     344                 :  * is correct and it will result in deallocation of currently assigned geometry
     345                 :  * without assigning new one.
     346                 :  *
     347                 :  * @return OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if
     348                 :  * the geometry type is illegal for the OGRFeatureDefn (checking not yet
     349                 :  * implemented). 
     350                 :  */ 
     351                 : 
     352           15732 : OGRErr OGRFeature::SetGeometry( OGRGeometry * poGeomIn )
     353                 : 
     354                 : {
     355           15732 :     delete poGeometry;
     356                 : 
     357           15732 :     if( poGeomIn != NULL )
     358           15636 :         poGeometry = poGeomIn->clone();
     359                 :     else
     360              96 :         poGeometry = NULL;
     361                 : 
     362                 :     // I should be verifying that the geometry matches the defn's type.
     363                 :     
     364           15732 :     return OGRERR_NONE;
     365                 : }
     366                 : 
     367                 : /************************************************************************/
     368                 : /*                         OGR_F_SetGeometry()                          */
     369                 : /************************************************************************/
     370                 : 
     371                 : /**
     372                 :  * \brief Set feature geometry.
     373                 :  *
     374                 :  * This function updates the features geometry, and operate exactly as
     375                 :  * SetGeometryDirectly(), except that this function does not assume ownership
     376                 :  * of the passed geometry, but instead makes a copy of it. 
     377                 :  *
     378                 :  * This function is the same as the C++ OGRFeature::SetGeometry().
     379                 :  *
     380                 :  * @param hFeat handle to the feature on which new geometry is applied to.
     381                 :  * @param hGeom handle to the new geometry to apply to feature.
     382                 :  *
     383                 :  * @return OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if
     384                 :  * the geometry type is illegal for the OGRFeatureDefn (checking not yet
     385                 :  * implemented). 
     386                 :  */ 
     387                 : 
     388           14722 : OGRErr OGR_F_SetGeometry( OGRFeatureH hFeat, OGRGeometryH hGeom )
     389                 : 
     390                 : {
     391           14722 :     VALIDATE_POINTER1( hFeat, "OGR_F_SetGeometry", CE_Failure );
     392                 : 
     393           14722 :     return ((OGRFeature *) hFeat)->SetGeometry((OGRGeometry *) hGeom);
     394                 : }
     395                 : 
     396                 : /************************************************************************/
     397                 : /*                           StealGeometry()                            */
     398                 : /************************************************************************/
     399                 : 
     400                 : /**
     401                 :  * \brief Take away ownership of geometry.
     402                 :  *
     403                 :  * Fetch the geometry from this feature, and clear the reference to the
     404                 :  * geometry on the feature.  This is a mechanism for the application to
     405                 :  * take over ownship of the geometry from the feature without copying. 
     406                 :  * Sort of an inverse to SetGeometryDirectly().
     407                 :  *
     408                 :  * After this call the OGRFeature will have a NULL geometry.
     409                 :  *
     410                 :  * @return the pointer to the geometry.
     411                 :  */
     412                 : 
     413              10 : OGRGeometry *OGRFeature::StealGeometry()
     414                 : 
     415                 : {
     416              10 :     OGRGeometry *poReturn = poGeometry;
     417              10 :     poGeometry = NULL;
     418              10 :     return poReturn;
     419                 : }
     420                 : 
     421                 : /************************************************************************/
     422                 : /*                           GetGeometryRef()                           */
     423                 : /************************************************************************/
     424                 : 
     425                 : /**
     426                 :  * \fn OGRGeometry *OGRFeature::GetGeometryRef();
     427                 :  *
     428                 :  * \brief Fetch pointer to feature geometry.
     429                 :  *
     430                 :  * This method is the same as the C function OGR_F_GetGeometryRef().
     431                 :  *
     432                 :  * @return pointer to internal feature geometry.  This object should
     433                 :  * not be modified.
     434                 :  */
     435                 : 
     436                 : /************************************************************************/
     437                 : /*                        OGR_F_GetGeometryRef()                        */
     438                 : /************************************************************************/
     439                 : 
     440                 : /**
     441                 :  * \brief Fetch an handle to feature geometry.
     442                 :  *
     443                 :  * This function is the same as the C++ method OGRFeature::GetGeometryRef().
     444                 :  *
     445                 :  * @param hFeat handle to the feature to get geometry from.
     446                 :  * @return an handle to internal feature geometry.  This object should
     447                 :  * not be modified.
     448                 :  */
     449                 : 
     450             665 : OGRGeometryH OGR_F_GetGeometryRef( OGRFeatureH hFeat )
     451                 : 
     452                 : {
     453             665 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetGeometryRef", NULL );
     454                 : 
     455             665 :     return (OGRGeometryH) ((OGRFeature *) hFeat)->GetGeometryRef();
     456                 : }
     457                 : 
     458                 : /************************************************************************/
     459                 : /*                               Clone()                                */
     460                 : /************************************************************************/
     461                 : 
     462                 : /**
     463                 :  * \brief Duplicate feature.
     464                 :  *
     465                 :  * The newly created feature is owned by the caller, and will have it's own
     466                 :  * reference to the OGRFeatureDefn.
     467                 :  *
     468                 :  * This method is the same as the C function OGR_F_Clone().
     469                 :  *
     470                 :  * @return new feature, exactly matching this feature.
     471                 :  */
     472                 : 
     473             451 : OGRFeature *OGRFeature::Clone()
     474                 : 
     475                 : {
     476             451 :     OGRFeature  *poNew = new OGRFeature( poDefn );
     477                 : 
     478             451 :     poNew->SetGeometry( poGeometry );
     479                 : 
     480            1536 :     for( int i = 0; i < poDefn->GetFieldCount(); i++ )
     481                 :     {
     482            1085 :         poNew->SetField( i, pauFields + i );
     483                 :     }
     484                 : 
     485             451 :     if( GetStyleString() != NULL )
     486               4 :         poNew->SetStyleString(GetStyleString());
     487                 : 
     488             451 :     poNew->SetFID( GetFID() );
     489                 : 
     490             451 :     return poNew;
     491                 : }
     492                 : 
     493                 : /************************************************************************/
     494                 : /*                            OGR_F_Clone()                             */
     495                 : /************************************************************************/
     496                 : 
     497                 : /**
     498                 :  * \brief Duplicate feature.
     499                 :  *
     500                 :  * The newly created feature is owned by the caller, and will have it's own
     501                 :  * reference to the OGRFeatureDefn.
     502                 :  *
     503                 :  * This function is the same as the C++ method OGRFeature::Clone().
     504                 :  *
     505                 :  * @param hFeat handle to the feature to clone.
     506                 :  * @return an handle to the new feature, exactly matching this feature.
     507                 :  */
     508                 : 
     509              36 : OGRFeatureH OGR_F_Clone( OGRFeatureH hFeat )
     510                 : 
     511                 : {
     512              36 :     VALIDATE_POINTER1( hFeat, "OGR_F_Clone", NULL );
     513                 : 
     514              36 :     return (OGRFeatureH) ((OGRFeature *) hFeat)->Clone();
     515                 : }
     516                 : 
     517                 : /************************************************************************/
     518                 : /*                           GetFieldCount()                            */
     519                 : /************************************************************************/
     520                 : 
     521                 : /**
     522                 :  * \fn int OGRFeature::GetFieldCount();
     523                 :  *
     524                 :  * \brief Fetch number of fields on this feature.
     525                 :  * This will always be the same
     526                 :  * as the field count for the OGRFeatureDefn.
     527                 :  *
     528                 :  * This method is the same as the C function OGR_F_GetFieldCount().
     529                 :  *
     530                 :  * @return count of fields.
     531                 :  */
     532                 : 
     533                 : /************************************************************************/
     534                 : /*                        OGR_F_GetFieldCount()                         */
     535                 : /************************************************************************/
     536                 : 
     537                 : /**
     538                 :  * \brief Fetch number of fields on this feature
     539                 :  * This will always be the same
     540                 :  * as the field count for the OGRFeatureDefn.
     541                 :  *
     542                 :  * This function is the same as the C++ method OGRFeature::GetFieldCount().
     543                 :  *
     544                 :  * @param hFeat handle to the feature to get the fields count from.
     545                 :  * @return count of fields.
     546                 :  */
     547                 : 
     548            1373 : int OGR_F_GetFieldCount( OGRFeatureH hFeat )
     549                 : 
     550                 : {
     551            1373 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldCount", 0 );
     552                 : 
     553            1373 :     return ((OGRFeature *) hFeat)->GetFieldCount();
     554                 : }
     555                 : 
     556                 : /************************************************************************/
     557                 : /*                          GetFieldDefnRef()                           */
     558                 : /************************************************************************/
     559                 : 
     560                 : /**
     561                 :  * \fn OGRFieldDefn *OGRFeature::GetFieldDefnRef( int iField );
     562                 :  *
     563                 :  * \brief Fetch definition for this field.
     564                 :  *
     565                 :  * This method is the same as the C function OGR_F_GetFieldDefnRef().
     566                 :  *
     567                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     568                 :  *
     569                 :  * @return the field definition (from the OGRFeatureDefn).  This is an
     570                 :  * internal reference, and should not be deleted or modified.
     571                 :  */
     572                 : 
     573                 : /************************************************************************/
     574                 : /*                       OGR_F_GetFieldDefnRef()                        */
     575                 : /************************************************************************/
     576                 : 
     577                 : /**
     578                 :  * \brief Fetch definition for this field.
     579                 :  *
     580                 :  * This function is the same as the C++ method OGRFeature::GetFieldDefnRef().
     581                 :  *
     582                 :  * @param hFeat handle to the feature on which the field is found.
     583                 :  * @param i the field to fetch, from 0 to GetFieldCount()-1.
     584                 :  *
     585                 :  * @return an handle to the field definition (from the OGRFeatureDefn).
     586                 :  * This is an internal reference, and should not be deleted or modified.
     587                 :  */
     588                 : 
     589            1322 : OGRFieldDefnH OGR_F_GetFieldDefnRef( OGRFeatureH hFeat, int i )
     590                 : 
     591                 : {
     592            1322 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldDefnRef", NULL );
     593                 : 
     594            1322 :     return (OGRFieldDefnH) ((OGRFeature *) hFeat)->GetFieldDefnRef(i);
     595                 : }
     596                 : 
     597                 : /************************************************************************/
     598                 : /*                           GetFieldIndex()                            */
     599                 : /************************************************************************/
     600                 : 
     601                 : /**
     602                 :  * \fn int OGRFeature::GetFieldIndex( const char * pszName );
     603                 :  * 
     604                 :  * \brief Fetch the field index given field name.
     605                 :  *
     606                 :  * This is a cover for the OGRFeatureDefn::GetFieldIndex() method. 
     607                 :  *
     608                 :  * This method is the same as the C function OGR_F_GetFieldIndex().
     609                 :  *
     610                 :  * @param pszName the name of the field to search for. 
     611                 :  *
     612                 :  * @return the field index, or -1 if no matching field is found.
     613                 :  */
     614                 : 
     615                 : /************************************************************************/
     616                 : /*                        OGR_F_GetFieldIndex()                         */
     617                 : /************************************************************************/
     618                 : 
     619                 : /**
     620                 :  * \brief Fetch the field index given field name.
     621                 :  *
     622                 :  * This is a cover for the OGRFeatureDefn::GetFieldIndex() method. 
     623                 :  *
     624                 :  * This function is the same as the C++ method OGRFeature::GetFieldIndex().
     625                 :  *
     626                 :  * @param hFeat handle to the feature on which the field is found.
     627                 :  * @param pszName the name of the field to search for. 
     628                 :  *
     629                 :  * @return the field index, or -1 if no matching field is found.
     630                 :  */
     631                 : 
     632             786 : int OGR_F_GetFieldIndex( OGRFeatureH hFeat, const char *pszName )
     633                 : 
     634                 : {
     635             786 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldIndex", 0 );
     636                 : 
     637             786 :     return ((OGRFeature *) hFeat)->GetFieldIndex( pszName );
     638                 : }
     639                 : 
     640                 : /************************************************************************/
     641                 : /*                             IsFieldSet()                             */
     642                 : /************************************************************************/
     643                 : 
     644                 : /**
     645                 :  * \fn int OGRFeature::IsFieldSet( int iField ) const;
     646                 :  *
     647                 :  * \brief Test if a field has ever been assigned a value or not.
     648                 :  *
     649                 :  * This method is the same as the C function OGR_F_IsFieldSet().
     650                 :  *
     651                 :  * @param iField the field to test.
     652                 :  *
     653                 :  * @return TRUE if the field has been set, otherwise false.
     654                 :  */
     655                 : 
     656                 : /************************************************************************/
     657                 : /*                          OGR_F_IsFieldSet()                          */
     658                 : /************************************************************************/
     659                 : 
     660                 : /**
     661                 :  * \brief Test if a field has ever been assigned a value or not.
     662                 :  *
     663                 :  * This function is the same as the C++ method OGRFeature::IsFieldSet().
     664                 :  *
     665                 :  * @param hFeat handle to the feature on which the field is.
     666                 :  * @param iField the field to test.
     667                 :  *
     668                 :  * @return TRUE if the field has been set, otherwise false.
     669                 :  */
     670                 : 
     671            1374 : int OGR_F_IsFieldSet( OGRFeatureH hFeat, int iField )
     672                 : 
     673                 : {
     674            1374 :     VALIDATE_POINTER1( hFeat, "OGR_F_IsFieldSet", 0 );
     675                 : 
     676            1374 :     return ((OGRFeature *)hFeat)->IsFieldSet( iField );
     677                 : }
     678                 : 
     679                 : /************************************************************************/
     680                 : /*                             UnsetField()                             */
     681                 : /************************************************************************/
     682                 : 
     683                 : /**
     684                 :  * \brief Clear a field, marking it as unset.
     685                 :  *
     686                 :  * This method is the same as the C function OGR_F_UnsetField().
     687                 :  *
     688                 :  * @param iField the field to unset.
     689                 :  */
     690                 : 
     691             131 : void OGRFeature::UnsetField( int iField )
     692                 : 
     693                 : {
     694             131 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
     695                 : 
     696                 :     CPLAssert( poFDefn != NULL || iField == -1 );
     697             131 :     if( poFDefn == NULL || !IsFieldSet(iField) )
     698             110 :         return;
     699                 :     
     700              21 :     switch( poFDefn->GetType() )
     701                 :     {
     702                 :       case OFTRealList:
     703                 :       case OFTIntegerList:
     704               0 :         CPLFree( pauFields[iField].IntegerList.paList );
     705               0 :         break;
     706                 : 
     707                 :       case OFTStringList:
     708               0 :         CSLDestroy( pauFields[iField].StringList.paList );
     709               0 :         break;
     710                 : 
     711                 :       case OFTString:
     712              12 :         CPLFree( pauFields[iField].String );
     713              12 :         break;
     714                 : 
     715                 :       case OFTBinary:
     716               0 :         CPLFree( pauFields[iField].Binary.paData );
     717                 :         break;
     718                 : 
     719                 :       default:
     720                 :         break;
     721                 :     }
     722                 : 
     723              21 :     pauFields[iField].Set.nMarker1 = OGRUnsetMarker;
     724              21 :     pauFields[iField].Set.nMarker2 = OGRUnsetMarker;
     725                 : }
     726                 : 
     727                 : /************************************************************************/
     728                 : /*                          OGR_F_UnsetField()                          */
     729                 : /************************************************************************/
     730                 : 
     731                 : /**
     732                 :  * \brief Clear a field, marking it as unset.
     733                 :  *
     734                 :  * This function is the same as the C++ method OGRFeature::UnsetField().
     735                 :  *
     736                 :  * @param hFeat handle to the feature on which the field is.
     737                 :  * @param iField the field to unset.
     738                 :  */
     739                 : 
     740              22 : void OGR_F_UnsetField( OGRFeatureH hFeat, int iField )
     741                 : 
     742                 : {
     743              22 :     VALIDATE_POINTER0( hFeat, "OGR_F_UnsetField" );
     744                 : 
     745              22 :     ((OGRFeature *) hFeat)->UnsetField( iField );
     746                 : }
     747                 : 
     748                 : /************************************************************************/
     749                 : /*                           GetRawFieldRef()                           */
     750                 : /************************************************************************/
     751                 : 
     752                 : /**
     753                 :  * \fn OGRField *OGRFeature::GetRawFieldRef( int iField );
     754                 :  *
     755                 :  * \brief Fetch a pointer to the internal field value given the index.  
     756                 :  *
     757                 :  * This method is the same as the C function OGR_F_GetRawFieldRef().
     758                 :  *
     759                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     760                 :  *
     761                 :  * @return the returned pointer is to an internal data structure, and should
     762                 :  * not be freed, or modified. 
     763                 :  */
     764                 : 
     765                 : /************************************************************************/
     766                 : /*                        OGR_F_GetRawFieldRef()                        */
     767                 : /************************************************************************/
     768                 : 
     769                 : /**
     770                 :  * \brief Fetch an handle to the internal field value given the index.  
     771                 :  *
     772                 :  * This function is the same as the C++ method OGRFeature::GetRawFieldRef().
     773                 :  *
     774                 :  * @param hFeat handle to the feature on which field is found.
     775                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     776                 :  *
     777                 :  * @return the returned handle is to an internal data structure, and should
     778                 :  * not be freed, or modified. 
     779                 :  */
     780                 : 
     781               0 : OGRField *OGR_F_GetRawFieldRef( OGRFeatureH hFeat, int iField )
     782                 : 
     783                 : {
     784               0 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetRawFieldRef", NULL );
     785                 : 
     786               0 :     return ((OGRFeature *)hFeat)->GetRawFieldRef( iField );
     787                 : }
     788                 : 
     789                 : /************************************************************************/
     790                 : /*                         GetFieldAsInteger()                          */
     791                 : /************************************************************************/
     792                 : 
     793                 : /**
     794                 :  * \brief Fetch field value as integer.
     795                 :  *
     796                 :  * OFTString features will be translated using atoi().  OFTReal fields
     797                 :  * will be cast to integer.   Other field types, or errors will result in
     798                 :  * a return value of zero.
     799                 :  *
     800                 :  * This method is the same as the C function OGR_F_GetFieldAsInteger().
     801                 :  *
     802                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     803                 :  *
     804                 :  * @return the field value.
     805                 :  */
     806                 : 
     807            2825 : int OGRFeature::GetFieldAsInteger( int iField )
     808                 : 
     809                 : {
     810            2825 :     int iSpecialField = iField - poDefn->GetFieldCount();
     811            2825 :     if (iSpecialField >= 0)
     812                 :     {
     813                 :     // special field value accessors
     814              26 :         switch (iSpecialField)
     815                 :         {
     816                 :         case SPF_FID:
     817              26 :             return GetFID();
     818                 : 
     819                 :         case SPF_OGR_GEOM_AREA:
     820               0 :             if( poGeometry == NULL )
     821               0 :                 return 0;
     822               0 :             return (int)OGR_G_GetArea((OGRGeometryH)poGeometry);
     823                 : 
     824                 :         default:
     825               0 :             return 0;
     826                 :         }
     827                 :     }
     828                 :     
     829            2799 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
     830                 :     
     831                 :     CPLAssert( poFDefn != NULL || iField == -1 );
     832            2799 :     if( poFDefn == NULL )
     833               0 :         return 0;
     834                 :     
     835            2799 :     if( !IsFieldSet(iField) )
     836               0 :         return 0;
     837                 :     
     838            2799 :     if( poFDefn->GetType() == OFTInteger )
     839            2799 :         return pauFields[iField].Integer;
     840               0 :     else if( poFDefn->GetType() == OFTReal )
     841               0 :         return (int) pauFields[iField].Real;
     842               0 :     else if( poFDefn->GetType() == OFTString )
     843                 :     {
     844               0 :         if( pauFields[iField].String == NULL )
     845               0 :             return 0;
     846                 :         else
     847               0 :             return atoi(pauFields[iField].String);
     848                 :     }
     849                 :     else
     850               0 :         return 0;
     851                 : }
     852                 : 
     853                 : /************************************************************************/
     854                 : /*                      OGR_F_GetFieldAsInteger()                       */
     855                 : /************************************************************************/
     856                 : 
     857                 : /**
     858                 :  * \brief Fetch field value as integer.
     859                 :  *
     860                 :  * OFTString features will be translated using atoi().  OFTReal fields
     861                 :  * will be cast to integer.   Other field types, or errors will result in
     862                 :  * a return value of zero.
     863                 :  *
     864                 :  * This function is the same as the C++ method OGRFeature::GetFieldAsInteger().
     865                 :  *
     866                 :  * @param hFeat handle to the feature that owned the field.
     867                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     868                 :  *
     869                 :  * @return the field value.
     870                 :  */
     871                 : 
     872            2408 : int OGR_F_GetFieldAsInteger( OGRFeatureH hFeat, int iField )
     873                 : 
     874                 : {
     875            2408 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsInteger", 0 );
     876                 : 
     877            2408 :     return ((OGRFeature *)hFeat)->GetFieldAsInteger(iField);
     878                 : }
     879                 : 
     880                 : /************************************************************************/
     881                 : /*                          GetFieldAsDouble()                          */
     882                 : /************************************************************************/
     883                 : 
     884                 : /**
     885                 :  * \brief Fetch field value as a double.
     886                 :  *
     887                 :  * OFTString features will be translated using atof().  OFTInteger fields
     888                 :  * will be cast to double.   Other field types, or errors will result in
     889                 :  * a return value of zero.
     890                 :  *
     891                 :  * This method is the same as the C function OGR_F_GetFieldAsDouble().
     892                 :  *
     893                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     894                 :  *
     895                 :  * @return the field value.
     896                 :  */
     897                 : 
     898            3069 : double OGRFeature::GetFieldAsDouble( int iField )
     899                 : 
     900                 : {
     901            3069 :     int iSpecialField = iField - poDefn->GetFieldCount();
     902            3069 :     if (iSpecialField >= 0)
     903                 :     {
     904                 :     // special field value accessors
     905               4 :         switch (iSpecialField)
     906                 :         {
     907                 :         case SPF_FID:
     908               0 :             return GetFID();
     909                 : 
     910                 :         case SPF_OGR_GEOM_AREA:
     911               4 :             if( poGeometry == NULL )
     912               0 :                 return 0.0;
     913               4 :             return OGR_G_GetArea((OGRGeometryH)poGeometry);
     914                 : 
     915                 :         default:
     916               0 :             return 0.0;
     917                 :         }
     918                 :     }
     919                 :     
     920            3065 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
     921                 :     
     922                 :     CPLAssert( poFDefn != NULL || iField == -1 );
     923            3065 :     if( poFDefn == NULL )
     924               0 :         return 0.0;
     925                 : 
     926            3065 :     if( !IsFieldSet(iField) )
     927               0 :         return 0.0;
     928                 :     
     929            3065 :     if( poFDefn->GetType() == OFTReal )
     930            3057 :         return pauFields[iField].Real;
     931               8 :     else if( poFDefn->GetType() == OFTInteger )
     932               2 :         return pauFields[iField].Integer;
     933               6 :     else if( poFDefn->GetType() == OFTString )
     934                 :     {
     935               6 :         if( pauFields[iField].String == NULL )
     936               0 :             return 0;
     937                 :         else
     938               6 :             return atof(pauFields[iField].String);
     939                 :     }
     940                 :     else
     941               0 :         return 0.0;
     942                 : }
     943                 : 
     944                 : /************************************************************************/
     945                 : /*                       OGR_F_GetFieldAsDouble()                       */
     946                 : /************************************************************************/
     947                 : 
     948                 : /**
     949                 :  * \brief Fetch field value as a double.
     950                 :  *
     951                 :  * OFTString features will be translated using atof().  OFTInteger fields
     952                 :  * will be cast to double.   Other field types, or errors will result in
     953                 :  * a return value of zero.
     954                 :  *
     955                 :  * This function is the same as the C++ method OGRFeature::GetFieldAsDouble().
     956                 :  *
     957                 :  * @param hFeat handle to the feature that owned the field.
     958                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     959                 :  *
     960                 :  * @return the field value.
     961                 :  */
     962                 : 
     963             481 : double OGR_F_GetFieldAsDouble( OGRFeatureH hFeat, int iField )
     964                 : 
     965                 : {
     966             481 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsDouble", 0 );
     967                 : 
     968             481 :     return ((OGRFeature *)hFeat)->GetFieldAsDouble(iField);
     969                 : }
     970                 : 
     971                 : /************************************************************************/
     972                 : /*                          GetFieldAsString()                          */
     973                 : /************************************************************************/
     974                 : 
     975                 : /**
     976                 :  * \brief Fetch field value as a string.
     977                 :  *
     978                 :  * OFTReal and OFTInteger fields will be translated to string using
     979                 :  * sprintf(), but not necessarily using the established formatting rules.
     980                 :  * Other field types, or errors will result in a return value of zero.
     981                 :  *
     982                 :  * This method is the same as the C function OGR_F_GetFieldAsString().
     983                 :  *
     984                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
     985                 :  *
     986                 :  * @return the field value.  This string is internal, and should not be
     987                 :  * modified, or freed.  It's lifetime may be very brief. 
     988                 :  */
     989                 : 
     990            8129 : const char *OGRFeature::GetFieldAsString( int iField )
     991                 : 
     992                 : {
     993                 : #define TEMP_BUFFER_SIZE 80
     994                 :     char         szTempBuffer[TEMP_BUFFER_SIZE];
     995                 : 
     996            8129 :     CPLFree(m_pszTmpFieldValue);
     997            8129 :     m_pszTmpFieldValue = NULL;            
     998                 : 
     999            8129 :     int iSpecialField = iField - poDefn->GetFieldCount();
    1000            8129 :     if (iSpecialField >= 0)
    1001                 :     {
    1002                 :         // special field value accessors
    1003              24 :         switch (iSpecialField)
    1004                 :         {
    1005                 :           case SPF_FID:
    1006               0 :             snprintf( szTempBuffer, TEMP_BUFFER_SIZE, "%ld", GetFID() );
    1007               0 :             return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1008                 : 
    1009                 :           case SPF_OGR_GEOMETRY:
    1010              20 :             if( poGeometry )
    1011              20 :                 return poGeometry->getGeometryName();
    1012                 :             else
    1013               0 :                 return "";
    1014                 : 
    1015                 :           case SPF_OGR_STYLE:
    1016               2 :             if( GetStyleString() == NULL )
    1017               0 :                 return "";
    1018                 :             else
    1019               2 :                 return GetStyleString();
    1020                 : 
    1021                 :           case SPF_OGR_GEOM_WKT:
    1022                 :           {
    1023               2 :               if( poGeometry == NULL )
    1024               0 :                   return "";
    1025                 : 
    1026               2 :               if (poGeometry->exportToWkt( &m_pszTmpFieldValue ) == OGRERR_NONE )
    1027               2 :                   return m_pszTmpFieldValue;
    1028                 :               else
    1029               0 :                   return "";
    1030                 :           }
    1031                 : 
    1032                 :           case SPF_OGR_GEOM_AREA:
    1033               0 :             if( poGeometry == NULL )
    1034               0 :                 return "";
    1035                 : 
    1036                 :             snprintf( szTempBuffer, TEMP_BUFFER_SIZE, "%.16g", 
    1037               0 :                       OGR_G_GetArea((OGRGeometryH)poGeometry) );
    1038               0 :             return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1039                 : 
    1040                 :           default:
    1041               0 :             return "";
    1042                 :         }
    1043                 :     }
    1044                 :     
    1045            8105 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1046                 :     
    1047                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1048            8105 :     if( poFDefn == NULL )
    1049               0 :         return "";
    1050                 :     
    1051            8105 :     if( !IsFieldSet(iField) )
    1052              69 :         return "";
    1053                 :     
    1054            8036 :     if( poFDefn->GetType() == OFTString )
    1055                 :     {
    1056            3284 :         if( pauFields[iField].String == NULL )
    1057               0 :             return "";
    1058                 :         else
    1059            3284 :             return pauFields[iField].String;
    1060                 :     }
    1061            4752 :     else if( poFDefn->GetType() == OFTInteger )
    1062                 :     {
    1063                 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE,
    1064            4166 :                   "%d", pauFields[iField].Integer );
    1065            4166 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1066                 :     }
    1067             586 :     else if( poFDefn->GetType() == OFTReal )
    1068                 :     {
    1069                 :         char    szFormat[64];
    1070                 : 
    1071             388 :         if( poFDefn->GetWidth() != 0 )
    1072                 :         {
    1073                 :             snprintf( szFormat, sizeof(szFormat), "%%%d.%df",
    1074             297 :                       poFDefn->GetWidth(), poFDefn->GetPrecision() );
    1075                 :         }
    1076                 :         else
    1077              91 :             strcpy( szFormat, "%.15g" );
    1078                 :         
    1079                 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE,
    1080             388 :                   szFormat, pauFields[iField].Real );
    1081                 :         
    1082             388 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1083                 :     }
    1084             198 :     else if( poFDefn->GetType() == OFTDateTime )
    1085                 :     {
    1086                 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE,
    1087                 :                   "%04d/%02d/%02d %2d:%02d:%02d", 
    1088              69 :                   pauFields[iField].Date.Year,
    1089              69 :                   pauFields[iField].Date.Month,
    1090              69 :                   pauFields[iField].Date.Day,
    1091              69 :                   pauFields[iField].Date.Hour,
    1092              69 :                   pauFields[iField].Date.Minute,
    1093             414 :                   pauFields[iField].Date.Second );
    1094                 :         
    1095              69 :         if( pauFields[iField].Date.TZFlag > 1 )
    1096                 :         {
    1097              47 :             int nOffset = (pauFields[iField].Date.TZFlag - 100) * 15;
    1098              47 :             int nHours = (int) (nOffset / 60);  // round towards zero
    1099              47 :             int nMinutes = ABS(nOffset - nHours * 60);
    1100                 : 
    1101              47 :             if( nOffset < 0 )
    1102                 :             {
    1103               6 :                 strcat( szTempBuffer, "-" );
    1104               6 :                 nHours = ABS(nHours);
    1105                 :             }
    1106                 :             else
    1107              41 :                 strcat( szTempBuffer, "+" );
    1108                 : 
    1109              47 :             if( nMinutes == 0 )
    1110                 :                 snprintf( szTempBuffer+strlen(szTempBuffer), 
    1111              43 :                           TEMP_BUFFER_SIZE-strlen(szTempBuffer), "%02d", nHours );
    1112                 :             else
    1113                 :                 snprintf( szTempBuffer+strlen(szTempBuffer), 
    1114               4 :                           TEMP_BUFFER_SIZE-strlen(szTempBuffer), "%02d%02d", nHours, nMinutes );
    1115                 :         }
    1116                 : 
    1117              69 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1118                 :     }
    1119             129 :     else if( poFDefn->GetType() == OFTDate )
    1120                 :     {
    1121                 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE, "%04d/%02d/%02d",
    1122              28 :                   pauFields[iField].Date.Year,
    1123              28 :                   pauFields[iField].Date.Month,
    1124              84 :                   pauFields[iField].Date.Day );
    1125                 : 
    1126              28 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1127                 :     }
    1128             101 :     else if( poFDefn->GetType() == OFTTime )
    1129                 :     {
    1130                 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE, "%2d:%02d:%02d", 
    1131              25 :                   pauFields[iField].Date.Hour,
    1132              25 :                   pauFields[iField].Date.Minute,
    1133              75 :                   pauFields[iField].Date.Second );
    1134                 :         
    1135              25 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1136                 :     }
    1137              76 :     else if( poFDefn->GetType() == OFTIntegerList )
    1138                 :     {
    1139                 :         char    szItem[32];
    1140              14 :         int     i, nCount = pauFields[iField].IntegerList.nCount;
    1141                 : 
    1142              14 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE, "(%d:", nCount );
    1143              42 :         for( i = 0; i < nCount; i++ )
    1144                 :         {
    1145                 :             snprintf( szItem, sizeof(szItem), "%d",
    1146              28 :                       pauFields[iField].IntegerList.paList[i] );
    1147              28 :             if( strlen(szTempBuffer) + strlen(szItem) + 6
    1148                 :                 >= sizeof(szTempBuffer) )
    1149                 :             {
    1150               0 :                 break;
    1151                 :             }
    1152                 :             
    1153              28 :             if( i > 0 )
    1154              14 :                 strcat( szTempBuffer, "," );
    1155                 :             
    1156              28 :             strcat( szTempBuffer, szItem );
    1157                 :         }
    1158                 : 
    1159              14 :         if( i < nCount )
    1160               0 :             strcat( szTempBuffer, ",...)" );
    1161                 :         else
    1162              14 :             strcat( szTempBuffer, ")" );
    1163                 :         
    1164              14 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1165                 :     }
    1166              62 :     else if( poFDefn->GetType() == OFTRealList )
    1167                 :     {
    1168                 :         char    szItem[40];
    1169                 :         char    szFormat[64];
    1170               4 :         int     i, nCount = pauFields[iField].RealList.nCount;
    1171                 : 
    1172               4 :         if( poFDefn->GetWidth() != 0 )
    1173                 :         {
    1174                 :             snprintf( szFormat, sizeof(szFormat), "%%%d.%df",
    1175               0 :                       poFDefn->GetWidth(), poFDefn->GetPrecision() );
    1176                 :         }
    1177                 :         else
    1178               4 :             strcpy( szFormat, "%.16g" );
    1179                 :         
    1180               4 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE, "(%d:", nCount );
    1181              12 :         for( i = 0; i < nCount; i++ )
    1182                 :         {
    1183                 :             snprintf( szItem, sizeof(szItem), szFormat,
    1184               8 :                       pauFields[iField].RealList.paList[i] );
    1185               8 :             if( strlen(szTempBuffer) + strlen(szItem) + 6
    1186                 :                 >= sizeof(szTempBuffer) )
    1187                 :             {
    1188               0 :                 break;
    1189                 :             }
    1190                 :             
    1191               8 :             if( i > 0 )
    1192               4 :                 strcat( szTempBuffer, "," );
    1193                 :             
    1194               8 :             strcat( szTempBuffer, szItem );
    1195                 :         }
    1196                 : 
    1197               4 :         if( i < nCount )
    1198               0 :             strcat( szTempBuffer, ",...)" );
    1199                 :         else
    1200               4 :             strcat( szTempBuffer, ")" );
    1201                 :         
    1202               4 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1203                 :     }
    1204              58 :     else if( poFDefn->GetType() == OFTStringList )
    1205                 :     {
    1206              42 :         int     i, nCount = pauFields[iField].StringList.nCount;
    1207                 : 
    1208              42 :         snprintf( szTempBuffer, TEMP_BUFFER_SIZE, "(%d:", nCount );
    1209             126 :         for( i = 0; i < nCount; i++ )
    1210                 :         {
    1211              84 :             const char  *pszItem = pauFields[iField].StringList.paList[i];
    1212                 :             
    1213              84 :             if( strlen(szTempBuffer) + strlen(pszItem)  + 6
    1214                 :                 >= sizeof(szTempBuffer) )
    1215                 :             {
    1216               0 :                 break;
    1217                 :             }
    1218                 : 
    1219              84 :             if( i > 0 )
    1220              42 :                 strcat( szTempBuffer, "," );
    1221                 :             
    1222              84 :             strcat( szTempBuffer, pszItem );
    1223                 :         }
    1224                 : 
    1225              42 :         if( i < nCount )
    1226               0 :             strcat( szTempBuffer, ",...)" );
    1227                 :         else
    1228              42 :             strcat( szTempBuffer, ")" );
    1229                 :         
    1230              42 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1231                 :     }
    1232              16 :     else if( poFDefn->GetType() == OFTBinary )
    1233                 :     {
    1234              16 :         int     nCount = pauFields[iField].Binary.nCount;
    1235                 :         char    *pszHex;
    1236                 :         
    1237              16 :         if( nCount > (int) sizeof(szTempBuffer) / 2 - 4 )
    1238               0 :             nCount = sizeof(szTempBuffer) / 2 - 4;
    1239                 : 
    1240              16 :         pszHex = CPLBinaryToHex( nCount, pauFields[iField].Binary.paData );
    1241                 : 
    1242              16 :         memcpy( szTempBuffer, pszHex, 2 * nCount );
    1243              16 :         szTempBuffer[nCount*2] = '\0';
    1244              16 :         if( nCount < pauFields[iField].Binary.nCount )
    1245               0 :             strcat( szTempBuffer, "..." );
    1246                 : 
    1247              16 :         CPLFree( pszHex );
    1248                 : 
    1249              16 :         return m_pszTmpFieldValue = CPLStrdup( szTempBuffer );
    1250                 :     }
    1251                 :     else
    1252               0 :         return "";
    1253                 : #undef TEMP_BUFFER_SIZE
    1254                 : }
    1255                 : 
    1256                 : /************************************************************************/
    1257                 : /*                       OGR_F_GetFieldAsString()                       */
    1258                 : /************************************************************************/
    1259                 : 
    1260                 : /**
    1261                 :  * \brief Fetch field value as a string.
    1262                 :  *
    1263                 :  * OFTReal and OFTInteger fields will be translated to string using
    1264                 :  * sprintf(), but not necessarily using the established formatting rules.
    1265                 :  * Other field types, or errors will result in a return value of zero.
    1266                 :  *
    1267                 :  * This function is the same as the C++ method OGRFeature::GetFieldAsString().
    1268                 :  *
    1269                 :  * @param hFeat handle to the feature that owned the field.
    1270                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1271                 :  *
    1272                 :  * @return the field value.  This string is internal, and should not be
    1273                 :  * modified, or freed.  It's lifetime may be very brief. 
    1274                 :  */
    1275                 : 
    1276             948 : const char *OGR_F_GetFieldAsString( OGRFeatureH hFeat, int iField )
    1277                 : 
    1278                 : {
    1279             948 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsString", NULL );
    1280                 : 
    1281             948 :     return ((OGRFeature *)hFeat)->GetFieldAsString(iField);
    1282                 : }
    1283                 : 
    1284                 : /************************************************************************/
    1285                 : /*                       GetFieldAsIntegerList()                        */
    1286                 : /************************************************************************/
    1287                 : 
    1288                 : /**
    1289                 :  * \brief Fetch field value as a list of integers.
    1290                 :  *
    1291                 :  * Currently this method only works for OFTIntegerList fields.
    1292                 :  *
    1293                 :  * This method is the same as the C function OGR_F_GetFieldAsIntegerList().
    1294                 :  *
    1295                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1296                 :  * @param pnCount an integer to put the list count (number of integers) into.
    1297                 :  *
    1298                 :  * @return the field value.  This list is internal, and should not be
    1299                 :  * modified, or freed.  It's lifetime may be very brief.  If *pnCount is zero
    1300                 :  * on return the returned pointer may be NULL or non-NULL.
    1301                 :  */
    1302                 : 
    1303              67 : const int *OGRFeature::GetFieldAsIntegerList( int iField, int *pnCount )
    1304                 : 
    1305                 : {
    1306              67 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1307                 : 
    1308                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1309              67 :     if( poFDefn == NULL )
    1310               0 :         return NULL;
    1311                 :     
    1312              67 :     if( !IsFieldSet(iField) )
    1313               0 :         return NULL;
    1314                 :     
    1315              67 :     if( poFDefn->GetType() == OFTIntegerList )
    1316                 :     {
    1317              67 :         if( pnCount != NULL )
    1318              67 :             *pnCount = pauFields[iField].IntegerList.nCount;
    1319                 : 
    1320              67 :         return pauFields[iField].IntegerList.paList;
    1321                 :     }
    1322                 :     else
    1323                 :     {
    1324               0 :         if( pnCount != NULL )
    1325               0 :             *pnCount = 0;
    1326                 :         
    1327               0 :         return NULL;
    1328                 :     }
    1329                 : }
    1330                 : 
    1331                 : /************************************************************************/
    1332                 : /*                    OGR_F_GetFieldAsIntegerList()                     */
    1333                 : /************************************************************************/
    1334                 : 
    1335                 : /**
    1336                 :  * \brief Fetch field value as a list of integers.
    1337                 :  *
    1338                 :  * Currently this function only works for OFTIntegerList fields.
    1339                 :  *
    1340                 :  * This function is the same as the C++ method 
    1341                 :  * OGRFeature::GetFieldAsIntegerList().
    1342                 :  *
    1343                 :  * @param hFeat handle to the feature that owned the field.
    1344                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1345                 :  * @param pnCount an integer to put the list count (number of integers) into.
    1346                 :  *
    1347                 :  * @return the field value.  This list is internal, and should not be
    1348                 :  * modified, or freed.  It's lifetime may be very brief.  If *pnCount is zero
    1349                 :  * on return the returned pointer may be NULL or non-NULL.
    1350                 :  */
    1351                 : 
    1352               1 : const int *OGR_F_GetFieldAsIntegerList( OGRFeatureH hFeat, int iField, 
    1353                 :                                   int *pnCount )
    1354                 : 
    1355                 : {
    1356               1 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsIntegerList", NULL );
    1357                 : 
    1358               1 :     return ((OGRFeature *)hFeat)->GetFieldAsIntegerList(iField, pnCount);
    1359                 : }
    1360                 : 
    1361                 : /************************************************************************/
    1362                 : /*                        GetFieldAsDoubleList()                        */
    1363                 : /************************************************************************/
    1364                 : 
    1365                 : /**
    1366                 :  * \brief Fetch field value as a list of doubles.
    1367                 :  *
    1368                 :  * Currently this method only works for OFTRealList fields.
    1369                 :  *
    1370                 :  * This method is the same as the C function OGR_F_GetFieldAsDoubleList().
    1371                 :  *
    1372                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1373                 :  * @param pnCount an integer to put the list count (number of doubles) into.
    1374                 :  *
    1375                 :  * @return the field value.  This list is internal, and should not be
    1376                 :  * modified, or freed.  It's lifetime may be very brief.  If *pnCount is zero
    1377                 :  * on return the returned pointer may be NULL or non-NULL.
    1378                 :  */
    1379                 : 
    1380              67 : const double *OGRFeature::GetFieldAsDoubleList( int iField, int *pnCount )
    1381                 : 
    1382                 : {
    1383              67 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1384                 : 
    1385                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1386              67 :     if( poFDefn == NULL )
    1387               0 :         return NULL;
    1388                 :     
    1389              67 :     if( !IsFieldSet(iField) )
    1390               0 :         return NULL;
    1391                 :     
    1392              67 :     if( poFDefn->GetType() == OFTRealList )
    1393                 :     {
    1394              67 :         if( pnCount != NULL )
    1395              67 :             *pnCount = pauFields[iField].RealList.nCount;
    1396                 : 
    1397              67 :         return pauFields[iField].RealList.paList;
    1398                 :     }
    1399                 :     else
    1400                 :     {
    1401               0 :         if( pnCount != NULL )
    1402               0 :             *pnCount = 0;
    1403                 :         
    1404               0 :         return NULL;
    1405                 :     }
    1406                 : }
    1407                 : 
    1408                 : /************************************************************************/
    1409                 : /*                     OGR_F_GetFieldAsDoubleList()                     */
    1410                 : /************************************************************************/
    1411                 : 
    1412                 : /**
    1413                 :  * \brief Fetch field value as a list of doubles.
    1414                 :  *
    1415                 :  * Currently this function only works for OFTRealList fields.
    1416                 :  *
    1417                 :  * This function is the same as the C++ method 
    1418                 :  * OGRFeature::GetFieldAsDoubleList().
    1419                 :  *
    1420                 :  * @param hFeat handle to the feature that owned the field.
    1421                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1422                 :  * @param pnCount an integer to put the list count (number of doubles) into.
    1423                 :  *
    1424                 :  * @return the field value.  This list is internal, and should not be
    1425                 :  * modified, or freed.  It's lifetime may be very brief.  If *pnCount is zero
    1426                 :  * on return the returned pointer may be NULL or non-NULL.
    1427                 :  */
    1428                 : 
    1429               1 : const double *OGR_F_GetFieldAsDoubleList( OGRFeatureH hFeat, int iField, 
    1430                 :                                           int *pnCount )
    1431                 : 
    1432                 : {
    1433               1 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsDoubleList", NULL );
    1434                 : 
    1435               1 :     return ((OGRFeature *)hFeat)->GetFieldAsDoubleList(iField, pnCount);
    1436                 : }
    1437                 : 
    1438                 : /************************************************************************/
    1439                 : /*                        GetFieldAsStringList()                        */
    1440                 : /************************************************************************/
    1441                 : 
    1442                 : /**
    1443                 :  * \brief Fetch field value as a list of strings.
    1444                 :  *
    1445                 :  * Currently this method only works for OFTStringList fields.
    1446                 :  *
    1447                 :  * The returned list is terminated by a NULL pointer. The number of
    1448                 :  * elements can also be calculated using CSLCount().
    1449                 :  *
    1450                 :  * This method is the same as the C function OGR_F_GetFieldAsStringList().
    1451                 :  *
    1452                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1453                 :  *
    1454                 :  * @return the field value.  This list is internal, and should not be
    1455                 :  * modified, or freed.  It's lifetime may be very brief.
    1456                 :  */
    1457                 : 
    1458              67 : char **OGRFeature::GetFieldAsStringList( int iField ) const
    1459                 : 
    1460                 : {
    1461              67 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1462                 : 
    1463                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1464              67 :     if( poFDefn == NULL )
    1465               0 :         return NULL;
    1466                 :     
    1467              67 :     if( !IsFieldSet(iField) )
    1468               0 :         return NULL;
    1469                 :     
    1470              67 :     if( poFDefn->GetType() == OFTStringList )
    1471                 :     {
    1472              67 :         return pauFields[iField].StringList.paList;
    1473                 :     }
    1474                 :     else
    1475                 :     {
    1476               0 :         return NULL;
    1477                 :     }
    1478                 : }
    1479                 : 
    1480                 : /************************************************************************/
    1481                 : /*                     OGR_F_GetFieldAsStringList()                     */
    1482                 : /************************************************************************/
    1483                 : 
    1484                 : /**
    1485                 :  * \brief Fetch field value as a list of strings.
    1486                 :  *
    1487                 :  * Currently this method only works for OFTStringList fields.
    1488                 :  *
    1489                 :  * The returned list is terminated by a NULL pointer. The number of
    1490                 :  * elements can also be calculated using CSLCount().
    1491                 :  *
    1492                 :  * This function is the same as the C++ method 
    1493                 :  * OGRFeature::GetFieldAsStringList().
    1494                 :  *
    1495                 :  * @param hFeat handle to the feature that owned the field.
    1496                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1497                 :  *
    1498                 :  * @return the field value.  This list is internal, and should not be
    1499                 :  * modified, or freed.  It's lifetime may be very brief.
    1500                 :  */
    1501                 : 
    1502               1 : char **OGR_F_GetFieldAsStringList( OGRFeatureH hFeat, int iField )
    1503                 : 
    1504                 : {
    1505               1 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsStringList", NULL );
    1506                 : 
    1507               1 :     return ((OGRFeature *)hFeat)->GetFieldAsStringList(iField);
    1508                 : }
    1509                 : 
    1510                 : /************************************************************************/
    1511                 : /*                          GetFieldAsBinary()                          */
    1512                 : /************************************************************************/
    1513                 : 
    1514                 : /**
    1515                 :  * \brief Fetch field value as binary data.
    1516                 :  *
    1517                 :  * Currently this method only works for OFTBinary fields.
    1518                 :  *
    1519                 :  * This method is the same as the C function OGR_F_GetFieldAsBinary().
    1520                 :  *
    1521                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1522                 :  * @param pnBytes location to put the number of bytes returned.
    1523                 :  *
    1524                 :  * @return the field value.  This data is internal, and should not be
    1525                 :  * modified, or freed.  It's lifetime may be very brief.
    1526                 :  */
    1527                 : 
    1528              15 : GByte *OGRFeature::GetFieldAsBinary( int iField, int *pnBytes )
    1529                 : 
    1530                 : {
    1531              15 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1532                 : 
    1533              15 :     *pnBytes = 0;
    1534                 : 
    1535                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1536              15 :     if( poFDefn == NULL )
    1537               0 :         return NULL;
    1538                 :     
    1539              15 :     if( !IsFieldSet(iField) )
    1540               0 :         return NULL;
    1541                 :     
    1542              15 :     if( poFDefn->GetType() == OFTBinary )
    1543                 :     {
    1544              15 :         *pnBytes = pauFields[iField].Binary.nCount;
    1545              15 :         return pauFields[iField].Binary.paData;
    1546                 :     }
    1547                 :     else
    1548                 :     {
    1549               0 :         return NULL;
    1550                 :     }
    1551                 : }
    1552                 : 
    1553                 : /************************************************************************/
    1554                 : /*                       OGR_F_GetFieldAsBinary()                       */
    1555                 : /************************************************************************/
    1556                 : 
    1557                 : /**
    1558                 :  * \brief Fetch field value as binary.
    1559                 :  *
    1560                 :  * Currently this method only works for OFTBinary fields.
    1561                 :  *
    1562                 :  * This function is the same as the C++ method 
    1563                 :  * OGRFeature::GetFieldAsBinary().
    1564                 :  *
    1565                 :  * @param hFeat handle to the feature that owned the field.
    1566                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1567                 :  * @param pnBytes location to place count of bytes returned.
    1568                 :  *
    1569                 :  * @return the field value.  This list is internal, and should not be
    1570                 :  * modified, or freed.  It's lifetime may be very brief.
    1571                 :  */
    1572                 : 
    1573              10 : GByte *OGR_F_GetFieldAsBinary( OGRFeatureH hFeat, int iField, int *pnBytes )
    1574                 : 
    1575                 : {
    1576              10 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsBinary", NULL );
    1577                 : 
    1578              10 :     return ((OGRFeature *)hFeat)->GetFieldAsBinary(iField,pnBytes);
    1579                 : }
    1580                 : 
    1581                 : /************************************************************************/
    1582                 : /*                         GetFieldAsDateTime()                         */
    1583                 : /************************************************************************/
    1584                 : 
    1585                 : /**
    1586                 :  * \brief Fetch field value as date and time.
    1587                 :  *
    1588                 :  * Currently this method only works for OFTDate, OFTTime and OFTDateTime fields.
    1589                 :  *
    1590                 :  * This method is the same as the C function OGR_F_GetFieldAsDateTime().
    1591                 :  *
    1592                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1593                 :  * @param pnYear (including century)
    1594                 :  * @param pnMonth (1-12)
    1595                 :  * @param pnDay (1-31)
    1596                 :  * @param pnHour (0-23)
    1597                 :  * @param pnMinute (0-59)
    1598                 :  * @param pnSecond (0-59)
    1599                 :  * @param pnTZFlag (0=unknown, 1=localtime, 100=GMT, see data model for details)
    1600                 :  *
    1601                 :  * @return TRUE on success or FALSE on failure.
    1602                 :  */
    1603                 : 
    1604             126 : int OGRFeature::GetFieldAsDateTime( int iField,
    1605                 :                                     int *pnYear, int *pnMonth, int *pnDay,
    1606                 :                                     int *pnHour, int *pnMinute, int *pnSecond,
    1607                 :                                     int *pnTZFlag )
    1608                 : 
    1609                 : {
    1610             126 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1611                 : 
    1612                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1613             126 :     if( poFDefn == NULL )
    1614               0 :         return FALSE;
    1615                 :     
    1616             126 :     if( !IsFieldSet(iField) )
    1617               0 :         return FALSE;
    1618                 :     
    1619             126 :     if( poFDefn->GetType() == OFTDate
    1620                 :         || poFDefn->GetType() == OFTTime
    1621                 :         || poFDefn->GetType() == OFTDateTime )
    1622                 : 
    1623                 :     {
    1624             126 :         if( pnYear )
    1625             126 :             *pnYear = pauFields[iField].Date.Year;
    1626             126 :         if( pnMonth )
    1627             126 :             *pnMonth = pauFields[iField].Date.Month;
    1628             126 :         if( pnDay )
    1629             126 :             *pnDay = pauFields[iField].Date.Day;
    1630             126 :         if( pnHour )
    1631             125 :             *pnHour = pauFields[iField].Date.Hour;
    1632             126 :         if( pnMinute )
    1633             125 :             *pnMinute = pauFields[iField].Date.Minute;
    1634             126 :         if( pnSecond )
    1635             125 :             *pnSecond = pauFields[iField].Date.Second;
    1636             126 :         if( pnTZFlag )
    1637             125 :             *pnTZFlag = pauFields[iField].Date.TZFlag;
    1638                 :         
    1639             126 :         return TRUE;
    1640                 :     }
    1641                 :     else
    1642                 :     {
    1643               0 :         return FALSE;
    1644                 :     }
    1645                 : }
    1646                 : 
    1647                 : /************************************************************************/
    1648                 : /*                      OGR_F_GetFieldAsDateTime()                      */
    1649                 : /************************************************************************/
    1650                 : 
    1651                 : /**
    1652                 :  * \brief Fetch field value as date and time.
    1653                 :  *
    1654                 :  * Currently this method only works for OFTDate, OFTTime and OFTDateTime fields.
    1655                 :  *
    1656                 :  * This function is the same as the C++ method 
    1657                 :  * OGRFeature::GetFieldAsDateTime().
    1658                 :  *
    1659                 :  * @param hFeat handle to the feature that owned the field.
    1660                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1661                 :  * @param pnYear (including century)
    1662                 :  * @param pnMonth (1-12)
    1663                 :  * @param pnDay (1-31)
    1664                 :  * @param pnHour (0-23)
    1665                 :  * @param pnMinute (0-59)
    1666                 :  * @param pnSecond (0-59)
    1667                 :  * @param pnTZFlag (0=unknown, 1=localtime, 100=GMT, see data model for details)
    1668                 :  *
    1669                 :  * @return TRUE on success or FALSE on failure.
    1670                 :  */
    1671                 : 
    1672               1 : int OGR_F_GetFieldAsDateTime( OGRFeatureH hFeat, int iField,
    1673                 :                               int *pnYear, int *pnMonth, int *pnDay,
    1674                 :                               int *pnHour, int *pnMinute, int *pnSecond,
    1675                 :                               int *pnTZFlag )
    1676                 :     
    1677                 : {
    1678               1 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFieldAsDateTime", 0 );
    1679                 : 
    1680                 :     return ((OGRFeature *)hFeat)->GetFieldAsDateTime( iField,
    1681                 :                                                       pnYear, pnMonth, pnDay,
    1682                 :                                                       pnHour, pnMinute,pnSecond,
    1683               1 :                                                       pnTZFlag );
    1684                 : }
    1685                 : 
    1686                 : /************************************************************************/
    1687                 : /*                              SetField()                              */
    1688                 : /************************************************************************/
    1689                 : 
    1690                 : /**
    1691                 :  * \brief Set field to integer value. 
    1692                 :  *
    1693                 :  * OFTInteger and OFTReal fields will be set directly.  OFTString fields
    1694                 :  * will be assigned a string representation of the value, but not necessarily
    1695                 :  * taking into account formatting constraints on this field.  Other field
    1696                 :  * types may be unaffected.
    1697                 :  *
    1698                 :  * This method is the same as the C function OGR_F_SetFieldInteger().
    1699                 :  *
    1700                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1701                 :  * @param nValue the value to assign.
    1702                 :  */
    1703                 : 
    1704           78457 : void OGRFeature::SetField( int iField, int nValue )
    1705                 : 
    1706                 : {
    1707           78457 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1708                 : 
    1709                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1710           78457 :     if( poFDefn == NULL )
    1711               0 :         return;
    1712                 :     
    1713           78457 :     if( poFDefn->GetType() == OFTInteger )
    1714                 :     {
    1715           78455 :         pauFields[iField].Integer = nValue;
    1716           78455 :         pauFields[iField].Set.nMarker2 = 0;
    1717                 :     }
    1718               2 :     else if( poFDefn->GetType() == OFTReal )
    1719                 :     {
    1720               0 :         pauFields[iField].Real = nValue;
    1721                 :     }
    1722               2 :     else if( poFDefn->GetType() == OFTString )
    1723                 :     {
    1724                 :         char    szTempBuffer[64];
    1725                 : 
    1726               2 :         sprintf( szTempBuffer, "%d", nValue );
    1727                 : 
    1728               2 :         if( IsFieldSet( iField) )
    1729               0 :             CPLFree( pauFields[iField].String );
    1730                 :         
    1731               2 :         pauFields[iField].String = CPLStrdup( szTempBuffer );
    1732                 :     }
    1733                 :     else
    1734                 :         /* do nothing for other field types */;
    1735                 : }
    1736                 : 
    1737                 : /************************************************************************/
    1738                 : /*                       OGR_F_SetFieldInteger()                        */
    1739                 : /************************************************************************/
    1740                 : 
    1741                 : /**
    1742                 :  * \brief Set field to integer value. 
    1743                 :  *
    1744                 :  * OFTInteger and OFTReal fields will be set directly.  OFTString fields
    1745                 :  * will be assigned a string representation of the value, but not necessarily
    1746                 :  * taking into account formatting constraints on this field.  Other field
    1747                 :  * types may be unaffected.
    1748                 :  *
    1749                 :  * This function is the same as the C++ method OGRFeature::SetField().
    1750                 :  *
    1751                 :  * @param hFeat handle to the feature that owned the field.
    1752                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1753                 :  * @param nValue the value to assign.
    1754                 :  */
    1755                 : 
    1756             291 : void OGR_F_SetFieldInteger( OGRFeatureH hFeat, int iField, int nValue )
    1757                 : 
    1758                 : {
    1759             291 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldInteger" );
    1760                 : 
    1761             291 :     ((OGRFeature *)hFeat)->SetField( iField, nValue );
    1762                 : }
    1763                 : 
    1764                 : /************************************************************************/
    1765                 : /*                              SetField()                              */
    1766                 : /************************************************************************/
    1767                 : 
    1768                 : /**
    1769                 :  * \brief Set field to double value. 
    1770                 :  *
    1771                 :  * OFTInteger and OFTReal fields will be set directly.  OFTString fields
    1772                 :  * will be assigned a string representation of the value, but not necessarily
    1773                 :  * taking into account formatting constraints on this field.  Other field
    1774                 :  * types may be unaffected.
    1775                 :  *
    1776                 :  * This method is the same as the C function OGR_F_SetFieldDouble().
    1777                 :  *
    1778                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1779                 :  * @param dfValue the value to assign.
    1780                 :  */
    1781                 : 
    1782           23940 : void OGRFeature::SetField( int iField, double dfValue )
    1783                 : 
    1784                 : {
    1785           23940 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1786                 : 
    1787                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1788           23940 :     if( poFDefn == NULL )
    1789               0 :         return;
    1790                 :     
    1791           23940 :     if( poFDefn->GetType() == OFTReal )
    1792                 :     {
    1793           23821 :         pauFields[iField].Real = dfValue;
    1794                 :     }
    1795             119 :     else if( poFDefn->GetType() == OFTInteger )
    1796                 :     {
    1797             117 :         pauFields[iField].Integer = (int) dfValue;
    1798             117 :         pauFields[iField].Set.nMarker2 = 0;
    1799                 :     }
    1800               2 :     else if( poFDefn->GetType() == OFTString )
    1801                 :     {
    1802                 :         char    szTempBuffer[128];
    1803                 : 
    1804               2 :         sprintf( szTempBuffer, "%.16g", dfValue );
    1805                 : 
    1806               2 :         if( IsFieldSet( iField) )
    1807               0 :             CPLFree( pauFields[iField].String );
    1808                 : 
    1809               2 :         pauFields[iField].String = CPLStrdup( szTempBuffer );
    1810                 :     }
    1811                 :     else
    1812                 :         /* do nothing for other field types */;
    1813                 : }
    1814                 : 
    1815                 : /************************************************************************/
    1816                 : /*                        OGR_F_SetFieldDouble()                        */
    1817                 : /************************************************************************/
    1818                 : 
    1819                 : /**
    1820                 :  * \brief Set field to double value. 
    1821                 :  *
    1822                 :  * OFTInteger and OFTReal fields will be set directly.  OFTString fields
    1823                 :  * will be assigned a string representation of the value, but not necessarily
    1824                 :  * taking into account formatting constraints on this field.  Other field
    1825                 :  * types may be unaffected.
    1826                 :  *
    1827                 :  * This function is the same as the C++ method OGRFeature::SetField().
    1828                 :  *
    1829                 :  * @param hFeat handle to the feature that owned the field.
    1830                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1831                 :  * @param dfValue the value to assign.
    1832                 :  */
    1833                 : 
    1834             136 : void OGR_F_SetFieldDouble( OGRFeatureH hFeat, int iField, double dfValue )
    1835                 : 
    1836                 : {
    1837             136 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldDouble" );
    1838                 : 
    1839             136 :     ((OGRFeature *)hFeat)->SetField( iField, dfValue );
    1840                 : }
    1841                 : 
    1842                 : /************************************************************************/
    1843                 : /*                              SetField()                              */
    1844                 : /************************************************************************/
    1845                 : 
    1846                 : /**
    1847                 :  * \brief Set field to string value. 
    1848                 :  *
    1849                 :  * OFTInteger fields will be set based on an atoi() conversion of the string.
    1850                 :  * OFTReal fields will be set based on an atof() conversion of the string.
    1851                 :  * Other field types may be unaffected.
    1852                 :  *
    1853                 :  * This method is the same as the C function OGR_F_SetFieldString().
    1854                 :  *
    1855                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1856                 :  * @param pszValue the value to assign.
    1857                 :  */
    1858                 : 
    1859           88609 : void OGRFeature::SetField( int iField, const char * pszValue )
    1860                 : 
    1861                 : {
    1862           88609 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1863                 : 
    1864                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1865           88609 :     if( poFDefn == NULL )
    1866               0 :         return;
    1867                 :     
    1868           88609 :     if( poFDefn->GetType() == OFTString )
    1869                 :     {
    1870           67910 :         if( IsFieldSet(iField) )
    1871             215 :             CPLFree( pauFields[iField].String );
    1872                 :             
    1873           67910 :         pauFields[iField].String = CPLStrdup( pszValue );
    1874                 :     }
    1875           20699 :     else if( poFDefn->GetType() == OFTInteger )
    1876                 :     {
    1877           20118 :         pauFields[iField].Integer = atoi(pszValue);
    1878           20118 :         pauFields[iField].Set.nMarker2 = OGRUnsetMarker;
    1879                 :     }
    1880             581 :     else if( poFDefn->GetType() == OFTReal )
    1881                 :     {
    1882             522 :         pauFields[iField].Real = atof(pszValue);
    1883                 :     }
    1884              59 :     else if( poFDefn->GetType() == OFTDate 
    1885                 :              || poFDefn->GetType() == OFTTime
    1886                 :              || poFDefn->GetType() == OFTDateTime )
    1887                 :     {
    1888                 :         OGRField sWrkField;
    1889                 : 
    1890              59 :         if( OGRParseDate( pszValue, &sWrkField, 0 ) )
    1891              58 :             memcpy( pauFields+iField, &sWrkField, sizeof(sWrkField));
    1892                 :     }
    1893                 :     else
    1894                 :         /* do nothing for other field types */;
    1895                 : }
    1896                 : 
    1897                 : /************************************************************************/
    1898                 : /*                        OGR_F_SetFieldString()                        */
    1899                 : /************************************************************************/
    1900                 : 
    1901                 : /**
    1902                 :  * \brief Set field to string value. 
    1903                 :  *
    1904                 :  * OFTInteger fields will be set based on an atoi() conversion of the string.
    1905                 :  * OFTReal fields will be set based on an atof() conversion of the string.
    1906                 :  * Other field types may be unaffected.
    1907                 :  *
    1908                 :  * This function is the same as the C++ method OGRFeature::SetField().
    1909                 :  *
    1910                 :  * @param hFeat handle to the feature that owned the field.
    1911                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    1912                 :  * @param pszValue the value to assign.
    1913                 :  */
    1914                 : 
    1915            4305 : void OGR_F_SetFieldString( OGRFeatureH hFeat, int iField, const char *pszValue)
    1916                 : 
    1917                 : {
    1918            4305 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldString" );
    1919                 : 
    1920            4305 :     ((OGRFeature *)hFeat)->SetField( iField, pszValue );
    1921                 : }
    1922                 : 
    1923                 : /************************************************************************/
    1924                 : /*                              SetField()                              */
    1925                 : /************************************************************************/
    1926                 : 
    1927                 : /**
    1928                 :  * \brief Set field to list of integers value. 
    1929                 :  *
    1930                 :  * This method currently on has an effect of OFTIntegerList fields.
    1931                 :  *
    1932                 :  * This method is the same as the C function OGR_F_SetFieldIntegerList().
    1933                 :  *
    1934                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    1935                 :  * @param nCount the number of values in the list being assigned.
    1936                 :  * @param panValues the values to assign.
    1937                 :  */
    1938                 : 
    1939           34184 : void OGRFeature::SetField( int iField, int nCount, int *panValues )
    1940                 : 
    1941                 : {
    1942           34184 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    1943                 : 
    1944                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    1945           34184 :     if( poFDefn == NULL )
    1946               0 :         return;
    1947                 :     
    1948           34184 :     if( poFDefn->GetType() == OFTIntegerList )
    1949                 :     {
    1950                 :         OGRField        uField;
    1951                 : 
    1952           34184 :         uField.IntegerList.nCount = nCount;
    1953           34184 :         uField.IntegerList.paList = panValues;
    1954                 : 
    1955           34184 :         SetField( iField, &uField );
    1956                 :     }
    1957                 : }
    1958                 : 
    1959                 : /************************************************************************/
    1960                 : /*                     OGR_F_SetFieldIntegerList()                      */
    1961                 : /************************************************************************/
    1962                 : 
    1963                 : /**
    1964                 :  * \brief Set field to list of integers value. 
    1965                 :  *
    1966                 :  * This function currently on has an effect of OFTIntegerList fields.
    1967                 :  *
    1968                 :  * This function is the same as the C++ method OGRFeature::SetField().
    1969                 :  *
    1970                 :  * @param hFeat handle to the feature that owned the field.
    1971                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    1972                 :  * @param nCount the number of values in the list being assigned.
    1973                 :  * @param panValues the values to assign.
    1974                 :  */
    1975                 : 
    1976               4 : void OGR_F_SetFieldIntegerList( OGRFeatureH hFeat, int iField, 
    1977                 :                                 int nCount, int *panValues )
    1978                 : 
    1979                 : {
    1980               4 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldIntegerList" );
    1981                 : 
    1982               4 :     ((OGRFeature *)hFeat)->SetField( iField, nCount, panValues );
    1983                 : }
    1984                 : 
    1985                 : /************************************************************************/
    1986                 : /*                              SetField()                              */
    1987                 : /************************************************************************/
    1988                 : 
    1989                 : /**
    1990                 :  * \brief Set field to list of doubles value. 
    1991                 :  *
    1992                 :  * This method currently on has an effect of OFTRealList fields.
    1993                 :  *
    1994                 :  * This method is the same as the C function OGR_F_SetFieldDoubleList().
    1995                 :  *
    1996                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    1997                 :  * @param nCount the number of values in the list being assigned.
    1998                 :  * @param padfValues the values to assign.
    1999                 :  */
    2000                 : 
    2001           11424 : void OGRFeature::SetField( int iField, int nCount, double * padfValues )
    2002                 : 
    2003                 : {
    2004           11424 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    2005                 : 
    2006                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    2007           11424 :     if( poFDefn == NULL )
    2008               0 :         return;
    2009                 :     
    2010           11424 :     if( poFDefn->GetType() == OFTRealList )
    2011                 :     {
    2012                 :         OGRField        uField;
    2013                 :         
    2014           11424 :         uField.RealList.nCount = nCount;
    2015           11424 :         uField.RealList.paList = padfValues;
    2016                 :         
    2017           11424 :         SetField( iField, &uField );
    2018                 :     }
    2019                 : }
    2020                 : 
    2021                 : /************************************************************************/
    2022                 : /*                      OGR_F_SetFieldDoubleList()                      */
    2023                 : /************************************************************************/
    2024                 : 
    2025                 : /**
    2026                 :  * \brief Set field to list of doubles value. 
    2027                 :  *
    2028                 :  * This function currently on has an effect of OFTRealList fields.
    2029                 :  *
    2030                 :  * This function is the same as the C++ method OGRFeature::SetField().
    2031                 :  *
    2032                 :  * @param hFeat handle to the feature that owned the field.
    2033                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    2034                 :  * @param nCount the number of values in the list being assigned.
    2035                 :  * @param padfValues the values to assign.
    2036                 :  */
    2037                 : 
    2038               4 : void OGR_F_SetFieldDoubleList( OGRFeatureH hFeat, int iField, 
    2039                 :                                int nCount, double *padfValues )
    2040                 : 
    2041                 : {
    2042               4 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldDoubleList" );
    2043                 : 
    2044               4 :     ((OGRFeature *)hFeat)->SetField( iField, nCount, padfValues );
    2045                 : }
    2046                 : 
    2047                 : /************************************************************************/
    2048                 : /*                              SetField()                              */
    2049                 : /************************************************************************/
    2050                 : 
    2051                 : /**
    2052                 :  * \brief Set field to list of strings value. 
    2053                 :  *
    2054                 :  * This method currently on has an effect of OFTStringList fields.
    2055                 :  *
    2056                 :  * This method is the same as the C function OGR_F_SetFieldStringList().
    2057                 :  *
    2058                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    2059                 :  * @param papszValues the values to assign.
    2060                 :  */
    2061                 : 
    2062              52 : void OGRFeature::SetField( int iField, char ** papszValues )
    2063                 : 
    2064                 : {
    2065              52 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    2066                 : 
    2067                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    2068              52 :     if( poFDefn == NULL )
    2069               0 :         return;
    2070                 :     
    2071              52 :     if( poFDefn->GetType() == OFTStringList )
    2072                 :     {
    2073                 :         OGRField        uField;
    2074                 :         
    2075              52 :         uField.StringList.nCount = CSLCount(papszValues);
    2076              52 :         uField.StringList.paList = papszValues;
    2077                 :         
    2078              52 :         SetField( iField, &uField );
    2079                 :     }
    2080                 : }
    2081                 : 
    2082                 : /************************************************************************/
    2083                 : /*                      OGR_F_SetFieldStringList()                      */
    2084                 : /************************************************************************/
    2085                 : 
    2086                 : /**
    2087                 :  * \brief Set field to list of strings value. 
    2088                 :  *
    2089                 :  * This function currently on has an effect of OFTStringList fields.
    2090                 :  *
    2091                 :  * This function is the same as the C++ method OGRFeature::SetField().
    2092                 :  *
    2093                 :  * @param hFeat handle to the feature that owned the field.
    2094                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    2095                 :  * @param papszValues the values to assign.
    2096                 :  */
    2097                 : 
    2098               4 : void OGR_F_SetFieldStringList( OGRFeatureH hFeat, int iField, 
    2099                 :                                char ** papszValues )
    2100                 : 
    2101                 : {
    2102               4 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldStringList" );
    2103                 : 
    2104               4 :     ((OGRFeature *)hFeat)->SetField( iField, papszValues );
    2105                 : }
    2106                 : 
    2107                 : /************************************************************************/
    2108                 : /*                              SetField()                              */
    2109                 : /************************************************************************/
    2110                 : 
    2111                 : /**
    2112                 :  * \brief Set field to binary data.
    2113                 :  *
    2114                 :  * This method currently on has an effect of OFTBinary fields.
    2115                 :  *
    2116                 :  * This method is the same as the C function OGR_F_SetFieldBinary().
    2117                 :  *
    2118                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    2119                 :  * @param nBytes bytes of data being set.
    2120                 :  * @param pabyData the raw data being applied. 
    2121                 :  */
    2122                 : 
    2123              29 : void OGRFeature::SetField( int iField, int nBytes, GByte *pabyData )
    2124                 : 
    2125                 : {
    2126              29 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    2127                 : 
    2128                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    2129              29 :     if( poFDefn == NULL )
    2130               0 :         return;
    2131                 :     
    2132              29 :     if( poFDefn->GetType() == OFTBinary )
    2133                 :     {
    2134                 :         OGRField        uField;
    2135                 : 
    2136              29 :         uField.Binary.nCount = nBytes;
    2137              29 :         uField.Binary.paData = pabyData;
    2138              29 :         SetField( iField, &uField );
    2139                 :     }
    2140                 : }
    2141                 : 
    2142                 : /************************************************************************/
    2143                 : /*                        OGR_F_SetFieldBinary()                        */
    2144                 : /************************************************************************/
    2145                 : 
    2146                 : /**
    2147                 :  * \brief Set field to binary data.
    2148                 :  *
    2149                 :  * This function currently on has an effect of OFTBinary fields.
    2150                 :  *
    2151                 :  * This function is the same as the C++ method OGRFeature::SetField().
    2152                 :  *
    2153                 :  * @param hFeat handle to the feature that owned the field.
    2154                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    2155                 :  * @param nBytes the number of bytes in pabyData array.
    2156                 :  * @param pabyData the data to apply.
    2157                 :  */
    2158                 : 
    2159               0 : void OGR_F_SetFieldBinary( OGRFeatureH hFeat, int iField, 
    2160                 :                            int nBytes, GByte *pabyData )
    2161                 : 
    2162                 : {
    2163               0 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldBinary" );
    2164                 : 
    2165               0 :     ((OGRFeature *)hFeat)->SetField( iField, nBytes, pabyData );
    2166                 : }
    2167                 : 
    2168                 : /************************************************************************/
    2169                 : /*                              SetField()                              */
    2170                 : /************************************************************************/
    2171                 : 
    2172                 : /**
    2173                 :  * \brief Set field to date.
    2174                 :  *
    2175                 :  * This method currently only has an effect for OFTDate, OFTTime and OFTDateTime
    2176                 :  * fields.
    2177                 :  *
    2178                 :  * This method is the same as the C function OGR_F_SetFieldDateTime().
    2179                 :  *
    2180                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    2181                 :  * @param nYear (including century)
    2182                 :  * @param nMonth (1-12)
    2183                 :  * @param nDay (1-31)
    2184                 :  * @param nHour (0-23)
    2185                 :  * @param nMinute (0-59)
    2186                 :  * @param nSecond (0-59)
    2187                 :  * @param nTZFlag (0=unknown, 1=localtime, 100=GMT, see data model for details)
    2188                 :  */
    2189                 : 
    2190              78 : void OGRFeature::SetField( int iField, int nYear, int nMonth, int nDay,
    2191                 :                            int nHour, int nMinute, int nSecond, 
    2192                 :                            int nTZFlag )
    2193                 : 
    2194                 : {
    2195              78 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    2196                 : 
    2197                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    2198              78 :     if( poFDefn == NULL )
    2199               0 :         return;
    2200                 :     
    2201              78 :     if( poFDefn->GetType() == OFTDate 
    2202                 :         || poFDefn->GetType() == OFTTime 
    2203                 :         || poFDefn->GetType() == OFTDateTime )
    2204                 :     {
    2205              78 :         pauFields[iField].Date.Year = (GInt16)nYear;
    2206              78 :         pauFields[iField].Date.Month = (GByte)nMonth;
    2207              78 :         pauFields[iField].Date.Day = (GByte)nDay;
    2208              78 :         pauFields[iField].Date.Hour = (GByte)nHour;
    2209              78 :         pauFields[iField].Date.Minute = (GByte)nMinute;
    2210              78 :         pauFields[iField].Date.Second = (GByte)nSecond;
    2211              78 :         pauFields[iField].Date.TZFlag = (GByte)nTZFlag;
    2212                 :     }
    2213                 : }
    2214                 : 
    2215                 : /************************************************************************/
    2216                 : /*                       OGR_F_SetFieldDateTime()                       */
    2217                 : /************************************************************************/
    2218                 : 
    2219                 : /**
    2220                 :  * \brief Set field to datetime.
    2221                 :  *
    2222                 :  * This method currently only has an effect for OFTDate, OFTTime and OFTDateTime
    2223                 :  * fields.
    2224                 :  *
    2225                 :  * @param hFeat handle to the feature that owned the field.
    2226                 :  * @param iField the field to set, from 0 to GetFieldCount()-1.
    2227                 :  * @param nYear (including century)
    2228                 :  * @param nMonth (1-12)
    2229                 :  * @param nDay (1-31)
    2230                 :  * @param nHour (0-23)
    2231                 :  * @param nMinute (0-59)
    2232                 :  * @param nSecond (0-59)
    2233                 :  * @param nTZFlag (0=unknown, 1=localtime, 100=GMT, see data model for details)
    2234                 :  */
    2235                 : 
    2236              25 : void OGR_F_SetFieldDateTime( OGRFeatureH hFeat, int iField, 
    2237                 :                              int nYear, int nMonth, int nDay,
    2238                 :                              int nHour, int nMinute, int nSecond, 
    2239                 :                              int nTZFlag )
    2240                 : 
    2241                 : 
    2242                 : {
    2243              25 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldDateTime" );
    2244                 : 
    2245                 :     ((OGRFeature *)hFeat)->SetField( iField, nYear, nMonth, nDay,
    2246              25 :                                      nHour, nMinute, nSecond, nTZFlag );
    2247                 : }
    2248                 : 
    2249                 : /************************************************************************/
    2250                 : /*                              SetField()                              */
    2251                 : /************************************************************************/
    2252                 : 
    2253                 : /**
    2254                 :  * \brief Set field.
    2255                 :  *
    2256                 :  * The passed value OGRField must be of exactly the same type as the
    2257                 :  * target field, or an application crash may occur.  The passed value
    2258                 :  * is copied, and will not be affected.  It remains the responsibility of
    2259                 :  * the caller. 
    2260                 :  *
    2261                 :  * This method is the same as the C function OGR_F_SetFieldRaw().
    2262                 :  *
    2263                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    2264                 :  * @param puValue the value to assign.
    2265                 :  */
    2266                 : 
    2267           47543 : void OGRFeature::SetField( int iField, OGRField * puValue )
    2268                 : 
    2269                 : {
    2270           47543 :     OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );
    2271                 : 
    2272                 :     CPLAssert( poFDefn != NULL || iField == -1 );
    2273           47543 :     if( poFDefn == NULL )
    2274               0 :         return;
    2275                 :     
    2276           47543 :     if( poFDefn->GetType() == OFTInteger )
    2277                 :     {
    2278             426 :         pauFields[iField] = *puValue;
    2279                 :     }
    2280           47117 :     else if( poFDefn->GetType() == OFTReal )
    2281                 :     {
    2282             488 :         pauFields[iField] = *puValue;
    2283                 :     }
    2284           46629 :     else if( poFDefn->GetType() == OFTString )
    2285                 :     {
    2286             509 :         if( IsFieldSet( iField ) )
    2287               0 :             CPLFree( pauFields[iField].String );
    2288                 :         
    2289             509 :         if( puValue->String == NULL )
    2290               0 :             pauFields[iField].String = NULL;
    2291             531 :         else if( puValue->Set.nMarker1 == OGRUnsetMarker
    2292                 :                  && puValue->Set.nMarker2 == OGRUnsetMarker )
    2293              22 :             pauFields[iField] = *puValue;
    2294                 :         else
    2295             487 :             pauFields[iField].String = CPLStrdup( puValue->String );
    2296                 :     }
    2297           46120 :     else if( poFDefn->GetType() == OFTDate
    2298                 :              || poFDefn->GetType() == OFTTime
    2299                 :              || poFDefn->GetType() == OFTDateTime )
    2300                 :     {
    2301             297 :         memcpy( pauFields+iField, puValue, sizeof(OGRField) );
    2302                 :     }
    2303           45823 :     else if( poFDefn->GetType() == OFTIntegerList )
    2304                 :     {
    2305           34223 :         int     nCount = puValue->IntegerList.nCount;
    2306                 :         
    2307           34223 :         if( IsFieldSet( iField ) )
    2308               2 :             CPLFree( pauFields[iField].IntegerList.paList );
    2309                 :         
    2310           34223 :         if( puValue->Set.nMarker1 == OGRUnsetMarker
    2311                 :             && puValue->Set.nMarker2 == OGRUnsetMarker )
    2312                 :         {
    2313               0 :             pauFields[iField] = *puValue;
    2314                 :         }
    2315                 :         else
    2316                 :         {
    2317           34223 :             pauFields[iField].IntegerList.paList =
    2318           34223 :                 (int *) CPLMalloc(sizeof(int) * nCount);
    2319           34223 :             memcpy( pauFields[iField].IntegerList.paList,
    2320                 :                     puValue->IntegerList.paList,
    2321           68446 :                     sizeof(int) * nCount );
    2322           34223 :             pauFields[iField].IntegerList.nCount = nCount;
    2323                 :         }
    2324                 :     }
    2325           11600 :     else if( poFDefn->GetType() == OFTRealList )
    2326                 :     {
    2327           11467 :         int     nCount = puValue->RealList.nCount;
    2328                 : 
    2329           11467 :         if( IsFieldSet( iField ) )
    2330               2 :             CPLFree( pauFields[iField].RealList.paList );
    2331                 : 
    2332           11467 :         if( puValue->Set.nMarker1 == OGRUnsetMarker
    2333                 :             && puValue->Set.nMarker2 == OGRUnsetMarker )
    2334                 :         {
    2335               0 :             pauFields[iField] = *puValue;
    2336                 :         }
    2337                 :         else
    2338                 :         {
    2339           11467 :             pauFields[iField].RealList.paList =
    2340           11467 :                 (double *) CPLMalloc(sizeof(double) * nCount);
    2341           11467 :             memcpy( pauFields[iField].RealList.paList,
    2342                 :                     puValue->RealList.paList,
    2343           22934 :                     sizeof(double) * nCount );
    2344           11467 :             pauFields[iField].RealList.nCount = nCount;
    2345                 :         }
    2346                 :     }
    2347             133 :     else if( poFDefn->GetType() == OFTStringList )
    2348                 :     {
    2349              99 :         if( IsFieldSet( iField ) )
    2350               2 :             CSLDestroy( pauFields[iField].StringList.paList );
    2351                 :         
    2352              99 :         if( puValue->Set.nMarker1 == OGRUnsetMarker
    2353                 :             && puValue->Set.nMarker2 == OGRUnsetMarker )
    2354                 :         {
    2355               0 :             pauFields[iField] = *puValue;
    2356                 :         }
    2357                 :         else
    2358                 :         {
    2359              99 :             pauFields[iField].StringList.paList =
    2360              99 :                 CSLDuplicate( puValue->StringList.paList );
    2361                 :             
    2362              99 :             pauFields[iField].StringList.nCount = puValue->StringList.nCount;
    2363                 :             CPLAssert( CSLCount(puValue->StringList.paList)
    2364                 :                        == puValue->StringList.nCount );
    2365                 :         }
    2366                 :     }
    2367              34 :     else if( poFDefn->GetType() == OFTBinary )
    2368                 :     {
    2369              34 :         if( IsFieldSet( iField ) )
    2370               0 :             CPLFree( pauFields[iField].Binary.paData );
    2371                 :         
    2372              34 :         if( puValue->Set.nMarker1 == OGRUnsetMarker
    2373                 :             && puValue->Set.nMarker2 == OGRUnsetMarker )
    2374                 :         {
    2375               0 :             pauFields[iField] = *puValue;
    2376                 :         }
    2377                 :         else
    2378                 :         {
    2379              34 :             pauFields[iField].Binary.nCount = puValue->Binary.nCount;
    2380              34 :             pauFields[iField].Binary.paData = 
    2381              34 :                 (GByte *) CPLMalloc(puValue->Binary.nCount);
    2382              34 :             memcpy( pauFields[iField].Binary.paData, 
    2383                 :                     puValue->Binary.paData, 
    2384              68 :                     puValue->Binary.nCount );
    2385                 :         }
    2386                 :     }
    2387                 :     else
    2388                 :         /* do nothing for other field types */;
    2389                 : }
    2390                 : 
    2391                 : /************************************************************************/
    2392                 : /*                      OGR_F_SetFieldRaw()                             */
    2393                 : /************************************************************************/
    2394                 : 
    2395                 : /**
    2396                 :  * \brief Set field.
    2397                 :  *
    2398                 :  * The passed value OGRField must be of exactly the same type as the
    2399                 :  * target field, or an application crash may occur.  The passed value
    2400                 :  * is copied, and will not be affected.  It remains the responsibility of
    2401                 :  * the caller. 
    2402                 :  *
    2403                 :  * This function is the same as the C++ method OGRFeature::SetField().
    2404                 :  *
    2405                 :  * @param hFeat handle to the feature that owned the field.
    2406                 :  * @param iField the field to fetch, from 0 to GetFieldCount()-1.
    2407                 :  * @param psValue handle on the value to assign.
    2408                 :  */
    2409                 : 
    2410               0 : void OGR_F_SetFieldRaw( OGRFeatureH hFeat, int iField, OGRField *psValue )
    2411                 : 
    2412                 : {
    2413               0 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetFieldRaw" );
    2414                 : 
    2415               0 :     ((OGRFeature *)hFeat)->SetField( iField, psValue );
    2416                 : }
    2417                 : 
    2418                 : /************************************************************************/
    2419                 : /*                            DumpReadable()                            */
    2420                 : /************************************************************************/
    2421                 : 
    2422                 : /**
    2423                 :  * \brief Dump this feature in a human readable form.
    2424                 :  *
    2425                 :  * This dumps the attributes, and geometry; however, it doesn't definition
    2426                 :  * information (other than field types and names), nor does it report the
    2427                 :  * geometry spatial reference system.
    2428                 :  *
    2429                 :  * A few options can be defined to change the default dump :
    2430                 :  * <ul>
    2431                 :  * <li>DISPLAY_FIELDS=NO : to hide the dump of the attributes</li>
    2432                 :  * <li>DISPLAY_STYLE=NO : to hide the dump of the style string</li>
    2433                 :  * <li>DISPLAY_GEOMETRY=NO : to hide the dump of the geometry</li>
    2434                 :  * <li>DISPLAY_GEOMETRY=SUMMARY : to get only a summary of the geometry</li>
    2435                 :  * </ul>
    2436                 :  *
    2437                 :  * This method is the same as the C function OGR_F_DumpReadable().
    2438                 :  *
    2439                 :  * @param fpOut the stream to write to, such as stdout.  If NULL stdout will
    2440                 :  * be used. 
    2441                 :  * @param papszOptions NULL terminated list of options (may be NULL)
    2442                 :  */
    2443                 : 
    2444              56 : void OGRFeature::DumpReadable( FILE * fpOut, char** papszOptions )
    2445                 : 
    2446                 : {
    2447              56 :     if( fpOut == NULL )
    2448              56 :         fpOut = stdout;
    2449                 : 
    2450              56 :     fprintf( fpOut, "OGRFeature(%s):%ld\n", poDefn->GetName(), GetFID() );
    2451                 : 
    2452                 :     const char* pszDisplayFields =
    2453              56 :             CSLFetchNameValue(papszOptions, "DISPLAY_FIELDS");
    2454              56 :     if (pszDisplayFields == NULL || CSLTestBoolean(pszDisplayFields))
    2455                 :     {
    2456             184 :         for( int iField = 0; iField < GetFieldCount(); iField++ )
    2457                 :         {
    2458             138 :             OGRFieldDefn    *poFDefn = poDefn->GetFieldDefn(iField);
    2459                 : 
    2460                 :             fprintf( fpOut, "  %s (%s) = ",
    2461                 :                     poFDefn->GetNameRef(),
    2462             138 :                     OGRFieldDefn::GetFieldTypeName(poFDefn->GetType()) );
    2463                 : 
    2464             138 :             if( IsFieldSet( iField ) )
    2465             138 :                 fprintf( fpOut, "%s\n", GetFieldAsString( iField ) );
    2466                 :             else
    2467               0 :                 fprintf( fpOut, "(null)\n" );
    2468                 : 
    2469                 :         }
    2470                 :     }
    2471                 : 
    2472                 : 
    2473              56 :     if( GetStyleString() != NULL )
    2474                 :     {
    2475                 :         const char* pszDisplayStyle =
    2476               0 :             CSLFetchNameValue(papszOptions, "DISPLAY_STYLE");
    2477               0 :         if (pszDisplayStyle == NULL || CSLTestBoolean(pszDisplayStyle))
    2478                 :         {
    2479               0 :             fprintf( fpOut, "  Style = %s\n", GetStyleString() );
    2480                 :         }
    2481                 :     }
    2482                 : 
    2483              56 :     if( poGeometry != NULL )
    2484                 :     {
    2485                 :         const char* pszDisplayGeometry =
    2486              56 :                 CSLFetchNameValue(papszOptions, "DISPLAY_GEOMETRY");
    2487              56 :         if ( ! (pszDisplayGeometry != NULL && EQUAL(pszDisplayGeometry, "NO") ) )
    2488              56 :             poGeometry->dumpReadable( fpOut, "  ", papszOptions );
    2489                 :     }
    2490                 : 
    2491              56 :     fprintf( fpOut, "\n" );
    2492              56 : }
    2493                 : 
    2494                 : /************************************************************************/
    2495                 : /*                         OGR_F_DumpReadable()                         */
    2496                 : /************************************************************************/
    2497                 : 
    2498                 : /**
    2499                 :  * \brief Dump this feature in a human readable form.
    2500                 :  *
    2501                 :  * This dumps the attributes, and geometry; however, it doesn't definition
    2502                 :  * information (other than field types and names), nor does it report the
    2503                 :  * geometry spatial reference system.
    2504                 :  *
    2505                 :  * This function is the same as the C++ method OGRFeature::DumpReadable().
    2506                 :  *
    2507                 :  * @param hFeat handle to the feature to dump.
    2508                 :  * @param fpOut the stream to write to, such as strout.
    2509                 :  */
    2510                 : 
    2511               0 : void OGR_F_DumpReadable( OGRFeatureH hFeat, FILE *fpOut )
    2512                 : 
    2513                 : {
    2514               0 :     VALIDATE_POINTER0( hFeat, "OGR_F_DumpReadable" );
    2515                 : 
    2516               0 :     ((OGRFeature *) hFeat)->DumpReadable( fpOut );
    2517                 : }
    2518                 : 
    2519                 : /************************************************************************/
    2520                 : /*                               GetFID()                               */
    2521                 : /************************************************************************/
    2522                 : 
    2523                 : /**
    2524                 :  * \fn long OGRFeature::GetFID();
    2525                 :  *
    2526                 :  * \brief Get feature identifier.
    2527                 :  *
    2528                 :  * This method is the same as the C function OGR_F_GetFID().
    2529                 :  *
    2530                 :  * @return feature id or OGRNullFID if none has been assigned.
    2531                 :  */
    2532                 : 
    2533                 : /************************************************************************/
    2534                 : /*                            OGR_F_GetFID()                            */
    2535                 : /************************************************************************/
    2536                 : 
    2537                 : /**
    2538                 :  * \brief Get feature identifier.
    2539                 :  *
    2540                 :  * This function is the same as the C++ method OGRFeature::GetFID().
    2541                 :  *
    2542                 :  * @param hFeat handle to the feature from which to get the feature
    2543                 :  * identifier.
    2544                 :  * @return feature id or OGRNullFID if none has been assigned.
    2545                 :  */
    2546                 : 
    2547             131 : long OGR_F_GetFID( OGRFeatureH hFeat )
    2548                 : 
    2549                 : {
    2550             131 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetFID", 0 );
    2551                 : 
    2552             131 :     return ((OGRFeature *) hFeat)->GetFID();
    2553                 : }
    2554                 : 
    2555                 : /************************************************************************/
    2556                 : /*                               SetFID()                               */
    2557                 : /************************************************************************/
    2558                 : 
    2559                 : /**
    2560                 :  * \brief Set the feature identifier.
    2561                 :  *
    2562                 :  * For specific types of features this operation may fail on illegal
    2563                 :  * features ids.  Generally it always succeeds.  Feature ids should be
    2564                 :  * greater than or equal to zero, with the exception of OGRNullFID (-1)
    2565                 :  * indicating that the feature id is unknown.
    2566                 :  *
    2567                 :  * This method is the same as the C function OGR_F_SetFID().
    2568                 :  *
    2569                 :  * @param nFID the new feature identifier value to assign.
    2570                 :  *
    2571                 :  * @return On success OGRERR_NONE, or on failure some other value. 
    2572                 :  */
    2573                 : 
    2574           85637 : OGRErr OGRFeature::SetFID( long nFID )
    2575                 : 
    2576                 : {
    2577           85637 :     this->nFID = nFID;
    2578                 :     
    2579           85637 :     return OGRERR_NONE;
    2580                 : }
    2581                 : 
    2582                 : /************************************************************************/
    2583                 : /*                            OGR_F_SetFID()                            */
    2584                 : /************************************************************************/
    2585                 : 
    2586                 : /**
    2587                 :  * \brief Set the feature identifier.
    2588                 :  *
    2589                 :  * For specific types of features this operation may fail on illegal
    2590                 :  * features ids.  Generally it always succeeds.  Feature ids should be
    2591                 :  * greater than or equal to zero, with the exception of OGRNullFID (-1)
    2592                 :  * indicating that the feature id is unknown.
    2593                 :  *
    2594                 :  * This function is the same as the C++ method OGRFeature::SetFID().
    2595                 :  *
    2596                 :  * @param hFeat handle to the feature to set the feature id to.
    2597                 :  * @param nFID the new feature identifier value to assign.
    2598                 :  *
    2599                 :  * @return On success OGRERR_NONE, or on failure some other value. 
    2600                 :  */
    2601                 : 
    2602              63 : OGRErr OGR_F_SetFID( OGRFeatureH hFeat, long nFID )
    2603                 : 
    2604                 : {
    2605              63 :     VALIDATE_POINTER1( hFeat, "OGR_F_SetFID", CE_Failure );
    2606                 : 
    2607              63 :     return ((OGRFeature *) hFeat)->SetFID(nFID);
    2608                 : }
    2609                 : 
    2610                 : /************************************************************************/
    2611                 : /*                               Equal()                                */
    2612                 : /************************************************************************/
    2613                 : 
    2614                 : /**
    2615                 :  * \brief Test if two features are the same.
    2616                 :  *
    2617                 :  * Two features are considered equal if the share them (pointer equality)
    2618                 :  * same OGRFeatureDefn, have the same field values, and the same geometry
    2619                 :  * (as tested by OGRGeometry::Equal()) as well as the same feature id.
    2620                 :  *
    2621                 :  * This method is the same as the C function OGR_F_Equal().
    2622                 :  *
    2623                 :  * @param poFeature the other feature to test this one against.
    2624                 :  *
    2625                 :  * @return TRUE if they are equal, otherwise FALSE.
    2626                 :  */
    2627                 : 
    2628              37 : OGRBoolean OGRFeature::Equal( OGRFeature * poFeature )
    2629                 : 
    2630                 : {
    2631              37 :     if( poFeature == this )
    2632               1 :         return TRUE;
    2633                 : 
    2634              36 :     if( GetFID() != poFeature->GetFID() )
    2635               1 :         return FALSE;
    2636                 :     
    2637              35 :     if( GetDefnRef() != poFeature->GetDefnRef() )
    2638               0 :         return FALSE;
    2639                 : 
    2640                 :     int i;
    2641              35 :     int nFields = GetDefnRef()->GetFieldCount();
    2642             245 :     for(i=0; i<nFields; i++)
    2643                 :     {
    2644             240 :         if( IsFieldSet(i) != poFeature->IsFieldSet(i) )
    2645               0 :             return FALSE;
    2646                 : 
    2647             240 :         if( !IsFieldSet(i) )
    2648               0 :             continue;
    2649                 : 
    2650             240 :         switch (GetDefnRef()->GetFieldDefn(i)->GetType() )
    2651                 :         {
    2652                 :             case OFTInteger:
    2653              34 :                 if( GetFieldAsInteger(i) !=
    2654                 :                        poFeature->GetFieldAsInteger(i) )
    2655               1 :                     return FALSE;
    2656              33 :                 break;
    2657                 : 
    2658                 :             case OFTReal:
    2659              33 :                 if( GetFieldAsDouble(i) !=
    2660                 :                        poFeature->GetFieldAsDouble(i) )
    2661               1 :                     return FALSE;
    2662              32 :                 break;
    2663                 : 
    2664                 :             case OFTString:
    2665              32 :                 if ( strcmp(GetFieldAsString(i), 
    2666                 :                             poFeature->GetFieldAsString(i)) != 0 )
    2667               1 :                     return FALSE;
    2668              31 :                 break;
    2669                 : 
    2670                 :             case OFTIntegerList:
    2671                 :             {
    2672                 :                 int nCount1, nCount2;
    2673              31 :                 const int* pnList1 = GetFieldAsIntegerList(i, &nCount1);
    2674                 :                 const int* pnList2 =
    2675              31 :                           poFeature->GetFieldAsIntegerList(i, &nCount2);
    2676              31 :                 if( nCount1 != nCount2 )
    2677               1 :                     return FALSE;
    2678                 :                 int j;
    2679              89 :                 for(j=0;j<nCount1;j++)
    2680                 :                 {
    2681              60 :                     if( pnList1[j] != pnList2[j] )
    2682               1 :                         return FALSE;
    2683                 :                 }
    2684              29 :                 break;
    2685                 :             }
    2686                 : 
    2687                 :             case OFTRealList:
    2688                 :             {
    2689                 :                 int nCount1, nCount2;
    2690                 :                 const double* padfList1 =
    2691              29 :                                    GetFieldAsDoubleList(i, &nCount1);
    2692                 :                 const double* padfList2 =
    2693              29 :                         poFeature->GetFieldAsDoubleList(i, &nCount2);
    2694              29 :                 if( nCount1 != nCount2 )
    2695               1 :                     return FALSE;
    2696                 :                 int j;
    2697              83 :                 for(j=0;j<nCount1;j++)
    2698                 :                 {
    2699              56 :                     if( padfList1[j] != padfList2[j] )
    2700               1 :                         return FALSE;
    2701                 :                 }
    2702              27 :                 break;
    2703                 :             }
    2704                 : 
    2705                 :             case OFTStringList:
    2706                 :             {
    2707                 :                 int nCount1, nCount2;
    2708              27 :                 char** papszList1 = GetFieldAsStringList(i);
    2709              27 :                 char** papszList2 = poFeature->GetFieldAsStringList(i);
    2710              27 :                 nCount1 = CSLCount(papszList1);
    2711              27 :                 nCount2 = CSLCount(papszList2);
    2712              27 :                 if( nCount1 != nCount2 )
    2713               1 :                     return FALSE;
    2714                 :                 int j;
    2715              77 :                 for(j=0;j<nCount1;j++)
    2716                 :                 {
    2717              52 :                     if( strcmp(papszList1[j], papszList2[j]) != 0 )
    2718               1 :                         return FALSE;
    2719                 :                 }
    2720              25 :                 break;
    2721                 :             }
    2722                 : 
    2723                 :             case OFTTime:
    2724                 :             case OFTDate:
    2725                 :             case OFTDateTime:
    2726                 :             {
    2727                 :                 int nYear1, nMonth1, nDay1, nHour1,
    2728                 :                     nMinute1, nSecond1, nTZFlag1;
    2729                 :                 int nYear2, nMonth2, nDay2, nHour2,
    2730                 :                     nMinute2, nSecond2, nTZFlag2;
    2731                 :                 GetFieldAsDateTime(i, &nYear1, &nMonth1, &nDay1,
    2732              54 :                               &nHour1, &nMinute1, &nSecond1, &nTZFlag1);
    2733                 :                 poFeature->GetFieldAsDateTime(i, &nYear2, &nMonth2, &nDay2,
    2734              54 :                               &nHour2, &nMinute2, &nSecond2, &nTZFlag2);
    2735                 : 
    2736              54 :                 if( !(nYear1 == nYear2 && nMonth1 == nMonth2 &&
    2737                 :                       nDay1 == nDay2 && nHour1 == nHour2 &&
    2738                 :                       nMinute1 == nMinute2 && nSecond1 == nSecond2 &&
    2739                 :                       nTZFlag1 == nTZFlag2) )
    2740              21 :                     return FALSE;
    2741              33 :                 break;
    2742                 :             }
    2743                 : 
    2744                 :             case OFTBinary:
    2745                 :             {
    2746                 :                 int nCount1, nCount2;
    2747               0 :                 GByte* pabyData1 = GetFieldAsBinary(i, &nCount1);
    2748               0 :                 GByte* pabyData2 = poFeature->GetFieldAsBinary(i, &nCount2);
    2749               0 :                 if( nCount1 != nCount2 )
    2750               0 :                     return FALSE;
    2751               0 :                 if( memcmp(pabyData1, pabyData2, nCount1) != 0 )
    2752               0 :                     return FALSE;
    2753               0 :                 break;
    2754                 :             }
    2755                 : 
    2756                 :             default:
    2757               0 :                 if( strcmp(GetFieldAsString(i), 
    2758                 :                            poFeature->GetFieldAsString(i)) != 0 )
    2759               0 :                     return FALSE;
    2760                 :                 break;
    2761                 :         }
    2762                 :     }
    2763                 : 
    2764               5 :     if( GetGeometryRef() == NULL && poFeature->GetGeometryRef() != NULL )
    2765               1 :         return FALSE;
    2766                 : 
    2767               4 :     if( GetGeometryRef() != NULL && poFeature->GetGeometryRef() == NULL )
    2768               1 :         return FALSE;
    2769                 : 
    2770               4 :     if( GetGeometryRef() != NULL && poFeature->GetGeometryRef() != NULL 
    2771               1 :         && (!GetGeometryRef()->Equals( poFeature->GetGeometryRef() ) ) )
    2772               0 :         return FALSE;
    2773                 : 
    2774               3 :     return TRUE;
    2775                 : }
    2776                 : 
    2777                 : /************************************************************************/
    2778                 : /*                            OGR_F_Equal()                             */
    2779                 : /************************************************************************/
    2780                 : 
    2781                 : /**
    2782                 :  * \brief Test if two features are the same.
    2783                 :  *
    2784                 :  * Two features are considered equal if the share them (handle equality)
    2785                 :  * same OGRFeatureDefn, have the same field values, and the same geometry
    2786                 :  * (as tested by OGR_G_Equal()) as well as the same feature id.
    2787                 :  *
    2788                 :  * This function is the same as the C++ method OGRFeature::Equal().
    2789                 :  *
    2790                 :  * @param hFeat handle to one of the feature.
    2791                 :  * @param hOtherFeat handle to the other feature to test this one against.
    2792                 :  *
    2793                 :  * @return TRUE if they are equal, otherwise FALSE.
    2794                 :  */
    2795                 : 
    2796              37 : int OGR_F_Equal( OGRFeatureH hFeat, OGRFeatureH hOtherFeat )
    2797                 : 
    2798                 : {
    2799              37 :     VALIDATE_POINTER1( hFeat, "OGR_F_Equal", 0 );
    2800              37 :     VALIDATE_POINTER1( hOtherFeat, "OGR_F_Equal", 0 );
    2801                 : 
    2802              37 :     return ((OGRFeature *) hFeat)->Equal( (OGRFeature *) hOtherFeat );
    2803                 : }
    2804                 : 
    2805                 : 
    2806                 : /************************************************************************/
    2807                 : /*                              SetFrom()                               */
    2808                 : /************************************************************************/
    2809                 : 
    2810                 : /**
    2811                 :  * \brief Set one feature from another.
    2812                 :  *
    2813                 :  * Overwrite the contents of this feature from the geometry and attributes
    2814                 :  * of another.  The poSrcFeature does not need to have the same
    2815                 :  * OGRFeatureDefn.  Field values are copied by corresponding field names.
    2816                 :  * Field types do not have to exactly match.  SetField() method conversion
    2817                 :  * rules will be applied as needed.
    2818                 :  *
    2819                 :  * This method is the same as the C function OGR_F_SetFrom().
    2820                 :  *
    2821                 :  * @param poSrcFeature the feature from which geometry, and field values will
    2822                 :  * be copied.
    2823                 :  *
    2824                 :  * @param bForgiving TRUE if the operation should continue despite lacking
    2825                 :  * output fields matching some of the source fields.
    2826                 :  *
    2827                 :  * @return OGRERR_NONE if the operation succeeds, even if some values are
    2828                 :  * not transferred, otherwise an error code.
    2829                 :  */
    2830                 : 
    2831             186 : OGRErr OGRFeature::SetFrom( OGRFeature * poSrcFeature, int bForgiving )
    2832                 : 
    2833                 : {
    2834                 : /* -------------------------------------------------------------------- */
    2835                 : /*      Retrieve the field ids by name.                                 */
    2836                 : /* -------------------------------------------------------------------- */
    2837                 :     int         iField, *panMap;
    2838                 :     OGRErr      eErr;
    2839                 : 
    2840             186 :     panMap = (int *) VSIMalloc( sizeof(int) * poSrcFeature->GetFieldCount() );
    2841            1097 :     for( iField = 0; iField < poSrcFeature->GetFieldCount(); iField++ )
    2842                 :     {
    2843             911 :         panMap[iField] = GetFieldIndex(
    2844             911 :             poSrcFeature->GetFieldDefnRef(iField)->GetNameRef() );
    2845                 : 
    2846             911 :         if( panMap[iField] == -1 )
    2847                 :         {
    2848              96 :             if( bForgiving )
    2849              96 :                 continue;
    2850                 :             else
    2851                 :             {
    2852               0 :                 VSIFree(panMap);
    2853               0 :                 return OGRERR_FAILURE;
    2854                 :             }
    2855                 :         }
    2856                 :     }
    2857                 : 
    2858             186 :     eErr = SetFrom( poSrcFeature, panMap, bForgiving );
    2859                 :     
    2860             186 :     VSIFree(panMap);
    2861                 :     
    2862             186 :     return eErr;
    2863                 : }
    2864                 : 
    2865                 : /************************************************************************/
    2866                 : /*                           OGR_F_SetFrom()                            */
    2867                 : /************************************************************************/
    2868                 : 
    2869                 : /**
    2870                 :  * \brief Set one feature from another.
    2871                 :  *
    2872                 :  * Overwrite the contents of this feature from the geometry and attributes
    2873                 :  * of another.  The hOtherFeature does not need to have the same
    2874                 :  * OGRFeatureDefn.  Field values are copied by corresponding field names.
    2875                 :  * Field types do not have to exactly match.  OGR_F_SetField*() function 
    2876                 :  * conversion rules will be applied as needed.
    2877                 :  *
    2878                 :  * This function is the same as the C++ method OGRFeature::SetFrom().
    2879                 :  *
    2880                 :  * @param hFeat handle to the feature to set to.
    2881                 :  * @param hOtherFeat handle to the feature from which geometry,
    2882                 :  * and field values will be copied.
    2883                 :  *
    2884                 :  * @param bForgiving TRUE if the operation should continue despite lacking
    2885                 :  * output fields matching some of the source fields.
    2886                 :  *
    2887                 :  * @return OGRERR_NONE if the operation succeeds, even if some values are
    2888                 :  * not transferred, otherwise an error code.
    2889                 :  */
    2890                 : 
    2891             180 : OGRErr OGR_F_SetFrom( OGRFeatureH hFeat, OGRFeatureH hOtherFeat, 
    2892                 :                       int bForgiving )
    2893                 : 
    2894                 : {
    2895             180 :     VALIDATE_POINTER1( hFeat, "OGR_F_SetFrom", CE_Failure );
    2896             180 :     VALIDATE_POINTER1( hOtherFeat, "OGR_F_SetFrom", CE_Failure );
    2897                 : 
    2898                 :     return ((OGRFeature *) hFeat)->SetFrom( (OGRFeature *) hOtherFeat, 
    2899             180 :                                            bForgiving );
    2900                 : }
    2901                 : 
    2902                 : /************************************************************************/
    2903                 : /*                              SetFrom()                               */
    2904                 : /************************************************************************/
    2905                 : 
    2906                 : /**
    2907                 :  * \brief Set one feature from another.
    2908                 :  *
    2909                 :  * Overwrite the contents of this feature from the geometry and attributes
    2910                 :  * of another.  The poSrcFeature does not need to have the same
    2911                 :  * OGRFeatureDefn.  Field values are copied according to the provided indices
    2912                 :  * map. Field types do not have to exactly match.  SetField() method
    2913                 :  * conversion rules will be applied as needed. This is more efficient than
    2914                 :  * OGR_F_SetFrom() in that this doesn't lookup the fields by their names.
    2915                 :  * Particularly useful when the field names don't match.
    2916                 :  *
    2917                 :  * This method is the same as the C function OGR_F_SetFromWithMap().
    2918                 :  *
    2919                 :  * @param poSrcFeature the feature from which geometry, and field values will
    2920                 :  * be copied.
    2921                 :  *
    2922                 :  * @param panMap Array of the indices of the feature's fields
    2923                 :  * stored at the corresponding index of the source feature's fields. A value of
    2924                 :  * -1 should be used to ignore the source's field. The array should not be NULL
    2925                 :  * and be as long as the number of fields in the source feature.
    2926                 :  * 
    2927                 :  * @param bForgiving TRUE if the operation should continue despite lacking
    2928                 :  * output fields matching some of the source fields.
    2929                 :  *
    2930                 :  * @return OGRERR_NONE if the operation succeeds, even if some values are
    2931                 :  * not transferred, otherwise an error code.
    2932                 :  */
    2933                 : 
    2934             369 : OGRErr OGRFeature::SetFrom( OGRFeature * poSrcFeature, int *panMap ,
    2935                 :                             int bForgiving )
    2936                 : 
    2937                 : {
    2938                 :     OGRErr      eErr;
    2939                 : 
    2940             369 :     SetFID( OGRNullFID );
    2941                 : 
    2942                 : /* -------------------------------------------------------------------- */
    2943                 : /*      Set the geometry.                                               */
    2944                 : /* -------------------------------------------------------------------- */
    2945             369 :     eErr = SetGeometry( poSrcFeature->GetGeometryRef() );
    2946             369 :     if( eErr != OGRERR_NONE )
    2947               0 :         return eErr;
    2948                 : 
    2949                 : /* -------------------------------------------------------------------- */
    2950                 : /*      Copy feature style string.                                      */
    2951                 : /* -------------------------------------------------------------------- */
    2952             369 :     SetStyleString( poSrcFeature->GetStyleString() );
    2953                 : 
    2954                 : /* -------------------------------------------------------------------- */
    2955                 : /*      Set the fields by name.                                         */
    2956                 : /* -------------------------------------------------------------------- */
    2957                 :     int         iField, iDstField;
    2958                 : 
    2959            1838 :     for( iField = 0; iField < poSrcFeature->GetFieldCount(); iField++ )
    2960                 :     {
    2961            1469 :         iDstField = panMap[iField];
    2962                 : 
    2963            1469 :         if( iDstField < 0 )
    2964             116 :             continue;
    2965                 :             
    2966            1353 :         if( GetFieldCount() <= iDstField )
    2967               0 :             return OGRERR_FAILURE;
    2968                 : 
    2969            1353 :         if( !poSrcFeature->IsFieldSet(iField) )
    2970                 :         {
    2971             109 :             UnsetField( iDstField );
    2972             109 :             continue;
    2973                 :         }
    2974                 : 
    2975            1244 :         switch( poSrcFeature->GetFieldDefnRef(iField)->GetType() )
    2976                 :         {
    2977                 :           case OFTInteger:
    2978              71 :             SetField( iDstField, poSrcFeature->GetFieldAsInteger( iField ) );
    2979              71 :             break;
    2980                 : 
    2981                 :           case OFTReal:
    2982             651 :             SetField( iDstField, poSrcFeature->GetFieldAsDouble( iField ) );
    2983             651 :             break;
    2984                 : 
    2985                 :           case OFTString:
    2986             473 :             SetField( iDstField, poSrcFeature->GetFieldAsString( iField ) );
    2987             473 :             break;
    2988                 : 
    2989                 :           case OFTDate:
    2990                 :           case OFTDateTime:
    2991                 :           case OFTTime:
    2992              20 :             if (GetFieldDefnRef(iDstField)->GetType() == OFTDate ||
    2993                 :                 GetFieldDefnRef(iDstField)->GetType() == OFTTime ||
    2994                 :                 GetFieldDefnRef(iDstField)->GetType() == OFTDateTime)
    2995                 :             {
    2996              20 :                 SetField( iDstField, poSrcFeature->GetRawFieldRef( iField ) );
    2997                 :             }
    2998               0 :             else if (GetFieldDefnRef(iDstField)->GetType() == OFTString)
    2999                 :             {
    3000               0 :                 SetField( iDstField, poSrcFeature->GetFieldAsString( iField ) );
    3001                 :             }
    3002               0 :             else if( !bForgiving )
    3003               0 :                 return OGRERR_FAILURE;
    3004              20 :             break;
    3005                 : 
    3006                 :           default:
    3007              29 :             if( poSrcFeature->GetFieldDefnRef(iField)->GetType()
    3008                 :                 == GetFieldDefnRef(iDstField)->GetType() )
    3009                 :             {
    3010              29 :                 SetField( iDstField, poSrcFeature->GetRawFieldRef(iField) );
    3011                 :             }
    3012               0 :             else if (GetFieldDefnRef(iDstField)->GetType() == OFTString)
    3013                 :             {
    3014               0 :                 SetField( iDstField, poSrcFeature->GetFieldAsString( iField ) );
    3015                 :             }
    3016               0 :             else if( !bForgiving )
    3017               0 :                 return OGRERR_FAILURE;
    3018                 :             break;
    3019                 :         }
    3020                 :     }
    3021                 : 
    3022             369 :     return OGRERR_NONE;
    3023                 : }
    3024                 : 
    3025                 : /************************************************************************/
    3026                 : /*                      OGR_F_SetFromWithMap()                          */
    3027                 : /************************************************************************/
    3028                 : 
    3029                 : /**
    3030                 :  * \brief Set one feature from another.
    3031                 :  *
    3032                 :  * Overwrite the contents of this feature from the geometry and attributes
    3033                 :  * of another.  The hOtherFeature does not need to have the same
    3034                 :  * OGRFeatureDefn.  Field values are copied according to the provided indices
    3035                 :  * map. Field types do not have to exactly match.  OGR_F_SetField*() function 
    3036                 :  * conversion rules will be applied as needed. This is more efficient than
    3037                 :  * OGR_F_SetFrom() in that this doesn't lookup the fields by their names.
    3038                 :  * Particularly useful when the field names don't match.
    3039                 :  *
    3040                 :  * This function is the same as the C++ method OGRFeature::SetFrom().
    3041                 :  *
    3042                 :  * @param hFeat handle to the feature to set to.
    3043                 :  * @param hOtherFeat handle to the feature from which geometry,
    3044                 :  * and field values will be copied.
    3045                 :  *
    3046                 :  * @param panMap Array of the indices of the destination feature's fields
    3047                 :  * stored at the corresponding index of the source feature's fields. A value of
    3048                 :  * -1 should be used to ignore the source's field. The array should not be NULL
    3049                 :  * and be as long as the number of fields in the source feature.
    3050                 :  * 
    3051                 :  * @param bForgiving TRUE if the operation should continue despite lacking
    3052                 :  * output fields matching some of the source fields.
    3053                 :  *
    3054                 :  * @return OGRERR_NONE if the operation succeeds, even if some values are
    3055                 :  * not transferred, otherwise an error code.
    3056                 :  */
    3057                 : 
    3058               0 : OGRErr OGR_F_SetFromWithMap( OGRFeatureH hFeat, OGRFeatureH hOtherFeat, 
    3059                 :                       int bForgiving, int *panMap )
    3060                 : 
    3061                 : {
    3062               0 :     VALIDATE_POINTER1( hFeat, "OGR_F_SetFrom", CE_Failure );
    3063               0 :     VALIDATE_POINTER1( hOtherFeat, "OGR_F_SetFrom", CE_Failure );
    3064               0 :     VALIDATE_POINTER1( panMap, "OGR_F_SetFrom", CE_Failure);
    3065                 : 
    3066                 :     return ((OGRFeature *) hFeat)->SetFrom( (OGRFeature *) hOtherFeat, 
    3067               0 :                                            panMap, bForgiving );
    3068                 : }
    3069                 : 
    3070                 : /************************************************************************/
    3071                 : /*                             GetStyleString()                         */
    3072                 : /************************************************************************/
    3073                 : 
    3074                 : /**
    3075                 :  * \brief Fetch style string for this feature.
    3076                 :  *
    3077                 :  * Set the OGR Feature Style Specification for details on the format of
    3078                 :  * this string, and ogr_featurestyle.h for services available to parse it.
    3079                 :  *
    3080                 :  * This method is the same as the C function OGR_F_GetStyleString().
    3081                 :  * 
    3082                 :  * @return a reference to a representation in string format, or NULL if 
    3083                 :  * there isn't one. 
    3084                 :  */
    3085                 : 
    3086            1090 : const char *OGRFeature::GetStyleString()
    3087                 : {
    3088                 :   int  iStyleFieldIndex;
    3089                 : 
    3090            1090 :   if (m_pszStyleString)
    3091              24 :        return m_pszStyleString;
    3092                 : 
    3093            1066 :   iStyleFieldIndex = GetFieldIndex("OGR_STYLE");
    3094            1066 :   if (iStyleFieldIndex >= 0)
    3095               0 :        return GetFieldAsString(iStyleFieldIndex);
    3096                 : 
    3097            1066 :   return NULL;
    3098                 : }
    3099                 : 
    3100                 : /************************************************************************/
    3101                 : /*                        OGR_F_GetStyleString()                        */
    3102                 : /************************************************************************/
    3103                 : 
    3104                 : /**
    3105                 :  * \brief Fetch style string for this feature.
    3106                 :  *
    3107                 :  * Set the OGR Feature Style Specification for details on the format of
    3108                 :  * this string, and ogr_featurestyle.h for services available to parse it.
    3109                 :  *
    3110                 :  * This function is the same as the C++ method OGRFeature::GetStyleString().
    3111                 :  * 
    3112                 :  * @param hFeat handle to the feature to get the style from.
    3113                 :  * @return a reference to a representation in string format, or NULL if 
    3114                 :  * there isn't one. 
    3115                 :  */
    3116                 : 
    3117               6 : const char *OGR_F_GetStyleString( OGRFeatureH hFeat )
    3118                 : {
    3119               6 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetStyleString", NULL );
    3120                 : 
    3121               6 :     return ((OGRFeature *)hFeat)->GetStyleString();
    3122                 : }
    3123                 : 
    3124                 : /************************************************************************/
    3125                 : /*                             SetStyleString()                         */
    3126                 : /************************************************************************/
    3127                 : 
    3128                 : /**
    3129                 :  * \brief Set feature style string.
    3130                 :  * This method operate exactly as
    3131                 :  * OGRFeature::SetStyleStringDirectly() except that it does not assume
    3132                 :  * ownership of the passed string, but instead makes a copy of it.
    3133                 :  *
    3134                 :  * This method is the same as the C function OGR_F_SetStyleString().
    3135                 :  *
    3136                 :  * @param pszString the style string to apply to this feature, cannot be NULL.
    3137                 :  */
    3138                 : 
    3139             533 : void OGRFeature::SetStyleString(const char *pszString)
    3140                 : {
    3141             533 :     if (m_pszStyleString)
    3142                 :     {
    3143               7 :         CPLFree(m_pszStyleString);
    3144               7 :         m_pszStyleString = NULL;
    3145                 :     }
    3146                 :     
    3147             533 :     if( pszString )
    3148              57 :         m_pszStyleString = CPLStrdup(pszString);
    3149             533 : }
    3150                 : 
    3151                 : /************************************************************************/
    3152                 : /*                        OGR_F_SetStyleString()                        */
    3153                 : /************************************************************************/
    3154                 : 
    3155                 : /**
    3156                 :  * \brief Set feature style string.
    3157                 :  * This method operate exactly as
    3158                 :  * OGR_F_SetStyleStringDirectly() except that it does not assume ownership
    3159                 :  * of the passed string, but instead makes a copy of it.
    3160                 :  *
    3161                 :  * This function is the same as the C++ method OGRFeature::SetStyleString().
    3162                 :  *
    3163                 :  * @param hFeat handle to the feature to set style to.
    3164                 :  * @param pszStyle the style string to apply to this feature, cannot be NULL.
    3165                 :  */
    3166                 : 
    3167               0 : void OGR_F_SetStyleString( OGRFeatureH hFeat, const char *pszStyle )
    3168                 : 
    3169                 : {
    3170               0 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetStyleString" );
    3171                 : 
    3172               0 :     ((OGRFeature *)hFeat)->SetStyleString( pszStyle );
    3173                 : }
    3174                 : 
    3175                 : /************************************************************************/
    3176                 : /*                       SetStyleStringDirectly()                       */
    3177                 : /************************************************************************/
    3178                 : 
    3179                 : /**
    3180                 :  * \brief Set feature style string.
    3181                 :  * This method operate exactly as
    3182                 :  * OGRFeature::SetStyleString() except that it assumes ownership of the passed
    3183                 :  * string.
    3184                 :  *
    3185                 :  * This method is the same as the C function OGR_F_SetStyleStringDirectly().
    3186                 :  *
    3187                 :  * @param pszString the style string to apply to this feature, cannot be NULL.
    3188                 :  */
    3189                 : 
    3190               0 : void OGRFeature::SetStyleStringDirectly(char *pszString)
    3191                 : {
    3192               0 :     if (m_pszStyleString)
    3193               0 :         CPLFree(m_pszStyleString);
    3194               0 :     m_pszStyleString = pszString;
    3195               0 : }
    3196                 : 
    3197                 : /************************************************************************/
    3198                 : /*                     OGR_F_SetStyleStringDirectly()                   */
    3199                 : /************************************************************************/
    3200                 : 
    3201                 : /**
    3202                 :  * \brief Set feature style string.
    3203                 :  * This method operate exactly as
    3204                 :  * OGR_F_SetStyleString() except that it assumes ownership of the passed
    3205                 :  * string.
    3206                 :  *
    3207                 :  * This function is the same as the C++ method
    3208                 :  * OGRFeature::SetStyleStringDirectly().
    3209                 :  *
    3210                 :  * @param hFeat handle to the feature to set style to.
    3211                 :  * @param pszStyle the style string to apply to this feature, cannot be NULL.
    3212                 :  */
    3213                 : 
    3214               0 : void OGR_F_SetStyleStringDirectly( OGRFeatureH hFeat, char *pszStyle )
    3215                 : 
    3216                 : {
    3217               0 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetStyleStringDirectly" );
    3218                 : 
    3219               0 :     ((OGRFeature *)hFeat)->SetStyleStringDirectly( pszStyle );
    3220                 : }
    3221                 : 
    3222                 : //************************************************************************/
    3223                 : /*                           SetStyleTable()                            */
    3224                 : /************************************************************************/
    3225               0 : void OGRFeature::SetStyleTable(OGRStyleTable *poStyleTable)
    3226                 : {
    3227               0 :     if ( m_poStyleTable )
    3228               0 :         delete m_poStyleTable;
    3229               0 :     m_poStyleTable = ( poStyleTable ) ? poStyleTable->Clone() : NULL;
    3230               0 : }
    3231                 : 
    3232                 : /************************************************************************/
    3233                 : /*                            RemapFields()                             */
    3234                 : /*                                                                      */
    3235                 : /*      This is used to transform a feature "in place" from one         */
    3236                 : /*      feature defn to another with minimum work.                      */
    3237                 : /************************************************************************/
    3238                 : 
    3239              17 : OGRErr OGRFeature::RemapFields( OGRFeatureDefn *poNewDefn, 
    3240                 :                                 int *panRemapSource )
    3241                 : 
    3242                 : {
    3243                 :     int  iDstField;
    3244                 :     OGRField *pauNewFields;
    3245                 : 
    3246              17 :     if( poNewDefn == NULL )
    3247              17 :         poNewDefn = poDefn;
    3248                 : 
    3249                 :     pauNewFields = (OGRField *) CPLCalloc( poNewDefn->GetFieldCount(), 
    3250              17 :                                            sizeof(OGRField) );
    3251                 : 
    3252             102 :     for( iDstField = 0; iDstField < poDefn->GetFieldCount(); iDstField++ )
    3253                 :     {
    3254              85 :         if( panRemapSource[iDstField] == -1 )
    3255                 :         {
    3256              17 :             pauNewFields[iDstField].Set.nMarker1 = OGRUnsetMarker;
    3257              17 :             pauNewFields[iDstField].Set.nMarker2 = OGRUnsetMarker;
    3258                 :         }
    3259                 :         else
    3260                 :         {
    3261                 :             memcpy( pauNewFields + iDstField, 
    3262              68 :                     pauFields + panRemapSource[iDstField],
    3263             136 :                     sizeof(OGRField) );
    3264                 :         }
    3265                 :     }
    3266                 : 
    3267                 :     /* 
    3268                 :     ** We really should be freeing memory for old columns that
    3269                 :     ** are no longer present.  We don't for now because it is a bit messy
    3270                 :     ** and would take too long to test.  
    3271                 :     */
    3272                 : 
    3273                 : /* -------------------------------------------------------------------- */
    3274                 : /*      Apply new definition and fields.                                */
    3275                 : /* -------------------------------------------------------------------- */
    3276              17 :     CPLFree( pauFields );
    3277              17 :     pauFields = pauNewFields;
    3278                 : 
    3279              17 :     poDefn = poNewDefn;
    3280                 : 
    3281              17 :     return OGRERR_NONE;
    3282                 : }
    3283                 : 
    3284                 : /************************************************************************/
    3285                 : /*                         OGR_F_GetStyleTable()                        */
    3286                 : /************************************************************************/
    3287                 : 
    3288               0 : OGRStyleTableH OGR_F_GetStyleTable( OGRFeatureH hFeat )
    3289                 : 
    3290                 : {
    3291               0 :     VALIDATE_POINTER1( hFeat, "OGR_F_GetStyleTable", NULL );
    3292                 :     
    3293               0 :     return (OGRStyleTableH) ((OGRFeature *) hFeat)->GetStyleTable( );
    3294                 : }
    3295                 : 
    3296                 : /************************************************************************/
    3297                 : /*                         OGR_F_SetStyleTableDirectly()                */
    3298                 : /************************************************************************/
    3299                 : 
    3300               0 : void OGR_F_SetStyleTableDirectly( OGRFeatureH hFeat,
    3301                 :                                   OGRStyleTableH hStyleTable )
    3302                 : 
    3303                 : {
    3304               0 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetStyleTableDirectly" );
    3305                 :     
    3306               0 :     ((OGRFeature *) hFeat)->SetStyleTableDirectly( (OGRStyleTable *) hStyleTable);
    3307                 : }
    3308                 : 
    3309                 : /************************************************************************/
    3310                 : /*                         OGR_F_SetStyleTable()                        */
    3311                 : /************************************************************************/
    3312                 : 
    3313               0 : void OGR_F_SetStyleTable( OGRFeatureH hFeat,
    3314                 :                           OGRStyleTableH hStyleTable )
    3315                 : 
    3316                 : {
    3317               0 :     VALIDATE_POINTER0( hFeat, "OGR_F_SetStyleTable" );
    3318               0 :     VALIDATE_POINTER0( hStyleTable, "OGR_F_SetStyleTable" );
    3319                 :     
    3320               0 :     ((OGRFeature *) hFeat)->SetStyleTable( (OGRStyleTable *) hStyleTable);
    3321                 : }

Generated by: LCOV version 1.7