📄 ogrfeature.cpp
字号:
if( strlen(szTempBuffer) + strlen(pszItem) + 6 > sizeof(szTempBuffer) ) { break; } if( i > 0 ) strcat( szTempBuffer, "," ); strcat( szTempBuffer, pszItem ); } if( i < nCount ) strcat( szTempBuffer, ",...)" ); else strcat( szTempBuffer, ")" ); return m_pszTmpFieldValue = CPLStrdup( szTempBuffer ); } else if( poFDefn->GetType() == OFTBinary ) { int nCount = pauFields[iField].Binary.nCount; char *pszHex; if( nCount > (int) sizeof(szTempBuffer) / 2 - 4 ) nCount = sizeof(szTempBuffer) / 2 - 4; pszHex = CPLBinaryToHex( nCount, pauFields[iField].Binary.paData ); memcpy( szTempBuffer, pszHex, 2 * nCount ); szTempBuffer[nCount*2] = '\0'; if( nCount < pauFields[iField].Binary.nCount ) strcat( szTempBuffer, "..." ); CPLFree( pszHex ); return m_pszTmpFieldValue = CPLStrdup( szTempBuffer ); } else return "";#undef TEMP_BUFFER_SIZE}/************************************************************************//* OGR_F_GetFieldAsString() *//************************************************************************//** * Fetch field value as a string. * * OFTReal and OFTInteger fields will be translated to string using * sprintf(), but not necessarily using the established formatting rules. * Other field types, or errors will result in a return value of zero. * * This function is the same as the C++ method OGRFeature::GetFieldAsString(). * * @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 string is internal, and should not be * modified, or freed. It's lifetime may be very brief. */const char *OGR_F_GetFieldAsString( OGRFeatureH hFeat, int iField ){ return ((OGRFeature *)hFeat)->GetFieldAsString(iField);}/************************************************************************//* GetFieldAsIntegerList() *//************************************************************************//** * Fetch field value as a list of integers. * * Currently this method only works for OFTIntegerList fields. * * This method is the same as the C function OGR_F_GetFieldAsIntegerList(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param pnCount an integer to put the list count (number of integers) 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 int *OGRFeature::GetFieldAsIntegerList( int iField, int *pnCount ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return NULL; if( !IsFieldSet(iField) ) return NULL; if( poFDefn->GetType() == OFTIntegerList ) { if( pnCount != NULL ) *pnCount = pauFields[iField].IntegerList.nCount; return pauFields[iField].IntegerList.paList; } else { if( pnCount != NULL ) *pnCount = 0; return NULL; }}/************************************************************************//* OGR_F_GetFieldAsIntegerList() *//************************************************************************//** * Fetch field value as a list of integers. * * Currently this function only works for OFTIntegerList fields. * * This function is the same as the C++ method * OGRFeature::GetFieldAsIntegerList(). * * @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 integers) 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 int *OGR_F_GetFieldAsIntegerList( OGRFeatureH hFeat, int iField, int *pnCount ){ return ((OGRFeature *)hFeat)->GetFieldAsIntegerList(iField, pnCount);}/************************************************************************//* GetFieldAsDoubleList() *//************************************************************************//** * Fetch field value as a list of doubles. * * Currently this method only works for OFTRealList fields. * * This method is the same as the C function OGR_F_GetFieldAsDoubleList(). * * @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 *OGRFeature::GetFieldAsDoubleList( int iField, int *pnCount ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return NULL; if( !IsFieldSet(iField) ) return NULL; if( poFDefn->GetType() == OFTRealList ) { if( pnCount != NULL ) *pnCount = pauFields[iField].RealList.nCount; return pauFields[iField].RealList.paList; } else { if( pnCount != NULL ) *pnCount = 0; return NULL; }}/************************************************************************//* 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 C++ 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 ) const{ 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 C++ 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);}/************************************************************************//* GetFieldAsBinary() *//************************************************************************//** * Fetch field value as binary data. * * Currently this method only works for OFTBinary fields. * * This method is the same as the C function OGR_F_GetFieldAsBinary(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param pnBytes location to put the number of bytes returned. * * @return the field value. This data is internal, and should not be * modified, or freed. It's lifetime may be very brief. */GByte *OGRFeature::GetFieldAsBinary( int iField, int *pnBytes ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); *pnBytes = 0; CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return NULL; if( !IsFieldSet(iField) ) return NULL; if( poFDefn->GetType() == OFTBinary ) { *pnBytes = pauFields[iField].Binary.nCount; return pauFields[iField].Binary.paData; } else { return NULL; }}/************************************************************************//* OGR_F_GetFieldAsBinary() *//************************************************************************//** * Fetch field value as binary. * * Currently this method only works for OFTBinary fields. * * This function is the same as the C++ method * OGRFeature::GetFieldAsBinary(). * * @param hFeat handle to the feature that owned the field. * @param iField the field to fetch, from 0 to GetFieldCount()-1. * @param pnBytes location to place count of bytes returned. * * @return the field value. This list is internal, and should not be * modified, or freed. It's lifetime may be very brief. */GByte *OGR_F_GetFieldAsBinary( OGRFeatureH hFeat, int iField, int *pnBytes ){ return ((OGRFeature *)hFeat)->GetFieldAsBinary(iField,pnBytes);}/************************************************************************//* GetFieldAsDateTime() *//************************************************************************//** * Fetch field value as date and time. * * Currently this method only works for OFTDate, OFTTime and OFTDateTime fields. * * This method is the same as the C function OGR_F_GetFieldAsDateTime(). * * @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 OGRFeature::GetFieldAsDateTime( int iField, int *pnYear, int *pnMonth, int *pnDay, int *pnHour, int *pnMinute, int *pnSecond, int *pnTZFlag ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL ) return FALSE; if( !IsFieldSet(iField) ) return FALSE; if( poFDefn->GetType() == OFTDate || poFDefn->GetType() == OFTTime || poFDefn->GetType() == OFTDateTime ) { if( pnYear ) *pnYear = pauFields[iField].Date.Year; if( pnMonth ) *pnMonth = pauFields[iField].Date.Month; if( pnDay ) *pnDay = pauFields[iField].Date.Day; if( pnHour ) *pnHour = pauFields[iField].Date.Hour; if( pnMinute ) *pnMinute = pauFields[iField].Date.Minute; if( pnSecond ) *pnSecond = pauFields[iField].Date.Second; if( pnTZFlag ) *pnTZFlag = pauFields[iField].Date.TZFlag;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -