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

📄 ogrspatialreference.cpp

📁 在linux环境下
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * $Id: ogrspatialreference.cpp,v 1.77 2003/06/19 17:10:26 warmerda Exp $ * * Project:  OpenGIS Simple Features Reference Implementation * Purpose:  The OGRSpatialReference 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: ogrspatialreference.cpp,v $ * Revision 1.77  2003/06/19 17:10:26  warmerda * a couple fixes in last commit * * Revision 1.76  2003/06/18 18:24:17  warmerda * added projection specific set methods to C API * * Revision 1.75  2003/05/30 18:34:41  warmerda * clear existing authority node in SetLinearUnits if one exists * * Revision 1.74  2003/05/28 19:16:43  warmerda * fixed up argument names and stuff for docs * * Revision 1.73  2003/04/01 14:34:45  warmerda * Clarify SetUTM() documentation. * * Revision 1.72  2003/03/28 17:42:05  warmerda * fixed reference/dereference problem * * Revision 1.71  2003/02/25 04:55:41  warmerda * Added SetGeogCSFrom() method. Modified SetWellKnownGeogCS() to use it. * Modfied SetGeogCS() to replace an existing GEOGCS node if there is one. * * Revision 1.70  2003/02/14 22:15:04  warmerda * expand tabs * * Revision 1.69  2003/02/08 00:37:15  warmerda * try to improve documentation * * Revision 1.68  2003/02/06 04:53:12  warmerda * added Fixup() method * * Revision 1.67  2003/01/31 02:27:08  warmerda * modified SetFromUserInput() to avoid large buffer on stack * * Revision 1.66  2003/01/08 18:14:28  warmerda * added FixupOrdering() * * Revision 1.65  2002/12/21 17:29:38  warmerda * fixed default degree/radian problem for GEOGCS * * Revision 1.64  2002/12/16 17:08:44  warmerda * added GetPrimeMeridian() method, and fiddled with OGRPrintDouble * * Revision 1.63  2002/12/16 14:41:19  warmerda * implement normalized Get/Set ProjParm * * Revision 1.62  2002/12/15 23:42:59  warmerda * added initial support for normalizing proj params * * Revision 1.61  2002/12/14 22:59:14  warmerda * added Krovak in ESRI compatible way * * Revision 1.60  2002/12/10 04:06:00  warmerda * updated well known GEOGCS descriptions * * Revision 1.59  2002/12/09 16:11:32  warmerda * fixed constness of get authority calls * * Revision 1.58  2002/12/01 21:16:10  warmerda * added Get/set angular units methods * * Revision 1.57  2002/12/01 20:22:39  warmerda * preserve a little more precision in projection parameters * * Revision 1.56  2002/11/30 16:44:08  warmerda * fixed some functions that claimed to use node paths, so they work * * Revision 1.55  2002/11/30 15:45:49  warmerda * be more careful about how AUTHORITY is fetched, to not get wrong one * * Revision 1.54  2002/11/25 16:12:54  warmerda * added GetAuthorityCode/Name * * Revision 1.53  2002/07/25 15:58:02  warmerda * Fixed docs for how to compute inverse flattening. * * Revision 1.52  2002/07/25 13:13:36  warmerda * fixed const correctness of some docs * * Revision 1.51  2002/04/25 20:56:28  warmerda * expanded tabs * * Revision 1.50  2002/04/18 14:22:45  warmerda * made OGRSpatialReference and co 'const correct' * * Revision 1.49  2002/03/12 18:06:09  warmerda * added ESRI:: style support to SetFromUserInput() * * Revision 1.48  2002/03/08 16:38:11  warmerda * ensure SetProjParm() will replace an existing node if available * * Revision 1.47  2002/03/05 14:25:14  warmerda * expand tabs * * Revision 1.46  2002/02/18 15:46:02  warmerda * Fixed serious problems in IsSame() method.  Still a work in progress. * * Revision 1.45  2002/01/24 16:22:18  warmerda * reworked StripCTParms and simplify support for prettywkt * * Revision 1.44  2002/01/18 15:30:41  warmerda * ensure all AXIS nodes wiped in StripCTParms * * Revision 1.43  2002/01/18 04:51:05  warmerda * added PROJ.4 support to SetFromUserInput() */#include "ogr_spatialref.h"#include "ogr_p.h"CPL_CVSID("$Id: ogrspatialreference.cpp,v 1.77 2003/06/19 17:10:26 warmerda Exp $");/************************************************************************//*                           OGRPrintDouble()                           *//************************************************************************/static void OGRPrintDouble( char * pszStrBuf, double dfValue ){    sprintf( pszStrBuf, "%.16g", dfValue );    int nLen = strlen(pszStrBuf);    // The following hack is intended to truncate some "precision" in cases    // that appear to be roundoff error.     if( nLen > 15         && (strcmp(pszStrBuf+nLen-6,"999999") == 0            || strcmp(pszStrBuf+nLen-6,"000001") == 0) )    {        sprintf( pszStrBuf, "%.15g", dfValue );    }}/************************************************************************//*                        OGRSpatialReference()                         *//************************************************************************//** * Constructor. * * This constructor takes an optional string argument which if passed * should be a WKT representation of an SRS.  Passing this is equivelent * to not passing it, and then calling importFromWkt() with the WKT string. * * Note that newly created objects are given a reference count of one.  * * The C function OSRNewSpatialReference() does the same thing as this * constructor.  * * @param pszWKT well known text definition to which the object should * be initialized, or NULL (the default).  */OGRSpatialReference::OGRSpatialReference( const char * pszWKT ){    bNormInfoSet = FALSE;    nRefCount = 1;    poRoot = NULL;    if( pszWKT != NULL )        importFromWkt( (char **) &pszWKT );}/************************************************************************//*                       OSRNewSpatialReference()                       *//************************************************************************/OGRSpatialReferenceH OSRNewSpatialReference( const char *pszWKT ){    OGRSpatialReference * poSRS;    poSRS = new OGRSpatialReference();    if( pszWKT != NULL && strlen(pszWKT) > 0 )    {        if( poSRS->importFromWkt( (char **) (&pszWKT) ) != OGRERR_NONE )        {            delete poSRS;            poSRS = NULL;        }    }    return poSRS;}/************************************************************************//*                        OGRSpatialReference()                         *//*                                                                      *//*      Simple copy constructor.  See also Clone().                     *//************************************************************************/OGRSpatialReference::OGRSpatialReference(const OGRSpatialReference &oOther){    bNormInfoSet = FALSE;    nRefCount = 1;    poRoot = NULL;    if( oOther.poRoot != NULL )        poRoot = oOther.poRoot->Clone();}/************************************************************************//*                        ~OGRSpatialReference()                        *//************************************************************************//** * OGRSpatialReference destructor.  * * The C function OSRDestroySpatialReference() does the same thing as this * method.  */OGRSpatialReference::~OGRSpatialReference(){    if( poRoot != NULL )        delete poRoot;}/************************************************************************//*                     OSRDestroySpatialReference()                     *//************************************************************************/void OSRDestroySpatialReference( OGRSpatialReferenceH hSRS ){    delete ((OGRSpatialReference *) hSRS);}/************************************************************************//*                               Clear()                                *//************************************************************************//** * Wipe current definition. * * Returns OGRSpatialReference to a state with no definition, as it  * exists when first created.  It does not affect reference counts. */void OGRSpatialReference::Clear(){    if( poRoot )        delete poRoot;    poRoot = NULL;}/************************************************************************//*                             operator=()                              *//************************************************************************/OGRSpatialReference &OGRSpatialReference::operator=(const OGRSpatialReference &oSource){    if( poRoot != NULL )    {        delete poRoot;        poRoot = NULL;    }        if( oSource.poRoot != NULL )        poRoot = oSource.poRoot->Clone();    return *this;}/************************************************************************//*                             Reference()                              *//************************************************************************//** * Increments the reference count by one. * * The reference count is used keep track of the number of OGRGeometry objects * referencing this SRS. * * The method does the same thing as the C function OSRReference().  * * @return the updated reference count. */int OGRSpatialReference::Reference(){    return ++nRefCount;}/************************************************************************//*                            OSRReference()                            *//************************************************************************/int OSRReference( OGRSpatialReferenceH hSRS ){    return ((OGRSpatialReference *) hSRS)->Reference();}/************************************************************************//*                            Dereference()                             *//************************************************************************//** * Decrements the reference count by one. * * The method does the same thing as the C function OSRDereference().  * * @return the updated reference count. */int OGRSpatialReference::Dereference(){    return --nRefCount;}/************************************************************************//*                           OSRDereference()                           *//************************************************************************/int OSRDereference( OGRSpatialReferenceH hSRS ){    return ((OGRSpatialReference *) hSRS)->Dereference();}/************************************************************************//*                         GetReferenceCount()                          *//************************************************************************//** * \fn int OGRSpatialReference::GetReferenceCount() const; * * Fetch current reference count. * * @return the current reference count. *//************************************************************************//*                              SetRoot()                               *//************************************************************************//** * Set the root SRS node. * * If the object has an existing tree of OGR_SRSNodes, they are destroyed * as part of assigning the new root.  Ownership of the passed OGR_SRSNode is * is assumed by the OGRSpatialReference. * * @param poNewRoot object to assign as root.

⌨️ 快捷键说明

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