📄 ogr_srs_esri.cpp
字号:
else if( EQUAL(pszProj,"STATEPLANE") )
{
int nZone = (int) OSR_GDV( papszPrj, "zone", 0.0 );
if( nZone != 0 )
nZone = ESRIToUSGSZone( nZone );
else
nZone = (int) OSR_GDV( papszPrj, "fipszone", 0.0 );
if( nZone != 0 )
{
if( EQUAL(OSR_GDS( papszPrj, "Datum", "NAD83"),"NAD27") )
SetStatePlane( nZone, FALSE );
else
SetStatePlane( nZone, TRUE );
}
}
else if( EQUAL(pszProj,"GREATBRITIAN_GRID")
|| EQUAL(pszProj,"GREATBRITAIN_GRID") )
{
const char *pszWkt =
"PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",49],PARAMETER[\"central_meridian\",-2],PARAMETER[\"scale_factor\",0.999601272],PARAMETER[\"false_easting\",400000],PARAMETER[\"false_northing\",-100000],UNIT[\"metre\",1]]";
importFromWkt( (char **) &pszWkt );
}
else if( EQUAL(pszProj,"ALBERS") )
{
SetACEA( OSR_GDV( papszPrj, "PARAM_1", 0.0 ),
OSR_GDV( papszPrj, "PARAM_2", 0.0 ),
OSR_GDV( papszPrj, "PARAM_4", 0.0 ),
OSR_GDV( papszPrj, "PARAM_3", 0.0 ),
OSR_GDV( papszPrj, "PARAM_5", 0.0 ),
OSR_GDV( papszPrj, "PARAM_6", 0.0 ) );
}
else if( EQUAL(pszProj,"LAMBERT") )
{
SetLCC( OSR_GDV( papszPrj, "PARAM_1", 0.0 ),
OSR_GDV( papszPrj, "PARAM_2", 0.0 ),
OSR_GDV( papszPrj, "PARAM_4", 0.0 ),
OSR_GDV( papszPrj, "PARAM_3", 0.0 ),
OSR_GDV( papszPrj, "PARAM_5", 0.0 ),
OSR_GDV( papszPrj, "PARAM_6", 0.0 ) );
}
else if( EQUAL(pszProj,"EQUIDISTANT_CONIC") )
{
int nStdPCount = (int) OSR_GDV( papszPrj, "PARAM_1", 0.0 );
if( nStdPCount == 1 )
{
SetEC( OSR_GDV( papszPrj, "PARAM_2", 0.0 ),
OSR_GDV( papszPrj, "PARAM_2", 0.0 ),
OSR_GDV( papszPrj, "PARAM_4", 0.0 ),
OSR_GDV( papszPrj, "PARAM_3", 0.0 ),
OSR_GDV( papszPrj, "PARAM_5", 0.0 ),
OSR_GDV( papszPrj, "PARAM_6", 0.0 ) );
}
else
{
SetEC( OSR_GDV( papszPrj, "PARAM_2", 0.0 ),
OSR_GDV( papszPrj, "PARAM_3", 0.0 ),
OSR_GDV( papszPrj, "PARAM_5", 0.0 ),
OSR_GDV( papszPrj, "PARAM_4", 0.0 ),
OSR_GDV( papszPrj, "PARAM_5", 0.0 ),
OSR_GDV( papszPrj, "PARAM_7", 0.0 ) );
}
}
else if( EQUAL(pszProj,"TRANSVERSE") )
{
SetTM( OSR_GDV( papszPrj, "PARAM_3", 0.0 ),
OSR_GDV( papszPrj, "PARAM_2", 0.0 ),
OSR_GDV( papszPrj, "PARAM_1", 0.0 ),
OSR_GDV( papszPrj, "PARAM_4", 0.0 ),
OSR_GDV( papszPrj, "PARAM_5", 0.0 ) );
}
else if( EQUAL(pszProj,"POLAR") )
{
SetPS( OSR_GDV( papszPrj, "PARAM_2", 0.0 ),
OSR_GDV( papszPrj, "PARAM_1", 0.0 ),
1.0,
OSR_GDV( papszPrj, "PARAM_3", 0.0 ),
OSR_GDV( papszPrj, "PARAM_4", 0.0 ) );
}
else
{
CPLDebug( "OGR_ESRI", "Unsupported projection: %s", pszProj );
SetLocalCS( pszProj );
}
/* -------------------------------------------------------------------- */
/* Try to translate the datum/spheroid. */
/* -------------------------------------------------------------------- */
if( !IsLocal() && GetAttrNode( "GEOGCS" ) == NULL )
{
const char *pszDatum;
pszDatum = OSR_GDS( papszPrj, "Datum", "");
if( EQUAL(pszDatum,"NAD27") || EQUAL(pszDatum,"NAD83")
|| EQUAL(pszDatum,"WGS84") || EQUAL(pszDatum,"WGS72") )
{
SetWellKnownGeogCS( pszDatum );
}
else if( EQUAL( pszDatum, "EUR" )
|| EQUAL( pszDatum, "ED50" ) )
{
SetWellKnownGeogCS( "EPSG:4230" );
}
else if( EQUAL( pszDatum, "GDA94" ) )
{
SetWellKnownGeogCS( "EPSG:4283" );
}
else
{
const char *pszSpheroid;
pszSpheroid = OSR_GDS( papszPrj, "Spheroid", "");
if( EQUAL(pszSpheroid,"INT1909")
|| EQUAL(pszSpheroid,"INTERNATIONAL1909") )
{
OGRSpatialReference oGCS;
oGCS.importFromEPSG( 4022 );
CopyGeogCSFrom( &oGCS );
}
else if( EQUAL(pszSpheroid,"AIRY") )
{
OGRSpatialReference oGCS;
oGCS.importFromEPSG( 4001 );
CopyGeogCSFrom( &oGCS );
}
else if( EQUAL(pszSpheroid,"CLARKE1866") )
{
OGRSpatialReference oGCS;
oGCS.importFromEPSG( 4008 );
CopyGeogCSFrom( &oGCS );
}
else if( EQUAL(pszSpheroid,"GRS80") )
{
OGRSpatialReference oGCS;
oGCS.importFromEPSG( 4019 );
CopyGeogCSFrom( &oGCS );
}
else if( EQUAL(pszSpheroid,"KRASOVSKY")
|| EQUAL(pszSpheroid,"KRASSOVSKY") )
{
OGRSpatialReference oGCS;
oGCS.importFromEPSG( 4024 );
CopyGeogCSFrom( &oGCS );
}
else
{
// If we don't know, default to WGS84 so there is something there.
SetWellKnownGeogCS( "WGS84" );
}
}
}
/* -------------------------------------------------------------------- */
/* Linear units translation */
/* -------------------------------------------------------------------- */
if( IsLocal() || IsProjected() )
{
const char *pszValue;
double dfOldUnits = GetLinearUnits();
pszValue = OSR_GDS( papszPrj, "Units", NULL );
if( pszValue == NULL )
SetLinearUnitsAndUpdateParameters( SRS_UL_METER, 1.0 );
else if( EQUAL(pszValue,"FEET") )
SetLinearUnitsAndUpdateParameters( SRS_UL_US_FOOT, atof(SRS_UL_US_FOOT_CONV) );
else if( atof(pszValue) != 0.0 )
SetLinearUnitsAndUpdateParameters( "user-defined",
1.0 / atof(pszValue) );
else
SetLinearUnitsAndUpdateParameters( pszValue, 1.0 );
// If we have reset the linear units we should clear any authority
// nodes on the PROJCS. This especially applies to state plane
// per bug 1697
double dfNewUnits = GetLinearUnits();
if( dfOldUnits != 0.0
&& (dfNewUnits / dfOldUnits < 0.9999999
|| dfNewUnits / dfOldUnits > 1.0000001) )
{
if( GetRoot()->FindChild( "AUTHORITY" ) != -1 )
GetRoot()->DestroyChild(GetRoot()->FindChild( "AUTHORITY" ));
}
}
return OGRERR_NONE;
}
/************************************************************************/
/* morphToESRI() */
/************************************************************************/
/**
* Convert in place from ESRI WKT format.
*
* The value notes of this coordinate system as modified in various manners
* to adhere more closely to the WKT standard. This mostly involves
* translating a variety of ESRI names for projections, arguments and
* datums to "standard" names, as defined by Adam Gawne-Cain's reference
* translation of EPSG to WKT for the CT specification.
*
* This does the same as the C function OSRMorphToESRI().
*
* @return OGRERR_NONE unless something goes badly wrong.
*/
OGRErr OGRSpatialReference::morphToESRI()
{
OGRErr eErr;
/* -------------------------------------------------------------------- */
/* Fixup ordering, missing linear units, etc. */
/* -------------------------------------------------------------------- */
eErr = Fixup();
if( eErr != OGRERR_NONE )
return eErr;
/* -------------------------------------------------------------------- */
/* Strip all CT parameters (AXIS, AUTHORITY, TOWGS84, etc). */
/* -------------------------------------------------------------------- */
eErr = StripCTParms();
if( eErr != OGRERR_NONE )
return eErr;
if( GetRoot() == NULL )
return OGRERR_NONE;
/* -------------------------------------------------------------------- */
/* There is a special case for Hotine Oblique Mercator to split */
/* out the case with an angle to rectified grid. Bug 423 */
/* -------------------------------------------------------------------- */
const char *pszProjection = GetAttrValue("PROJECTION");
if( pszProjection != NULL
&& EQUAL(pszProjection,SRS_PT_HOTINE_OBLIQUE_MERCATOR)
&& fabs(GetProjParm(SRS_PP_AZIMUTH, 0.0 )-90) < 0.0001
&& fabs(GetProjParm(SRS_PP_RECTIFIED_GRID_ANGLE, 0.0 )-90) < 0.0001 )
{
SetNode( "PROJCS|PROJECTION",
"Hotine_Oblique_Mercator_Azimuth_Center" );
/* ideally we should strip out of the rectified_grid_angle */
pszProjection = GetAttrValue("PROJECTION");
}
/* -------------------------------------------------------------------- */
/* Polar_Stereographic maps to ESRI codes */
/* Stereographic_South_Pole or Stereographic_North_Pole based */
/* on latitude. */
/* -------------------------------------------------------------------- */
if( pszProjection != NULL
&& EQUAL(pszProjection,SRS_PT_POLAR_STEREOGRAPHIC) )
{
if( GetProjParm(SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) < 0.0 )
{
SetNode( "PROJCS|PROJECTION",
"Stereographic_South_Pole" );
pszProjection = GetAttrValue("PROJECTION");
}
else
{
SetNode( "PROJCS|PROJECTION",
"Stereographic_North_Pole" );
pszProjection = GetAttrValue("PROJECTION");
}
}
/* -------------------------------------------------------------------- */
/* Translate PROJECTION keywords that are misnamed. */
/* -------------------------------------------------------------------- */
GetRoot()->applyRemapper( "PROJECTION",
apszProjMapping+1, apszProjMapping, 2 );
pszProjection = GetAttrValue("PROJECTION");
/* -------------------------------------------------------------------- */
/* Translate DATUM keywords that are misnamed. */
/* -------------------------------------------------------------------- */
InitDatumMappingTable();
GetRoot()->applyRemapper( "DATUM",
papszDatumMapping+2, papszDatumMapping+1, 3 );
/* -------------------------------------------------------------------- */
/* Very specific handling for some well known geographic */
/* coordinate systems. */
/* -------------------------------------------------------------------- */
OGR_SRSNode *poGeogCS = GetAttrNode( "GEOGCS" );
if( poGeogCS != NULL )
{
const char *pszGeogCSName = poGeogCS->GetChild(0)->GetValue();
const char *pszAuthName = GetAuthorityName("GEOGCS");
const char *pszUTMPrefix = NULL;
int nGCSCode = -1;
if( pszAuthName != NULL && EQUAL(pszAuthName,"EPSG") )
nGCSCode = atoi(GetAuthorityCode("GEOGCS"));
if( nGCSCode == 4326
|| EQUAL(pszGeogCSName,"WGS84")
|| EQUAL(pszGeogCSName,"WGS 84") )
{
poGeogCS->GetChild(0)->SetValue( "GCS_WGS_1984" );
pszUTMPrefix = "WGS_1984";
}
else if( nGCSCode == 4267
|| EQUAL(pszGeogCSName,"NAD27")
|| EQUAL(pszGeogCSName,"NAD 27") )
{
poGeogCS->GetChild(0)->SetValue( "GCS_North_American_1927" );
pszUTMPrefix = "NAD_1927";
}
else if( nGCSCode == 4269
|| EQUAL(pszGeogCSName,"NAD83")
|| EQUAL(pszGeogCSName,"NAD 83") )
{
poGeogCS->GetChild(0)->SetValue( "GCS_North_American_1983" );
pszUTMPrefix = "NAD_1983";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -