Convert Degrees/Minutes/Seconds to Decimal Coordinates

前端 未结 7 1323
青春惊慌失措
青春惊慌失措 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条回答
  •  旧时难觅i
    2020-12-01 13:12

    Since degrees are each worth 1 coordinate total, and minutes are worth 1/60 of a coordinate total, and seconds are worth 1/3600 of a coordinate total, you should be able to put them back together with:

    new_coord = deg + min/60 + sec/3600
    

    Beware that it won't be the exact same as the original, though, due to floating-point rounding.

提交回复
热议问题