📄 ogrfeature.cpp
字号:
* * This method updates the features geometry, and operate exactly as * SetGeometryDirectly(), except that this method does not assume ownership * of the passed geometry, but instead makes a copy of it. * * This method is the same as the C function OGR_F_SetGeometry(). * * @param poGeomIn new geometry to apply to feature. Passing NULL value here * is correct and it will result in deallocation of currently assigned geometry * without assigning new one. * * @return OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if * the geometry type is illegal for the OGRFeatureDefn (checking not yet * implemented). */ OGRErr OGRFeature::SetGeometry( OGRGeometry * poGeomIn ){ delete poGeometry; if( poGeomIn != NULL ) poGeometry = poGeomIn->clone(); else poGeometry = NULL; // I should be verifying that the geometry matches the defn's type. return OGRERR_NONE;}/************************************************************************//* OGR_F_SetGeometry() *//************************************************************************//** * Set feature geometry. * * This function updates the features geometry, and operate exactly as * SetGeometryDirectly(), except that this function does not assume ownership * of the passed geometry, but instead makes a copy of it. * * This function is the same as the C++ OGRFeature::SetGeometry(). * * @param hFeat handle to the feature on which new geometry is applied to. * @param hGeom handle to the new geometry to apply to feature. * * @return OGRERR_NONE if successful, or OGR_UNSUPPORTED_GEOMETRY_TYPE if * the geometry type is illegal for the OGRFeatureDefn (checking not yet * implemented). */ OGRErr OGR_F_SetGeometry( OGRFeatureH hFeat, OGRGeometryH hGeom ){ return ((OGRFeature *) hFeat)->SetGeometry((OGRGeometry *) hGeom);}/************************************************************************//* StealGeometry() *//************************************************************************//** * Take away ownership of geometry. * * Fetch the geometry from this feature, and clear the reference to the * geometry on the feature. This is a mechanism for the application to * take over ownship of the geometry from the feature without copying. * Sort of an inverse to SetGeometryDirectly(). * * After this call the OGRFeature will have a NULL geometry. * * @return the pointer to the geometry. */OGRGeometry *OGRFeature::StealGeometry(){ OGRGeometry *poReturn = poGeometry; poGeometry = NULL; return poReturn;}/************************************************************************//* GetGeometryRef() *//************************************************************************//** * \fn OGRGeometry *OGRFeature::GetGeometryRef(); * * Fetch pointer to feature geometry. * * This method is the same as the C function OGR_F_GetGeometryRef(). * * @return pointer to internal feature geometry. This object should * not be modified. *//************************************************************************//* OGR_F_GetGeometryRef() *//************************************************************************//** * Fetch an handle to feature geometry. * * This function is the same as the C++ method OGRFeature::GetGeometryRef(). * * @param hFeat handle to the feature to get geometry from. * @return an handle to internal feature geometry. This object should * not be modified. */OGRGeometryH OGR_F_GetGeometryRef( OGRFeatureH hFeat ){ return ((OGRFeature *) hFeat)->GetGeometryRef();}/************************************************************************//* Clone() *//************************************************************************//** * Duplicate feature. * * The newly created feature is owned by the caller, and will have it's own * reference to the OGRFeatureDefn. * * This method is the same as the C function OGR_F_Clone(). * * @return new feature, exactly matching this feature. */OGRFeature *OGRFeature::Clone(){ OGRFeature *poNew = new OGRFeature( poDefn ); poNew->SetGeometry( poGeometry ); for( int i = 0; i < poDefn->GetFieldCount(); i++ ) { poNew->SetField( i, pauFields + i ); } if( GetStyleString() != NULL ) poNew->SetStyleString(GetStyleString()); poNew->SetFID( GetFID() ); return poNew;}/************************************************************************//* OGR_F_Clone() *//************************************************************************//** * Duplicate feature. * * The newly created feature is owned by the caller, and will have it's own * reference to the OGRFeatureDefn. * * This function is the same as the C++ method OGRFeature::Clone(). * * @param hFeat handle to the feature to clone. * @return an handle to the new feature, exactly matching this feature. */OGRFeatureH OGR_F_Clone( OGRFeatureH hFeat ){ return (OGRFeatureH) ((OGRFeature *) hFeat)->Clone();}/************************************************************************//* GetFieldCount() *//************************************************************************//** * \fn int OGRFeature::GetFieldCount(); * * Fetch number of fields on this feature. This will always be the same * as the field count for the OGRFeatureDefn. * * This method is the same as the C function OGR_F_GetFieldCount(). * * @return count of fields. *//************************************************************************//* OGR_F_GetFieldCount() *//************************************************************************//** * Fetch number of fields on this feature. This will always be the same * as the field count for the OGRFeatureDefn. * * This function is the same as the C++ method OGRFeature::GetFieldCount(). * * @param hFeat handle to the feature to get the fields count from. * @return count of fields. */int OGR_F_GetFieldCount( OGRFeatureH hFeat ){ return ((OGRFeature *) hFeat)->GetFieldCount();}/************************************************************************//* GetFieldDefnRef() *//************************************************************************//** * \fn OGRFieldDefn *OGRFeature::GetFieldDefnRef( int iField ); * * Fetch definition for this field. * * This method is the same as the C function OGR_F_GetFieldDefnRef(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * * @return the field definition (from the OGRFeatureDefn). This is an * internal reference, and should not be deleted or modified. *//************************************************************************//* OGR_F_GetFieldDefnRef() *//************************************************************************//** * Fetch definition for this field. * * This function is the same as the C++ method OGRFeature::GetFieldDefnRef(). * * @param hFeat handle to the feature on which the field is found. * @param i the field to fetch, from 0 to GetFieldCount()-1. * * @return an handle to the field definition (from the OGRFeatureDefn). * This is an internal reference, and should not be deleted or modified. */OGRFieldDefnH OGR_F_GetFieldDefnRef( OGRFeatureH hFeat, int i ){ return (OGRFieldDefnH) ((OGRFeature *) hFeat)->GetFieldDefnRef(i);}/************************************************************************//* GetFieldIndex() *//************************************************************************//** * \fn int OGRFeature::GetFieldIndex( const char * pszName ); * * Fetch the field index given field name. * * This is a cover for the OGRFeatureDefn::GetFieldIndex() method. * * This method is the same as the C function OGR_F_GetFieldIndex(). * * @param pszName the name of the field to search for. * * @return the field index, or -1 if no matching field is found. *//************************************************************************//* OGR_F_GetFieldIndex() *//************************************************************************//** * Fetch the field index given field name. * * This is a cover for the OGRFeatureDefn::GetFieldIndex() method. * * This function is the same as the C++ method OGRFeature::GetFieldIndex(). * * @param hFeat handle to the feature on which the field is found. * @param pszName the name of the field to search for. * * @return the field index, or -1 if no matching field is found. */int OGR_F_GetFieldIndex( OGRFeatureH hFeat, const char *pszName ){ return ((OGRFeature *) hFeat)->GetFieldIndex( pszName );}/************************************************************************//* IsFieldSet() *//************************************************************************//** * \fn int OGRFeature::IsFieldSet( int iField ); * * Test if a field has ever been assigned a value or not. * * This method is the same as the C function OGR_F_IsFieldSet(). * * @param iField the field to test. * * @return TRUE if the field has been set, otherwise false. *//************************************************************************//* OGR_F_IsFieldSet() *//************************************************************************//** * Test if a field has ever been assigned a value or not. * * This function is the same as the C++ method OGRFeature::IsFieldSet(). * * @param hFeat handle to the feature on which the field is. * @param iField the field to test. * * @return TRUE if the field has been set, otherwise false. */int OGR_F_IsFieldSet( OGRFeatureH hFeat, int iField ){ return ((OGRFeature *)hFeat)->IsFieldSet( iField );}/************************************************************************//* UnsetField() *//************************************************************************//** * Clear a field, marking it as unset. * * This method is the same as the C function OGR_F_UnsetField(). * * @param iField the field to unset. */void OGRFeature::UnsetField( int iField ){ OGRFieldDefn *poFDefn = poDefn->GetFieldDefn( iField ); CPLAssert( poFDefn != NULL || iField == -1 ); if( poFDefn == NULL || !IsFieldSet(iField) ) return; switch( poFDefn->GetType() ) { case OFTRealList: case OFTIntegerList: CPLFree( pauFields[iField].IntegerList.paList ); break; case OFTStringList: CSLDestroy( pauFields[iField].StringList.paList ); break; case OFTString: CPLFree( pauFields[iField].String ); break; case OFTBinary: CPLFree( pauFields[iField].Binary.paData ); break; default: break; } pauFields[iField].Set.nMarker1 = OGRUnsetMarker; pauFields[iField].Set.nMarker2 = OGRUnsetMarker;}/************************************************************************//* OGR_F_UnsetField() *//************************************************************************//** * Clear a field, marking it as unset. * * This function is the same as the C++ method OGRFeature::UnsetField(). * * @param hFeat handle to the feature on which the field is. * @param iField the field to unset. */void OGR_F_UnsetField( OGRFeatureH hFeat, int iField ){ ((OGRFeature *) hFeat)->UnsetField( iField );}/************************************************************************//* GetRawFieldRef() *//************************************************************************//** * \fn OGRField *OGRFeature::GetRawFieldRef( int iField ); * * Fetch a pointer to the internal field value given the index. * * This method is the same as the C function OGR_F_GetRawFieldRef(). * * @param iField the field to fetch, from 0 to GetFieldCount()-1. * * @return the returned pointer is to an internal data structure, and should * not be freed, or modified. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -