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

📄 ogrdatasource.cpp

📁 在linux环境下
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************** * $Id: ogrdatasource.cpp,v 1.20 2003/05/28 19:18:04 warmerda Exp $ * * Project:  OpenGIS Simple Features Reference Implementation * Purpose:  The generic portions of the OGRDataSource class. * Author:   Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 1999,  Les Technologies SoftMap Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * $Log: ogrdatasource.cpp,v $ * Revision 1.20  2003/05/28 19:18:04  warmerda * fixup argument names for docs * * Revision 1.19  2003/05/21 04:54:29  warmerda * avoid warnings about unused formal parameters and possibly uninit variables * * Revision 1.18  2003/04/23 16:27:15  warmerda * (re) filled OGR_DS_GetName() * * Revision 1.17  2003/04/22 19:36:04  warmerda * Added SyncToDisk * * Revision 1.16  2003/04/08 19:31:58  warmerda * added CopyLayer and CopyDataSource entry points * * Revision 1.15  2003/03/20 20:21:40  warmerda * implement DROP INDEX command * * Revision 1.14  2003/03/20 19:11:55  warmerda * added debug messages * * Revision 1.13  2003/03/19 20:35:49  warmerda * Added support for reference counting. * Added support for joins from tables in other datasources. * * Revision 1.12  2003/03/19 05:12:34  warmerda * fixed memory leak * * Revision 1.11  2003/03/05 05:13:49  warmerda * added getlayerbyname, implement join support * * Revision 1.10  2003/03/04 05:47:49  warmerda * added CREATE INDEX support * * Revision 1.9  2003/03/03 05:06:27  warmerda * added support for DeleteDataSource and DeleteLayer * * Revision 1.8  2002/09/26 18:16:19  warmerda * added C entry points * * Revision 1.7  2002/05/01 18:26:27  warmerda * Fixed reporting of error on table. * * Revision 1.6  2002/04/29 19:35:50  warmerda * fixes for selecting FID * * Revision 1.5  2002/04/25 03:42:04  warmerda * fixed spatial filter support on SQL results * * Revision 1.4  2002/04/25 02:24:45  warmerda * added ExecuteSQL method * * Revision 1.3  2001/07/18 04:55:16  warmerda * added CPL_CSVID * * Revision 1.2  2000/08/21 16:37:43  warmerda * added constructor, and initialization of styletable * * Revision 1.1  1999/11/04 21:10:51  warmerda * New * */#include "ogrsf_frmts.h"#include "ogr_api.h"#include "ogr_p.h"#include "ogr_gensql.h"#include "ogr_attrind.h"CPL_C_START#include "swq.h"CPL_C_ENDCPL_CVSID("$Id: ogrdatasource.cpp,v 1.20 2003/05/28 19:18:04 warmerda Exp $");/************************************************************************//*                           ~OGRDataSource()                           *//************************************************************************/OGRDataSource::OGRDataSource(){    m_poStyleTable = NULL;    m_nRefCount = 0;}/************************************************************************//*                           ~OGRDataSource()                           *//************************************************************************/OGRDataSource::~OGRDataSource(){    CPLDebug( "OGR", "~OGRDDataSource(%p)", this );}/************************************************************************//*                           OGR_DS_Destroy()                           *//************************************************************************/void OGR_DS_Destroy( OGRDataSourceH hDS ){    delete (OGRDataSource *) hDS;}/************************************************************************//*                             Reference()                              *//************************************************************************/int OGRDataSource::Reference(){    return ++m_nRefCount;}/************************************************************************//*                          OGR_DS_Reference()                          *//************************************************************************/int OGR_DS_Reference( OGRDataSourceH hDataSource ){    return ((OGRDataSource *) hDataSource)->Reference();}/************************************************************************//*                            Dereference()                             *//************************************************************************/int OGRDataSource::Dereference(){    return --m_nRefCount;}/************************************************************************//*                         OGR_DS_Dereference()                         *//************************************************************************/int OGR_DS_Dereference( OGRDataSourceH hDataSource ){    return ((OGRDataSource *) hDataSource)->Dereference();}/************************************************************************//*                            GetRefCount()                             *//************************************************************************/int OGRDataSource::GetRefCount() const{    return m_nRefCount;}/************************************************************************//*                         OGR_DS_GetRefCount()                         *//************************************************************************/int OGR_DS_GetRefCount( OGRDataSourceH hDataSource ){    return ((OGRDataSource *) hDataSource)->GetRefCount();}/************************************************************************//*                         GetSummaryRefCount()                         *//************************************************************************/int OGRDataSource::GetSummaryRefCount() const{    int nSummaryCount = m_nRefCount;    int iLayer;    OGRDataSource *poUseThis = (OGRDataSource *) this;    for( iLayer=0; iLayer < poUseThis->GetLayerCount(); iLayer++ )        nSummaryCount += poUseThis->GetLayer( iLayer )->GetRefCount();    return nSummaryCount;}/************************************************************************//*                     OGR_DS_GetSummaryRefCount()                      *//************************************************************************/int OGR_DS_GetSummaryRefCount( OGRDataSourceH hDataSource ){    return ((OGRDataSource *) hDataSource)->GetSummaryRefCount();}/************************************************************************//*                            CreateLayer()                             *//************************************************************************/OGRLayer *OGRDataSource::CreateLayer( const char * pszName,                                      OGRSpatialReference * poSpatialRef,                                      OGRwkbGeometryType eGType,                                      char **papszOptions ){    (void) eGType;    (void) poSpatialRef;    (void) pszName;    (void) papszOptions;    CPLError( CE_Failure, CPLE_NotSupported,              "CreateLayer() not supported by this data source." );                  return NULL;}/************************************************************************//*                         OGR_DS_CreateLayer()                         *//************************************************************************/OGRLayerH OGR_DS_CreateLayer( OGRDataSourceH hDS,                               const char * pszName,                              OGRSpatialReferenceH hSpatialRef,                              OGRwkbGeometryType eType,                              char ** papszOptions ){    return ((OGRDataSource *)hDS)->CreateLayer(         pszName, (OGRSpatialReference *) hSpatialRef, eType, papszOptions );}/************************************************************************//*                             CopyLayer()                              *//************************************************************************/OGRLayer *OGRDataSource::CopyLayer( OGRLayer *poSrcLayer,                                     const char *pszNewName,                                     char **papszOptions ){    OGRFeatureDefn *poSrcDefn = poSrcLayer->GetLayerDefn();    OGRLayer *poDstLayer = NULL;/* -------------------------------------------------------------------- *//*      Create the layer.                                               *//* -------------------------------------------------------------------- */    if( !TestCapability( ODsCCreateLayer ) )    {        CPLError( CE_Failure, CPLE_NotSupported,                   "This datasource does not support creation of layers." );        return NULL;    }    CPLErrorReset();    poDstLayer = CreateLayer( pszNewName, poSrcLayer->GetSpatialRef(),                              poSrcDefn->GetGeomType(), papszOptions );        if( poDstLayer == NULL )        return NULL;/* -------------------------------------------------------------------- *//*      Add fields.  Default to copy all field.                         *//*      If only a subset of all fields requested, then output only      *//*      the selected fields, and in the order that they were            *//*      selected.                                                       *//* -------------------------------------------------------------------- */    int         iField;        for( iField = 0; iField < poSrcDefn->GetFieldCount(); iField++ )        poDstLayer->CreateField( poSrcDefn->GetFieldDefn(iField) );/* -------------------------------------------------------------------- *//*      Transfer features.                                              *//* -------------------------------------------------------------------- */    OGRFeature  *poFeature;        poSrcLayer->ResetReading();    while( TRUE )    {        OGRFeature      *poDstFeature = NULL;        poFeature = poSrcLayer->GetNextFeature();                if( poFeature == NULL )            break;        CPLErrorReset();        poDstFeature = OGRFeature::CreateFeature( poDstLayer->GetLayerDefn() );

⌨️ 快捷键说明

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