public void SwerefToWGS84() { SWEREF99Position swePos = new SWEREF99Position(6652797.165, 658185.201); WGS84Position wgsPos = swePos.ToWGS84(); // String values from Lantmateriet.se, they convert DMS only. // Reference: http://www.lantmateriet.se/templates/LMV_Enkelkoordinattransformation.aspx?id=11500 string latDmsStringFromLM = "N 59º 58' 55.23001\""; string lonDmsStringFromLM = "E 17º 50' 6.11997\""; Assert.AreEqual(latDmsStringFromLM, wgsPos.LatitudeToString(WGS84Position.WGS84Format.DegreesMinutesSeconds)); Assert.AreEqual(lonDmsStringFromLM, wgsPos.LongitudeToString(WGS84Position.WGS84Format.DegreesMinutesSeconds)); }
public void WGS84ToSweref() { WGS84Position wgsPos = new WGS84Position(); wgsPos.SetLatitudeFromString("N 59º 58' 55.23\"", WGS84Position.WGS84Format.DegreesMinutesSeconds); wgsPos.SetLongitudeFromString("E 017º 50' 06.12\"", WGS84Position.WGS84Format.DegreesMinutesSeconds); SWEREF99Position rtPos = new SWEREF99Position(wgsPos, SWEREF99Position.SWEREFProjection.sweref_99_tm); // Conversion values from Lantmateriet.se, they convert from DMS only. // Reference: http://www.lantmateriet.se/templates/LMV_Enkelkoordinattransformation.aspx?id=11500 double xPosFromLM = 6652797.165; double yPosFromLM = 658185.201; Assert.AreEqual(Math.Round(rtPos.Latitude, 3), xPosFromLM); Assert.AreEqual(Math.Round(rtPos.Longitude, 3), yPosFromLM); }