I have a piece of code that converts a map extent from one projection to another using GeometryEngine.Project() function, then later convert it back to the original projection. What I noticed is that as I do this, my extent keeps growing in size through each conversion. Here's my sample code to demonstrate this issue:
SpatialReference spRef1 = _map1.SpatialReference;
SpatialReference spRef2 = _map2.SpatialReference;
Geometry extent1 = MyMapView.Extent;
System.Console.WriteLine("extent1:" + extent1);
Geometry extent2 = GeometryEngine.Project(extent1, spRef2);
System.Console.WriteLine("extent2:" + extent2);
Geometry extent3 = GeometryEngine.Project(extent2, spRef1);
System.Console.WriteLine("extent3:" + extent3);
Geometry extent4 = GeometryEngine.Project(extent3, spRef2);
System.Console.WriteLine("extent4:" + extent4);
I took the map extent and project it back and forth between the projection. Here's e output result:
extent1:Envelope[XMin=-13657052.8897704, YMin=5704031.99454925, XMax=-13654690.3535498, YMax=5705394.14433894, Wkid=102100]
extent2:Envelope[XMin=7642556.79710776, YMin=683718.917830887, XMax=7648078.00265341, YMax=686989.703265818, Wkid=2913]
extent3:Envelope[XMin=-13657089.5657256, YMin=5703968.27772793, XMax=-13654654.0392246, YMax=5705457.8619931, Wkid=102100]
extent4:Envelope[XMin=7642468.43306019, YMin=683570.513830889, XMax=7648165.48222178, YMax=687138.129620944, Wkid=2913]
If projection works as expected, I would expect extent1 = extent3, and extent2 = extent4, but as you can see that is not the case. Is there something I am missing in my understanding on how the GeometryEngine.Project() function works?