tools/vincenty/zh_CN.html
2023-05-18 14:46:08 +08:00

234 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>椭球模型地球上点之间的距离</title>
<!-- Bootstrap -->
<link href="https://cdn.gh.ink/assembly/bootstrap/4.6.1/css/bootstrap.min.css" rel="stylesheet">
<!-- Favicon -->
<link rel="icon" href="https://2-cdn.ianxia.com/images/avatar/common.png" type="image/png">
<script src="https://cdn.gh.ink/js/vue/2.6.14/vue.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="https://tools.ianxia.com"><b>Ian</b>Tools</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
语言
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="en_US.html"><b>English</b></a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.ianxia.com">首页</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://blog.ianxia.com">博客</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://demo.ianxia.com">DEMO</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://adsb.ianxia.com">ADS-B</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="../zh_CN.html">小工具</a>
</li>
</ul>
</div>
</nav>
<section>
<div class="jumbotron text-center mt-2">
<div class="container">
<div class="row">
<div class="col-12">
<h1>椭球模型地球上点之间的距离</h1>
</div>
</div>
</div>
</div>
</section>
<section>
<div class="container">
<div class="row" id="app">
<div class="col-md-1"></div>
<div class="col-md-5">
<form class="form-horizontal" role="form">
<div class="form-inline">
<label><b>A点经度</b>&nbsp;</label>
<input type="number" step="0.01" class="form-control" max="180" min="-180" v-model="lopa" placeholder="A点经度">
</div><br>
<div class="form-inline">
<label><b>A点纬度</b>&nbsp;</label>
<input type="number" step="0.01" class="form-control" max="90" min="-90" v-model="lapa" placeholder="A点纬度">
</div><br>
<div class="form-inline">
<label><b>B点经度</b>&nbsp;</label>
<input type="number" step="0.01" class="form-control" max="180" min="-180" v-model="lopb" placeholder="B点经度">
</div><br>
<div class="form-inline">
<label><b>B点纬度</b>&nbsp;</label>
<input type="number" step="0.01" class="form-control" max="90" min="-90" v-model="lapb" placeholder="B点纬度">
</div><br>
</form>
</div>
<div class="col-md-6">
<h5>计算结果:</h5>
<h5>距离:{{distance}} km</h5>
</div>
</div>
<div class="text-center">
<hr>
<h5>算法来源:<a href="http://www.movable-type.co.uk/scripts/latlong-vincenty.html">Vincenty solutions of geodesics on the ellipsoid</a></h5>
<h5>语言翻译Bigsk</h5>
</div>
</div>
</section>
<hr>
<script>
let a = 6378137;
let b = 6356752.314245;
let f = 1 / 298.257223563;
function getDistance(lat_one, lon_one, lat_two, lon_two) {
let L = toRadians(lon_one - lon_two);
let U1 = Math.atan((1 - f) * Math.tan(toRadians(lat_one)));
let U2 = Math.atan((1 - f) * Math.tan(toRadians(lat_two)));
let sinU1 = Math.sin(U1), cosU1 = Math.cos(U1),
sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
let lambda = L, lambdaP = Math.PI;
let cosSqAlpha = 0, sinSigma = 0, cos2SigmaM = 0, cosSigma = 0, sigma = 0;
let circleCount = 40;
while (Math.abs(lambda - lambdaP) > 1e-12 && --circleCount > 0) {
let sinLambda = Math.sin(lambda), cosLambda = Math.cos(lambda);
sinSigma = Math.sqrt((cosU2 * sinLambda) * (cosU2 * sinLambda) +
(cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
if (sinSigma == 0) {
return 0;
}
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
sigma = Math.atan2(sinSigma, cosSigma);
let alpha = Math.asin(cosU1 * cosU2 * sinLambda / sinSigma);
cosSqAlpha = Math.cos(alpha) * Math.cos(alpha);
cos2SigmaM = cosSigma - 2 * sinU1 * sinU2 / cosSqAlpha;
let C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
lambdaP = lambda;
lambda = L + (1 - C) * f * Math.sin(alpha) *
(sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
}
if (circleCount == 0) {
return NaN;
}
let uSq = cosSqAlpha * (a * a - b * b) / (b * b);
let A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
let B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
let deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM) -
B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
let result = b * A * (sigma - deltaSigma) / 1000;
return result;
}
function toRadians(angle) {
let result = 0;
if (angle != null) {
result = angle * Math.PI / 180;
}
return result;
}
new Vue({
el: '#app',
data: {
lopa: 120,
lapa: 30,
lopb: 79,
lapb: 44
},
computed: {
distance: function() {
return getDistance(this.lapa, this.lopa, this.lapb, this.lopb);
}
}
})
let date = new Date();
</script>
<footer class="text-center">
<div class="container">
<div class="row">
<div class="col-12">
<p style="color: #516069"><strong>版权所有 © Ian Xia <script>document.write(date.getFullYear().toString());</script> 保留所有权利</strong></p>
</div>
</div>
</div>
</footer>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://cdn.gh.ink/js/jquery/jquery-3.6.0.min.js"></script>
<!-- Grey Filter Detector -->
<script>
$.ajax({
type: "GET",
url: "https://open.geh.ink/grey_filter",
dataType: "json",
success: function(data, textStatus){
for (let i=0;i<data["content"]["accurate_slot"].length;i++) {
// Accurate Slot
if (Date.now()/1000 >= data["content"]["accurate_slot"][i][0] && Date.now()/1000 <= data["content"]["accurate_slot"][i][1]) {
$("html").css({
'-webkit-filter': 'grayscale(100%)',
'-moz-filter': 'grayscale(100%)',
'-ms-filter': 'grayscale(100%)',
'-o-filter': 'grayscale(100%)',
'filter': 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)',
'_filter': 'none'
});
break;
}
}
for (let i=0;i<data["content"]["day_slot"].length;i++) {
// Day Slot
let begin = new Date(
date.getFullYear().toString() + "-" +
data["content"]["day_slot"][i][0][0].toString() + "-" +
data["content"]["day_slot"][i][0][1].toString() + " " +
data["content"]["day_slot"][i][0][2].toString() + ":" +
data["content"]["day_slot"][i][0][3].toString() + ":" +
data["content"]["day_slot"][i][0][4].toString()
)
let end = new Date(
date.getFullYear().toString() + "-" +
data["content"]["day_slot"][i][1][0].toString() + "-" +
data["content"]["day_slot"][i][1][1].toString() + " " +
data["content"]["day_slot"][i][1][2].toString() + ":" +
data["content"]["day_slot"][i][1][3].toString() + ":" +
data["content"]["day_slot"][i][1][4].toString()
)
if (Date.now() >= begin.getTime() && Date.now() <= end.getTime()) {
$("html").css({
'-webkit-filter': 'grayscale(100%)',
'-moz-filter': 'grayscale(100%)',
'-ms-filter': 'grayscale(100%)',
'-o-filter': 'grayscale(100%)',
'filter': 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)',
'_filter': 'none'
});
break;
}
}
}
});
</script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://cdn.gh.ink/js/popper/1.16.1/popper.min.js"></script>
<script src="https://cdn.gh.ink/assembly/bootstrap/4.6.1/js/bootstrap.min.js"></script>
</body>
</html>