开发者

Converting degree/minutes/seconds to decimal degrees

I'm asking this question in a different way, another user let me know what I need to ask for, I'm basically looking to convert to "decimal degrees". The conversion of course must be accurate. I see javascript solutions out there like this javascript example. I need ruby. Maybe someone could write the javascript in Ruby and I can try that, if that's easy of course and if it's right that is?

Basically I have this in my DB.

开发者_开发百科<coordinates_east>6'01.4</coordinates_east>
<coordinates_north>45'05.5</coordinates_north>

I need a routine written in Ruby to convert these to decimal degrees for use with the google maps API, possible?


you want like this? not understand your question well though.

puts "6'01.4".scan(/(\d+)'(\d+)\.(\d+)/).map{|x,y,z|x.to_f+y.to_f/60+z.to_f/3600}
6.01777777777778
puts "36'57.9".scan(/(\d+)'(\d+)\.(\d+)/).map{|x,y,z|x.to_f+y.to_f/60+z.to_f/3600}
36.9525
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