public static WebMercatorPosition ToWebMercator(this RT90Position pos)
        {
            var calc  = new WebMercatorCalculator();
            var wgs84 = pos.ToWGS84();

            return(new WebMercatorPosition(calc.LatitudeToY(wgs84.Latitude), calc.LongitudeToX(wgs84.Longitude)));
        }
Example #2
0
        [TestCase(6396528, 1267363, 6392120.265, 315499.415, 0)]            // Välen, Göteborg
        public void ToSweRef99_FromRt90(double lat, double lng, double expectedLat, double expectedLng, int decimals)
        {
            var pos       = new RT90Position(lat, lng);
            var converted = PositionConverter.ToSweRef99(pos);

            Assert.AreEqual(Math.Round(expectedLat, decimals, MidpointRounding.AwayFromZero), Math.Round(converted.Latitude, decimals, MidpointRounding.AwayFromZero));
            Assert.AreEqual(Math.Round(expectedLng, decimals, MidpointRounding.AwayFromZero), Math.Round(converted.Longitude, decimals, MidpointRounding.AwayFromZero));
        }
Example #3
0
        public void WGS84ToRT90()
        {
            WGS84Position wgsPos = new WGS84Position("N 59º 58' 55.23\" E 017º 50' 06.12\"", WGS84Position.WGS84Format.DegreesMinutesSeconds);
            RT90Position  rtPos  = new RT90Position(wgsPos, RT90Position.RT90Projection.rt90_2_5_gon_v);

            // Conversion values from Lantmateriet.se, they convert from DMS only.
            // Reference: http://www.lantmateriet.se/templates/LMV_Enkelkoordinattransformation.aspx?id=11500
            double xPosFromLM = 6653174.343;
            double yPosFromLM = 1613318.742;

            Assert.AreEqual(Math.Round(rtPos.Latitude, 3), xPosFromLM);
            Assert.AreEqual(Math.Round(rtPos.Longitude, 3), yPosFromLM);
        }
Example #4
0
        public void RT90ToWGS84()
        {
            RT90Position  position = new RT90Position(6583052, 1627548);
            WGS84Position wgsPos   = position.ToWGS84();

            // Values from Hitta.se for the conversion
            double latFromHitta = 59.3489;
            double lonFromHitta = 18.0473;

            double lat = Math.Round(wgsPos.Latitude, 4);
            double lon = Math.Round(wgsPos.Longitude, 4);

            Assert.AreEqual(latFromHitta, lat);
            Assert.AreEqual(lonFromHitta, lon);

            // String values from Lantmateriet.se, they convert DMS only.
            // Reference: http://www.lantmateriet.se/templates/LMV_Enkelkoordinattransformation.aspx?id=11500
            string latDmsStringFromLM = "N 59º 20' 56.09287\"";
            string lonDmsStringFromLM = "E 18º 2' 50.34806\"";

            Assert.AreEqual(latDmsStringFromLM, wgsPos.LatitudeToString(WGS84Position.WGS84Format.DegreesMinutesSeconds));
            Assert.AreEqual(lonDmsStringFromLM, wgsPos.LongitudeToString(WGS84Position.WGS84Format.DegreesMinutesSeconds));
        }
 public static WGS84Position ToWgs84(this RT90Position pos)
 {
     return(pos.ToWGS84());
 }
 public static SWEREF99Position ToSweRef99(this RT90Position pos)
 {
     return(new SWEREF99Position(pos.ToWGS84(), SWEREF99Position.SWEREFProjection.sweref_99_tm));
 }