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

📄 ugklayer.cpp

📁 linux下一款GIS程序源码
💻 CPP
字号:
// ugklayer.cpp: implementation of the UGKLayer class.////////////////////////////////////////////////////////////////////////#include "ugklayer.h"/************************************************************************//*                              UGKLayer()                              *//************************************************************************/UGKLayer::UGKLayer(){	m_poStyleTable = NULL;	m_poAttrIndex = NULL;	m_nRefCount = 0;	m_nFeaturesRead = 0;	m_poFilterGeom = NULL;	m_bFilterIsEnvelope = FALSE;}/************************************************************************//*                             ~UGKLayer()                              *//************************************************************************/UGKLayer::~UGKLayer(){    if( m_poAttrIndex != NULL )    {        delete m_poAttrIndex;        m_poAttrIndex = NULL;    }    if( m_poFilterGeom )    {        delete m_poFilterGeom;        m_poFilterGeom = NULL;    }}/************************************************************************//*                             Reference()                              *//************************************************************************/int UGKLayer::Reference(){    return ++m_nRefCount;}/************************************************************************//*                            Dereference()                             *//************************************************************************/int UGKLayer::Dereference(){    return --m_nRefCount;}/************************************************************************//*                            GetRefCount()                             *//************************************************************************/int UGKLayer::GetRefCount() const{    return m_nRefCount;}/************************************************************************//*                          GetFeatureCount()                           *//************************************************************************/int UGKLayer::GetFeatureCount( int bForce ){    UGKFeature     *poFeature;    int            nFeatureCount = 0;    if( !bForce )        return -1;    ResetReading();    while( (poFeature = GetNextFeature()) != NULL )    {        nFeatureCount++;        delete poFeature;    }    ResetReading();    return nFeatureCount;}/************************************************************************//*                             GetExtent()                              *//************************************************************************/UGKErr UGKLayer::GetExtent(UGKEnvelope *psExtent, int bForce ){    UGKFeature     *poFeature;    UGKEnvelope   oEnv;    UGKBool     bExtentSet = FALSE;/* -------------------------------------------------------------------- *//*      If this layer has a none geometry type, then we can             *//*      reasonably assume there are not extents available.              *//* -------------------------------------------------------------------- */    if( GetLayerDefn()->GetGeomType() == wkbNone )    {        psExtent->MinX = 0.0;        psExtent->MaxX = 0.0;        psExtent->MinY = 0.0;        psExtent->MaxY = 0.0;                return UGKERR_FAILURE;    }/* -------------------------------------------------------------------- *//*      If not forced, we should avoid having to scan all the           *//*      features and just return a failure.                             *//* -------------------------------------------------------------------- */    if( !bForce )        return UGKERR_FAILURE;/* -------------------------------------------------------------------- *//*      OK, we hate to do this, but go ahead and read through all       *//*      the features to collect geometries and build extents.           *//* -------------------------------------------------------------------- */    ResetReading();    while( (poFeature = GetNextFeature()) != NULL )    {        UGKGeometry *poGeom = poFeature->GetGeometryRef();        if (poGeom && !bExtentSet)        {            poGeom->getEnvelope(psExtent);            bExtentSet = TRUE;        }        else if (poGeom)        {            poGeom->getEnvelope(&oEnv);            if (oEnv.MinX < psExtent->MinX)                 psExtent->MinX = oEnv.MinX;            if (oEnv.MinY < psExtent->MinY)                 psExtent->MinY = oEnv.MinY;            if (oEnv.MaxX > psExtent->MaxX)                 psExtent->MaxX = oEnv.MaxX;            if (oEnv.MaxY > psExtent->MaxY)                 psExtent->MaxY = oEnv.MaxY;        }        delete poFeature;    }    ResetReading();    return (bExtentSet ? UGKERR_NONE : UGKERR_FAILURE);}/************************************************************************//*                             GetFeature()                             *//************************************************************************/UGKFeature *UGKLayer::GetFeature( long nFID ){    UGKFeature *poFeature;    ResetReading();    while( (poFeature = GetNextFeature()) != NULL )    {        if( poFeature->GetFID() == nFID )            return poFeature;        else            delete poFeature;    }        return NULL;}/************************************************************************//*                           SetNextByIndex()                           *//************************************************************************/UGKErr UGKLayer::SetNextByIndex( long nIndex ){    UGKFeature *poFeature;    ResetReading();    while( nIndex-- > 0 )    {        poFeature = GetNextFeature();        if( poFeature == NULL )            return UGKERR_FAILURE;        delete poFeature;    }    return UGKERR_NONE;}/************************************************************************//*                             SetFeature()                             *//************************************************************************/UGKErr UGKLayer::SetFeature( UGKFeature * ){    return UGKERR_UNSUPPORTED_OPERATION;}/************************************************************************//*                           CreateFeature()                            *//************************************************************************/UGKErr UGKLayer::CreateFeature( UGKFeature * ){    return UGKERR_UNSUPPORTED_OPERATION;}/************************************************************************//*                              GetInfo()                               *//************************************************************************/const char *UGKLayer::GetInfo( const char * pszTag ){    (void) pszTag;    return NULL;}/************************************************************************//*                            CreateField()                             *//************************************************************************/UGKErr UGKLayer::CreateField( UGKFieldDefn * poField, int bApproxOK ){    (void) poField;    (void) bApproxOK;                  return UGKERR_UNSUPPORTED_OPERATION;}/************************************************************************//*                          StartTransaction()                          *//************************************************************************/UGKErr UGKLayer::StartTransaction(){    return UGKERR_NONE;}/************************************************************************//*                         CommitTransaction()                          *//************************************************************************/UGKErr UGKLayer::CommitTransaction(){    return UGKERR_NONE;}/************************************************************************//*                        RollbackTransaction()                         *//************************************************************************/UGKErr UGKLayer::RollbackTransaction(){    return UGKERR_UNSUPPORTED_OPERATION;}/************************************************************************//*                          GetSpatialFilter()                          *//************************************************************************/UGKGeometry *UGKLayer::GetSpatialFilter(){    return m_poFilterGeom;}/************************************************************************//*                       InitializeIndexSupport()                       *//*                                                                      *//*      This is only intended to be called by driver layer              *//*      implementations but we don't make it protected so that the      *//*      datasources can do it too if that is more appropriate.          *//************************************************************************/UGKErr UGKLayer::InitializeIndexSupport( const char *pszFilename ){    UGKErr eErr;    //m_poAttrIndex = new UGKMILayerAttrIndex();    eErr = m_poAttrIndex->Initialize( pszFilename, this );    if( eErr != UGKERR_NONE )    {        delete m_poAttrIndex;        m_poAttrIndex = NULL;    }    return eErr;}/************************************************************************//*                             SyncToDisk()                             *//************************************************************************/UGKErr UGKLayer::SyncToDisk(){    return UGKERR_NONE;}/************************************************************************//*                           DeleteFeature()                            *//************************************************************************/UGKErr UGKLayer::DeleteFeature( long nFID ){    return UGKERR_UNSUPPORTED_OPERATION;}/************************************************************************//*                          GetFeaturesRead()                           *//************************************************************************/UGKInt64 UGKLayer::GetFeaturesRead(){    return m_nFeaturesRead;}

⌨️ 快捷键说明

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