feiyu02
2025-08-14 b10c22af595bd995e56946bff63b8f2f984b13e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.flightfeather.uav.model.underwaygrid
 
import com.flightfeather.uav.model.BaseWeight
import com.flightfeather.uav.socket.eunm.FactorType
import java.math.BigDecimal
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.sqrt
 
/**
 * 风速距离权重
 * 监测点与污染源之间的物理距离与当前风速得出的权重
 * @date 2025/3/21
 * @author feiyu02
 */
class GridWindDisWeight : BaseWeight<GridCellAndData, GridCellSop>() {
 
    override val tag: String = "风速距离权重"
 
    override val sectionValues: List<Double> = listOf(2.0, 5.0, 8.0, 12.0, 20.0, 30.0)
 
    override val weights: List<Double> = listOf(1.0, 0.8, 0.6, 0.5, 0.3, 0.0)
 
    override fun onWeightFactor(mData: GridCellAndData, sop: GridCellSop): Double? {
        val p1 = Pair(mData.gridCell.longitude, mData.gridCell.latitude)
        val p2 = Pair(sop.gridCell.longitude, sop.gridCell.latitude)
        val ws = mData.getFactorData(FactorType.WIND_SPEED)
        return if (ws == null) null else getWindSpeed(p1, p2, ws)
    }
 
    private fun getWindSpeed(p1: Pair<BigDecimal, BigDecimal>, p2: Pair<BigDecimal, BigDecimal>, ws: Double): Double {
        val dx = (p2.first - p1.first).toDouble()
        val dy = (p2.second - p1.second).toDouble()
        val dis = sqrt(abs(dx * dx) + abs(dy * dy)) * 100
        val min = dis * 1000 / max(ws, 1.0) / 60
        return min
    }
}