Created
August 3, 2010 00:36
-
-
Save mumoshu/505589 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 参考: http://blog.livedoor.jp/sawamur/archives/50450768.html | |
*/ | |
var CIRCLE_IN_METERS = 40000000 | |
/** | |
* 引数に渡した緯度における経度1秒の長さをメートル単位で返す | |
* @param {number} latitude -180~+180の緯度 | |
*/ | |
function longitudeInSecondsAtLatitude(latitude) { | |
/* 赤道(緯度0度)における1ラジアンあたりの東西方向の距離(メートル) */ | |
var metersPerRadian = CIRCLE_IN_METERS /( 2 * Math.PI ); | |
/* 緯度(latitude / 180度)における1ラジアンあたりの東西方向の距離(メートル) */ | |
var r2 = Math.cos( ( latitude / 180 ) * Math.PI ) * metersPerRadian; | |
var m = (r2 * 2 * Math.PI) / (360 * 60 * 60); | |
return m; | |
} | |
var latitudes = { | |
"東京": 35, | |
"那覇": 26, | |
"札幌": 43 | |
}; | |
for (name in latitudes) { | |
var latInDegree = latitudes[name]; | |
var metersPerLngInSeconds = longitudeInSecondsAtLatitude(latInDegree); | |
console.log(name, metersPerLngInSeconds); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment