📄 ogrfeature.cpp
字号:
return TRUE; } else { return FALSE; }}/************************************************************************//* OGR_F_GetFieldAsDateTime() *//************************************************************************//** * Fetch field value as date and time. * * Currently this method only works for OFTDate, OFTTime and OFTDateTime fields. * * This function is the same as the C++ method * OGRFeature::GetFieldAsDateTime(). * * @param hFeat handle to the feature that owned the field. * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param int pnYear (including century) * @param int pnMonth (1-12) * @param int pnDay (1-31) * @param int pnHour (0-23) * @param int pnMinute (0-59) * @param int pnSecond (0-59) * @param int pnTZFlag (0=unknown, 1=localtime, 100=GMT, see data model for details) * * @return TRUE on success or FALSE on failure. */int OGR_F_GetFieldAsDateTime( OGRFeatureH hFeat, int iField, int *pnYear, int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, int *pnSecond, int *pnTZFlag ) { return ((OGRFeature *)hFeat)->GetFieldAsDateTime( iField, pnYear, pnMonth, pnDay, pnHour, pnMinute,pnSecond, pnTZFlag );}/************************************************************************//* SetField() *//************************************************************************//** * Set field to integer value. * * OFTInteger and OFTReal fields will be set directly. OFTString fields * will be assigned a string representation of the value, but not necessarily * taking into account formatting constraints on this field. Other field * types may be unaffected. * * This method is the same as the C function OGR_F_SetFieldInteger(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param nValue the value to assign. */void OGRFeature::SetField( int iField, int nValue ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return; if( poFDefn->GetType() == OFTInteger ) { pauFields[iField].Integer = nValue; pauFields[iField].Set.nMarker2 = 0; } else if( poFDefn->GetType() == OFTReal ) { pauFields[iField].Real = nValue; } else if( poFDefn->GetType() == OFTString ) { char szTempBuffer[64]; sprintf( szTempBuffer, "%d", nValue ); if( IsFieldSet( iField) ) CPLFree( pauFields[iField].String ); pauFields[iField].String = CPLStrdup( szTempBuffer ); } else /* do nothing for other field types */;}/************************************************************************//* OGR_F_SetFieldInteger() *//************************************************************************//** * Set field to integer value. * * OFTInteger and OFTReal fields will be set directly. OFTString fields * will be assigned a string representation of the value, but not necessarily * taking into account formatting constraints on this field. Other field * types may be unaffected. * * This function is the same as the C++ 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 nValue the value to assign. */void OGR_F_SetFieldInteger( OGRFeatureH hFeat, int iField, int nValue ){ ((OGRFeature *)hFeat)->SetField( iField, nValue );}/************************************************************************//* SetField() *//************************************************************************//** * Set field to double value. * * OFTInteger and OFTReal fields will be set directly. OFTString fields * will be assigned a string representation of the value, but not necessarily * taking into account formatting constraints on this field. Other field * types may be unaffected. * * This method is the same as the C function OGR_F_SetFieldDouble(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param dfValue the value to assign. */void OGRFeature::SetField( int iField, double dfValue ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return; if( poFDefn->GetType() == OFTReal ) { pauFields[iField].Real = dfValue; } else if( poFDefn->GetType() == OFTInteger ) { pauFields[iField].Integer = (int) dfValue; pauFields[iField].Set.nMarker2 = 0; } else if( poFDefn->GetType() == OFTString ) { char szTempBuffer[128]; sprintf( szTempBuffer, "%.16g", dfValue ); if( IsFieldSet( iField) ) CPLFree( pauFields[iField].String ); pauFields[iField].String = CPLStrdup( szTempBuffer ); } else /* do nothing for other field types */;}/************************************************************************//* OGR_F_SetFieldDouble() *//************************************************************************//** * Set field to double value. * * OFTInteger and OFTReal fields will be set directly. OFTString fields * will be assigned a string representation of the value, but not necessarily * taking into account formatting constraints on this field. Other field * types may be unaffected. * * This function is the same as the C++ 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 dfValue the value to assign. */void OGR_F_SetFieldDouble( OGRFeatureH hFeat, int iField, double dfValue ){ ((OGRFeature *)hFeat)->SetField( iField, dfValue );}/************************************************************************//* SetField() *//************************************************************************//** * Set field to string value. * * OFTInteger fields will be set based on an atoi() conversion of the string. * OFTReal fields will be set based on an atof() conversion of the string. * Other field types may be unaffected. * * This method is the same as the C function OGR_F_SetFieldString(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param pszValue the value to assign. */void OGRFeature::SetField( int iField, const char * pszValue ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return; if( poFDefn->GetType() == OFTString ) { if( IsFieldSet(iField) ) CPLFree( pauFields[iField].String ); pauFields[iField].String = CPLStrdup( pszValue ); } else if( poFDefn->GetType() == OFTInteger ) { pauFields[iField].Integer = atoi(pszValue); pauFields[iField].Set.nMarker2 = OGRUnsetMarker; } else if( poFDefn->GetType() == OFTReal ) { pauFields[iField].Real = atof(pszValue); } else if( poFDefn->GetType() == OFTDate || poFDefn->GetType() == OFTTime || poFDefn->GetType() == OFTDateTime ) { OGRField sWrkField; if( OGRParseDate( pszValue, &sWrkField, 0 ) ) memcpy( pauFields+iField, &sWrkField, sizeof(sWrkField)); } else /* do nothing for other field types */;}/************************************************************************//* OGR_F_SetFieldString() *//************************************************************************//** * Set field to string value. * * OFTInteger fields will be set based on an atoi() conversion of the string. * OFTReal fields will be set based on an atof() conversion of the string. * Other field types may be unaffected. * * This function is the same as the C++ 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 pszValue the value to assign. */void OGR_F_SetFieldString( OGRFeatureH hFeat, int iField, const char *pszValue){ ((OGRFeature *)hFeat)->SetField( iField, pszValue );}/************************************************************************//* SetField() *//************************************************************************//** * Set field to list of integers value. * * This method currently on has an effect of OFTIntegerList fields. * * This method is the same as the C function OGR_F_SetFieldIntegerList(). * * @param iField the field to set, from 0 to GetFieldCount()-1. * @param nCount the number of values in the list being assigned. * @param panValues the values to assign. */void OGRFeature::SetField( int iField, int nCount, int *panValues ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return; if( poFDefn->GetType() == OFTIntegerList ) { OGRField uField; uField.IntegerList.nCount = nCount; uField.IntegerList.paList = panValues; SetField( iField, &uField ); }}/************************************************************************//* OGR_F_SetFieldIntegerList() *//************************************************************************//** * Set field to list of integers value. * * This function currently on has an effect of OFTIntegerList fields. * * This function is the same as the C++ 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 panValues the values to assign. */void OGR_F_SetFieldIntegerList( OGRFeatureH hFeat, int iField, int nCount, int *panValues ){ ((OGRFeature *)hFeat)->SetField( iField, nCount, panValues );}/************************************************************************//* SetField() *//************************************************************************//** * Set field to list of doubles value. * * This method currently on has an effect of OFTRealList fields. * * This method is the same as the C function OGR_F_SetFieldDoubleList(). * * @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 OGRFeature::SetField( int iField, int nCount, double * padfValues ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return; if( poFDefn->GetType() == OFTRealList ) { OGRField uField; uField.RealList.nCount = nCount; uField.RealList.paList = padfValues; SetField( iField, &uField ); }}/************************************************************************//* OGR_F_SetFieldDoubleList() *//************************************************************************//** * Set field to list of doubles value. * * This function currently on has an effect of OFTRealList fields. * * This function is the same as the C++ 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. * * Th
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -