View Ticket
Not logged in
Ticket Hash: 8c09a2fd879dc4e7d5f0679f7a62f2dddce7d4bf
Title: ST_Transform should ignore Z value as default, adding bAttempt3D Parameter
Status: Tested Type: Code_Defect
Severity: Critical Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2017-09-25 13:32:58
Version Found In: dev
User Comments:
mj10777 added on 2017-09-10 05:19:46:

While importing the 1.116 billion 1 meter based height data for Berlin,
which I also need to transform from 'ETRS89 / UTM zone 33N' to 'DHDN / Soldner Berlin', I have noticed that proj4 'rapes' the given Z value.

In 2012 this was also meantioned here:

    https://lists.osgeo.org/pipermail/postgis-users/2012-April/033278.html

Sample:
echo "391475.000 5819347.000 30.11"  | cs2cs +init=epsg:25833 +to +init=epsg:3068

24747.12 20725.15 -10.81
A difference of 40.92 meters. In Berlin the range is from 24.0 to 120.0 meters.
Making the results completely unusable.

For this reason I would suggest changing the default behavior of ST_Transform (gaiaTransformCommon),
so that the z values are not given to pj_transform
  /* applying reprojection        */
  if (is2d)
   rc=pj_transform (from_cs, to_cs, cnt, 0, xx, yy, NULL);
  else
   rc=pj_transform (from_cs, to_cs, cnt, 0, xx, yy, zz);
  if (rc == 0)
  {
// needed 4 times inside gaiaTransformCommon

Since this is a destructive function, attempting to utilize a 3D transformation should be made optional.
A clear warning in the present documentation and for a new optional parameter should be clearly stated.

I have no idea what proj4 does here,
but if they don't take into consideration that each system could have a different '0' point as it's base (which in time could change),
a falsification is very likely.
I hard-coded a 'int is2d=1' in gaiaTransformCommon, after which the above result came out correctly.
gaiaTransformCommon is called from:
    gaiaTransform
    gaiaTransform_r
      fnct_Transform
      fnct_AsKml1
      fnct_AsKml3


mj10777 added on 2017-09-25 13:32:58:

The implemented new Function 'ST_TransformXY()' works as expected.