From d978297ae85b2d7453054e616bbbe87bfabe9cbe Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 12 七月 2021 17:38:09 +0800
Subject: [PATCH] 1. 新增用电量数据查询接口 2. 调整污染权重算法

---
 src/main/kotlin/com/flightfeather/uav/model/epw/WindDirWeight.kt |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/model/epw/WindDirWeight.kt b/src/main/kotlin/com/flightfeather/uav/model/epw/WindDirWeight.kt
index 1ede99c..3dbde08 100644
--- a/src/main/kotlin/com/flightfeather/uav/model/epw/WindDirWeight.kt
+++ b/src/main/kotlin/com/flightfeather/uav/model/epw/WindDirWeight.kt
@@ -11,7 +11,7 @@
 /**
  * 椋庡悜鏉冮噸
  */
-class WindDirWeight : BaseWeight<DataVo, CompanySOP>() {
+class WindDirWeight(var defaultLocation: Pair<Double, Double>?) : BaseWeight<DataVo, CompanySOP>() {
 
     override val tag: String = "椋庡悜鏉冮噸"
 
@@ -19,8 +19,9 @@
 
     override val weights: List<Double> = listOf(1.0, 0.8, 0.5, 0.2, 0.1)
 
-    override fun onWeightFactor(mData: DataVo, sop: CompanySOP): Double? {
-        val p1 = Pair(mData.lng!!, mData.lat!!)
+    override fun onWeightFactor(mData: DataVo, sop: CompanySOP): 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 wd = mData.getFactorData(FactorType.WIND_DIRECTION) ?: 0.0
         return getAngle(p1, p2, wd)

--
Gitblit v1.9.3