html动态日出,日出日落及方位角计算html

太阳高度角的计算-太阳高度角在线计算器-太阳方位角计算软件// sunangle.jsvar showedLongitudeMeridianWarning = false;//console.log("调试");// 检查输入功能//function CheckInputs () {var error = false;var error_message = "注意!下面的输入必须予以纠正,才可以计...
摘要由CSDN通过智能技术生成
太阳高度角的计算-太阳高度角在线计算器-太阳方位角计算软件

// sunangle.js

var showedLongitudeMeridianWarning = false;

//console.log("调试");

// 检查输入功能//

function CheckInputs () {

var error = false;

var error_message = "注意!下面的输入必须予以纠正,才可以计算出太阳的角度:\n\n";

var f = document.theForm;

var inputLatitude = f.inputLatitude.value;

var inputLongitude = f.inputLongitude.value;

var inputTime = f.inputTime.value;

var inputElevation = f.inputElevation.value;

//纬度

var latitudeOkay = false;

if (inputLatitude.search ("^[0-9]+[dD][0-9]+[mM][0-9]+[sS]$") > -1) { latitudeOkay = true; }

else { if ((inputLatitude >= 0 ) && (inputLatitude <= 90)) { latitudeOkay = true; } }

if (! latitudeOkay) {

error_message = error_message + "* T纬度必须介于0到90度之间\n";

error = true;

}

// 经度

var longitudeOkay = false;

if (inputLongitude.search ("^[0-9]+[dD][0-9]+[mM][0-9]+[sS]$") > -1) { longitudeOkay = true; }

else { if ((inputLongitude >= 0 ) && (inputLongitude <= 360)) { longitudeOkay = true; } }

if (! longitudeOkay) {

error_message = error_message + "* 经度必须介于0到360度之间\n";

error = true;

}

//海拔

if ((inputElevation != '') && (inputElevation.search ("[^0-9]") > -1)) {

error_message = error_message + "* 高程仅包含数字\n";

error = true;

}

// 时间

if ((inputTime != '') && (inputTime.search ("^[0-9]+:?[0-9][0-9]$") < 0)) {

error_message = error_message + "* 时间必须是XX:XX或XXXX格式,如12点10分,填12:10或1210 \n";

error = true;

}

//警报/返回

if (error == true) { alert (error_message); }

return (! error);

}

///

// 主函数计算//

///

function compute () {

if (CheckInputs ()) {

var f = document.theForm;

//常量

var degreesToRadians = 3.1416 / 180.0000;

var radiansToDegrees = 180.0000 / 3.1416;

var degreeMinutesToDecimal = 1.0000 / 60.0000;

var degreeSecondsToDecimal = 1.0000 / 3600.0000;

// 检索输入的值

var inputLongitude = f.inputLongitude.value;

var inputEastWest = f.inputEastWest.options[f.inputEastWest.selectedIndex].text;

var inputLatitude = f.inputLatitude.value;

var inputNorthSouth = f.inputNorthSouth.options[f.inputNorthSouth.selectedIndex].text;

var inputElevation = f.inputElevation.value;

//var inputFeetMeters = f.inputFeetMeters.options[f.inputFeetMeters.selectedIndex].text;

var inputMonth = f.inputMonth.options[f.inputMonth.selectedIndex].text;

var inputDate = f.inputDate.options[f.inputDate.selectedIndex].text - 0;

var inputYear = f.inputYear.options[f.inputYear.selectedIndex].text - 0;

var inputTime = f.inputTime.value;

var inputAMPM = f.inputAMPM.options[f.inputAMPM.selectedIndex].text;

var inputTimeFormat = f.inputTimeFormat.options[f.inputTimeFormat.selectedIndex].text;

var inputTimeZone = f.inputTimeZone.options[f.inputTimeZone.selectedIndex].value - 0;

var inputZeroAzimuth = f.inputZeroAzimuth.options[f.inputZeroAzimuth.selectedIndex].value - 0;

if (inputLongitude.indexOf("d") != -1) {

degMarker = inputLongitude.indexOf("d");

minMarker = inputLongitude.indexOf("m");

secMarker = inputLongitude.indexOf("s");

longitudeDeg = inputLongitude.substr(0,degMarker) - 0;

longitudeMin = inputLongitude.substr(degMarker+1,minMarker-degMarker-1) - 0;

longitudeSec = inputLongitude.substr(minMarker+1,secMarker-minMarker-1) - 0;

inputLongitude = longitudeDeg + (longitudeMin * degreeMinutesToDecimal) + (longitudeSec * degreeSecondsToDecimal);

}

else { inputLongitude -= 0; }

if (inputLatitude.indexOf("d") != -1) {

degMarker = inputLatitude.indexOf("d");

minMarker = inputLatitude.indexOf("m");

secMarker = inputLatitude.indexOf("s");

LatitudeDeg = inputLatitude.substr(0,degMarker) - 0;

LatitudeMin = inputLatitude.substr(degMarker+1,minMarker-degMarker-1) - 0;

LatitudeSec = inputLatitude.substr(minMarker+1,secMarker-minMarker-1) - 0;

inputLatitude = LatitudeDeg + (LatitudeMin * degreeMinutesToDecimal) + (LatitudeSec * degreeSecondsToDecimal);

}

else { inputLatitude -= 0; }

//检查输入值的有效性

var validInputTime = true;

// 避免由于纬度或经度数学错误 = 0

if ((inputLatitude == 0) && (f.inputLatitude.value.length > 0)) { inputLatitude = 0.000000001; }

if ((inputLongitude == 0) && (f.inputLongitude.value.length > 0)) { inputLongitude =

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值