Hello everyone,

I have a question about the GDAL Warp API and the gdalwarp utility.

I have added a new projection to PROJ4 (ticket #179), and would like
to use it with GDAL Warp.

For this purpose, I use the string
"+proj=qsc +a=6378137.0 +b=6356752.314245 +lat_0=90 +lon_0=0 +units=m"
as an argument to the -t_srs option of gdalwarp, and also to
OGRSpatialReference::importFromProj4() for passing the result to the
Warp API.

However, this requires explicit support for the projection not just in
PROJ4, but also in GDAL. I currently use the attached patch to add
that support, but is there a way to avoid patching GDAL for this
purpose?

Best regards,
Martin
>From 6fa1411d314bb966ddaede09339921318db6a948 Mon Sep 17 00:00:00 2001
From: Martin Lambers <[email protected]>
Date: Thu, 15 Dec 2011 11:05:13 +0100
Subject: [PATCH 2/2] Add the Quadrilateralized Spherical Cube (QSC)
 projection.

---
 ogr/ogr_opt.cpp             |    6 ++++++
 ogr/ogr_spatialref.h        |    3 +++
 ogr/ogr_srs_api.h           |    6 ++++++
 ogr/ogr_srs_proj4.cpp       |   14 ++++++++++++++
 ogr/ogr_srs_validate.cpp    |    6 ++++++
 ogr/ogrspatialreference.cpp |   28 ++++++++++++++++++++++++++++
 6 files changed, 63 insertions(+)

diff --git a/ogr/ogr_opt.cpp b/ogr/ogr_opt.cpp
index 456493f..848261e 100644
--- a/ogr/ogr_opt.cpp
+++ b/ogr/ogr_opt.cpp
@@ -475,6 +475,12 @@ static const char *papszProjectionDefinitions[] = {
     SRS_PP_FALSE_EASTING, 
     SRS_PP_FALSE_NORTHING,
 
+    "*",
+    SRS_PT_QSC,
+    "Quadrilateralized Spherical Cube",
+    SRS_PP_LATITUDE_OF_ORIGIN,
+    SRS_PP_CENTRAL_MERIDIAN,
+
     NULL
 };
 
diff --git a/ogr/ogr_spatialref.h b/ogr/ogr_spatialref.h
index c14dcec..8c550c5 100644
--- a/ogr/ogr_spatialref.h
+++ b/ogr/ogr_spatialref.h
@@ -536,6 +536,9 @@ class CPL_DLL OGRSpatialReference
     OGRErr      SetWagner( int nVariation, double dfCenterLat,
                            double dfFalseEasting, double dfFalseNorthing );
 
+    /** Quadrilateralized Spherical Cube */
+    OGRErr      SetQSC(double dfCenterLat, double dfCenterLong);
+
     /** State Plane */
     OGRErr      SetStatePlane( int nZone, int bNAD83 = TRUE,
                                const char *pszOverrideUnitName = NULL,
diff --git a/ogr/ogr_srs_api.h b/ogr/ogr_srs_api.h
index 27d8298..82d09f7 100644
--- a/ogr/ogr_srs_api.h
+++ b/ogr/ogr_srs_api.h
@@ -183,6 +183,7 @@ typedef enum {
 #define SRS_PT_WAGNER_V         "Wagner_V"
 #define SRS_PT_WAGNER_VI        "Wagner_VI"
 #define SRS_PT_WAGNER_VII       "Wagner_VII"
+#define SRS_PT_QSC              "Quadrilateralized Spherical Cube"
                                 
 
 #define SRS_PP_CENTRAL_MERIDIAN         "central_meridian"
@@ -665,6 +666,11 @@ OGRErr CPL_DLL OSRSetWagner( OGRSpatialReferenceH hSRS, int nVariation,
                              double dfFalseEasting,
                              double dfFalseNorthing );
 
+/** Quadrilateralized Spherical Cube */
+OGRErr CPL_DLL OSRSetQSC( OGRSpatialReferenceH hSRS,
+                              double dfCenterLat, double dfCenterLong );
+
+
 void CPL_DLL OSRCleanup( void );
 
 /* -------------------------------------------------------------------- */
diff --git a/ogr/ogr_srs_proj4.cpp b/ogr/ogr_srs_proj4.cpp
index 823e4f4..b86d323 100644
--- a/ogr/ogr_srs_proj4.cpp
+++ b/ogr/ogr_srs_proj4.cpp
@@ -867,6 +867,12 @@ OGRErr OGRSpatialReference::importFromProj4( const char * pszProj4 )
                    OSR_GDV( papszNV, "y_0", 0.0 ) );
     }
 
+    else if( EQUAL(pszProj,"qsc") )
+    {
+        SetQSC( OSR_GDV( papszNV, "lat_0", 0.0 ),
+                OSR_GDV( papszNV, "lon_0", 0.0 ) );
+    }
+
     else if( EQUAL(pszProj,"tpeqd") )
     {
         SetTPED( OSR_GDV( papszNV, "lat_1", 0.0 ), 
@@ -2020,6 +2026,14 @@ OGRErr OGRSpatialReference::exportToProj4( char ** ppszProj4 ) const
                  GetNormProjParm(SRS_PP_FALSE_NORTHING, 0.0) );
     }
 
+    else if( EQUAL(pszProjection,SRS_PT_QSC) )
+    {
+        sprintf( szProj4+strlen(szProj4),
+                 "+proj=qsc +lat_0=%.16g +lon_0=%.16g ",
+                 GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0),
+                 GetNormProjParm(SRS_PP_CENTRAL_MERIDIAN,0.0) );
+    }
+
     /* Note: This never really gets used currently.  See bug 423 */
     else if( EQUAL(pszProjection,SRS_PT_SWISS_OBLIQUE_CYLINDRICAL) )
     {
diff --git a/ogr/ogr_srs_validate.cpp b/ogr/ogr_srs_validate.cpp
index 397c4ed..d6dd960 100644
--- a/ogr/ogr_srs_validate.cpp
+++ b/ogr/ogr_srs_validate.cpp
@@ -126,6 +126,7 @@ static const char *papszProjectionSupported[] =
     SRS_PT_WAGNER_V,
     SRS_PT_WAGNER_VI,
     SRS_PT_WAGNER_VII,
+    SRS_PT_QSC,
     SRS_PT_GAUSSSCHREIBERTMERCATOR,
     SRS_PT_KROVAK,
     SRS_PT_CYLINDRICAL_EQUAL_AREA,
@@ -512,6 +513,11 @@ static const char *papszProjWithParms[] = {
     SRS_PP_FALSE_NORTHING,
     NULL,
 
+    SRS_PT_QSC,
+    SRS_PP_LATITUDE_OF_ORIGIN,
+    SRS_PP_CENTRAL_MERIDIAN,
+    NULL,
+
     SRS_PT_GAUSSSCHREIBERTMERCATOR,
     SRS_PP_LATITUDE_OF_ORIGIN,
     SRS_PP_CENTRAL_MERIDIAN,
diff --git a/ogr/ogrspatialreference.cpp b/ogr/ogrspatialreference.cpp
index e2443a9..1cfb280 100644
--- a/ogr/ogrspatialreference.cpp
+++ b/ogr/ogrspatialreference.cpp
@@ -5570,6 +5570,34 @@ OGRErr OSRSetWagner( OGRSpatialReferenceH hSRS,
 }
 
 /************************************************************************/
+/*                            SetQSC()                     */
+/************************************************************************/
+
+OGRErr OGRSpatialReference::SetQSC( double dfCenterLat, double dfCenterLong )
+
+{
+    SetProjection( SRS_PT_QSC );
+    SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
+    SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
+
+    return OGRERR_NONE;
+}
+
+/************************************************************************/
+/*                           OSRSetQSC()                   */
+/************************************************************************/
+
+OGRErr OSRSetQSC( OGRSpatialReferenceH hSRS,
+                       double dfCenterLat, double dfCenterLong )
+
+{
+    VALIDATE_POINTER1( hSRS, "OSRSetQSC", CE_Failure );
+
+    return ((OGRSpatialReference *) hSRS)->SetQSC(
+        dfCenterLat, dfCenterLong );
+}
+
+/************************************************************************/
 /*                            SetAuthority()                            */
 /************************************************************************/
 
-- 
1.7.9.5

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to