feiyu02
2025-01-09 6c1e7c5ac983301c34f003415cda2ef7c7e176a6
src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt
@@ -1,6 +1,8 @@
package com.flightfeather.uav.biz.satellite
import com.flightfeather.uav.common.utils.MapUtil
import com.flightfeather.uav.domain.entity.GridCell
import kotlin.math.PI
import kotlin.math.sqrt
/**
@@ -10,12 +12,13 @@
 * @date 2025/1/8
 * @author feiyu02
 */
class SatelliteGridManage {
object SatelliteGridManage {
    /**
     * 根据正方形网格中心点坐标,计算4个顶点坐标
     * @param points 网格中心坐标点数组
     */
    fun calGridVertex(points:List<Pair<Double, Double>>):List<Array<Pair<Double, Double>>> {
    fun calGridVertex(points: List<Pair<Double, Double>>): List<GridVertex> {
        if (points.size < 2) return emptyList()
        val p1 = points[0];
        val p2 = points[1];
@@ -27,13 +30,13 @@
        val halfDiagonal = sqrt((dis / 2) * (dis / 2) * 2);
        // 计算首个正方形各顶点相对于中心点的角度,得到正方形各顶点的坐标
        val angle1 = MapUtil.plusAngle(angle, 45.0);
        val gp1 = MapUtil.getPointByLen(p1, halfDiagonal, angle1);
        val gp1 = MapUtil.getPointByLen(p1, halfDiagonal, angle1 * PI / 180);
        val angle2 = MapUtil.plusAngle(angle1, 90.0);
        val gp2 = MapUtil.getPointByLen(p1, halfDiagonal, angle2);
        val gp2 = MapUtil.getPointByLen(p1, halfDiagonal, angle2 * PI / 180);
        val angle3 = MapUtil.plusAngle(angle2, 90.0);
        val gp3 = MapUtil.getPointByLen(p1, halfDiagonal, angle3);
        val gp3 = MapUtil.getPointByLen(p1, halfDiagonal, angle3 * PI / 180);
        val angle4 = MapUtil.plusAngle(angle3, 90.0);
        val gp4 = MapUtil.getPointByLen(p1, halfDiagonal, angle4);
        val gp4 = MapUtil.getPointByLen(p1, halfDiagonal, angle4 * PI / 180);
        // 计算4个顶点分别与中心点的经纬度差值
        val dx1 = gp1.first - p1.first
        val dy1 = gp1.second - p1.second
@@ -45,12 +48,12 @@
        val dy4 = gp4.second - p1.second
        // 得到所有正方形网格的4个顶点信息
        return points.map { p->
            arrayOf(
                p.first + dx1 to p.second + dy1,
                p.first + dx2 to p.second + dy2,
                p.first + dx3 to p.second + dy3,
                p.first + dx4 to p.second + dy4,
        return points.map { p ->
            GridVertex(
                p.first + dx1, p.second + dy1,
                p.first + dx2, p.second + dy2,
                p.first + dx3, p.second + dy3,
                p.first + dx4, p.second + dy4,
            )
        }
    }
@@ -58,8 +61,8 @@
    /**
     * 拆分网格
     */
    fun splitGrid() {
    fun splitGrid(gridCellList: List<GridCell?>): List<GridCell> {
        TODO()
    }
}