📄 ogr_srs_esri.cpp
字号:
/******************************************************************************
* $Id: ogr_srs_esri.cpp 11828 2007-08-01 23:15:47Z warmerdam $
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: OGRSpatialReference translation to/from ESRI .prj definitions.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2000, Frank Warmerdam
*
* 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.
****************************************************************************/
#include "ogr_spatialref.h"
#include "ogr_p.h"
#include "cpl_csv.h"
CPL_CVSID("$Id: ogr_srs_esri.cpp 11828 2007-08-01 23:15:47Z warmerdam $");
static char *apszProjMapping[] = {
"Albers", SRS_PT_ALBERS_CONIC_EQUAL_AREA,
"Cassini", SRS_PT_CASSINI_SOLDNER,
"Plate_Carree", SRS_PT_EQUIRECTANGULAR,
"Hotine_Oblique_Mercator_Azimuth_Natural_Origin",
SRS_PT_HOTINE_OBLIQUE_MERCATOR,
"Hotine_Oblique_Mercator_Azimuth_Center",
SRS_PT_HOTINE_OBLIQUE_MERCATOR,
"Lambert_Conformal_Conic", SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP,
"Lambert_Conformal_Conic", SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP,
"Van_der_Grinten_I", SRS_PT_VANDERGRINTEN,
SRS_PT_TRANSVERSE_MERCATOR, SRS_PT_TRANSVERSE_MERCATOR,
"Gauss_Kruger", SRS_PT_TRANSVERSE_MERCATOR,
"Mercator", SRS_PT_MERCATOR_1SP,
"Equidistant_Cylindrical", SRS_PT_EQUIRECTANGULAR,
NULL, NULL };
static char *apszAlbersMapping[] = {
SRS_PP_CENTRAL_MERIDIAN, SRS_PP_LONGITUDE_OF_CENTER,
SRS_PP_LATITUDE_OF_ORIGIN, SRS_PP_LATITUDE_OF_CENTER,
"Central_Parallel", SRS_PP_LATITUDE_OF_CENTER,
NULL, NULL };
static char *apszECMapping[] = {
SRS_PP_CENTRAL_MERIDIAN, SRS_PP_LONGITUDE_OF_CENTER,
SRS_PP_LATITUDE_OF_ORIGIN, SRS_PP_LATITUDE_OF_CENTER,
NULL, NULL };
static char *apszMercatorMapping[] = {
SRS_PP_STANDARD_PARALLEL_1, SRS_PP_LATITUDE_OF_ORIGIN,
NULL, NULL };
static char *apszPolarStereographicMapping[] = {
SRS_PP_STANDARD_PARALLEL_1, SRS_PP_LATITUDE_OF_ORIGIN,
NULL, NULL };
static char **papszDatumMapping = NULL;
static char *apszDefaultDatumMapping[] = {
"6267", "North_American_1927", SRS_DN_NAD27,
"6269", "North_American_1983", SRS_DN_NAD83,
NULL, NULL, NULL };
static char *apszUnitMapping[] = {
"Meter", "meter",
"Meter", "metre",
"Foot", "foot",
"Foot", "feet",
"Foot_US", SRS_UL_US_FOOT,
"Degree", "degree",
"Degree", "degrees",
"Degree", SRS_UA_DEGREE,
"Radian", SRS_UA_RADIAN,
NULL, NULL };
/* -------------------------------------------------------------------- */
/* Table relating USGS and ESRI state plane zones. */
/* -------------------------------------------------------------------- */
static int anUsgsEsriZones[] =
{
101, 3101,
102, 3126,
201, 3151,
202, 3176,
203, 3201,
301, 3226,
302, 3251,
401, 3276,
402, 3301,
403, 3326,
404, 3351,
405, 3376,
406, 3401,
407, 3426,
501, 3451,
502, 3476,
503, 3501,
600, 3526,
700, 3551,
901, 3601,
902, 3626,
903, 3576,
1001, 3651,
1002, 3676,
1101, 3701,
1102, 3726,
1103, 3751,
1201, 3776,
1202, 3801,
1301, 3826,
1302, 3851,
1401, 3876,
1402, 3901,
1501, 3926,
1502, 3951,
1601, 3976,
1602, 4001,
1701, 4026,
1702, 4051,
1703, 6426,
1801, 4076,
1802, 4101,
1900, 4126,
2001, 4151,
2002, 4176,
2101, 4201,
2102, 4226,
2103, 4251,
2111, 6351,
2112, 6376,
2113, 6401,
2201, 4276,
2202, 4301,
2203, 4326,
2301, 4351,
2302, 4376,
2401, 4401,
2402, 4426,
2403, 4451,
2500, 0,
2501, 4476,
2502, 4501,
2503, 4526,
2600, 0,
2601, 4551,
2602, 4576,
2701, 4601,
2702, 4626,
2703, 4651,
2800, 4676,
2900, 4701,
3001, 4726,
3002, 4751,
3003, 4776,
3101, 4801,
3102, 4826,
3103, 4851,
3104, 4876,
3200, 4901,
3301, 4926,
3302, 4951,
3401, 4976,
3402, 5001,
3501, 5026,
3502, 5051,
3601, 5076,
3602, 5101,
3701, 5126,
3702, 5151,
3800, 5176,
3900, 0,
3901, 5201,
3902, 5226,
4001, 5251,
4002, 5276,
4100, 5301,
4201, 5326,
4202, 5351,
4203, 5376,
4204, 5401,
4205, 5426,
4301, 5451,
4302, 5476,
4303, 5501,
4400, 5526,
4501, 5551,
4502, 5576,
4601, 5601,
4602, 5626,
4701, 5651,
4702, 5676,
4801, 5701,
4802, 5726,
4803, 5751,
4901, 5776,
4902, 5801,
4903, 5826,
4904, 5851,
5001, 6101,
5002, 6126,
5003, 6151,
5004, 6176,
5005, 6201,
5006, 6226,
5007, 6251,
5008, 6276,
5009, 6301,
5010, 6326,
5101, 5876,
5102, 5901,
5103, 5926,
5104, 5951,
5105, 5976,
5201, 6001,
5200, 6026,
5200, 6076,
5201, 6051,
5202, 6051,
5300, 0,
5400, 0
};
void OGREPSGDatumNameMassage( char ** ppszDatum );
/************************************************************************/
/* RemapSpheroidName() */
/* */
/* Convert Spheroid name to ESRI style name */
/************************************************************************/
static const char* RemapSpheroidName(const char* pszName)
{
if (strcmp(pszName, "WGS 84") == 0)
return "WGS 1984";
if (strcmp(pszName, "WGS 72") == 0)
return "WGS 1972";
return pszName;
}
/************************************************************************/
/* ESRIToUSGSZone() */
/* */
/* Convert ESRI style state plane zones to USGS style state */
/* plane zones. */
/************************************************************************/
static int ESRIToUSGSZone( int nESRIZone )
{
int nPairs = sizeof(anUsgsEsriZones) / (2*sizeof(int));
int i;
for( i = 0; i < nPairs; i++ )
{
if( anUsgsEsriZones[i*2+1] == nESRIZone )
return anUsgsEsriZones[i*2];
}
return 0;
}
/************************************************************************/
/* MorphNameToESRI() */
/* */
/* Make name ESRI compatible. Convert spaces and special */
/* characters to underscores and then strip down. */
/************************************************************************/
static void MorphNameToESRI( char ** ppszName )
{
int i, j;
char *pszName = *ppszName;
/* -------------------------------------------------------------------- */
/* Translate non-alphanumeric values to underscores. */
/* -------------------------------------------------------------------- */
for( i = 0; pszName[i] != '\0'; i++ )
{
if( !(pszName[i] >= 'A' && pszName[i] <= 'Z')
&& !(pszName[i] >= 'a' && pszName[i] <= 'z')
&& !(pszName[i] >= '0' && pszName[i] <= '9') )
{
pszName[i] = '_';
}
}
/* -------------------------------------------------------------------- */
/* Remove repeated and trailing underscores. */
/* -------------------------------------------------------------------- */
for( i = 1, j = 0; pszName[i] != '\0'; i++ )
{
if( pszName[j] == '_' && pszName[i] == '_' )
continue;
pszName[++j] = pszName[i];
}
if( pszName[j] == '_' )
pszName[j] = '\0';
else
pszName[j+1] = '\0';
}
/************************************************************************/
/* CleanESRIDatumMappingTable() */
/************************************************************************/
CPL_C_START
void CleanupESRIDatumMappingTable()
{
if( papszDatumMapping == NULL )
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -