📄 ogrfmedatasource.cpp
字号:
/****************************************************************************** * $Id: ogrfmedatasource.cpp,v 1.17 2005/01/14 18:25:37 fwarmerdam Exp $ * * Project: FMEObjects Translator * Purpose: Implementations of the OGRFMEDataSource class. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 1999, 2001, 2002 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: ogrfmedatasource.cpp,v $ * Revision 1.17 2005/01/14 18:25:37 fwarmerdam * Added http as another exception. * * Revision 1.16 2004/12/17 18:01:49 fwarmerdam * Fixed last change. Might as well use legal C++ syntax! * * Revision 1.15 2004/12/16 19:29:23 fwarmerdam * dont try to open mysql: targets * * Revision 1.14 2004/02/19 06:27:57 warmerda * more prefixes to avoid trying to open * * Revision 1.13 2003/07/16 22:16:03 warmerda * dont try FMEObjects on OCI: names * * Revision 1.12 2003/02/06 14:25:51 warmerda * Added test if createStringArray() fails just after creating session. * * Revision 1.11 2003/02/03 15:59:36 warmerda * Move oCacheIndex testing into its own scope in destructor to avoid weird * compiler bug. * * Revision 1.10 2002/11/01 15:28:03 warmerda * added OGRFME_TMPDIR environment variable support * * Revision 1.9 2002/09/04 19:03:48 warmerda * avoid creating session if datasetname is not for FME * * Revision 1.8 2002/09/04 18:44:48 warmerda * try to make aggregates into multipolygons * * Revision 1.7 2002/09/04 15:29:16 warmerda * fixed bug in datasource destructor * * Revision 1.6 2002/08/14 21:15:25 warmerda * improved error recovery logic if session doesnt initialize * * Revision 1.33 2002/08/13 13:38:53 warmerda * updated * * Revision 1.5 2002/08/13 13:41:54 warmerda * removed MEDC stuff * * Revision 1.4 2002/07/24 19:25:53 warmerda * Initialize pszReaderName. * * Revision 1.3 2002/07/11 16:09:04 warmerda * added creation time, improved temp path handling * * Revision 1.2 2002/05/29 20:37:07 warmerda * add indirect load of fme.dll * * Revision 1.1 2002/05/24 06:23:57 warmerda * New * * Revision 1.31 2002/05/24 06:17:01 warmerda * clean up dependencies on strimp.h, and fme2ogrspatialref func * * Revision 1.30 2002/05/24 05:14:05 warmerda * removed stuff moved to minixml in cpl * * Revision 1.29 2002/05/24 03:59:56 warmerda * added support for cache index and related stuff * * Revision 1.28 2002/05/06 14:06:37 warmerda * override coordsys from cached features if needed * * Revision 1.27 2002/05/03 14:14:25 warmerda * Added support for clarifying geometry types, based in part on scanning all * the features. Also - convert polygons to multipolygons if the layer type * is multipolygon. * * Revision 1.26 2002/05/02 19:54:37 warmerda * replace printf() with CPLDebug call * * Revision 1.25 2002/04/30 17:16:00 warmerda * update from Ryan * * Revision 3.9 2002/04/26 17:30:50 ryan * MEDC -- SQL stuff included * * Revision 3.8 2002/04/26 00:01:16 ryan * FMEOLEDB -- Removed DLL_EXPIRES code again. * * Revision 3.7 2002/04/25 22:07:57 ryan * FMEOLEDB -- New FMEOLEDB from Frank with SQL changes * * Revision 1.24 2002/04/25 21:28:45 warmerda * drop cached layers with no features * * Revision 1.23 2002/04/25 21:14:06 warmerda * merge upgrades from Ryan * * Revision 3.4 2002/04/18 00:25:33 ryan * FMEOLEDB SDP -- Working merged FMEOLEDB Project * * Revision 3.3 2002/04/17 21:18:44 ryan * FMEOLEDB SDP -- Extents, debugging and project changes for merge (I) * * Revision 3.2 2002/04/11 16:51:39 ryan * FMEOLEDB -- Update from Frank - includes extents column and better geometry mappings * * Revision 1.22 2002/04/10 20:10:38 warmerda * Added support for getting geometry extents * * Revision 1.21 2002/01/11 20:34:58 warmerda * added debugging statements * * Revision 1.20 2001/11/27 17:04:22 warmerda * Dale added directive to log BADNEWS messages * * Revision 1.19 2001/11/22 21:18:42 warmerda * added SDE connection caching * * Revision 1.18 2001/11/21 15:45:41 warmerda * implement ExtractSRS * * Revision 1.17 2001/11/20 18:02:20 warmerda * disable mutex debugging for now, redirect FME log via CPLDebug * * Revision 1.16 2001/11/19 22:34:38 warmerda * try to set SPATIAL_SETTINGS flag * * Revision 1.15 2001/11/19 22:11:11 warmerda * clear rings in feature vector to avoid big leak * * Revision 1.14 2001/11/15 21:44:21 warmerda * preserve reader name * * Revision 1.13 2001/11/13 22:19:14 warmerda * make mutex anonymous, and log its handle * * Revision 1.12 2001/11/01 21:52:39 warmerda * added mutex to protect access to session * * Revision 1.11 2001/10/25 14:35:00 warmerda * force extension of new def files to fdd * * Revision 1.10 2001/10/25 14:30:28 warmerda * added 'fdd' file handling * * Revision 1.9 2001/09/27 17:00:30 warmerda * updated to FME2002 dir structure * * Revision 1.8 2001/09/07 17:26:04 warmerda * enable logging * * Revision 1.7 2001/09/07 15:54:32 warmerda * database reading no longer handled by this class * * Revision 1.6 2001/08/17 20:08:50 warmerda * capture user directives in prompt logic * * Revision 1.5 2001/07/27 18:21:36 warmerda * improve SDE test * * Revision 1.4 2001/07/27 17:27:06 warmerda * added CVSID * * Revision 1.3 2001/07/27 17:24:45 warmerda * First phase rewrite for MapGuide * * Revision 1.2 1999/11/23 15:39:51 warmerda * tab expantion * * Revision 1.1 1999/11/23 15:22:58 warmerda * New */#include "fme2ogr.h"//#include "ogr2fme.h"#include "cpl_conv.h"#include "cpl_string.h"//#include "ogrfme_cdsys.h"#include "cpl_multiproc.h"#include <idialog.h>#include <ilogfile.h>#include <icrdsysmgr.h>const char* kPROVIDERNAME = "FME_OLEDB";CPL_CVSID("$Id: ogrfmedatasource.cpp,v 1.17 2005/01/14 18:25:37 fwarmerdam Exp $");#ifdef WIN32#define FMEDLL_NAME "fme.dll"#define PATH_CHAR '\\'#else#define FMEDLL_NAME "libfmeobj.so"#define PATH_CHAR '/'#endifstatic IFMESession *poSharedSession = NULL;static int nSharedSessionRefCount = 0;static void *hSessionMutex = NULL;typedef struct { IFMEUniversalReader *poReader; char *pszReaderType; char *pszDefinition;} CachedConnection;static int nCachedConnectionCount = 0;static CachedConnection *pasCachedConnections = NULL;typedef struct { OGREnvelope sExtent; char *pszIndFile; char *pszCoordSys; IFMESpatialIndex *poIndex; OGRwkbGeometryType eBestGeomType;} CacheLayerInfo;/************************************************************************//* FME_Logger() *//* *//* Output that would normally go to the FME log file will *//* instead be redirected through this function. *//************************************************************************/void FME_Logger( FME_MsgLevel severity, const char *message ){ char *pszMessageCopy = CPLStrdup(message); if( pszMessageCopy[strlen(pszMessageCopy)-1] == '\n' ) pszMessageCopy[strlen(pszMessageCopy)-1] = '\0'; CPLDebug( "FME_LOG", "%d:%s", severity, pszMessageCopy ); CPLFree( pszMessageCopy );}/************************************************************************//* GetTmpDir() *//************************************************************************/static const char *GetTmpDir(){ const char *pszTmpDir; pszTmpDir = getenv("OGRFME_TMPDIR"); if( pszTmpDir == NULL ) pszTmpDir = getenv("TMPDIR"); if( pszTmpDir == NULL ) pszTmpDir = getenv("TEMPDIR"); if( pszTmpDir == NULL ) //20020419 - ryan pszTmpDir = getenv("TMP"); if( pszTmpDir == NULL ) pszTmpDir = getenv("TEMP"); if( pszTmpDir == NULL ) {#ifdef WIN32 pszTmpDir = "C:\\";#else pszTmpDir = "/tmp";#endif } return pszTmpDir;}/************************************************************************//* BuildTmpNam() *//* *//* Create a basename for the temporary file for a given layer *//* on this dataset. *//************************************************************************/static char *BuildTmpNam( const char *pszLayerName ){ int i; char szFilename[2048]; VSIStatBuf sStat; const char *pszTmpDir = GetTmpDir();/* -------------------------------------------------------------------- *//* Look for an unused name. *//* -------------------------------------------------------------------- */ for( i = -1; TRUE; i++ ) { if( i == -1 ) sprintf( szFilename, "%s%c%s_%s", pszTmpDir, PATH_CHAR, kPROVIDERNAME, pszLayerName ); else sprintf( szFilename, "%s%c%s_%s_%d", pszTmpDir, PATH_CHAR, kPROVIDERNAME, pszLayerName, i ); if( VSIStat( szFilename, &sStat ) != 0 ) break; } return CPLStrdup( szFilename );}/************************************************************************//* OGRFMEDataSource() *//************************************************************************/OGRFMEDataSource::OGRFMEDataSource(){ pszName = NULL; pszDataset = NULL; pszReaderName = NULL; poSession = NULL; poReader = NULL; poFMEFeature = NULL; nLayers = 0; papoLayers = NULL; poUserDirectives = NULL; bUseCaching = FALSE;}/************************************************************************//* ~OGRFMEDataSource() *//************************************************************************/OGRFMEDataSource::~OGRFMEDataSource(){ CPLDebug( kPROVIDERNAME, "~OGRFMEDataSource(): %p", this ); if( poSharedSession == NULL ) return; AcquireSession();/* -------------------------------------------------------------------- *//* Destroy the layers, so we know we don't still have the *//* caches open when we dereference them. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -