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

📄 ogrfmelayerdb.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * $Id: ogrfmelayerdb.cpp,v 1.3 2005/02/22 12:57:19 fwarmerdam Exp $ * * Project:  FMEObjects Translator * Purpose:  Implementation of the OGRFMELayerDB class.  This is the *           class implementing behaviour for layers that are built on *           smart readers representing databases with spatial constraints,  *           and where clause support.  * Author:   Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 1999, 2001 Safe Software Inc. * All Rights Reserved * * This software may not be copied or reproduced, in all or in part,  * without the prior written consent of Safe Software Inc. * * The entire risk as to the results and performance of the software, * supporting text and other information contained in this file * (collectively called the "Software") is with the user.  Although * Safe Software Incorporated has used considerable efforts in preparing  * the Software, Safe Software Incorporated does not warrant the * accuracy or completeness of the Software. In no event will Safe Software  * Incorporated be liable for damages, including loss of profits or  * consequential damages, arising out of the use of the Software. ****************************************************************************** * * $Log: ogrfmelayerdb.cpp,v $ * Revision 1.3  2005/02/22 12:57:19  fwarmerdam * use OGRLayer base spatial filter support * * Revision 1.2  2005/02/02 20:54:27  fwarmerdam * track m_nFeaturesRead * * Revision 1.1  2002/05/24 06:23:57  warmerda * New * * Revision 1.8  2002/05/24 06:17:01  warmerda * clean up dependencies on strimp.h, and fme2ogrspatialref func * * Revision 1.7  2002/01/31 17:00:06  warmerda * added debug statement about first feature in layer * * Revision 1.6  2001/11/26 23:36:43  warmerda * override SetAttributeFilter on OGRFMELayerDB to avoid parsing * * Revision 1.5  2001/11/26 18:37:58  warmerda * Use WHERE instead of WHERE_CLAUSE for SDE * * Revision 1.4  2001/11/15 21:44:34  warmerda * add macros support for SDE * * Revision 1.3  2001/11/01 21:52:39  warmerda * added mutex to protect access to session * * Revision 1.2  2001/09/27 17:02:33  warmerda * updated to fME2002 dir structure * * Revision 1.1  2001/09/07 15:53:39  warmerda * New * */#include "fme2ogr.h"#include "cpl_conv.h"#include "cpl_string.h"CPL_CVSID("$Id: ogrfmelayerdb.cpp,v 1.3 2005/02/22 12:57:19 fwarmerdam Exp $");/************************************************************************//*                           OGRFMELayerDB()                            *//************************************************************************/OGRFMELayerDB::OGRFMELayerDB( OGRFMEDataSource *poDSIn,                               const char *pszReaderNameIn,                               const char *pszDatasetIn,                              IFMEStringArray *poUserDirectivesIn )        : OGRFMELayer( poDSIn ){    nPreviousFeature = -1;    poReader = NULL;    pszReaderName = CPLStrdup( pszReaderNameIn );    pszDataset = CPLStrdup( pszDatasetIn );    poUserDirectives = poDS->GetFMESession()->createStringArray();    for( FME_UInt32 i = 0; i < poUserDirectivesIn->entries(); i++ )    {        CPLDebug( "FMEOLEDB", "userDirective[%d] = %s\n",                   i, (const char *) (*poUserDirectivesIn)(i) );        poUserDirectives->append( (*poUserDirectivesIn)(i) );    }}/************************************************************************//*                           ~OGRFMELayerDB()                           *//************************************************************************/OGRFMELayerDB::~OGRFMELayerDB(){    if( poReader != NULL )        poDS->GetFMESession()->destroyReader( poReader );    CPLFree( pszReaderName );    CPLFree( pszDataset );}/************************************************************************//*                           TestCapability()                           *//************************************************************************/int OGRFMELayerDB::TestCapability( const char * pszCap ){    if( EQUAL(pszCap,OLCRandomRead) )        return FALSE;    else if( EQUAL(pszCap,OLCSequentialWrite)              || EQUAL(pszCap,OLCRandomWrite) )        return FALSE;    else if( EQUAL(pszCap,OLCFastFeatureCount) )        return TRUE;    else if( EQUAL(pszCap,OLCFastSpatialFilter) )        return TRUE;    else         return FALSE;}/************************************************************************//*                           GetNextFeature()                           *//************************************************************************/OGRFeature *OGRFMELayerDB::GetNextFeature(){    OGRFeature      *poFeature;    FME_Boolean     eEndOfSchema;    FME_MsgNum      err;    poDS->AcquireSession();    if( poReader == NULL )    {        if( !CreateReader() )        {            return NULL;            poDS->ReleaseSession();        }    }    err = poReader->read( *poFMEFeature, eEndOfSchema );    if( err )    {        CPLFMEError( poDS->GetFMESession(), "Error while reading feature." );        poDS->ReleaseSession();        return NULL;    }    if( eEndOfSchema == FME_TRUE )    {        poDS->ReleaseSession();        return NULL;    }    poFeature = poDS->ProcessFeature( this, poFMEFeature );    if( nPreviousFeature == -1 )        CPLDebug( "FMEOLEDB", "Fetching first feature from layer `%s'.",                   GetLayerDefn()->GetName() );    poFeature->SetFID( ++nPreviousFeature );    m_nFeaturesRead++;    poDS->ReleaseSession();    return poFeature;}/************************************************************************//*                            ResetReading()                            *//************************************************************************/ void OGRFMELayerDB::ResetReading(){    nPreviousFeature = -1;    poDS->AcquireSession();/* -------------------------------------------------------------------- *//*      Blow away existing reader, if we have one.                      *//* -------------------------------------------------------------------- */    if( poReader != NULL )        poDS->GetFMESession()->destroyReader( poReader );    poReader = NULL;    poDS->ReleaseSession();}/************************************************************************//*                              SetMacro()                              *//*                                                                      *//*      Set the value of one macro within a set of macros stored in     *//*      comma delimeted name value pairs (as per RUNTIME_MACROS in      *//*      user directives).                                               *//************************************************************************/static void SetMacro( IFMEString *poMacros, const char *pszTarget,                       const char *pszNewValue ){    char      *pszWorking, *pszValStart;    int       nOldValLength;    pszWorking = (char *) CPLMalloc(strlen(poMacros->data())                                     + strlen(pszNewValue)                                     + strlen(pszTarget) + 20 );    strcpy( pszWorking, poMacros->data() );    pszValStart = strstr( pszWorking, pszTarget );    if( pszValStart == NULL         || pszValStart[strlen(pszTarget)] != ',' )    {        if( strlen(pszWorking) > 0 )            strcat( pszWorking, "," );        sprintf( pszWorking + strlen(pszWorking), "%s,%s",                  pszTarget, pszNewValue );        *poMacros = pszWorking;

⌨️ 快捷键说明

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