ThinkGeo.com    |     Documentation    |     Premium Support

Convert Euref89 To Wgs84

Hi I can't get the expected result when trying to convert euref89 to wgs84


Here i have a small test with input and what the correct result needs to be...


How can i get the expected result?


      public static PointShape TESTConvertEuref89ToWgs84()


        {
            double x = 6227738.595D;
            double y = 594538.991D;
 
            // correct result needs to be 
            //56.1852203615381
            //10.5231905076627
            PointShape xx = new PointShape();            
            Proj4Projection proj4 = new Proj4Projection();            
            //proj4.InternalProjectionParametersString = Proj4Projection. ???
            proj4.ExternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString();
 
            proj4.Open();
            Vertex wgs84Vertex = proj4.ConvertToExternalProjection(x,y);
            xx.X = wgs84Vertex.X;
            xx.Y = wgs84Vertex.Y;
            proj4.Close();
            return xx;
        }

Hello Niels, 
  
 Thanks for your post, but sorry to say, we couldn’t find any information on this projection. Could you please find the projection you are wanting to use at spatialreference.org and provide the link for it to us? 
  
 Regards, 
  
 Gary

etrs89 / utm zone 32n 
 spatialreference.org/ref/epsg/25832/ 
  
 But still if I use proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(25832); 
 I the result doesn’t match the official danish convert service. 
 To validate result compare with Danish official convert site. geo.oiorest.dk/wgs84?etrs89=6227738.595,594538.991 
  


Hello Niels, 
  
 Thank you for the further information.  It will be reviewed and assigned to our development team during the next week.  Once the problem has been resolved I will post here so that you will be aware of the resolution.  If you ever need a status update, please feel free to let us know. 
  
 Regards, 
  
 Gary

Hello Niels, 
  
 Thanks for your patience, we have fixed this bug and please get the latest version and have another try. 
  
 Feel free to let us know if you still meet the problem. 
  
 Regards, 
  
 Gary

Hi in 6.0.192.0 it’s broken again. 
 Including failing unittest. 
  
  
using Xunit;

    public class CoordinateTransformationServiceTest
    {
        [Fact]
        public void ConvertEuref89ToWgs84Test()
        {
            //Validate here
            //geo.oiorest.dk/wgs84?etrs89=6227738.595,594538.991
            double xEast = 6227738.595D;
            double yNorth = 594538.991D;          
            var resp = ServiceModel.Operations.ConvertCoordSystem.ConvertEuRef89ToWgs84(xEast.ToString(), yNorth.ToString());
            string respxLongtitude = “10.5231905076627”;
            string respyLatitude = “56.1852203615381”;
            Assert.Contains(respxLongtitude, resp.X.ToString());
            Assert.Contains(respyLatitude, resp.Y.ToString());
        }

//////////////////////////////////////////////////////

public static PointShape ConvertEuRef89ToWgs84(string xEast, string yNorth)
        {           
            xEast =  ReplaceComma(xEast);
            yNorth = ReplaceComma(yNorth);
            PointShape xx = new PointShape();
            Proj4Projection proj4 = new Proj4Projection();
            proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(25832);
            proj4.ExternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString();
            proj4.Open();
            Vertex wgs84Vertex = proj4.ConvertToExternalProjection(StringToDouble(xEast), StringToDouble(yNorth));            
            xx.X = wgs84Vertex.X;
            xx.Y = wgs84Vertex.Y;
            proj4.Close();
            return xx;
        }

public static string ReplaceComma(string input)
        {
            if(input.Contains(","))
            {
                input = input.Replace(",", “.”);
            }
            return input;
        }


Hello Niels, 
  
 We did more investigated with MapSuite Core 6.0.192.0, and compare the result with following website: 
  
  spatialreference.org/ref/epsg/etrs89-utm-zone-32n/ 
  result: 
  Input Coordinates: 54.93125, 3.425625  
  Output Coordinates: 6251553.18741, 544706.197055 
  cs2cs.mygeodata.eu/ 
  result: 
  Input Coordinates: 6251553.18741, 544706.197055  
  Output Coordinates: 54.8272766872, 3.44019683542 
   
  Our results as follows: 
                  Input Coordinates: 6251553.18741, 544706.197055 
  Output Coordinates:54.8272766871834,3.44019683542281 
   
 But on the website you provide: 
  
 geo.oiorest.dk/wgs84?etrs89=6251553.18741,544706.197055 
  
 We got result 56.4064489759172, 9.7244439941052 
  
 I think the problem is your expect result in your unit test is wrong. 
  
 Please let us know if we have misunderstanding. 
  
 Regards, 
  
 Gary