[Gdal-dev] Building a Projection Dialog
Diaren
diarenwhan at yahoo.co.uk
Mon May 11 15:53:19 EDT 2009
Frank Warmerdam wrote:
>
> 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
>
Indeed those methods are exposed, a small example follows with how one could
build a list of the available projection methods.
var projectionMethods = Osr.GetProjectionMethods();
Console.WriteLine("\nProjection
Methods\n===================================");
for (i = 0; i < projectionMethods.Length; i++)
{
Console.WriteLine(projectionMethods[i]);
string username;
var paramList =
Osr.GetProjectionMethodParameterList(projectionMethods[i], out username);
for (var p = 0; p < paramList.Length; p++)
{
string plname;
string pltype;
var defaultValue = 0d;
Osr.GetProjectionMethodParamInfo(projectionMethods[i],
paramList[p], out plname, out pltype, ref defaultValue);
Console.WriteLine(" {0}, {1}, {2}, {3}", username,
plname, pltype, defaultValue);
}
}
Which returns something like:
Projection Methods
===================================
Transverse_Mercator
Transverse Mercator, Latitude of Origin, Lat,
Transverse Mercator, Central Meridian, Long, 0
Transverse Mercator, Scale Factor, Ratio, 1
Transverse Mercator, False Easting, m, 0
Transverse Mercator, False Northing, m, 0
> 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;
> }
>
Ah ok, so as opposed to building some wierd code to call the appropriate
method e.g. SetTM I can use SetNormProjParam, hence thinking about this as
'building a dialog', I assume the parameter names returned from
Osr.GetProjectionMethodParamInfo (as in the earlier example) map directly to
the SRS_PP_* constants e.g. SRS_PP_LATITUDE_OF_ORIGIN is 'Latitude of
Origin'.?
That would solve part of the dialog... the next part is listing / editing
the supported Datums. There are various files in the data folder namely:
coordinate_axis.csv
cubewerx_extra.wkt
ecw_cs.wkt
ellipsoid.csv
epsg.wkt
esri_extra.wkt
gcs.csv
gcs.override.csv
gdalicon.png
GDALLogoBW.svg
GDALLogoColor.svg
GDALLogoGS.svg
gdal_datum.csv
gt_datum.csv
gt_ellips.csv
pcs.csv
pcs.override.csv
prime_meridian.csv
projop_wparm.csv
s57agencies.csv
s57attributes.csv
s57attributes_aml.csv
s57attributes_iw.csv
s57expectedinput.csv
s57objectclasses.csv
s57objectclasses_aml.csv
s57objectclasses_iw.csv
seed_2d.dgn
seed_3d.dgn
stateplane.csv
unit_of_measure.csv
By examining some of these files, I can see the list of datums with their
ellipsoids, but can't see a sensible way of reading the files and producing
a list of datums along with their associated ellipsoids, as I don't know
what some of the columns mean or how robust the relationships are. It would
be real handy if someone could tell me which of these files is actually
required by GDAL/Proj and how the relationships between datums and
ellipsoids is established, as such so that I can build a drop down of
available datums, alogn with an Add / Edit button which would again ahave a
dropdown with the available ellipsoids. This way I can also even build a
database driven approach which may generate these files as our application
is launched or something.
--
View this message in context: http://n2.nabble.com/Building-a-Projection-Dialog-tp2864034p2865108.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list