riku
2021-06-21 62a55369aa23d4b9cee5e66e0520b3803c33de6f
1. 新增走航检测污染溯源模型逻辑
已修改2个文件
30 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/model/epw/EPWModel.kt 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/WindDisWeight.kt 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/EPWModel.kt
@@ -11,8 +11,8 @@
 */
class EPWModel {
//    private val windDirWeight = WindDirWeight()
//    private val windDisWeight = WindDisWeight()
    private val windDirWeight = WindDirWeight()
    private val windDisWeight = WindDisWeight()
    private lateinit var datas: List<DataVo>
    private lateinit var sources: List<Company>
@@ -23,15 +23,26 @@
                return@d
            }
            var con = 0
            var ws = 0.0
            var wd = 0
            var hr = 0
            val lng = d.lng
            val lat = d.lat
            sources.forEach s@ { s ->
                // 经纬度有效性判断
                if (s.ciLongitude == null || s.ciLongitude == BigDecimal(0) || s.ciLatitude == null || s.ciLatitude == BigDecimal(0)) {
                    return@s
                }
                val p1 = Pair(d.lng!!, d.lat!!)
                val p1 = Pair(lng!!, lat!!)
                val p2 = Pair(s.ciLongitude.toDouble(), s.ciLatitude.toDouble())
//                windDirWeight.getWeight(p1, p2)
                windDirWeight.getWeight(p1, p2, wd)
                windDisWeight.getWeight(p1, p2, ws)
            }
        }
    }
src/main/kotlin/com/flightfeather/uav/model/epw/WindDisWeight.kt
@@ -1,6 +1,8 @@
package com.flightfeather.uav.model.epw
import com.flightfeather.uav.model.BaseWeight
import kotlin.math.abs
import kotlin.math.sqrt
/**
 * 风速距离权重
@@ -12,7 +14,14 @@
    override val weights: List<Double> = listOf(1.0, 0.8, 0.6, 0.5, 0.3, 0.0)
    fun getWeight(dis: Double, ws: Double): Double {
        val value = dis / ws / 60
        val value = dis / 1000 / ws / 60
        return weightCal(value)
    }
    fun getWeight(p1: Pair<Double, Double>, p2: Pair<Double, Double>, ws: Double): Double {
        val dx = p2.first - p1.first
        val dy = p2.second - p1.second
        val dis = sqrt(abs(dx * dx) + abs(dy * dy)) * 100
        return getWeight(dis, ws)
    }
}