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

📄 ogrspatialreference.cpp

📁 用于读取TAB、MIF、SHP文件的类
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * $Id: ogrspatialreference.cpp,v 1.104 2006/12/18 16:22:51 fwarmerdam 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.104  2006/12/18 16:22:51  fwarmerdam * added support for x-ogc as well as ogc namespace * * Revision 1.103  2006/11/30 17:48:32  fwarmerdam * Avoid uninitialized variable warning. * * Revision 1.102  2006/11/24 17:58:15  fwarmerdam * added extension management methods * * Revision 1.101  2006/11/21 21:25:27  fwarmerdam * Applied ESRI:: modifier to dictionary lookups if requested. * * Revision 1.100  2006/11/07 18:55:07  fwarmerdam * added OGC importFromURN() * * Revision 1.99  2006/10/14 01:31:14  fwarmerdam * NULL target for GetAuthorityName/Code now returns for the root node. * * Revision 1.98  2005/12/20 02:08:07  fwarmerdam * UTM should default to a linear units of meter. * * Revision 1.97  2005/12/01 04:59:46  fwarmerdam * added two point equidistant support * * Revision 1.96  2005/10/16 01:32:41  fwarmerdam * Apply epsilon testing to UTM zone false easting and northing. * * Revision 1.95  2005/09/21 03:00:42  fwarmerdam * fixed return for Release * * Revision 1.94  2005/09/21 00:51:27  fwarmerdam * added Release * * Revision 1.93  2005/04/06 00:02:05  fwarmerdam * various osr and oct functions now stdcall * * Revision 1.92  2005/03/03 04:55:42  fwarmerdam * make exportToWkt() const * * Revision 1.91  2005/02/11 14:21:28  fwarmerdam * added GEOS projection support * * Revision 1.90  2005/01/13 05:17:37  fwarmerdam * added SetLinearUnitsAndUpdateParameters * * Revision 1.89  2005/01/05 21:02:33  fwarmerdam * added Goode Homolosine * * Revision 1.88  2004/11/11 18:28:45  fwarmerdam * added Bonne projection support * * Revision 1.87  2004/09/23 16:20:13  fwarmerdam * added OSRCleanup * * Revision 1.86  2004/09/10 20:59:06  fwarmerdam * Added note on SetSOC() being deprecated. * * Revision 1.85  2004/05/06 19:26:04  dron * Added OSRSetProjection() function. * * Revision 1.84  2004/05/04 17:54:45  warmerda * internal longitude format is greenwich relative - no adjustments needed * * Revision 1.83  2004/03/04 18:04:45  warmerda * added importFromDict() support * * Revision 1.82  2004/02/05 17:07:59  dron * Support for HOM projection, specified by two points on centerline. * * Revision 1.81  2003/12/05 16:22:49  warmerda * optimized IsProjected * * Revision 1.80  2003/10/07 04:20:50  warmerda * added WMS AUTO: support * * Revision 1.79  2003/09/18 14:43:40  warmerda * Ensure that SetAuthority() clears old nodes. * Don't crash on NULL root in exportToPrettyWkt(). * * Revision 1.78  2003/08/18 13:26:01  warmerda * added SetTMVariant() and related definitions * * 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() */#include "ogr_spatialref.h"#include "ogr_p.h"#include "cpl_csv.h"CPL_CVSID("$Id: ogrspatialreference.cpp,v 1.104 2006/12/18 16:22:51 fwarmerdam Exp $");// The current opinion is that WKT longitudes like central meridian// should be relative to greenwich, not the prime meridian in use. // Define the following if they should be relative to the prime meridian// of then geogcs.#undef WKT_LONGITUDE_RELATIVE_TO_PM/************************************************************************//*                           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 CPL_STDCALL 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 CPL_STDCALL 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 )

⌨️ 快捷键说明

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