feiyu02
2025-09-30 94fee0b511279679b43e210878d3d36e5a14384b
src/main/kotlin/com/flightfeather/uav/model/epw/WindDisWeight.kt
@@ -2,6 +2,7 @@
import com.flightfeather.uav.lightshare.bean.CompanySOP
import com.flightfeather.uav.lightshare.bean.DataVo
import com.flightfeather.uav.model.BaseSOP
import com.flightfeather.uav.model.BaseWeight
import com.flightfeather.uav.socket.eunm.FactorType
import kotlin.math.abs
@@ -12,7 +13,7 @@
 * 风速距离权重
 * 监测点与污染源之间的物理距离与当前风速得出的权重
 */
class WindDisWeight : BaseWeight<DataVo, CompanySOP>() {
class WindDisWeight(var defaultLocation: Pair<Double, Double>?) : BaseWeight<DataVo, BaseSOP>() {
    override val tag: String = "风速距离权重"
@@ -20,8 +21,9 @@
    override val weights: List<Double> = listOf(1.0, 0.8, 0.6, 0.5, 0.3, 0.0)
    override fun onWeightFactor(mData: DataVo, sop: CompanySOP): Double? {
        val p1 = Pair(mData.lng!!, mData.lat!!)
    override fun onWeightFactor(mData: DataVo, sop: BaseSOP): Double? {
        val p1 = if (mData.lng == null || mData.lat == null || mData.lng == .0 || mData.lat == .0) defaultLocation else Pair(mData.lng!!, mData.lat!!)
        p1 ?: return .0
        val p2 = Pair(sop.ciLongitude!!.toDouble(), sop.ciLatitude!!.toDouble())
        val ws = mData.getFactorData(FactorType.WIND_SPEED)
        return if (ws == null) null else getWindSpeed(p1, p2, ws)