[Gdal-dev] USGS projection class

April Shimitz shimitz at usgs.gov
Mon Dec 2 12:20:07 EST 2002


Frank,

We've run into several issues now with using an OGR spatial reference
system to represent the projection system of a LAS image. Among others, the
main issue with using it is the inability to carry along partially complete
projection information (we need this ability to process some historical
datasets). We've decided the best solution for the situation is to develop
a new class for the GDAL core that will store the projection in USGS format
so we do not have to go through OGR when just reading and writing imagery
in the LAS format (for now until other drivers use the USGS class where
desired). Here is the class description. The methods are very short, simply
allowing the data members to be set and retrieved:

class CPL_DLL GDALUSGSProj
{
  private:
    /* Projection definition elements */
    int     proj;             /* Map projection code */
    int     datum;            /* Datum/Spheroid code */
    int     zone;             /* Zone code */
    double  proj_parms[15];   /* Projection parameters */
    int     units;            /* Projection units */

    /* Validity flags */
    int     valid_proj;       /* Proj code valid: TRUE/FALSE */
    int     valid_datum;      /* Datum valid: TRUE/FALSE */
    int     valid_zone;       /* Zone valid: TRUE/FALSE */
    int     valid_proj_parms; /* Proj parms valid: TRUE/FALSE */
    int     valid_units;      /* Proj units valid: TRUE/FALSE */

  public:
            GDALUSGSProj();
            GDALUSGSProj(const char *); /* create from an OGR spatial
                                           reference system */

    /* Methods to set and retrieve the projection information */
    void    SetProjCode(int);
    void    GetProjCode(int *, int *);
    void    SetDatumCode(int);
    void    GetDatumCode(int *, int *);
    void    SetZoneCode(int);
    void    GetZoneCode(int *, int *);
    void    SetProjParms(double []);
    void    GetProjParms(double *, int *);
    void    SetProjUnits(int);
    void    GetProjUnits(int *, int *);
    CPLErr  toOGR(char **);  /* convert the GDALUSGSProj information
                                to an OGR SRS */
};

I have the class completed and incorporated into GDAL locally. I'm still
brainstorming, though, on how this can be made compatible with drivers that
use the OGR container for the projection system. I've implemented some
conversion routines to go between the two formats of representing a
projection system, but so far I have not been able to determine when these
conversions should take place, since I'm not familiar with how GDAL is used
to convert between image formats, or how to detect, during that process,
which projection system format is used by the new image format so we know
if a projection system format conversion should happen as part of the image
format conversion. I haven't determined where the projection system format
conversion routines should reside yet either - as stand-alone support
routines, or perhaps the GDALUSGSProj class and the OGRSpatialReference
class should each implement a constructor that takes as input the
projection system defined by the opposing class. I've also implemeted some
overloaded routines for GetProjectionRef() and SetProjection() to get/set
the projection in the proper format, but I'm not sure if there are more
routines within GDAL that modify any of the projection infomation that need
to be addressed as well. Since I am not as familiar with the GDAL core as
you are, I wondered if you'd be willing to tackle what's still needed to
incorporate this class into GDAL so I don't miss anything?

If you'd be willing to do this (or anyone else???), let me know and I'll
give you a patch for the changes I've made to the code so far and let you
run with it.

-April





More information about the Gdal-dev mailing list