From 594de76ed51fd49fb79b912212bb0052a63e7671 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 09 四月 2026 16:10:45 +0800
Subject: [PATCH] 2026.4.9
---
src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt | 76 +++++++++++++++++++++++++++++--------
1 files changed, 59 insertions(+), 17 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt b/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
index c17296d..92cca2d 100644
--- a/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
@@ -12,6 +12,7 @@
import kotlin.math.min
import kotlin.math.round
import kotlin.math.sqrt
+import kotlin.time.times
/**
* 鏁版嵁骞虫粦棰勫鐞�
@@ -29,10 +30,7 @@
// 鍧囧�煎�嶆暟鍙傛暟
private val xratio = 3
- // 杩炵画鏁版嵁鐨勫悎鐞嗘渶澶у闀垮�嶇巼
- private val multiplier = 20
-
- // 闇�瑕佸鐞嗙殑鍥犲瓙绫诲瀷
+ // 闇�瑕佸钩婊戝鐞嗙殑鍥犲瓙绫诲瀷
private var calTypes = when (deviceType) {
UWDeviceType.VEHICLE,
UWDeviceType.UAV,
@@ -41,6 +39,25 @@
UWDeviceType.GRID -> WeightType.prepFixed
else -> WeightType.prepFixed
}
+
+ // 鍙渶瑕佹鏌ヨ寖鍥村拰鍙樺寲骞呭害鐨勫洜瀛愮被鍨�
+ private var rangeTypes = listOf(
+ FactorType.PM25.des,
+ FactorType.PM10.des,
+ FactorType.VOC.des
+ )
+
+ // 鏃犻渶淇鐨勫洜瀛愮被鍨�
+ private var noCalTypes = listOf(
+ FactorType.TEMPERATURE.des,
+ FactorType.HUMIDITY.des,
+ FactorType.LNG.des,
+ FactorType.LAT.des,
+ FactorType.VELOCITY.des,
+ FactorType.TIME.des,
+ FactorType.WIND_DIRECTION.des,
+ FactorType.HEIGHT.des
+ )
private val lastData = mutableListOf<DataVo>()
@@ -66,7 +83,7 @@
val it = mDataList[i].values?.get(y) ?: continue
if (!calTypes.contains(it.factorName)) continue
- val vMax = FactorType.getVMax(it.factorName) ?: continue
+ val vMax = FactorType.getVMin(it.factorName) ?: continue
it.factorData ?: continue
if (it.factorData!! > vMax) {
@@ -132,9 +149,10 @@
i = 0
}
while (i < mDataList.size) {
+ // 閽堝姣忎釜鐩戞祴鍥犲瓙锛屽垎鍒仛鏁版嵁骞虫粦澶勭悊
for (y in mDataList[i].values?.indices ?: 0..0) {
val it = mDataList[i].values?.get(y) ?: continue
- val vMax = FactorType.getVMax(it.factorName) ?: continue
+ val vMax = FactorType.getVMin(it.factorName) ?: continue
it.factorData ?: continue
if (it.factorData!! > vMax) {
@@ -151,26 +169,50 @@
// 鍘婚櫎鏃犳晥鍊肩殑鏍囧噯宸�
val std = standardDeviation(avg.first, list, it.factorName)
// 鍚堢悊鏈�澶у��
- val max = max(avg.first + std * nstd, avg.first + avg.first * xratio)
+ var maxValue = max(avg.first + std * nstd, avg.first + avg.first * xratio)
+ maxValue = max(maxValue, FactorType.getRange(it.factorName)?.second ?: .0)
// 鍚堢悊鏈�灏忓��
- val min = min(avg.first - std * nstd, avg.first / (1 + xratio))
+ val minValue = min(avg.first - std * nstd, avg.first / (1 + xratio))
// 鍒ゆ柇鐩戞祴鍥犲瓙鏄惁闇�瑕佽繘琛屽钩婊戝鐞嗭紝
- // 鑻ヤ笉闇�瑕侊紝鍒欏垽鏂噺绾ф槸鍚﹀湪鍚堢悊鑼冨洿鍐呬互鍙婂彉鍖栧�嶇巼鏄惁鍦ㄥ悎鐞嗚寖鍥村唴
- if (!calTypes.contains(it.factorName)) {
- if (isInRange(it) != true || excessiveChange(it) == true) {
- // 閲囩敤璁$畻鎵�寰楀潎鍊间唬鏇垮師濮嬪��
- it.factorData = avg.first
- }
- } else {
+ if (calTypes.contains(it.factorName)) {
// 鏁版嵁涓嶅浜庡悎鐞嗚寖鍥村苟涓旀湁鏁堜釜鏁拌揪鏍囨椂锛岄噰鐢ㄨ绠楁墍寰楀潎鍊间唬鏇垮師濮嬪��
if (avg.second > max(ncal / 5, 2)
- && (it.factorData!! < min || it.factorData!! > max)
+ && (it.factorData!! < minValue || it.factorData!! > maxValue)
) {
it.factorData = avg.first
}
}
+ // 鍒ゆ柇閲忕骇鏄惁鍦ㄥ悎鐞嗚寖鍥村唴浠ュ強鍙樺寲鍊嶇巼鏄惁鍦ㄥ悎鐞嗚寖鍥村唴
+ else if (rangeTypes.contains(it.factorName)) {
+ if (isInRange(it) != true || excessiveChange(it) == true) {
+ // 閲囩敤璁$畻鎵�寰楀潎鍊间唬鏇垮師濮嬪��
+ it.factorData = avg.first
+ }
+ }
+ }
+ }
+ }
+ // 鏍规嵁鐗╃悊瑙勫緥锛屽墧闄ゆ垨淇涓嶅悎鐞嗙殑鏁版嵁
+ val data = mDataList[i]
+ // 1. PM2.5 搴旇濮嬬粓灏忎簬PM10
+ val pm25 = data.getFactorData(FactorType.PM25)
+ val pm10 = data.getFactorData(FactorType.PM10)
+ if (pm25 != null && pm10 != null) {
+ // 鑻m2.5澶т簬pm10
+ if (pm25 >= pm10){
+ val lastIndex = i - 1
+ // 鍒欏皢pm2.5淇敼涓哄墠涓�涓暟鎹殑鍊�
+ if (lastIndex >= 0) {
+ data.setFactorData(FactorType.PM25, mDataList[lastIndex].getFactorData(FactorType.PM25))
+ } else {
+ if (lastData.isEmpty()) {
+ // 娌℃湁鍘嗗彶鏁版嵁鏃讹紝淇敼涓簆m10鐨�80%(鍚庣画寰呬紭鍖栨瘮渚� 2026.3.6)
+ data.setFactorData(FactorType.PM25, data.getFactorData(FactorType.PM10)?.times(.8))
+ } else {
+ data.setFactorData(FactorType.PM25, lastData.last().getFactorData(FactorType.PM25))
+ }
}
}
}
@@ -289,6 +331,6 @@
break
}
}
- return m > multiplier
+ return m > FactorType.getMultiplier(airData.factorName)
}
}
\ No newline at end of file
--
Gitblit v1.9.3