用计算python两点之间的距离math_计算空间任意两个坐标点之间距离的Python程序脚本...

#coding:UTF-8

"""

Python implementation of Haversine formula

Copyright (C) <2009>

Bartek G

ó

rny

This program is free software: you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY W

ARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with this program.

If not, see .

"""

import math

def recalculate_coordinate(val,

_as=None):

"""

Accepts a coordinate as a tuple (degree, minutes, seconds)

You can give only one of them (e.g. only minutes as a floating point number)

and it will be duly recalculated into degrees, minutes and seconds.

Return value can be specified as 'deg', 'min' or 'sec'; default return value is

a proper coordinate tuple.

"""

deg,

min,

sec = val

# pass outstanding values from right to left

min = (min or 0) + int(sec) / 60

sec = sec % 60

deg = (deg or 0) + int(min) / 60

min = min % 60

# pass decimal part from left to right

dfrac,

dint = math.modf(deg)

min = min + dfrac * 60

deg = dint

mfrac,

mint = math.modf(min)

sec = sec + mfrac * 60

min = mint

if _as:

sec = sec + min * 60 + deg * 3600

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值