This commit is contained in:
苏尹岚
2020-09-01 15:20:33 +08:00
parent 9cdee81b21
commit 9eb7a3b841
2 changed files with 57 additions and 0 deletions

View File

@@ -1584,6 +1584,33 @@ func UploadJdsImage(ctx *jxcontext.Context) (err error) {
// fmt.Println("updateList2", utils.Format4Output(updateList, false))
// fmt.Println("deleteList2", deleteList)
// cms.DeletedDuplicateWaitAuditData(ctx, dao.GetDB())
type tmp struct {
jdID string
s float64
}
var (
ss []*tmp
)
storeMaps, _ := dao.GetStoresMapList(dao.GetDB(), []int{model.VendorIDJD}, nil, nil, model.StoreStatusAll, model.StoreIsSyncAll, "", "")
for _, v := range storeMaps {
station, _ := jd.GetAPI("320406").GetDeliveryRangeByStationNo2(v.VendorStoreID)
if station.DeliveryRangeType == 2 {
ss = append(ss, &tmp{
jdID: v.VendorStoreID,
s: jxutils.ComputeSignedArea(strings.Split(station.DeliveryRange, ";")),
})
}
}
for i := 0; i < len(ss)-1; i++ {
for j := 0; j < len(ss)-1-i; j++ {
if ss[j].s > ss[j+1].s {
temp := ss[j]
ss[j] = ss[j+1]
ss[j+1] = temp
}
}
}
fmt.Println("111111111111111111111111111111111111111", utils.Format4Output(ss, false))
return err
}

View File

@@ -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))
}