[Gdal-dev] Building a Projection Dialog

Frank Warmerdam warmerdam at pobox.com
Mon May 11 14:23:29 EDT 2009


Diaren wrote:
> Using the SWIG C# libraries I'm attemtping to build a projected/Geographic
> SpatialReference creation/edit dialog like you see in various GIS
> applications, which has as the main components:
> 
> Projection Method
> Projection Parameters
> Datum
> Edit Datum -> Ellipsoid, 3/7 Parameter Transformation parameters
> 
> The end result of the dialog would be to return a SpatialReference object.
> 
> I've opened the files in the data folder e.g epsg.wkt, pcs.csv,
> gt_datum.csv, but am not sure of a rock solid way to build this dialog with
> all the options. And even if I could list all the options, is there a
> simpler way to set the parameters on a SpatialReference object other than
> calling SetTM or one of the many other similar methods.

Diaren,

It is possible to more directly create the spatial reference nodes rather
than calling stuff like SetTM(), but if you do this you should try to
be pretty careful.  The specific methods ensure the right parameters
are created and gives us a place to do any extra normalization that might
be required.  You can look at the methods to see what they do - normally
pretty simple.

OGRErr OGRSpatialReference::SetTM( double dfCenterLat, double dfCenterLong,
                                    double dfScale,
                                    double dfFalseEasting,
                                    double dfFalseNorthing )

{
     SetProjection( SRS_PT_TRANSVERSE_MERCATOR );
     SetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, dfCenterLat );
     SetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, dfCenterLong );
     SetNormProjParm( SRS_PP_SCALE_FACTOR, dfScale );
     SetNormProjParm( SRS_PP_FALSE_EASTING, dfFalseEasting );
     SetNormProjParm( SRS_PP_FALSE_NORTHING, dfFalseNorthing );

     return OGRERR_NONE;
}

> Basically, I'm not the most confident person on coordinate systems and is
> attemting to build this common dialog, some help with how the dialog options
> should map to the specific methods on SpatialReference would be greatly
> appreciated? It may even make a good code snippet tutorial for GDAL.

I will mention the rarely used OPT functions:

char CPL_DLL ** OPTGetProjectionMethods();
char CPL_DLL ** OPTGetParameterList( const char * pszProjectionMethod,
                              char ** ppszUserName );
int CPL_DLL OPTGetParameterInfo( const char * pszProjectionMethod,
                                  const char * pszParameterName,
                                  char ** ppszUserName,
                                  char ** ppszType,
                                  double *pdfDefaultValue );

These are intended to allow an application to fetch a list of
projection methods and then find out what parameters go with them
and some other information about them.  The code for these methods
is in gdal/ogr/ogr_opt.cpp and they are documented at:

http://www.gdal.org/ogr/ogr__srs__api_8h.html#dc8a62ab9c92100ac23acae8825a7fab

My main concern is that the tables supporting these functions are not
always well maintained and so their information may be somewhat out
of date.  Nevertheless they should be good for common coordinate systems.

I have not checked to see if they are exposed through swig or not.  If
they are not, we should likely try and add them for 1.7.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list