Convert Degrees/Minutes/Seconds to Decimal Coordinates

前端 未结 7 1280
青春惊慌失措
青春惊慌失措 2020-12-01 12:31

In one part of my code I convert from decimal coordinates to degrees/minutes/seconds and I use this:

double coord = 59.345235;
int sec = (int)Math.Round(coor         


        
7条回答
  •  时光取名叫无心
    2020-12-01 13:17

    CoordinateSharp is available as a Nuget package and can handle Coordinate conversions for you. It even does UTM/MGRS conversion and provides solar/lunar times relative to the input location. It's really easy to use!

    Coordinate c = new Coordinate(40.465, -75.089);
    
    //Display DMS Format
    c.FormatOptions.Format = CoordinateFormatType.Degree_Minutes_Seconds;
    c.ToString();//N 40º 27' 54" W 75º 5' 20.4"
    c.Latitude.ToString();//N 40º 27' 54"
    c.Latitude.ToDouble();//40.465
    

    Coordinate properties are iObservable as as well. So if you change a latitude minute value for example, everything else will update.

提交回复
热议问题