| | |
| | | import com.flightfeather.uav.common.utils.MapUtil |
| | | import com.flightfeather.uav.domain.entity.SceneInfo |
| | | import com.flightfeather.uav.domain.repository.SceneInfoRep |
| | | import com.flightfeather.uav.lightshare.bean.AreaVo |
| | | import com.flightfeather.uav.lightshare.bean.SceneInfoVo |
| | | import com.flightfeather.uav.lightshare.eunm.SceneType |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.web.context.ContextLoader |
| | | import kotlin.math.min |
| | | |
| | | /** |
| | | * 污染来源 |
| | |
| | | */ |
| | | |
| | | // 溯源企业 |
| | | var sceneList:List<SceneInfo?>? = null |
| | | var sceneList:List<SceneInfoVo?>? = null |
| | | |
| | | init { |
| | | |
| | | } |
| | | |
| | | fun searchScenes(pollutedArea: PollutedArea, factor: FactorFilter.SelectedFactor) { |
| | | ContextLoader.getCurrentWebApplicationContext()?.getBean(SceneInfoRep::class.java)?.run { |
| | |
| | | fun searchScenes(pollutedArea: PollutedArea, sceneInfoRep: SceneInfoRep, factor: FactorFilter.SelectedFactor) { |
| | | // Fixme 2025.5.14: 污染源的坐标是高德地图坐标系(火星坐标系),而走航数据是WGS84坐标系 |
| | | // 按照区域检索内部污染源信息 |
| | | // 1. 首先按照四至范围从数据库初步筛选污染源,需要先将坐标转换为gcj02(火星坐标系),因为污染源场景信息都为此坐标系 |
| | | val polygonTmp = pollutedArea.polygon!!.map { |
| | | MapUtil.gcj02ToWgs84(it) |
| | | } |
| | | // 1. 首先按照四至范围从数据库初步筛选污染源 |
| | | // val polygonTmp = pollutedArea.polygon!!.map { |
| | | // MapUtil.gcj02ToWgs84(it) |
| | | // } |
| | | val polygonTmp = pollutedArea.polygon!! |
| | | val fb = MapUtil.calFourBoundaries(polygonTmp) |
| | | val sceneList = sceneInfoRep.findByCoordinateRange(fb) |
| | | // 2. 再精确判断是否在反向溯源区域多边形内部 |
| | |
| | | } |
| | | } |
| | | |
| | | this.sceneList = result |
| | | findClosestStation(sceneInfoRep, result) |
| | | |
| | | TODO("按照所选监测因子类型,区分污染源类型") |
| | | |
| | | // TODO("按照所选监测因子类型,区分污染源类型") |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 计算可能的相关污染场景类型 |
| | | */ |
| | | private fun calFactorType(factor: FactorFilter.SelectedFactor) { |
| | | // when (factor.main) { |
| | | // FactorType.PM25 -> {} |
| | | // |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 计算最近的监测站点 |
| | | */ |
| | | private fun findClosestStation(sceneInfoRep: SceneInfoRep, sceneList: List<SceneInfo>) { |
| | | val res1 = sceneInfoRep.findByArea(AreaVo().apply { |
| | | sceneTypeId = SceneType.TYPE19.value.toString() |
| | | }) |
| | | |
| | | val res2 = sceneInfoRep.findByArea(AreaVo().apply { |
| | | sceneTypeId = SceneType.TYPE20.value.toString() |
| | | }) |
| | | val res = res1.toMutableList().apply { addAll(res2) } |
| | | |
| | | this.sceneList = sceneList.map { |
| | | var minLen = -1.0 |
| | | var selectedRes: SceneInfo? = null |
| | | res.forEach { r-> |
| | | val dis = MapUtil.getDistance( |
| | | it.longitude.toDouble(), |
| | | it.latitude.toDouble(), |
| | | r!!.longitude.toDouble(), |
| | | r.latitude.toDouble() |
| | | ) |
| | | if (minLen < 0 || dis < minLen) { |
| | | minLen = dis |
| | | selectedRes = r |
| | | } |
| | | } |
| | | val vo = SceneInfoVo() |
| | | BeanUtils.copyProperties(it, vo) |
| | | vo.closestStation = selectedRes |
| | | vo.length = minLen |
| | | |
| | | return@map vo |
| | | } |
| | | } |
| | | } |