From 4d065a305b997bfb66f41b33a31d59de63b1958d Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 29 五月 2025 17:43:21 +0800 Subject: [PATCH] 1. 新增动态污染溯源新的判定逻辑(待完成) --- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt | 101 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 99 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt index bcfe4e2..fac9ce7 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt @@ -1,18 +1,115 @@ package com.flightfeather.uav.biz.sourcetrace.model +import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig +import com.flightfeather.uav.common.net.AMapService +import com.flightfeather.uav.common.utils.MapUtil +import com.flightfeather.uav.domain.entity.BaseRealTimeData +import com.flightfeather.uav.domain.entity.avg +import kotlin.math.PI + /** * 鍔ㄦ�佹函婧愭薄鏌撳尯鍩� * 閫氳繃鍦板浘鍧愭爣鐐瑰舰鎴愬杈瑰舰鏉ユ弿杩颁竴鍧楁薄鏌撳尯鍩� * @date 2025/5/27 * @author feiyu02 */ -class PollutedArea { +class PollutedArea() { - var name: String? = null + /** + * 婧簮瑙掑害鍙缃� + */ + + constructor( + exceptionData: List<BaseRealTimeData>, + config: RTExcWindLevelConfig, + windLevelCondition: RTExcWindLevelConfig.WindLevelCondition, + ) : this() { + distanceType = windLevelCondition.mutationRate.second + sourceTrace(exceptionData, config, windLevelCondition) + } + + var address: String? = null // 姹℃煋鑼冨洿鍖哄煙(缁忕含搴﹀杈瑰舰) var polygon: List<Pair<Double, Double>>? = null // 姹℃煋鍙兘鐨勫彂鐢熻窛绂� var distanceType: DistanceType? = null + + /** + * 鍙嶅悜婧簮 + */ + private fun sourceTrace( + exceptionData: List<BaseRealTimeData>, + config: RTExcWindLevelConfig, + windLevelCondition: RTExcWindLevelConfig.WindLevelCondition, + ) { + val avgData = if (exceptionData.size == 1) { + exceptionData.first() + } else { + exceptionData.avg() + } + + val pair = avgData.longitude!!.toDouble() to avgData.latitude!!.toDouble() + + polygon = calSector( + avgData.windSpeed!!.toDouble(), + pair, + windLevelCondition.mutationRate.second.disRange, + config.sourceTraceDegOffset + ) + + try { + val address = AMapService.reGeo(pair) + this.address = address.township + address.street + } catch (e: Exception) { + e.printStackTrace() + } + + } + + /** + * 鏍规嵁涓績鐐瑰潗鏍囥�侀鍚戝拰婧簮璺濈锛屼互鍙婄粰瀹氱殑澶硅锛岃绠椾互涓績鐐规寜鐓ч鍚戝悜澶栨墿鏁e舰鎴愮殑鎵囧舰鐨勭偣鍧愭爣 + * @param windDir 椋庡悜锛屽崟浣嶏細搴� + * @param center 涓績鐐瑰潗鏍囩粡绾害 + * @param distanceRange 婧簮璺濈鑼冨洿锛屽崟浣嶏細绫� + * @param defaultDegOffset 鎵╂暎鍋忕Щ瑙掑害 + * @return 澶氳竟褰㈤《鐐瑰潗鏍囬泦鍚� + */ + private fun calSector( + windDir: Double, + center: Pair<Double, Double>, + distanceRange: Pair<Double, Double>, + defaultDegOffset: Double = 60.0, + ): List<Pair<Double, Double>> { + + val sDeg = windDir - defaultDegOffset / 2 + val eDeg = windDir + defaultDegOffset / 2 + + val result = mutableListOf<Pair<Double, Double>>() + + if (distanceRange.first == .0) { + result.add(center) + } else { + // 浠庡紑濮嬭搴﹀惊鐜绠楀潗鏍囩偣鍊肩粨鏉熻搴︼紝姝ラ暱1掳 + var startDeg = sDeg + while (startDeg <= eDeg) { + val p = MapUtil.getPointByLen(center, distanceRange.first, startDeg * PI / 180) + result.add(p) + startDeg++ + } + } + + if (distanceRange.second > .0) { + // 姝ゅ闇�瑕佷粠缁撴潫瑙掑害寮�濮嬪弽鍚戝惊鐜绠楄嚦寮�濮嬭搴︼紝姝ラ暱1掳锛屼娇寰椾袱缁勫潗鏍囩偣鎸夐『搴忔帓鍒楋紝鍙粯鍒跺搴旂殑澶氳竟褰� + var startDeg = eDeg + while (startDeg >= sDeg) { + val p = MapUtil.getPointByLen(center, distanceRange.second, startDeg * PI / 180) + result.add(p) + startDeg-- + } + } + + return result + } } \ No newline at end of file -- Gitblit v1.9.3