[geotk] Is WKT always sufficient to define a CRS?
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Tue Aug 2 16:15:06 EDT 2011
Hello Jon
Le 02/08/11 18:38, Jon Blower a écrit :
> * If I'm using the embedded EPSG database within Geotoolkit, can I get hold of the Proj4 string in my application?
We don't have yet a mechanism for formatting Proj4 string from a CRS. However
this has been a request for a long time, something we will have to do soon or
later. In the main time, I think that something along that line would work for
ProjectedCRS:
private final Properties OGCtoProj4 = ...; // TODO: This is the tedious part, see below.
private String getProj4Name(IdentifiedObject object) {
return OGCtoProj4.get(IdentifiedObjects.getIdentifiers(object, Citations.OGC).getCode());
}
public String getProj4String(ProjectedCRS crs) {
StringBuilder proj4String = new StringBuilder();
proj4String.append("proj=").append(getProj4Name(crs));
for (GeneralParameterValue param : crs.getConversionFromBase().getParametersValues().values()) {
double value = ((ParameterValue) param).doubleValue();
proj4String.append(" +").append(getProj4Name(param)).append('=').append(value);
}
return proj4String.toString();
}
The part which would be a bit tedious would be to fill a map of "OGC to Proj4"
name, something like that:
Albers_Conic_Equal_Area = eae
standard_parallel_1 = lat_1
standard_parallel_2 = lat_2
latitude_of_center = lat_0
etc...
There is a high probability that this mapping already exists somewhere. With
such mapping, I think it would be trivial to add Proj4 formatting support
straight into Geotk.
> * Do Proj4 string contain all the info from the EPSG database, or do they fall short in the ways you describe below?
As far as I know, they have the same limitation than WKT: no information about
area of validity, scope, accuracy, aliases and remarks.
There is also one more thing which is unique to the EPSG database: for some
pairs of CRS, the database specifies explicitly which transformation path should
be used. Many transformation paths exist, for example a datum shift could be
performed by "Geocentric translation", "Molodensky" or "Abridged Molodensky"
methods among others. Without EPSG database, the method choosen is
implementation-dependent. With an EPSG database, it is formaly defined. Simple
syntax like WKT don't do that (well, a database of transformation paths with WKT
would be possible, but I'm not aware of anyone doing that). Proj4 don't do
neither, or at least the PostGIS "spatial_ref_sys" table doesn't contain any
information about transformation paths.
Regards,
Martin
More information about the Geotoolkit
mailing list