Inheritance: MightyLittleGeodesy.Classes.Position
Ejemplo n.º 1
0
 /// <summary>
 /// Create a RT90 position by converting a WGS84 position
 /// </summary>
 /// <param name="position">WGS84 position to convert</param>
 /// <param name="rt90projection">Projection to convert to</param>
 public RT90Position(WGS84Position position, RT90Projection rt90projection)
     : base(Grid.RT90)
 {
     GaussKreuger gkProjection = new GaussKreuger();
     gkProjection.swedish_params(GetProjectionString(rt90projection));
     var lat_lon = gkProjection.geodetic_to_grid(position.Latitude, position.Longitude);
     Latitude = lat_lon[0];
     Longitude = lat_lon[1];
     Projection = rt90projection;
 }
 /// <summary>
 /// Create a RT90 position by converting a WGS84 position
 /// </summary>
 /// <param name="position">WGS84 position to convert</param>
 /// <param name="rt90projection">Projection to convert to</param>
 public SWEREF99Position(WGS84Position position, SWEREFProjection projection)
     : base(Grid.SWEREF99)
 {
     GaussKreuger gkProjection = new GaussKreuger();
     gkProjection.swedish_params(GetProjectionString(projection));
     var lat_lon = gkProjection.geodetic_to_grid(position.Latitude, position.Longitude);
     Latitude = lat_lon[0];
     Longitude = lat_lon[1];
     Projection = projection;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a RT90 position by converting a WGS84 position
        /// </summary>
        /// <param name="position">WGS84 position to convert</param>
        /// <param name="rt90projection">Projection to convert to</param>
        public RT90Position(WGS84Position position, RT90Projection rt90projection)
            : base(Grid.RT90)
        {
            GaussKreuger gkProjection = new GaussKreuger();

            gkProjection.swedish_params(GetProjectionString(rt90projection));
            var lat_lon = gkProjection.geodetic_to_grid(position.Latitude, position.Longitude);

            Latitude   = lat_lon[0];
            Longitude  = lat_lon[1];
            Projection = rt90projection;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a RT90 position by converting a WGS84 position
        /// </summary>
        /// <param name="position">WGS84 position to convert</param>
        /// <param name="rt90projection">Projection to convert to</param>
        public SWEREF99Position(WGS84Position position, SWEREFProjection projection)
            : base(Grid.SWEREF99)
        {
            GaussKreuger gkProjection = new GaussKreuger();

            gkProjection.swedish_params(GetProjectionString(projection));
            var lat_lon = gkProjection.geodetic_to_grid(position.Latitude, position.Longitude);

            Latitude   = lat_lon[0];
            Longitude  = lat_lon[1];
            Projection = projection;
        }
Ejemplo n.º 5
0
        public void WGS84ParseString()
        {
            // Values from Eniro.se
            WGS84Position wgsPosDM = new WGS84Position("N 62º 10.560' E 015º 54.180'", WGS84Position.WGS84Format.DegreesMinutes);
            WGS84Position wgsPosDMs = new WGS84Position("N 62º 10' 33.60\" E 015º 54' 10.80\"", WGS84Position.WGS84Format.DegreesMinutesSeconds);

            Assert.AreEqual(62.176, Math.Round(wgsPosDM.Latitude, 3));
            Assert.AreEqual(15.903, Math.Round(wgsPosDM.Longitude, 3));

            Assert.AreEqual(62.176, Math.Round(wgsPosDMs.Latitude, 3));
            Assert.AreEqual(15.903, Math.Round(wgsPosDMs.Longitude, 3));
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Convert the position to WGS84 format
        /// </summary>
        /// <returns></returns>
        public WGS84Position ToWGS84()
        {
            GaussKreuger gkProjection = new GaussKreuger();

            gkProjection.swedish_params(ProjectionString);
            var lat_lon = gkProjection.grid_to_geodetic(Latitude, Longitude);

            WGS84Position newPos = new WGS84Position()
            {
                Latitude   = lat_lon[0],
                Longitude  = lat_lon[1],
                GridFormat = Grid.WGS84
            };

            return(newPos);
        }
        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);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Convert the position to WGS84 format
        /// </summary>
        /// <returns></returns>
        public WGS84Position ToWGS84()
        {
            GaussKreuger gkProjection = new GaussKreuger();
            gkProjection.swedish_params(ProjectionString);
            var lat_lon = gkProjection.grid_to_geodetic(Latitude, Longitude);

            WGS84Position newPos = new WGS84Position()
            {
                Latitude = lat_lon[0],
                Longitude = lat_lon[1],
                GridFormat = Grid.WGS84
            };

            return newPos;
        }