门店配送面积计算(根据经纬度计算多边形球面积-凸多边形和凹多边形)
This commit is contained in:
@@ -367,17 +367,6 @@ func ScoreFullVendor(storeList []*cms.StoreExt) {
|
||||
}
|
||||
}
|
||||
|
||||
func CalcPolygonArea(points [][2]float64) (area float64) {
|
||||
count := len(points)
|
||||
for i := 0; i < count-1; i++ {
|
||||
area += (points[i][0] - points[i+1][0]) * (points[i][1] + points[i+1][1])
|
||||
}
|
||||
area += (points[count-1][0] - points[0][0]) * (points[count-1][1] + points[0][1])
|
||||
area = math.Abs(area) / 2
|
||||
|
||||
return area
|
||||
}
|
||||
|
||||
//经营范围面积大于半径2km的圆得满分10分,低于1km得分0
|
||||
func ScoreStoreRange(storeList []*cms.StoreExt) {
|
||||
for _, storeInfo := range storeList {
|
||||
@@ -385,7 +374,7 @@ func ScoreStoreRange(storeList []*cms.StoreExt) {
|
||||
storeID := storeInfo.ID
|
||||
if storeInfo.DeliveryRangeType == model.DeliveryRangeTypePolygon {
|
||||
points := jxutils.CoordinateStr2Points(storeInfo.DeliveryRange)
|
||||
area := CalcPolygonArea(points)
|
||||
area := jxutils.CalcPolygonAreaByLngAndLat(points)
|
||||
goodArea := math.Pi * StoreRangeGoodRadius * StoreRangeGoodRadius
|
||||
badArea := math.Pi * StoreRangeBadRadius * StoreRangeBadRadius
|
||||
if area >= goodArea {
|
||||
@@ -398,7 +387,7 @@ func ScoreStoreRange(storeList []*cms.StoreExt) {
|
||||
finalScore = ItemTotalScore - int(math.Round(diff*ratio))
|
||||
}
|
||||
} else if storeInfo.DeliveryRangeType == model.DeliveryRangeTypeRadius {
|
||||
deliveryRadius := utils.Str2Float64WithDefault(storeInfo.DeliveryRange, 0)
|
||||
deliveryRadius := utils.Str2Float64(storeInfo.DeliveryRange) / 1000
|
||||
if deliveryRadius >= StoreRangeGoodRadius {
|
||||
finalScore = ItemTotalScore
|
||||
} else if deliveryRadius <= StoreRangeBadRadius {
|
||||
|
||||
Reference in New Issue
Block a user