Skip to content

Commit

Permalink
Added SCH support to OGR
Browse files Browse the repository at this point in the history
  • Loading branch information
Piyush Agram committed Jan 2, 2016
1 parent 1d405cd commit 7e8f3c5
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 1 deletion.
14 changes: 13 additions & 1 deletion gdal/ogr/ogr_opt.cpp
Expand Up @@ -52,7 +52,11 @@ static const char * const papszParameterDefinitions[] = {
SRS_PP_LONGITUDE_OF_POINT_3,"Longitude of Point 3", "Long", "0.0",
SRS_PP_LATITUDE_OF_POINT_3, "Latitude of Point 3", "Lat", "0.0",
SRS_PP_RECTIFIED_GRID_ANGLE,"Rectified Grid Angle", "Angle", "0.0",
SRS_PP_SATELLITE_HEIGHT, "Satellite Height", "m", "35785831.0",
SRS_PP_SATELLITE_HEIGHT, "Satellite Height", "m", "35785831.0",
SRS_PP_PEG_POINT_LATITUDE, "Peg Point Latitude", "Lat", "0.0",
SRS_PP_PEG_POINT_LONGITUDE, "Peg Point Longitude", "Long", "0.0",
SRS_PP_PEG_POINT_HEADING, "Peg Point Heading", "Angle", "0.0",
SRS_PP_PEG_POINT_HEIGHT, "Peg Point Height", "m", "0.0",
NULL
};

Expand Down Expand Up @@ -474,6 +478,14 @@ static const char * const papszProjectionDefinitions[] = {
SRS_PP_LATITUDE_OF_ORIGIN,
SRS_PP_CENTRAL_MERIDIAN,

"*",
SRS_PT_SCH,
"Spherical Crosstrack Height",
SRS_PP_PEG_POINT_LATITUDE,
SRS_PP_PEG_POINT_LONGITUDE,
SRS_PP_PEG_POINT_HEADING,
SRS_PP_PEG_POINT_HEIGHT,

NULL
};

Expand Down
3 changes: 3 additions & 0 deletions gdal/ogr/ogr_spatialref.h
Expand Up @@ -539,6 +539,9 @@ class CPL_DLL OGRSpatialReference
/** Quadrilateralized Spherical Cube */
OGRErr SetQSC(double dfCenterLat, double dfCenterLong);

