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

📄 ogrfeaturedefn.cpp

📁 在linux环境下
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * $Id: ogrfeaturedefn.cpp,v 1.11 2003/05/28 19:16:42 warmerda Exp $ * * Project:  OpenGIS Simple Features Reference Implementation * Purpose:  The OGRFeatureDefn class implementation. * Author:   Frank Warmerdam, warmerda@home.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: ogrfeaturedefn.cpp,v $ * Revision 1.11  2003/05/28 19:16:42  warmerda * fixed up argument names and stuff for docs * * Revision 1.10  2003/04/08 20:57:06  warmerda * added Clone * * Revision 1.9  2003/04/03 23:39:11  danmo * Small updates to C API docs (Normand S.) * * Revision 1.8  2003/03/31 15:55:42  danmo * Added C API function docs * * Revision 1.7  2002/09/26 18:12:38  warmerda * added C support * * Revision 1.6  2002/08/07 21:37:47  warmerda * added indirect OGRFeaturedefn constructor/destructor * * Revision 1.5  2001/07/18 05:03:05  warmerda * added CPL_CVSID * * Revision 1.4  1999/10/01 14:46:38  warmerda * don't blow assertion trying to get non-existant fields * * Revision 1.3  1999/08/28 03:12:06  warmerda * Improve debug message for left over reference count message. * * Revision 1.2  1999/07/05 17:19:52  warmerda * added docs * * Revision 1.1  1999/06/11 19:21:02  warmerda * New */#include "ogr_feature.h"#include "ogr_api.h"#include "ogr_p.h"CPL_CVSID("$Id: ogrfeaturedefn.cpp,v 1.11 2003/05/28 19:16:42 warmerda Exp $");/************************************************************************//*                           OGRFeatureDefn()                           *//************************************************************************//** * Constructor * * The OGRFeatureDefn maintains a reference count, but this starts at * zero.  It is mainly intended to represent a count of OGRFeature's * based on this definition. * * This method is the same as the C function OGR_FD_Create(). * * @param pszName the name to be assigned to this layer/class.  It does not * need to be unique.  */OGRFeatureDefn::OGRFeatureDefn( const char * pszName ){    pszFeatureClassName = CPLStrdup( pszName );    nRefCount = 0;    nFieldCount = 0;    papoFieldDefn = NULL;    eGeomType = wkbUnknown;}/************************************************************************//*                           OGR_FD_Create()                            *//************************************************************************//** * Create a new feature definition object to held the field definitions. * * The OGRFeatureDefn maintains a reference count, but this starts at * zero.  It is mainly intended to represent a count of OGRFeature's * based on this definition. * * This function is the same as the CPP method  * OGRFeatureDefn::OGRFeatureDefn(). * * @param pszName the name to be assigned to this layer/class.  It does not * need to be unique.  * @return handle to the newly created feature definition. */OGRFeatureDefnH OGR_FD_Create( const char *pszName ){    return (OGRFeatureDefnH) new OGRFeatureDefn( pszName );}/************************************************************************//*                          ~OGRFeatureDefn()                           *//************************************************************************/OGRFeatureDefn::~OGRFeatureDefn(){    if( nRefCount != 0 )    {        CPLDebug( "OGRFeatureDefn",                  "OGRFeatureDefn %s with a ref count of %d deleted!\n",                  pszFeatureClassName, nRefCount );    }        CPLFree( pszFeatureClassName );    for( int i = 0; i < nFieldCount; i++ )    {        delete papoFieldDefn[i];    }    CPLFree( papoFieldDefn );}/************************************************************************//*                           OGR_FD_Destroy()                           *//************************************************************************//** * Destroy a feature definition object and release all memory  * associated with it.  * * This function is the same as the CPP method  * OGRFeatureDefn::~OGRFeatureDefn(). * * @param hDefn handle to the feature definition to be destroyed. */void OGR_FD_Destroy( OGRFeatureDefnH hDefn ){    delete (OGRFeatureDefn *) hDefn;}/************************************************************************//*                               Clone()                                *//************************************************************************//** * \fn OGRFeatureDefn *OGRFeatureDefn::Clone(); * * Create a copy of this feature definition. * * Creates a deep copy of the feature definition.  *  * @return the copy.  */OGRFeatureDefn *OGRFeatureDefn::Clone(){    OGRFeatureDefn *poCopy;    poCopy = new OGRFeatureDefn( GetName() );    poCopy->SetGeomType( GetGeomType() );    for( int i = 0; i < GetFieldCount(); i++ )        poCopy->AddFieldDefn( GetFieldDefn( i ) );    return poCopy;}/************************************************************************//*                              GetName()                               *//************************************************************************//** * \fn const char *OGRFeatureDefn::GetName(); * * Get name of this OGRFeatureDefn. * * This method is the same as the C function OGR_FD_GetName(). * * @return the name.  This name is internal and should not be modified, or * freed. *//************************************************************************//*                           OGR_FD_GetName()                           *//************************************************************************//** * Get name of the OGRFeatureDefn passed as an argument. * * This function is the same as the CPP method OGRFeatureDefn::GetName(). * * @param hDefn handle to the feature definition to get the name from. * @return the name.  This name is internal and should not be modified, or * freed. */const char *OGR_FD_GetName( OGRFeatureDefnH hDefn ){    return ((OGRFeatureDefn *) hDefn)->GetName();}/************************************************************************//*                           GetFieldCount()                            *//************************************************************************//** * \fn int OGRFeatureDefn::GetFieldCount(); * * Fetch number of fields on this feature. * * This method is the same as the C function OGR_FD_GetFieldCount(). * @return count of fields. *//************************************************************************//*                        OGR_FD_GetFieldCount()                        *//************************************************************************//** * Fetch number of fields on the passed feature definition. * * This function is the same as the CPP OGRFeatureDefn::GetFieldCount(). * * @param hDefn handle to the feature definition to get the fields count from. * @return count of fields. */int OGR_FD_GetFieldCount( OGRFeatureDefnH hDefn ){    return ((OGRFeatureDefn *) hDefn)->GetFieldCount();}/************************************************************************//*                            GetFieldDefn()                            *//************************************************************************//** * Fetch field definition. * * This method is the same as the C function OGR_FD_GetFieldDefn(). * * @param iField the field to fetch, between 0 and GetFieldCount()-1. * * @return a pointer to an internal field definition object.  This object * should not be modified or freed by the application. */OGRFieldDefn *OGRFeatureDefn::GetFieldDefn( int iField ){    if( iField < 0 || iField >= nFieldCount )    {        return NULL;    }    return papoFieldDefn[iField];}/************************************************************************//*                        OGR_FD_GetFieldDefn()                         *//************************************************************************//** * Fetch field definition of the passed feature definition. * * This function is the same as the CPP method  * OGRFeatureDefn::GetFieldDefn(). * * @param hDefn handle to the feature definition to get the field definition * from. * @param iField the field to fetch, between 0 and GetFieldCount()-1. * * @return an handle to an internal field definition object.  This object * should not be modified or freed by the application. */OGRFieldDefnH OGR_FD_GetFieldDefn( OGRFeatureDefnH hDefn, int iField ){    return ((OGRFeatureDefn *) hDefn)->GetFieldDefn( iField );}/************************************************************************/

⌨️ 快捷键说明

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