Select to view content in your preferred language

Bug? Unable to use Inverse GeographicTransformation in ProjectionTransformation

605
2
Jump to solution
06-29-2018 10:23 AM
JonHutchings
Emerging Contributor

This is my test code for OSGB <-> WGS84 using ProjectEx():

// Create SR "British_National_Grid"

SpatialReference sr27700 = SpatialReferenceBuilder.CreateSpatialReference(27700);

// Create SR "GCS_WGS_1984"
SpatialReference sr4326 = SpatialReferenceBuilder.CreateSpatialReference(4326);
MapPoint mp27700 = MapPointBuilder.CreateMapPoint(400000, 100000, sr27700);
MapPoint mp4326 = MapPointBuilder.CreateMapPoint(-2.00138787, 50.79949658, sr4326);

// Create GT "OSGB_1936_To_WGS_1984_Petroleum"
GeographicTransformation gt = GeographicTransformation.Create(1314);

   // gt.IsForward==true

GeographicTransformation gti = gt.GetInverse() as GeographicTransformation;

   // gti.IsForward==false

ProjectionTransformation pt27700to4326 = ProjectionTransformation.CreateEx(sr27700, sr4326, gt);

   // pt27700to4326 Transformation.IsForward==true
ProjectionTransformation pt4326to27700 = ProjectionTransformation.CreateEx(sr4326, sr27700, gti);

   // pt4326to27700 Transformation.IsForward==true !!!
MapPoint mp27700as4326 = GeometryEngine.Instance.ProjectEx(mp27700, pt27700to4326) as MapPoint;

   // correct: -2.0013671162770108, 50.799560607190806
MapPoint mp4326as27700 = GeometryEngine.Instance.ProjectEx(mp4326, pt4326to27700) as MapPoint;

   // incorrect: 399805.88250306522, 100118.3440916813 !!!

The problem appears to occur at the bolded line, where the Transformation inside the ProjectionTransformation gets IsForward set to true, despite the passed in Transformation having IsForward set to false. I would expect it to be still be false at that point, unless I'm missing something.

The final line confirms that the Datum Transform has indeed operated incorrectly. The correct result would be close to 400000, 100000. Failing to apply the Datum Transform would result in approx 100m offset. The incorrect result has an offset about double that.

Bug, or have I missed something?

0 Kudos
1 Solution

Accepted Solutions
AnnetteLocke
Esri Contributor

Hi Jon,

Indeed, this is a bug. It will be fixed in the next release. 

Good news though. There is a workaround. Create a composite transformation from a list that contains the inverse geographic transformation, and then create the projection transformation from that. 

List listOfGTs = new List() { gti };

CompositeGeographicTransformation cgt = CompositeGeographicTransformation.Create(listOfGTs);

ProjectionTransformation pt4326to27700 = ProjectionTransformation.CreateEx(sr4326, sr27700, cgt);

MapPoint mp4326as27700 = GeometryEngine.Instance.ProjectEx(mp4326, pt4326to27700) as MapPoint;

 

Thanks for bringing this to our attention.

Annette

View solution in original post

0 Kudos
2 Replies
AnnetteLocke
Esri Contributor

Hi Jon,

Indeed, this is a bug. It will be fixed in the next release. 

Good news though. There is a workaround. Create a composite transformation from a list that contains the inverse geographic transformation, and then create the projection transformation from that. 

List listOfGTs = new List() { gti };

CompositeGeographicTransformation cgt = CompositeGeographicTransformation.Create(listOfGTs);

ProjectionTransformation pt4326to27700 = ProjectionTransformation.CreateEx(sr4326, sr27700, cgt);

MapPoint mp4326as27700 = GeometryEngine.Instance.ProjectEx(mp4326, pt4326to27700) as MapPoint;

 

Thanks for bringing this to our attention.

Annette

0 Kudos
JonHutchings
Emerging Contributor

Thanks for the confirmation, Annette. The workaround works fine.

0 Kudos