哈哈
This commit is contained in:
@@ -974,3 +974,33 @@ func GetDefendPriceIssue() (issue int) {
|
||||
func GetLastDefendPriceIssue() (issue int) {
|
||||
return utils.Str2Int(time.Now().AddDate(0, 0, 1).Format("20060102"))
|
||||
}
|
||||
|
||||
//根据一堆坐标求面积
|
||||
//有待考证,不过暂时拿来用
|
||||
func ComputeSignedArea(path []string) (s float64) {
|
||||
var (
|
||||
radius = 6371009
|
||||
len = len(path)
|
||||
total float64
|
||||
prev = path[len-1]
|
||||
)
|
||||
if len < 3 {
|
||||
return
|
||||
}
|
||||
prevTanLat := math.Tan(((math.Pi/2 - utils.Str2Float64(strings.Split(prev, ",")[1])/180*math.Pi) / 2))
|
||||
prevLng := utils.Str2Float64(strings.Split(prev, ",")[0]) / 180 * math.Pi
|
||||
for i := 0; i < len; i++ {
|
||||
tanLat := math.Tan(((math.Pi/2 - utils.Str2Float64(strings.Split(path[i], ",")[1])/180*math.Pi) / 2))
|
||||
lng := utils.Str2Float64(strings.Split(path[i], ",")[0]) / 180 * math.Pi
|
||||
total += polarTriangleArea(tanLat, lng, prevTanLat, prevLng)
|
||||
prevTanLat = tanLat
|
||||
prevLng = lng
|
||||
}
|
||||
return math.Abs(total * (float64(radius) * float64(radius)))
|
||||
}
|
||||
|
||||
func polarTriangleArea(tan1, lng1, tan2, lng2 float64) (s float64) {
|
||||
deltaLng := lng1 - lng2
|
||||
t := tan1 * tan2
|
||||
return 2 * math.Atan2(t*math.Sin(deltaLng), 1+t*math.Cos(deltaLng))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user