⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ogrfeature.cpp

📁 在linux环境下
💻 CPP
📖 第 1 页 / 共 5 页
字号:
 * * This function is the same as the CPP method OGRFeature::SetField(). * * @param hFeat handle to the feature that owned the field. * @param iField the field to set, from 0 to GetFieldCount()-1. * @param nCount the number of values in the list being assigned. * @param padfValues the values to assign. */void OGR_F_SetFieldDoubleList( OGRFeatureH hFeat, int iField,                                int nCount, double *padfValues ){    ((OGRFeature *)hFeat)->SetField( iField, nCount, padfValues );}/************************************************************************//*                              SetField()                              *//************************************************************************//** * Set field to list of strings value.  * * This method currently on has an effect of OFTStringList fields. * * This method is the same as the C function OGR_F_SetFieldStringList(). * * @param iField the field to set, from 0 to GetFieldCount()-1. * @param papszValues the values to assign. */void OGRFeature::SetField( int iField, char ** papszValues ){    OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );    CPLAssert( poFDefn != NULL || iField == -1 );    if( poFDefn == NULL )        return;        if( poFDefn->GetType() == OFTStringList )    {        OGRField        uField;                uField.StringList.nCount = CSLCount(papszValues);        uField.StringList.paList = papszValues;                SetField( iField, &uField );    }}/************************************************************************//*                      OGR_F_SetFieldStringList()                      *//************************************************************************//** * Set field to list of strings value.  * * This function currently on has an effect of OFTStringList fields. * * This function is the same as the CPP method OGRFeature::SetField(). * * @param hFeat handle to the feature that owned the field. * @param iField the field to set, from 0 to GetFieldCount()-1. * @param papszValues the values to assign. */void OGR_F_SetFieldStringList( OGRFeatureH hFeat, int iField,                                char ** papszValues ){    ((OGRFeature *)hFeat)->SetField( iField, papszValues );}/************************************************************************//*                              SetField()                              *//************************************************************************//** * Set field. * * The passed value OGRField must be of exactly the same type as the * target field, or an application crash may occur.  The passed value * is copied, and will not be affected.  It remains the responsibility of * the caller.  * * This method is the same as the C function OGR_F_SetFieldRaw(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param puValue the value to assign. */void OGRFeature::SetField( int iField, OGRField * puValue ){    OGRFieldDefn        *poFDefn = poDefn->GetFieldDefn( iField );    CPLAssert( poFDefn != NULL || iField == -1 );    if( poFDefn == NULL )        return;        if( poFDefn->GetType() == OFTInteger )    {        pauFields[iField] = *puValue;    }    else if( poFDefn->GetType() == OFTReal )    {        pauFields[iField] = *puValue;    }    else if( poFDefn->GetType() == OFTString )    {        if( IsFieldSet( iField ) )            CPLFree( pauFields[iField].String );                if( puValue->String == NULL )            pauFields[iField].String = NULL;        else if( puValue->Set.nMarker1 == OGRUnsetMarker                 && puValue->Set.nMarker2 == OGRUnsetMarker )            pauFields[iField] = *puValue;        else            pauFields[iField].String = CPLStrdup( puValue->String );    }    else if( poFDefn->GetType() == OFTIntegerList )    {        int     nCount = puValue->IntegerList.nCount;                if( IsFieldSet( iField ) )            CPLFree( pauFields[iField].IntegerList.paList );                if( puValue->Set.nMarker1 == OGRUnsetMarker            && puValue->Set.nMarker2 == OGRUnsetMarker )        {            pauFields[iField] = *puValue;        }        else        {            pauFields[iField].IntegerList.paList =                (int *) CPLMalloc(sizeof(int) * nCount);            memcpy( pauFields[iField].IntegerList.paList,                    puValue->IntegerList.paList,                    sizeof(int) * nCount );            pauFields[iField].IntegerList.nCount = nCount;        }    }    else if( poFDefn->GetType() == OFTRealList )    {        int     nCount = puValue->RealList.nCount;        if( IsFieldSet( iField ) )            CPLFree( pauFields[iField].RealList.paList );        if( puValue->Set.nMarker1 == OGRUnsetMarker            && puValue->Set.nMarker2 == OGRUnsetMarker )        {            pauFields[iField] = *puValue;        }        else        {            pauFields[iField].RealList.paList =                (double *) CPLMalloc(sizeof(double) * nCount);            memcpy( pauFields[iField].RealList.paList,                    puValue->RealList.paList,                    sizeof(double) * nCount );            pauFields[iField].RealList.nCount = nCount;        }    }    else if( poFDefn->GetType() == OFTStringList )    {        if( IsFieldSet( iField ) )            CSLDestroy( pauFields[iField].StringList.paList );                if( puValue->Set.nMarker1 == OGRUnsetMarker            && puValue->Set.nMarker2 == OGRUnsetMarker )        {            pauFields[iField] = *puValue;        }        else        {            pauFields[iField].StringList.paList =                CSLDuplicate( puValue->StringList.paList );                        pauFields[iField].StringList.nCount = puValue->StringList.nCount;            CPLAssert( CSLCount(puValue->StringList.paList)                       == puValue->StringList.nCount );        }    }    else        /* do nothing for other field types */;}/************************************************************************//*                      OGR_F_SetFieldRaw()                             *//************************************************************************//** * Set field. * * The passed value OGRField must be of exactly the same type as the * target field, or an application crash may occur.  The passed value * is copied, and will not be affected.  It remains the responsibility of * the caller.  * * This function is the same as the CPP method OGRFeature::SetField(). * * @param hFeat handle to the feature that owned the field. * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param psValue handle on the value to assign. */void OGR_F_SetFieldRaw( OGRFeatureH hFeat, int iField, OGRField *psValue ){    ((OGRFeature *)hFeat)->SetField( iField, psValue );}/************************************************************************//*                            DumpReadable()                            *//************************************************************************//** * Dump this feature in a human readable form. * * This dumps the attributes, and geometry; however, it doesn't definition * information (other than field types and names), nor does it report the * geometry spatial reference system. * * This method is the same as the C function OGR_F_DumpReadable(). * * @param fpOut the stream to write to, such as strout. */void OGRFeature::DumpReadable( FILE * fpOut ){    if( fpOut == NULL )        fpOut = stdout;    fprintf( fpOut, "OGRFeature(%s):%ld\n", poDefn->GetName(), GetFID() );    for( int iField = 0; iField < GetFieldCount(); iField++ )    {        OGRFieldDefn    *poFDefn = poDefn->GetFieldDefn(iField);                fprintf( fpOut, "  %s (%s) = ",                 poFDefn->GetNameRef(),                 OGRFieldDefn::GetFieldTypeName(poFDefn->GetType()) );        if( IsFieldSet( iField ) )            fprintf( fpOut, "%s\n", GetFieldAsString( iField ) );        else            fprintf( fpOut, "(null)\n" );                }    if( GetStyleString() != NULL )        fprintf( fpOut, "  Style = %s\n", GetStyleString() );        if( poGeometry != NULL )        poGeometry->dumpReadable( fpOut, "  " );    fprintf( fpOut, "\n" );}/************************************************************************//*                         OGR_F_DumpReadable()                         *//************************************************************************//** * Dump this feature in a human readable form. * * This dumps the attributes, and geometry; however, it doesn't definition * information (other than field types and names), nor does it report the * geometry spatial reference system. * * This function is the same as the CPP method OGRFeature::DumpReadable(). * * @param hFeat handle to the feature to dump. * @param fpOut the stream to write to, such as strout. */void OGR_F_DumpReadable( OGRFeatureH hFeat, FILE *fpOut ){    ((OGRFeature *) hFeat)->DumpReadable( fpOut );}/************************************************************************//*                               GetFID()                               *//************************************************************************//** * \fn long OGRFeature::GetFID(); * * Get feature identifier. * * This method is the same as the C function OGR_F_GetFID(). * * @return feature id or OGRNullFID if none has been assigned. *//************************************************************************//*                            OGR_F_GetFID()                            *//************************************************************************//** * Get feature identifier. * * This function is the same as the CPP method OGRFeature::GetFID(). * * @param hFeat handle to the feature from which to get the feature * identifier. * @return feature id or OGRNullFID if none has been assigned. */long OGR_F_GetFID( OGRFeatureH hFeat ){    return ((OGRFeature *) hFeat)->GetFID();}/************************************************************************//*                               SetFID()                               *//************************************************************************//** * Set the feature identifier. * * For specific types of features this operation may fail on illegal * features ids.  Generally it always succeeds.  Feature ids should be * greater than or equal to zero, with the exception of OGRNullFID (-1) * indicating that the feature id is unknown. * * This method is the same as the C function OGR_F_SetFID(). * * @param nFID the new feature identifier value to assign. * * @return On success OGRERR_NONE, or on failure some other value.  */OGRErr OGRFeature::SetFID( long nFID ){    this->nFID = nFID;        return OGRERR_NONE;}/************************************************************************//*                            OGR_F_SetFID()                            *//************************************************************************//** * Set the feature identifier. * * For specific types of features this operation may fail on illegal * features ids.  Generally it always succeeds.  Feature ids should be * greater than or equal to zero, with the exception of OGRNullFID (-1) * indicating that the feature id is unknown. * * This function is the same as the CPP method OGRFeature::SetFID(). * * @param hFeat handle to the feature to set the feature id to. * @param nFID the new feature identifier value to assign. * * @return On success OGRERR_NONE, or on failure some other value.  */OGRErr OGR_F_SetFID( OGRFeatureH hFeat, long nFID ){    return ((OGRFeature *) hFeat)->SetFID(nFID);}/************************************************************************//*                               Equal()                                *//************************************************************************//** * Test if two features are the same. * * Two features are considered equal if the share them (pointer equality) * same OGRFeatureDefn, have the same field values, and the same geometry * (as tested by OGRGeometry::Equal()) as well as the same feature id. * * This method is the same as the C function OGR_F_Equal(). * * @param poFeature the other feature to test this one against. * * @return TRUE if they are equal, otherwise FALSE. */OGRBoolean OGRFeature::Equal( OGRFeature * poFeature ){    if( poFeature == this )        return TRUE;    if( GetFID() != poFeature->GetFID() )        return FALSE;        if( GetDefnRef() != poFeature->GetDefnRef() )        return FALSE;    //notdef: add testing of attributes at a later date.    if( GetGeometryRef() != NULL        && (!GetGeometryRef()->Equal( poFeature->GetGeometryRef() ) ) )        return FALSE;    return TRUE;}/************************************************************************//*              

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -