feiyu02
2025-05-29 4d065a305b997bfb66f41b33a31d59de63b1958d
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt
@@ -1,5 +1,10 @@
package com.flightfeather.uav.biz.sourcetrace.model
import com.flightfeather.uav.biz.FactorFilter
import com.flightfeather.uav.common.utils.MapUtil
import com.flightfeather.uav.domain.entity.SceneInfo
import com.flightfeather.uav.domain.repository.SceneInfoRep
/**
 * 污染来源
 * 系统内部的污染场景、电子地图搜索得到的实际路段路口等标志信息
@@ -8,5 +13,38 @@
 */
class PollutedSource {
    /**
     * 溯源清单显示与临近监测站点的距离(国控、市控、网格化监测点)
     *
     */
    // 溯源企业
    var sceneList:List<SceneInfo?>? = null
    /**
     * 查找系统内部溯源范围内的污染企业
     */
    fun searchScenes(pollutedArea: PollutedArea, sceneInfoRep: SceneInfoRep, factor: FactorFilter.SelectedFactor) {
        // Fixme 2025.5.14: 污染源的坐标是高德地图坐标系(火星坐标系),而走航数据是WGS84坐标系
        // 按照区域检索内部污染源信息
        // 1. 首先按照四至范围从数据库初步筛选污染源,需要先将坐标转换为gcj02(火星坐标系),因为污染源场景信息都为此坐标系
        val polygonTmp = pollutedArea.polygon!!.map {
            MapUtil.gcj02ToWgs84(it)
        }
        val fb = MapUtil.calFourBoundaries(polygonTmp)
        val sceneList = sceneInfoRep.findByCoordinateRange(fb)
        // 2. 再精确判断是否在反向溯源区域多边形内部
        val result = mutableListOf<SceneInfo>()
        sceneList.forEach {
            val point = it!!.longitude.toDouble() to it.latitude.toDouble()
            if (MapUtil.isPointInPolygon(point, polygonTmp)) {
                result.add(it)
            }
        }
        this.sceneList = result
        TODO("按照所选监测因子类型,区分污染源类型")
    }
}