feiyu02
2025-01-09 6c1e7c5ac983301c34f003415cda2ef7c7e176a6
1. 新增卫星遥测网格4个顶点坐标计算逻辑
已修改8个文件
已添加1个文件
229 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/biz/satellite/GridVertex.kt 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/GridCell.java 110 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/generator/generatorConfig.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/GridCellMapper.xml 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImplTest.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/satellite/GridVertex.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.flightfeather.uav.biz.satellite
/**
 * å«æ˜Ÿé¥æµ‹ç½‘格顶点信息
 * åŒ…含正方形网格的四个顶点坐标
 * @date 2025/1/9
 * @author feiyu02
 */
data class GridVertex(
    var point1Lon: Double,
    var point1Lat: Double,
    var point2Lon: Double,
    var point2Lat: Double,
    var point3Lon: Double,
    var point3Lat: Double,
    var point4Lon: Double,
    var point4Lat: Double,
)
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
@@ -46,11 +49,11 @@
        // å¾—到所有正方形网格的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,
            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()
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/GridCell.java
@@ -15,62 +15,62 @@
    private Integer groupId;
    /**
     * çº¬åº¦
     */
    private BigDecimal latitude;
    /**
     * ç»åº¦
     */
    private BigDecimal longitude;
    /**
     * çº¬åº¦
     */
    private BigDecimal latitude;
    /**
     * çŸ©å½¢ç½‘格顶点经度
     */
    @Column(name = "point1_lon")
    private String point1Lon;
    private BigDecimal point1Lon;
    /**
     * çŸ©å½¢ç½‘格顶点纬度
     */
    @Column(name = "point1_lat")
    private String point1Lat;
    private BigDecimal point1Lat;
    /**
     * çŸ©å½¢ç½‘格顶点经度
     */
    @Column(name = "point2_lon")
    private String point2Lon;
    private BigDecimal point2Lon;
    /**
     * çŸ©å½¢ç½‘格顶点纬度
     */
    @Column(name = "point2_lat")
    private String point2Lat;
    private BigDecimal point2Lat;
    /**
     * çŸ©å½¢ç½‘格顶点经度
     */
    @Column(name = "point3_lon")
    private String point3Lon;
    private BigDecimal point3Lon;
    /**
     * çŸ©å½¢ç½‘格顶点纬度
     */
    @Column(name = "point3_lat")
    private String point3Lat;
    private BigDecimal point3Lat;
    /**
     * çŸ©å½¢ç½‘格顶点经度
     */
    @Column(name = "point4_lon")
    private String point4Lon;
    private BigDecimal point4Lon;
    /**
     * çŸ©å½¢ç½‘格顶点纬度
     */
    @Column(name = "point4_lat")
    private String point4Lat;
    private BigDecimal point4Lat;
    /**
     * @return id
@@ -105,24 +105,6 @@
    }
    /**
     * èŽ·å–çº¬åº¦
     *
     * @return latitude - çº¬åº¦
     */
    public BigDecimal getLatitude() {
        return latitude;
    }
    /**
     * è®¾ç½®çº¬åº¦
     *
     * @param latitude çº¬åº¦
     */
    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }
    /**
     * èŽ·å–ç»åº¦
     *
     * @return longitude - ç»åº¦
@@ -141,11 +123,29 @@
    }
    /**
     * èŽ·å–çº¬åº¦
     *
     * @return latitude - çº¬åº¦
     */
    public BigDecimal getLatitude() {
        return latitude;
    }
    /**
     * è®¾ç½®çº¬åº¦
     *
     * @param latitude çº¬åº¦
     */
    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }
    /**
     * èŽ·å–çŸ©å½¢ç½‘æ ¼é¡¶ç‚¹ç»åº¦
     *
     * @return point1_lon - çŸ©å½¢ç½‘格顶点经度
     */
    public String getPoint1Lon() {
    public BigDecimal getPoint1Lon() {
        return point1Lon;
    }
@@ -154,8 +154,8 @@
     *
     * @param point1Lon çŸ©å½¢ç½‘格顶点经度
     */
    public void setPoint1Lon(String point1Lon) {
        this.point1Lon = point1Lon == null ? null : point1Lon.trim();
    public void setPoint1Lon(BigDecimal point1Lon) {
        this.point1Lon = point1Lon;
    }
    /**
@@ -163,7 +163,7 @@
     *
     * @return point1_lat - çŸ©å½¢ç½‘格顶点纬度
     */
    public String getPoint1Lat() {
    public BigDecimal getPoint1Lat() {
        return point1Lat;
    }
@@ -172,8 +172,8 @@
     *
     * @param point1Lat çŸ©å½¢ç½‘格顶点纬度
     */
    public void setPoint1Lat(String point1Lat) {
        this.point1Lat = point1Lat == null ? null : point1Lat.trim();
    public void setPoint1Lat(BigDecimal point1Lat) {
        this.point1Lat = point1Lat;
    }
    /**
@@ -181,7 +181,7 @@
     *
     * @return point2_lon - çŸ©å½¢ç½‘格顶点经度
     */
    public String getPoint2Lon() {
    public BigDecimal getPoint2Lon() {
        return point2Lon;
    }
@@ -190,8 +190,8 @@
     *
     * @param point2Lon çŸ©å½¢ç½‘格顶点经度
     */
    public void setPoint2Lon(String point2Lon) {
        this.point2Lon = point2Lon == null ? null : point2Lon.trim();
    public void setPoint2Lon(BigDecimal point2Lon) {
        this.point2Lon = point2Lon;
    }
    /**
@@ -199,7 +199,7 @@
     *
     * @return point2_lat - çŸ©å½¢ç½‘格顶点纬度
     */
    public String getPoint2Lat() {
    public BigDecimal getPoint2Lat() {
        return point2Lat;
    }
@@ -208,8 +208,8 @@
     *
     * @param point2Lat çŸ©å½¢ç½‘格顶点纬度
     */
    public void setPoint2Lat(String point2Lat) {
        this.point2Lat = point2Lat == null ? null : point2Lat.trim();
    public void setPoint2Lat(BigDecimal point2Lat) {
        this.point2Lat = point2Lat;
    }
    /**
@@ -217,7 +217,7 @@
     *
     * @return point3_lon - çŸ©å½¢ç½‘格顶点经度
     */
    public String getPoint3Lon() {
    public BigDecimal getPoint3Lon() {
        return point3Lon;
    }
@@ -226,8 +226,8 @@
     *
     * @param point3Lon çŸ©å½¢ç½‘格顶点经度
     */
    public void setPoint3Lon(String point3Lon) {
        this.point3Lon = point3Lon == null ? null : point3Lon.trim();
    public void setPoint3Lon(BigDecimal point3Lon) {
        this.point3Lon = point3Lon;
    }
    /**
@@ -235,7 +235,7 @@
     *
     * @return point3_lat - çŸ©å½¢ç½‘格顶点纬度
     */
    public String getPoint3Lat() {
    public BigDecimal getPoint3Lat() {
        return point3Lat;
    }
@@ -244,8 +244,8 @@
     *
     * @param point3Lat çŸ©å½¢ç½‘格顶点纬度
     */
    public void setPoint3Lat(String point3Lat) {
        this.point3Lat = point3Lat == null ? null : point3Lat.trim();
    public void setPoint3Lat(BigDecimal point3Lat) {
        this.point3Lat = point3Lat;
    }
    /**
@@ -253,7 +253,7 @@
     *
     * @return point4_lon - çŸ©å½¢ç½‘格顶点经度
     */
    public String getPoint4Lon() {
    public BigDecimal getPoint4Lon() {
        return point4Lon;
    }
@@ -262,8 +262,8 @@
     *
     * @param point4Lon çŸ©å½¢ç½‘格顶点经度
     */
    public void setPoint4Lon(String point4Lon) {
        this.point4Lon = point4Lon == null ? null : point4Lon.trim();
    public void setPoint4Lon(BigDecimal point4Lon) {
        this.point4Lon = point4Lon;
    }
    /**
@@ -271,7 +271,7 @@
     *
     * @return point4_lat - çŸ©å½¢ç½‘格顶点纬度
     */
    public String getPoint4Lat() {
    public BigDecimal getPoint4Lat() {
        return point4Lat;
    }
@@ -280,7 +280,7 @@
     *
     * @param point4Lat çŸ©å½¢ç½‘格顶点纬度
     */
    public void setPoint4Lat(String point4Lat) {
        this.point4Lat = point4Lat == null ? null : point4Lat.trim();
    public void setPoint4Lat(BigDecimal point4Lat) {
        this.point4Lat = point4Lat;
    }
}
src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
@@ -9,6 +9,7 @@
import com.flightfeather.uav.domain.mapper.GridGroupMapper
import com.flightfeather.uav.lightshare.bean.AreaVo
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
@@ -113,7 +114,11 @@
                    .andEqualTo("cellId", it.cellId)
            })
        }
    }
    @Transactional
    fun updateGridCellBatch(gridCellList: List<GridCell?>) {
        gridCellList.forEach { gridCellMapper.updateByPrimaryKey(it) }
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt
@@ -44,4 +44,10 @@
    fun importGridAOD(groupId: Int, dataTime: LocalDateTime?, update: Boolean, file: MultipartFile): GridDataImportResult?
    fun downloadAODTemplate(response: HttpServletResponse): Boolean
    /**
     * æ ¹æ®å«æ˜Ÿé¥æµ‹ç½‘格的中心坐标点,计算网格4个顶点坐标
     * @param groupId ç½‘格组索引id
     */
    fun calGridVertex(groupId: Int): List<GridCell?>
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt
@@ -1,6 +1,7 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.biz.satellite.SatelliteDataMix
import com.flightfeather.uav.biz.satellite.SatelliteGridManage
import com.flightfeather.uav.common.exception.BizException
import com.flightfeather.uav.common.utils.FileExchange
import com.flightfeather.uav.domain.entity.GridAod
@@ -204,4 +205,33 @@
        }
        return true
    }
    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
    }
}
src/main/resources/generator/generatorConfig.xml
@@ -61,9 +61,9 @@
<!--        <table tableName="real_time_data_grid_opt" domainObjectName="RealTimeDataGridOpt" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="scene_info" domainObjectName="SceneInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="segment_info" domainObjectName="SegmentInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
        <table tableName="grid_group" domainObjectName="GridGroup" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<!--        <table tableName="grid_group" domainObjectName="GridGroup" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
        <table tableName="grid_cell" domainObjectName="GridCell" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
        <table tableName="grid_data" domainObjectName="GridData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
        <table tableName="grid_data_detail" domainObjectName="GridDataDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<!--        <table tableName="grid_data" domainObjectName="GridData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="grid_data_detail" domainObjectName="GridDataDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
    </context>
</generatorConfiguration>
src/main/resources/mapper/GridCellMapper.xml
@@ -7,22 +7,22 @@
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="group_id" jdbcType="INTEGER" property="groupId" />
    <result column="latitude" jdbcType="DECIMAL" property="latitude" />
    <result column="longitude" jdbcType="DECIMAL" property="longitude" />
    <result column="point1_lon" jdbcType="VARCHAR" property="point1Lon" />
    <result column="point1_lat" jdbcType="VARCHAR" property="point1Lat" />
    <result column="point2_lon" jdbcType="VARCHAR" property="point2Lon" />
    <result column="point2_lat" jdbcType="VARCHAR" property="point2Lat" />
    <result column="point3_lon" jdbcType="VARCHAR" property="point3Lon" />
    <result column="point3_lat" jdbcType="VARCHAR" property="point3Lat" />
    <result column="point4_lon" jdbcType="VARCHAR" property="point4Lon" />
    <result column="point4_lat" jdbcType="VARCHAR" property="point4Lat" />
    <result column="latitude" jdbcType="DECIMAL" property="latitude" />
    <result column="point1_lon" jdbcType="DECIMAL" property="point1Lon" />
    <result column="point1_lat" jdbcType="DECIMAL" property="point1Lat" />
    <result column="point2_lon" jdbcType="DECIMAL" property="point2Lon" />
    <result column="point2_lat" jdbcType="DECIMAL" property="point2Lat" />
    <result column="point3_lon" jdbcType="DECIMAL" property="point3Lon" />
    <result column="point3_lat" jdbcType="DECIMAL" property="point3Lat" />
    <result column="point4_lon" jdbcType="DECIMAL" property="point4Lon" />
    <result column="point4_lat" jdbcType="DECIMAL" property="point4Lat" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    id, group_id, latitude, longitude, point1_lon, point1_lat, point2_lon, point2_lat,
    id, group_id, longitude, latitude, point1_lon, point1_lat, point2_lon, point2_lat,
    point3_lon, point3_lat, point4_lon, point4_lat
  </sql>
</mapper>
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImplTest.kt
@@ -22,4 +22,9 @@
    fun mixGridData() {
        satelliteTelemetryService.mixGridData(listOf(24, 25))
    }
    @Test
    fun calGridVertex() {
        satelliteTelemetryService.calGridVertex(1)
    }
}