feiyu02
23 小时以前 8eb584869b4fd4de0f51c93f2616f12e51df9193
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt
@@ -1,5 +1,7 @@
package com.flightfeather.uav.biz.sourcetrace.model
import com.flightfeather.uav.biz.FactorFilter
import com.flightfeather.uav.biz.dataanalysis.model.ExceptionTag
import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig
import com.flightfeather.uav.common.net.AMapService
import com.flightfeather.uav.common.utils.MapUtil
@@ -20,23 +22,32 @@
     */
    constructor(
        historyData: List<BaseRealTimeData>,
        exceptionData: List<BaseRealTimeData>,
        pollutedData: PollutedData,
        config: RTExcWindLevelConfig,
        windLevelCondition: RTExcWindLevelConfig.WindLevelCondition?,
    ) : this() {
    ) : this(){
        distanceType = windLevelCondition?.distanceType
        distanceRange = distanceType?.disRange
        distanceDes = distanceType?.des
        windLevelCondition?.let { sourceTrace(historyData, exceptionData, config, it) }
        windLevelCondition?.let { sourceTrace(pollutedData, config, it) }
    }
    // 所属街镇
    var township:String? = null
    // 格式化地址
    var address: String? = null
    // 交叉路段信息
    // 所在道路名称
    var street:String? = null
    // 所在道路上的最近门牌号
    var streetNumber:String? = null
    // 处于该门牌号的方向
    var direction:String? = null
    // 处于该门牌号的方向距离
    var distance: String? = null
    // 所处最近交叉路口的方向和距离
    var roadinter:String? = null
    // 所处最近交叉路口的距离
    var distance2: String? = null
    // 污染范围扇形区域(经纬度多边形)
    var polygon: List<Pair<Double, Double>>? = null
@@ -54,19 +65,13 @@
     * 反向溯源
     */
    private fun sourceTrace(
        historyData: List<BaseRealTimeData>,
        exceptionData: List<BaseRealTimeData>,
        pollutedData: PollutedData,
        config: RTExcWindLevelConfig,
        windLevelCondition: RTExcWindLevelConfig.WindLevelCondition,
    ) {
        val avgData = if (exceptionData.size == 1) {
            exceptionData.first()
        } else {
            exceptionData.avg()
        }
        val avgData = pollutedData.getExceptionAvgData()
        val pair = avgData.longitude!!.toDouble() to avgData.latitude!!.toDouble()
        polygon = calSector(
            avgData.windDirection?.toDouble() ?: .0,
            pair,
@@ -77,7 +82,7 @@
            MapUtil.wgs84ToGcj02(it)
        }
        closePolygon = closeSourceTrace(historyData, pair).map {
        closePolygon = closeSourceTrace(pair).map {
            // 将坐标转换为gcj02(火星坐标系),因为污染源场景信息都为此坐标系
            MapUtil.wgs84ToGcj02(it)
        }
@@ -85,10 +90,15 @@
        if (config.isSearchAddress) {
            try {
                val address = AMapService.reGeo(MapUtil.wgs84ToGcj02(pair))
                this.township = address.province+address.district+address.township
                this.address = address.address + address.streetNumber
                this.township = address.province + address.district + address.township
                this.address = address.address
                this.street = address.street
                this.streetNumber = address.streetNumber
                this.direction = address.direction
                this.distance = address.distance
                this.roadinter = address.roadinter
//                Thread.sleep(100)
                this.distance2 = address.distance2
                Thread.sleep(100)
            } catch (e: Exception) {
                e.printStackTrace()
            }
@@ -146,10 +156,7 @@
        return result
    }
    private fun closeSourceTrace(
        historyData: List<BaseRealTimeData>,
        center: Pair<Double, Double>,
    ): List<Pair<Double, Double>> {
    private fun closeSourceTrace(center: Pair<Double, Double>): List<Pair<Double, Double>> {
        val result = mutableListOf<Pair<Double, Double>>()
        var startDeg = 0
        while (startDeg <= 360) {