1. 修改融合数据逻辑中,融合数据id数组为先排序后转换为字符串,修复同一批原始数据因为id排序不一样被判定为不同的融合数据的问题;
已修改3个文件
已添加2个文件
184 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteDataMix.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt 110 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteDataMix.kt
@@ -50,7 +50,7 @@
            groupId = firstGridData?.groupId
            dataTime = Date()
            type = SatelliteDataType.Mix.value.toByte()
            mixDataId = dataIdList.joinToString(",")
            mixDataId = dataIdList.sorted().joinToString(",")
        }
        gridDataMapper.insert(avgGridData)
src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt
@@ -16,27 +16,32 @@
    /**
     * æ ¹æ®æ­£æ–¹å½¢ç½‘格中心点坐标,计算4个顶点坐标
     * ç½‘格中心点坐标按照从左到右、从上到下的顺序排列
     * @param points ç½‘格中心坐标点数组
     */
    fun calGridVertex(points: List<Pair<Double, Double>>): List<GridVertex> {
        // ç½‘格少于2个,则无法绘制
        if (points.size < 2) return emptyList()
        val p1 = points[0];
        val p2 = points[1];
        // èŽ·å–å‰ä¸¤ä¸ªç½‘æ ¼
        // Fixme 2025.01.10: ç›®å‰å…ˆç®€åŒ–逻辑,按照前两个点是左右排布,且点p2在点p1的东边
        val p1 = points[0]
        val p2 = points[1]
        // ä¸¤ä¸­å¿ƒç‚¹é—´çš„角度
        val angle = MapUtil.getAngle(p1.first, p1.second, p2.first, p2.second);
        val angle = MapUtil.getAngle(p1.first, p1.second, p2.first, p2.second)
        // ä¸¤ä¸­å¿ƒç‚¹é—´çš„距离
        val dis = MapUtil.getDistance(p1.first, p1.second, p2.first, p2.second);
        val dis = MapUtil.getDistance(p1.first, p1.second, p2.first, p2.second)
        // ç½‘格正方形对角线的一半长度
        val halfDiagonal = sqrt((dis / 2) * (dis / 2) * 2);
        val halfDiagonal = sqrt((dis / 2) * (dis / 2) * 2)
        // è®¡ç®—首个正方形各顶点相对于中心点的角度,得到正方形各顶点的坐标
        val angle1 = MapUtil.plusAngle(angle, 45.0);
        val gp1 = MapUtil.getPointByLen(p1, halfDiagonal, angle1 * PI / 180);
        val angle2 = MapUtil.plusAngle(angle1, 90.0);
        val gp2 = MapUtil.getPointByLen(p1, halfDiagonal, angle2 * PI / 180);
        val angle3 = MapUtil.plusAngle(angle2, 90.0);
        val gp3 = MapUtil.getPointByLen(p1, halfDiagonal, angle3 * PI / 180);
        val angle4 = MapUtil.plusAngle(angle3, 90.0);
        val gp4 = MapUtil.getPointByLen(p1, halfDiagonal, angle4 * PI / 180);
        // 4个顶点按照从左上角开始,顺时针方向的顺序进行排列
        val angle1 = MapUtil.plusAngle(angle, 45.0 + 180.0)
        val gp1 = MapUtil.getPointByLen(p1, halfDiagonal, angle1 * PI / 180)
        val angle2 = MapUtil.plusAngle(angle1, 90.0)
        val gp2 = MapUtil.getPointByLen(p1, halfDiagonal, angle2 * PI / 180)
        val angle3 = MapUtil.plusAngle(angle2, 90.0)
        val gp3 = MapUtil.getPointByLen(p1, halfDiagonal, angle3 * PI / 180)
        val angle4 = MapUtil.plusAngle(angle3, 90.0)
        val gp4 = MapUtil.getPointByLen(p1, halfDiagonal, angle4 * PI / 180)
        // è®¡ç®—4个顶点分别与中心点的经纬度差值
        val dx1 = gp1.first - p1.first
        val dy1 = gp1.second - p1.second
@@ -59,10 +64,83 @@
    }
    /**
     * æ‹†åˆ†ç½‘æ ¼
     * æ‹†åˆ†ç½‘格为细分网格
     * æ ¹æ®ç›¸ä¼¼çŸ©å½¢çš„原理,可以分别按比例得到每个细分网格的经纬度
     * @param gridCellList åŽŸå§‹ç½‘æ ¼æ•°ç»„
     * @param scale æ‹†åˆ†çš„系数,例如 2,表示将原有网格按边长的 1/2 æ‹†åˆ†æˆ 2 * 2 çš„4个网格
     */
    fun splitGrid(gridCellList: List<GridCell?>): List<GridCell> {
        TODO()
    fun splitGrid(gridCellList: List<GridCell>, scale: Int): List<GridCell> {
        if (scale <= 0) throw IllegalArgumentException("网格拆分的数量不能小于1")
        // æ‹†åˆ†ç³»æ•°ä¸º1,则表示不拆分
        if (scale == 1) return gridCellList
        if (gridCellList.isEmpty()) return emptyList()
        val newGridCellList = mutableListOf<GridCell>()
        // æ ¹æ®å‡½æ•°[calGridVertex]生成的网格4个顶点坐标,以上北下南左西右东方向为标准
        // è®¡ç®—首个网格中心坐标点分别和4个顶点的经纬度差值
        val p = gridCellList[0]
        // ï¼ˆé€šè¿‡è¿‘似平面坐标系的方式)根据单个原始网格的4个顶点坐标,分别确定以下三组坐标点之间的经纬度单位偏移量
        val p1 = p.point1Lon to p.point1Lat
        val p2 = p.point2Lon to p.point2Lat
        val p3 = p.point3Lon to p.point3Lat
        val p4 = p.point4Lon to p.point4Lat
        // p1、p3的经纬度单位差值
        val dx1 = (p3.first - p1.first) / scale.toBigDecimal()
        val dy1 = (p3.second - p1.second) / scale.toBigDecimal()
        // p1、p2的经纬度单位差值
        val dx2 = (p2.first - p1.first) / scale.toBigDecimal()
        val dy2 = (p2.second - p1.second) / scale.toBigDecimal()
        // p3、p4的经纬度单位差值
        val dx3 = (p4.first - p3.first) / scale.toBigDecimal()
        val dy3 = (p4.second - p3.second) / scale.toBigDecimal()
        // ä¸­å¿ƒç‚¹å’Œp1的经纬度单位差值
        val dxC = (p.longitude - p1.first) / scale.toBigDecimal()
        val dyC = (p.latitude - p1.second) / scale.toBigDecimal()
        // ç½‘格行循环
        for (row in 0 until scale) {
            val newGridCell1 = GridCell()
            // ç¡®å®šæ¯ä¸€è¡Œé¦–个细分网格的中心坐标和4个顶点坐标
            // å·¦ä¸Šè§’顶点根据所在行数在原始网格顶点基础上增加偏移量
            newGridCell1.point1Lon = p1.first + dx1 * row.toBigDecimal()
            newGridCell1.point1Lat = p1.second + dy1 * row.toBigDecimal()
            // å·¦ä¸‹è§’顶点根据所在行数在原始网格顶点基础上增加偏移量(比左上角顶点多一个偏移)
            newGridCell1.point3Lon = p1.first + dx1 * (row + 1).toBigDecimal()
            newGridCell1.point3Lat = p1.second + dy1 * (row + 1).toBigDecimal()
            // å³ä¸Šè§’顶点在细分网格左上角的基础上增加相应的偏移量
            newGridCell1.point2Lon = newGridCell1.point1Lon + dx2
            newGridCell1.point2Lat = newGridCell1.point1Lat + dy2
            // å³ä¸‹è§’顶点在细分网格左下角的基础上增加相应的偏移量
            newGridCell1.point4Lon = newGridCell1.point3Lon + dx3
            newGridCell1.point4Lat = newGridCell1.point3Lat + dy3
            // ä¸­å¿ƒç‚¹åœ¨ç»†åˆ†ç½‘格左上角的基础上增加固定偏移量
            newGridCell1.longitude = newGridCell1.point1Lon + dxC
            newGridCell1.latitude = newGridCell1.point1Lat + dyC
            // åŠ å…¥ç»“æžœé›†åˆ
            newGridCellList.add(newGridCell1)
            // ç½‘格列循环(从第2列开始)
            for (col in 1 until scale) {
                val newGridCell = GridCell()
                newGridCell.point1Lon = newGridCell1.point1Lon + dx2 * col.toBigDecimal()
                newGridCell.point1Lat = newGridCell1.point1Lat + dy2 * col.toBigDecimal()
                newGridCell.point2Lon = newGridCell1.point2Lon + dx2 * col.toBigDecimal()
                newGridCell.point2Lat = newGridCell1.point2Lat + dy2 * col.toBigDecimal()
                newGridCell.point3Lon = newGridCell1.point3Lon + dx3 * col.toBigDecimal()
                newGridCell.point3Lat = newGridCell1.point3Lat + dy3 * col.toBigDecimal()
                newGridCell.point4Lon = newGridCell1.point4Lon + dx3 * col.toBigDecimal()
                newGridCell.point4Lat = newGridCell1.point4Lat + dy3 * col.toBigDecimal()
                newGridCell.longitude = newGridCell.point1Lon + dxC
                newGridCell.latitude = newGridCell.point1Lat + dyC
                newGridCellList.add(newGridCell)
            }
        }
        return newGridCellList
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.flightfeather.uav.lightshare.service
import com.flightfeather.uav.domain.entity.GridCell
/**
 *
 * @date 2025/1/13
 * @author feiyu02
 */
interface SatelliteDataCalculateService {
    /**
     * æ ¹æ®å«æ˜Ÿé¥æµ‹ç½‘格的中心坐标点,计算网格4个顶点坐标
     * @param groupId ç½‘格组索引id
     */
    fun calGridVertex(groupId: Int): List<GridCell?>
    fun splitGrid(groupId: Int): List<GridCell?>
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,51 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.biz.satellite.SatelliteGridManage
import com.flightfeather.uav.common.exception.BizException
import com.flightfeather.uav.domain.entity.GridCell
import com.flightfeather.uav.domain.repository.SatelliteGridRep
import com.flightfeather.uav.lightshare.service.SatelliteDataCalculateService
import org.springframework.stereotype.Service
/**
 *
 * @date 2025/1/15
 * @author feiyu02
 */
@Service
class SatelliteDataCalculateServiceImpl(private val satelliteGridRep: SatelliteGridRep) : SatelliteDataCalculateService {
    override fun calGridVertex(groupId: Int): List<GridCell?> {
        val cellList = satelliteGridRep.fetchGridCell(groupId)
        val vertexList = SatelliteGridManage.calGridVertex(cellList.map {
            if (it?.longitude == null || it.latitude == null) {
                throw BizException("卫星遥测网格计算顶点坐标点失败,存在中心点坐标为空的情况")
            }
            it.longitude?.toDouble()!! to it.latitude?.toDouble()!!
        })
        cellList.forEachIndexed { i, c ->
            val v = vertexList[i]
            c?.point1Lon = v.point1Lon.toBigDecimal()
            c?.point1Lat = v.point1Lat.toBigDecimal()
            c?.point2Lon = v.point2Lon.toBigDecimal()
            c?.point2Lat = v.point2Lat.toBigDecimal()
            c?.point3Lon = v.point3Lon.toBigDecimal()
            c?.point3Lat = v.point3Lat.toBigDecimal()
            c?.point4Lon = v.point4Lon.toBigDecimal()
            c?.point4Lat = v.point4Lat.toBigDecimal()
        }
        satelliteGridRep.updateGridCellBatch(cellList)
        return cellList
    }
    override fun splitGrid(groupId: Int): List<GridCell?> {
        TODO("Not yet implemented")
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt
@@ -72,7 +72,7 @@
        // 1. æ ¹æ®æ•°æ®ä¸»é”®id数组,查询该组合下是否已有数据融合记录
        val exist = satelliteGridRep.fetchGridData(GridData().apply {
            type = 1
            mixDataId = dataIdList.joinToString(",")
            mixDataId = dataIdList.sorted().joinToString(",")
        })
        // 2. è‹¥èžåˆæ•°æ®å·²å­˜åœ¨ï¼Œç›´æŽ¥è¿”回
        return exist.ifEmpty {