GNSSから日本時間を取得する方法とGNSSの2地点間の距離を計算する方法
import datetime
def gps_to_jst(gwk, gms):
# GPSエポック(1980年1月6日)からの秒数を計算
gps_epoch = datetime.datetime(1980, 1, 6)
# 1週間は60秒 * 60分 * 24時間 * 7日
seconds_per_week = 60 * 60 * 24 * 7
# GPS時間からの秒数を計算
gps_seconds = gwk * seconds_per_week + gms
# Unixエポック(1970年1月1日)からの秒数に変換
unix_epoch = datetime.datetime(1970, 1, 1)
delta = gps_epoch - unix_epoch
gps_to_unix_offset = delta.total_seconds()
# Unixエポックからの秒数を計算
unix_time = gps_seconds + gps_to_unix_offset
# datetimeオブジェクトに変換
utc_time = datetime.datetime.utcfromtimestamp(unix_time)
# 9時間のオフセットを追加して日本時間に変換
jst_time = utc_time + datetime.timedelta(hours=9)
return jst_time
# 例:GWK = 2000週, GMS = 345600秒(週の4日目の正午)
gwk = 2316
gms = 520695000/1000
jst_time = gps_to_jst(gwk, gms)
print(jst_time.strftime('%Y-%m-%d %H:%M:%S'))
=SQRT(((E3-C3)*PI()/180*6378137*(1-0.00669437999)/SQRT(1-0.00669437999*SIN((E3+C3)/2*PI()/180)^2)^3)^2+((F3-D3)*PI()/180*6378137/SQRT(1-0.00669437999*SIN((E3+C3)/2*PI()/180)^2)*COS((E3+C3)/2*PI()/180))^2)
![](https://assets.st-note.com/img/1717307667154-f79HYOzLVf.png?width=1200)
ChatGPTさまも、グーグル先生も優秀ですね。
普段何気なく使用している時間とか距離ですが、なにか活用しようとすると急にハードル上げてくる♪