📄 ogr_srs_esri.cpp
字号:
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_2", 0.0 ), OSR_GDV( papszPrj, "PARAM_3", 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 { const char *pszSpheroid; pszSpheroid = OSR_GDS( papszPrj, "Spheroid", ""); if( EQUAL(pszSpheroid,"INT1909") ) { 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 we don't know, default to WGS84 so there is something there. SetWellKnownGeogCS( "WGS84" ); } } }/* -------------------------------------------------------------------- *//* Linear units translation *//* -------------------------------------------------------------------- */ if( IsLocal() || IsProjected() ) { const char *pszValue; pszValue = OSR_GDS( papszPrj, "Units", NULL ); if( pszValue == NULL ) SetLinearUnits( SRS_UL_METER, 1.0 ); else if( EQUAL(pszValue,"FEET") ) SetLinearUnits( SRS_UL_FOOT, atof(SRS_UL_FOOT_CONV) ); else SetLinearUnits( pszValue, 1.0 ); } 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;/* -------------------------------------------------------------------- *//* Strip all CT parameters (AXIS, AUTHORITY, TOWGS84, etc). *//* -------------------------------------------------------------------- */ eErr = StripCTParms(); if( eErr != OGRERR_NONE ) return eErr; if( GetRoot() == NULL ) return OGRERR_NONE;/* -------------------------------------------------------------------- *//* Translate PROJECTION keywords that are misnamed. *//* -------------------------------------------------------------------- */ GetRoot()->applyRemapper( "PROJECTION", apszProjMapping+1, apszProjMapping, 2 );/* -------------------------------------------------------------------- *//* Translate DATUM keywords that are misnamed. *//* -------------------------------------------------------------------- */ InitDatumMappingTable(); GetRoot()->applyRemapper( "DATUM", papszDatumMapping+2, papszDatumMapping+1, 3 );/* -------------------------------------------------------------------- *//* Translate UNIT keywords that are misnamed, or even the wrong *//* case. *//* -------------------------------------------------------------------- */ GetRoot()->applyRemapper( "UNIT", apszUnitMapping+1, apszUnitMapping, 2 );/* -------------------------------------------------------------------- *//* reset constants for decimal degrees to the exact string ESRI *//* expects when encountered to ensure a matchup. *//* -------------------------------------------------------------------- */ OGR_SRSNode *poUnit = GetAttrNode( "GEOGCS|UNIT" ); if( poUnit != NULL && poUnit->GetChildCount() >= 2 && ABS(GetAngularUnits()-0.0174532925199433) < 0.00000000001 ) { poUnit->GetChild(0)->SetValue("Degree"); poUnit->GetChild(1)->SetValue("0.017453292519943295"); }/* -------------------------------------------------------------------- *//* Make sure we reproduce US Feet exactly too. *//* -------------------------------------------------------------------- */ poUnit = GetAttrNode( "PROJCS|UNIT" ); if( poUnit != NULL && poUnit->GetChildCount() >= 2 && ABS(GetLinearUnits()- 0.30480060960121924) < 0.000000000000001) { poUnit->GetChild(0)->SetValue("Foot_US"); poUnit->GetChild(1)->SetValue("0.30480060960121924"); }/* -------------------------------------------------------------------- *//* Remap parameters used for Albers. *//* -------------------------------------------------------------------- */ const char *pszProjection = GetAttrValue("PROJECTION"); if( pszProjection != NULL && EQUAL(pszProjection,"Albers") ) GetRoot()->applyRemapper( "PARAMETER", apszAlbersMapping + 1, apszAlbersMapping + 0, 2 );/* -------------------------------------------------------------------- *//* Try to insert a D_ in front of the datum name. *//* -------------------------------------------------------------------- */ OGR_SRSNode *poDatum; poDatum = GetAttrNode( "DATUM" ); if( poDatum != NULL ) poDatum = poDatum->GetChild(0); if( poDatum != NULL ) { if( !EQUALN(poDatum->GetValue(),"D_",2) ) { char *pszNewValue; pszNewValue = (char *) CPLMalloc(strlen(poDatum->GetValue())+3); strcpy( pszNewValue, "D_" ); strcat( pszNewValue, poDatum->GetValue() ); poDatum->SetValue( pszNewValue ); CPLFree( pszNewValue ); } } return OGRERR_NONE;}/************************************************************************//* OSRMorphToESRI() *//************************************************************************/OGRErr OSRMorphToESRI( OGRSpatialReferenceH hSRS ){ return ((OGRSpatialReference *) hSRS)->morphToESRI();}/************************************************************************//* morphFromESRI() *//* *//* modify this definition from the ESRI definition of WKT to *//* the "Standard" definition. *//************************************************************************//** * Convert in place to ESRI WKT format. * * The value nodes of this coordinate system as modified in various manners * more closely map onto the ESRI concept of WKT format. This includes * renaming a variety of projections and arguments, and stripping out * nodes note recognised by ESRI (like AUTHORITY and AXIS). * * This does the same as the C function OSRMorphFromESRI(). * * @return OGRERR_NONE unless something goes badly wrong. */OGRErr OGRSpatialReference::morphFromESRI(){ OGRErr eErr = OGRERR_NONE; if( GetRoot() == NULL ) return OGRERR_NONE;/* -------------------------------------------------------------------- *//* Translate DATUM keywords that are oddly named. *//* -------------------------------------------------------------------- */ InitDatumMappingTable(); GetRoot()->applyRemapper( "DATUM", papszDatumMapping+1, papszDatumMapping+2, 3 );/* -------------------------------------------------------------------- *//* Try to remove any D_ in front of the datum name. *//* -------------------------------------------------------------------- */ OGR_SRSNode *poDatum; poDatum = GetAttrNode( "DATUM" ); if( poDatum != NULL ) poDatum = poDatum->GetChild(0); if( poDatum != NULL ) { if( EQUALN(poDatum->GetValue(),"D_",2) ) { char *pszNewValue = CPLStrdup( poDatum->GetValue() + 2 ); poDatum->SetValue( pszNewValue ); CPLFree( pszNewValue ); } }/* -------------------------------------------------------------------- *//* Split Lambert_Conformal_Conic into 1SP or 2SP form. *//* *//* See bugzilla.remotesensing.org/show_bug.cgi?id=187 *//* -------------------------------------------------------------------- */ const char *pszProjection = GetAttrValue("PROJECTION"); if( pszProjection != NULL && EQUAL(pszProjection,"Lambert_Conformal_Conic") ) { if( GetProjParm( "Scale_Factor", 2.0 ) == 2.0 ) SetNode( "PROJCS|PROJECTION", SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP ); else SetNode( "PROJCS|PROJECTION", SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP ); }/* -------------------------------------------------------------------- *//* Remap albers parameters. *//* -------------------------------------------------------------------- */ if( pszProjection != NULL && EQUAL(pszProjection,"Albers") ) GetRoot()->applyRemapper( "PARAMETER", apszAlbersMapping + 0, apszAlbersMapping + 1, 2 );/* -------------------------------------------------------------------- *//* Translate PROJECTION keywords that are misnamed. *//* -------------------------------------------------------------------- */ GetRoot()->applyRemapper( "PROJECTION", apszProjMapping, apszProjMapping+1, 2 ); /* -------------------------------------------------------------------- *//* Translate DATUM keywords that are misnamed. *//* -------------------------------------------------------------------- */ InitDatumMappingTable(); GetRoot()->applyRemapper( "DATUM", papszDatumMapping+1, papszDatumMapping+2, 3 ); return eErr;}/************************************************************************//* OSRMorphFromESRI() *//************************************************************************/OGRErr OSRMorphFromESRI( OGRSpatialReferenceH hSRS ){ return ((OGRSpatialReference *) hSRS)->morphFromESRI();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -