緯度経度変換クラス - 簡易版
Nowral氏のサイトのロジックをRubyにて。
# #=== Overview # 緯度経度・測地系変換クラス(簡易版) # via : http://homepage3.nifty.com/Nowral/02_DATUM/02_DATUM.html # class SimpleDatumConvert # #=== Params #+lat+:: # Latitude(degree format) #=> 35.668991 #+lon+:: # Longitude(degree format) #=> 139.744418 # #=== Return # hash #=> {"lat" => "35.672219", "lon" => "139.741212"} # def SimpleDatumConvert::tokyo2wgs84(lat,lon) hash = Hash.new hash["lat"] = lat - lat*0.00010695 + lon*0.000017464 + 0.0046017 hash["lon"] = lon - lat*0.000046038 - lon*0.000083043 + 0.010040 return hash end def SimpleDatumConvert::wgs842tokyo(lat, lon) hash = Hash.new hash["lat"] = lat + lat*0.00010696 - lon*0.000017467 - 0.0046020 hash["lon"] = lon + lat*0.000046047 + lon*0.000083049 - 0.010041 return hash end # #=== Params #+deg+:: # Degree #=> 35 #+min+:: # Min #=> 40 #+sec+:: # Second #=> 08.371 # #=== Return # degree #=> 35.672219 # def SimpleDatumConvert::dms2degree(deg, min, sec) f = deg.to_f + (min.to_f*60 + sec.to_f)/3600 return f end end
Molodensky法はまた別途。