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

📄 ogr_srs_proj4.cpp

📁 用于读取TAB、MIF、SHP文件的类
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * $Id: ogr_srs_proj4.cpp,v 1.66 2006/11/24 17:58:30 fwarmerdam Exp $ * * Project:  OpenGIS Simple Features Reference Implementation * Purpose:  OGRSpatialReference interface to PROJ.4. * 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: ogr_srs_proj4.cpp,v $ * Revision 1.66  2006/11/24 17:58:30  fwarmerdam * added support for +wktext / PROJ4 EXTENSION hackery * * Revision 1.65  2006/11/01 04:37:39  fwarmerdam * fixed two point equidistant, preliminary mercator2sp support * * Revision 1.64  2006/05/05 17:02:54  fwarmerdam * Added Krovak PROJ.4 to WKT translation. * * Revision 1.63  2006/04/21 03:33:23  fwarmerdam * Per bug 811 we should not actually be adjusting the central meridian or * other longitudes.  They are relative to the geogcs prime meridian in * WKT and PROJ.4 format.  Ugg. * * Revision 1.62  2006/04/21 02:44:35  fwarmerdam * Fixed bogota meridian sign (west, not east). * * Revision 1.61  2006/03/21 15:12:22  fwarmerdam * Fixed support for +R parameter. * * Revision 1.60  2005/12/13 15:57:28  dron * Export scale coefficient when exporting to stereographic projection. * * Revision 1.59  2005/12/01 04:59:46  fwarmerdam * added two point equidistant support * * Revision 1.58  2005/11/10 04:12:40  fwarmerdam * The last change related to: * http://bugzilla.remotesensing.org/show_bug.cgi?id=980 * * Revision 1.57  2005/11/10 04:12:14  fwarmerdam * Changed the translation for Oblique Stereographic from proj=stere to * proj=sterea. * * Revision 1.56  2005/09/29 20:22:26  dmorissette * Improved support for MapInfo modified TM projections in exportToProj4() * (Anthony D - MITAB bug 1155) * * Revision 1.55  2005/09/05 20:42:52  fwarmerdam * ensure that non-geographic, non-projected srses return empty string * * Revision 1.54  2005/04/06 00:02:05  fwarmerdam * various osr and oct functions now stdcall * * Revision 1.53  2005/02/28 15:01:56  fwarmerdam * Applied patch to add +towgs84 parameter if one is well known for a given * EPSG GEOGCS, and no datum shifting info is available in the source defn. * See http://bugzilla.remotesensing.org/show_bug.cgi?id=784 * * Revision 1.52  2005/02/09 20:25:39  fwarmerdam * Changed default height for GEOS projection. * * Revision 1.51  2005/01/05 21:02:33  fwarmerdam * added Goode Homolosine * * Revision 1.50  2004/11/11 18:28:45  fwarmerdam * added Bonne projection support * * Revision 1.49  2004/09/10 21:04:51  fwarmerdam * Various fixes for swiss oblique mercator (somerc) support. * http://bugzilla.remotesensing.org/show_bug.cgi?id=423 * * Revision 1.48  2004/09/10 20:29:16  fwarmerdam * Re bug 423: fixed up SRS_PT_SWISS_OBLIQUE_CYLINDRICAL to use somerc. * * Revision 1.47  2004/05/12 14:27:47  warmerda * added translation for nzgd49 and potsdam using epsg codes * * Revision 1.46  2004/05/04 18:49:43  warmerda * Fixed handling of prime meridian.  In PROJ.4 strings the central meridian * or other longitude parameters are relative to the prime meridian.  Apply * appropriate transformations going and coming from WKT where that is not * the case. * * Revision 1.45  2004/02/05 17:07:59  dron * Support for HOM projection, specified by two points on centerline. * * Revision 1.44  2003/06/27 19:02:04  warmerda * added OSRProj4Tokenize(), fixes plus related tokenizing bug in bug 355 * * Revision 1.43  2003/06/27 17:54:12  warmerda * allow k_0 in place of k parsing proj4, bug 355 * * Revision 1.42  2003/06/21 23:25:03  warmerda * added +towgs84 support in importFromProj4() * * Revision 1.41  2003/05/28 18:17:38  warmerda * treat meter or m as meter * * Revision 1.40  2003/05/20 18:09:36  warmerda * fixed so that importFromProj4() will transform linear parameter units * * Revision 1.39  2003/02/13 19:27:28  warmerda * always append no_defs to avoid getting hosted by defaults file * * Revision 1.38  2002/12/15 23:42:59  warmerda * added initial support for normalizing proj params * * Revision 1.37  2002/12/14 19:50:21  warmerda * implement support for NZMG (New Zealand Map Grid) * * Revision 1.36  2002/12/10 04:05:04  warmerda * fixed some translation problems with prime meridians * * Revision 1.35  2002/12/09 23:03:45  warmerda * Fixed translation of paris prime meridian. * * Revision 1.34  2002/12/09 18:55:07  warmerda * moved DMS stuff to gdal/port * * Revision 1.33  2002/12/09 16:12:14  warmerda * added +pm= support * * Revision 1.32  2002/12/03 15:38:10  warmerda * dont write linear units to geograpic srs but avoid freaking out * * Revision 1.31  2002/12/01 20:19:21  warmerda * use %.16g to preserve precision as per bug 184 * * Revision 1.30  2002/11/29 21:23:38  warmerda * implement LCC1SP PROJ.4 to WKT translation * * Revision 1.29  2002/11/29 20:56:37  warmerda * added LCC1SP conversion to PROJ.4, missing reverse * * Revision 1.28  2002/11/25 03:28:16  warmerda * added/improved documentation * * Revision 1.27  2002/07/09 14:49:07  warmerda * Improved translation from/to polar stereographic as per * http://bugzilla.remotesensing.org/show_bug.cgi?id=172 * * Revision 1.26  2002/06/11 18:02:03  warmerda * add PROJ.4 normalization and EPSG support * * Revision 1.25  2002/04/18 14:22:45  warmerda * made OGRSpatialReference and co 'const correct' * * Revision 1.24  2002/03/08 20:17:52  warmerda * assume WGS84 if ellipse info missing * * Revision 1.23  2002/01/18 04:48:48  warmerda * clean tabs, and newlines from input to importProj4 * * Revision 1.22  2001/12/12 20:18:06  warmerda * added support for units in proj.4 to WKT * * Revision 1.21  2001/11/07 22:08:51  warmerda * dont put + in to_meter value * * Revision 1.20  2001/11/02 22:21:15  warmerda * fixed memory leak * * Revision 1.19  2001/10/11 19:23:30  warmerda * fixed datum names * * Revision 1.18  2001/07/18 05:03:05  warmerda * added CPL_CVSID * * Revision 1.17  2001/03/02 04:37:43  danmo * Return empty string for LOCAL_CS in exportToProj4(). * * Revision 1.16  2001/01/22 14:00:28  warmerda * added untested support for Swiss Oblique Cylindrical * * Revision 1.15  2001/01/19 21:10:46  warmerda * replaced tabs * * Revision 1.14  2000/12/05 23:10:34  warmerda * Added cassini support * * Revision 1.13  2000/12/05 17:46:16  warmerda * Use +R_A for VanDerGrinten and miller * * Revision 1.12  2000/09/25 20:22:21  warmerda * ensure pszPROJ4Units is initialized * * Revision 1.11  2000/09/25 15:46:56  warmerda * added sphere * * Revision 1.10  2000/08/28 20:13:23  warmerda * added importFromProj4 * * Revision 1.9  2000/07/11 01:02:06  warmerda * added ExportToProj4() * * Revision 1.8  2000/07/09 20:49:21  warmerda * added +datum support * * Revision 1.7  2000/03/06 02:23:54  warmerda * don't use +datum syntax * * Revision 1.6  1999/12/22 15:39:43  warmerda * fix to differentiate WGS variants * * Revision 1.5  1999/12/13 16:29:59  warmerda * Added improved units, and ellipse support. * * Revision 1.4  1999/12/08 16:34:05  warmerda * added five or six more projections * * Revision 1.1  1999/07/29 17:29:15  warmerda * New * */#include "ogr_spatialref.h"#include "ogr_p.h"#include "cpl_conv.h"extern int EPSGGetWGS84Transform( int nGeogCS, double *padfTransform );CPL_CVSID("$Id: ogr_srs_proj4.cpp,v 1.66 2006/11/24 17:58:30 fwarmerdam Exp $");/* -------------------------------------------------------------------- *//*      The following list comes from osrs/proj/src/pj_ellps.c          *//*      ... please update from time to time.                            *//* -------------------------------------------------------------------- */static const char *ogr_pj_ellps[] = {"MERIT",        "a=6378137.0", "rf=298.257", "MERIT 1983","SGS85",        "a=6378136.0", "rf=298.257",  "Soviet Geodetic System 85","GRS80",        "a=6378137.0", "rf=298.257222101", "GRS 1980(IUGG, 1980)","IAU76",        "a=6378140.0", "rf=298.257", "IAU 1976","airy",         "a=6377563.396", "b=6356256.910", "Airy 1830","APL4.9",       "a=6378137.0.",  "rf=298.25", "Appl. Physics. 1965","NWL9D",        "a=6378145.0.",  "rf=298.25", "Naval Weapons Lab., 1965","mod_airy",     "a=6377340.189", "b=6356034.446", "Modified Airy","andrae",       "a=6377104.43",  "rf=300.0",    "Andrae 1876 (Den., Iclnd.)","aust_SA",      "a=6378160.0", "rf=298.25", "Australian Natl & S. Amer. 1969","GRS67",        "a=6378160.0", "rf=298.2471674270", "GRS 67(IUGG 1967)","bessel",       "a=6377397.155", "rf=299.1528128", "Bessel 1841","bess_nam",     "a=6377483.865", "rf=299.1528128", "Bessel 1841 (Namibia)","clrk66",       "a=6378206.4", "b=6356583.8", "Clarke 1866","clrk80",       "a=6378249.145", "rf=293.4663", "Clarke 1880 mod.","CPM",          "a=6375738.7", "rf=334.29", "Comm. des Poids et Mesures 1799","delmbr",       "a=6376428.",  "rf=311.5", "Delambre 1810 (Belgium)","engelis",      "a=6378136.05", "rf=298.2566", "Engelis 1985","evrst30",  "a=6377276.345", "rf=300.8017",  "Everest 1830","evrst48",  "a=6377304.063", "rf=300.8017",  "Everest 1948","evrst56",  "a=6377301.243", "rf=300.8017",  "Everest 1956","evrst69",  "a=6377295.664", "rf=300.8017",  "Everest 1969","evrstSS",  "a=6377298.556", "rf=300.8017",  "Everest (Sabah & Sarawak)","fschr60",  "a=6378166.",   "rf=298.3", "Fischer (Mercury Datum) 1960","fschr60m", "a=6378155.",   "rf=298.3", "Modified Fischer 1960","fschr68",  "a=6378150.",   "rf=298.3", "Fischer 1968","helmert",  "a=6378200.",   "rf=298.3", "Helmert 1906","hough",        "a=6378270.0", "rf=297.", "Hough","intl",         "a=6378388.0", "rf=297.", "International 1909 (Hayford)","krass",        "a=6378245.0", "rf=298.3", "Krassovsky, 1942","kaula",        "a=6378163.",  "rf=298.24", "Kaula 1961","lerch",        "a=6378139.",  "rf=298.257", "Lerch 1979","mprts",        "a=6397300.",  "rf=191.", "Maupertius 1738","new_intl",     "a=6378157.5", "b=6356772.2", "New International 1967","plessis",      "a=6376523.",  "b=6355863.", "Plessis 1817 (France)","SEasia",       "a=6378155.0", "b=6356773.3205", "Southeast Asia","walbeck",      "a=6376896.0", "b=6355834.8467", "Walbeck","WGS60",    "a=6378165.0",  "rf=298.3", "WGS 60","WGS66",        "a=6378145.0", "rf=298.25", "WGS 66","WGS72",        "a=6378135.0", "rf=298.26", "WGS 72","WGS84",    "a=6378137.0",  "rf=298.257223563", "WGS 84","sphere",   "a=6370997.0",  "b=6370997.0", "Normal Sphere (r=6370997)",0, 0, 0, 0,};/************************************************************************//*                          OSRProj4Tokenize()                          *//*                                                                      *//*      Custom tokenizing function for PROJ.4 strings.  The main        *//*      reason we can't just use CSLTokenizeString is to handle         *//*      strings with a + sign in the exponents of parameter values.     *//************************************************************************/char **OSRProj4Tokenize( const char *pszFull ){    char *pszStart = NULL;    char *pszFullWrk;    char **papszTokens = NULL;    int  i;    if( pszFull == NULL )        return NULL;    pszFullWrk = CPLStrdup( pszFull );    for( i=0; pszFullWrk[i] != '\0'; i++ )    {        switch( pszFullWrk[i] )        {          case '+':            if( i == 0 || pszFullWrk[i-1] == '\0' )            {                if( pszStart != NULL )                {                    if( strstr(pszStart,"=") != NULL )                        papszTokens = CSLAddString( papszTokens, pszStart );                    else                    {                        CPLString osAsBoolean = pszStart;                        osAsBoolean += "=yes";                        papszTokens = CSLAddString( papszTokens, osAsBoolean );                    }                }                pszStart = pszFullWrk + i + 1;            }            break;          case ' ':

⌨️ 快捷键说明

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