/** Spherical, Cross-track, Height */
OGRErr SetSCH( double dfPegLat, double dfPegLong,
double dfPegHeading, double dfPegHgt);
/** State Plane */
OGRErr SetStatePlane( int nZone, int bNAD83 = TRUE,
const char *pszOverrideUnitName = NULL,
Expand Down
11 changes: 11 additions & 0 deletions gdal/ogr/ogr_srs_api.h
Expand Up @@ -193,6 +193,7 @@ typedef enum {
#define SRS_PT_CRASTER_PARABOLIC "Craster_Parabolic"
#define SRS_PT_LOXIMUTHAL "Loximuthal"
#define SRS_PT_QUARTIC_AUTHALIC "Quartic_Authalic"
#define SRS_PT_SCH "Spherical_Cross_Track_Height"

#define SRS_PP_CENTRAL_MERIDIAN "central_meridian"
#define SRS_PP_SCALE_FACTOR "scale_factor"
Expand Down Expand Up @@ -223,6 +224,10 @@ typedef enum {
#define SRS_PP_LONGITUDE_OF_1ST_POINT "Longitude_Of_1st_Point"
#define SRS_PP_LATITUDE_OF_2ND_POINT "Latitude_Of_2nd_Point"
#define SRS_PP_LONGITUDE_OF_2ND_POINT "Longitude_Of_2nd_Point"
#define SRS_PP_PEG_POINT_LATITUDE "peg_point_latitude"
#define SRS_PP_PEG_POINT_LONGITUDE "peg_point_longitude"
#define SRS_PP_PEG_POINT_HEADING "peg_point_heading"
#define SRS_PP_PEG_POINT_HEIGHT "peg_point_height"

#define SRS_UL_METER "Meter"
#define SRS_UL_FOOT "Foot (International)" /* or just "FOOT"? */
Expand Down Expand Up @@ -732,6 +737,12 @@ OGRErr CPL_DLL OSRSetWagner( OGRSpatialReferenceH hSRS, int nVariation,
OGRErr CPL_DLL OSRSetQSC( OGRSpatialReferenceH hSRS,
double dfCenterLat, double dfCenterLong );

/** Spherical, Cross-track, Height */
OGRErr CPL_DLL OSRSetSCH( OGRSpatialReferenceH hSRS,
double dfPegLat, double dfPegLong,
double dfPegHeading, double dfPegHgt);


double CPL_DLL OSRCalcInvFlattening( double dfSemiMajor, double dfSemiMinor );
double CPL_DLL OSRCalcSemiMinorFromInvFlattening( double dfSemiMajor, double dfInvFlattening );

Expand Down
17 changes: 17 additions & 0 deletions gdal/ogr/ogr_srs_proj4.cpp
Expand Up @@ -925,6 +925,13 @@ OGRErr OGRSpatialReference::importFromProj4( const char * pszProj4 )
SetQSC( OSR_GDV( papszNV, "lat_0", 0.0 ),
OSR_GDV( papszNV, "lon_0", 0.0 ) );
}
else if( EQUAL(pszProj,"sch") )
{
SetSCH( OSR_GDV( papszNV, "plat_0", 0.0 ),
OSR_GDV( papszNV, "plon_0", 0.0 ),
OSR_GDV( papszNV, "phdg_0", 0.0 ),
OSR_GDV( papszNV, "h_0", 0.0) );
}

else if( EQUAL(pszProj,"tpeqd") )
{
Expand Down Expand Up @@ -2191,6 +2198,16 @@ OGRErr OGRSpatialReference::exportToProj4( char ** ppszProj4 ) const
GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0) );
}

else if ( EQUAL(pszProjection, SRS_PT_SCH) )
{
CPLsnprintf( szProj4+strlen(szProj4), sizeof(szProj4)-strlen(szProj4),
"+proj=sch +plat_0=%.16g +plon_0=%.16g +phdg_0=%.16g +h_0=%.16g ",
GetNormProjParm(SRS_PP_PEG_POINT_LATITUDE, 0.0),
GetNormProjParm(SRS_PP_PEG_POINT_LONGITUDE, 0.0),
GetNormProjParm(SRS_PP_PEG_POINT_HEADING, 0.0),
GetNormProjParm(SRS_PP_PEG_POINT_HEIGHT, 0.0) );
}

/* Note: This never really gets used currently. See bug 423 */
else if( EQUAL(pszProjection,SRS_PT_SWISS_OBLIQUE_CYLINDRICAL) )
{
Expand Down
8 changes: 8 additions & 0 deletions gdal/ogr/ogr_srs_validate.cpp
Expand Up @@ -128,6 +128,7 @@ static const char * const papszProjectionSupported[] =
SRS_PT_WAGNER_VI,
SRS_PT_WAGNER_VII,
SRS_PT_QSC,
SRS_PT_SCH,
SRS_PT_GAUSSSCHREIBERTMERCATOR,
SRS_PT_KROVAK,
SRS_PT_CYLINDRICAL_EQUAL_AREA,
Expand Down Expand Up @@ -512,6 +513,13 @@ static const char * const papszProjWithParms[] = {
SRS_PP_CENTRAL_MERIDIAN,
NULL,

SRS_PT_SCH,
SRS_PP_PEG_POINT_LATITUDE,
SRS_PP_PEG_POINT_LONGITUDE,
SRS_PP_PEG_POINT_HEADING,
SRS_PP_PEG_POINT_HEIGHT,
NULL,

SRS_PT_GAUSSSCHREIBERTMERCATOR,
SRS_PP_LATITUDE_OF_ORIGIN,
SRS_PP_CENTRAL_MERIDIAN,
Expand Down
32 changes: 32 additions & 0 deletions gdal/ogr/ogrspatialreference.cpp
Expand Up @@ -5720,6 +5720,38 @@ OGRErr OSRSetQSC( OGRSpatialReferenceH hSRS,
dfCenterLat, dfCenterLong );
}

/************************************************************************/
/* SetSCH() */
/************************************************************************/

OGRErr OGRSpatialReference::SetSCH( double dfPegLat, double dfPegLong,
double dfPegHeading, double dfPegHgt)

{
SetProjection( SRS_PT_SCH );
SetNormProjParm( SRS_PP_PEG_POINT_LATITUDE, dfPegLat );
SetNormProjParm( SRS_PP_PEG_POINT_LONGITUDE, dfPegLong );
SetNormProjParm( SRS_PP_PEG_POINT_HEADING, dfPegHeading );
SetNormProjParm( SRS_PP_PEG_POINT_HEIGHT, dfPegHgt);

return OGRERR_NONE;
}

/************************************************************************/
/* OSRSetSCH() */
/************************************************************************/

OGRErr OSRSetSCH( OGRSpatialReferenceH hSRS,
double dfPegLat, double dfPegLong,
double dfPegHeading, double dfPegHgt)

{
VALIDATE_POINTER1( hSRS, "OSRSetSCH", OGRERR_FAILURE );

return ((OGRSpatialReference *) hSRS)->SetSCH(
dfPegLat, dfPegLong, dfPegHeading, dfPegHgt );
}

/************************************************************************/
/* SetAuthority() */
/************************************************************************/
Expand Down

0 comments on commit 7e8f3c5

Please sign in to comment.