📄 ogrfeature.cpp
字号:
/* OGR_F_GetFieldAsDoubleList() *//************************************************************************//** * Fetch field value as a list of doubles. * * Currently this function only works for OFTRealList fields. * * This function is the same as the CPP method * OGRFeature::GetFieldAsDoubleList(). * * @param hFeat handle to the feature that owned the field. * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param pnCount an integer to put the list count (number of doubles) into. * * @return the field value. This list is internal, and should not be * modified, or freed. It's lifetime may be very brief. If *pnCount is zero * on return the returned pointer may be NULL or non-NULL. */const double *OGR_F_GetFieldAsDoubleList( OGRFeatureH hFeat, int iField, int *pnCount ){ return ((OGRFeature *)hFeat)->GetFieldAsDoubleList(iField, pnCount);}/************************************************************************//* GetFieldAsStringList() *//************************************************************************//** * Fetch field value as a list of strings. * * Currently this method only works for OFTStringList fields. * * This method is the same as the C function OGR_F_GetFieldAsStringList(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * * @return the field value. This list is internal, and should not be * modified, or freed. It's lifetime may be very brief. */char **OGRFeature::GetFieldAsStringList( int iField ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return NULL; if( !IsFieldSet(iField) ) return NULL; if( poFDefn->GetType() == OFTStringList ) { return pauFields[iField].StringList.paList; } else { return NULL; }}/************************************************************************//* OGR_F_GetFieldAsStringList() *//************************************************************************//** * Fetch field value as a list of strings. * * Currently this method only works for OFTStringList fields. * * This function is the same as the CPP method * OGRFeature::GetFieldAsStringList(). * * @param hFeat handle to the feature that owned the field. * @param iField the field to fetch, from 0 to GetFieldCount()-1. * * @return the field value. This list is internal, and should not be * modified, or freed. It's lifetime may be very brief. */char **OGR_F_GetFieldAsStringList( OGRFeatureH hFeat, int iField ){ return ((OGRFeature *)hFeat)->GetFieldAsStringList(iField);}/************************************************************************//* 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 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 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 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 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 /* 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 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 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 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 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -