From 698f8f0f22af4c66581ce284407e986ca036aec6 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 23 一月 2025 17:10:26 +0800 Subject: [PATCH] 1. 网格细分逻辑(编写中) --- src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt | 95 ++++++++++++++++++++++++++++------------------- 1 files changed, 56 insertions(+), 39 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt b/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt index 0322e9a..783ceb6 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt @@ -64,12 +64,14 @@ } /** - * 鎷嗗垎缃戞牸涓虹粏鍒嗙綉鏍� + * 鎷嗗垎缃戞牸涓虹粏鍒嗙綉鏍硷紝鎵�鏈夌綉鏍煎簲璇ユ槸鐩稿悓杈归暱鐨勬鏂瑰舰 * 鏍规嵁鐩镐技鐭╁舰鐨勫師鐞嗭紝鍙互鍒嗗埆鎸夋瘮渚嬪緱鍒版瘡涓粏鍒嗙綉鏍肩殑缁忕含搴� * @param gridCellList 鍘熷缃戞牸鏁扮粍 * @param scale 鎷嗗垎鐨勭郴鏁帮紝渚嬪 2锛岃〃绀哄皢鍘熸湁缃戞牸鎸夎竟闀跨殑 1/2 鎷嗗垎鎴� 2 * 2 鐨�4涓綉鏍� + * @param groupId 缁嗗垎鍚庣殑缃戞牸鎵�灞炵殑缃戞牸缁刬d + * @return */ - fun splitGrid(gridCellList: List<GridCell>, scale: Int): List<GridCell> { + fun splitGrid(gridCellList: List<GridCell?>, scale: Int, groupId:Int): List<GridCell?> { if (scale <= 0) throw IllegalArgumentException("缃戞牸鎷嗗垎鐨勬暟閲忎笉鑳藉皬浜�1") // 鎷嗗垎绯绘暟涓�1锛屽垯琛ㄧず涓嶆媶鍒� if (scale == 1) return gridCellList @@ -79,7 +81,7 @@ // 鏍规嵁鍑芥暟[calGridVertex]鐢熸垚鐨勭綉鏍�4涓《鐐瑰潗鏍囷紝浠ヤ笂鍖椾笅鍗楀乏瑗垮彸涓滄柟鍚戜负鏍囧噯 // 璁$畻棣栦釜缃戞牸涓績鍧愭爣鐐瑰垎鍒拰4涓《鐐圭殑缁忕含搴﹀樊鍊� - val p = gridCellList[0] + val p = gridCellList.find { it != null }!! // 锛堥�氳繃杩戜技骞抽潰鍧愭爣绯荤殑鏂瑰紡锛夋牴鎹崟涓師濮嬬綉鏍肩殑4涓《鐐瑰潗鏍囷紝鍒嗗埆纭畾浠ヤ笅涓夌粍鍧愭爣鐐逛箣闂寸殑缁忕含搴﹀崟浣嶅亸绉婚噺 val p1 = p.point1Lon to p.point1Lat val p2 = p.point2Lon to p.point2Lat @@ -98,48 +100,63 @@ 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() + // 缃戞牸绱㈠紩 + var cellIndex = 0 - // 纭畾姣忎竴琛岄涓粏鍒嗙綉鏍肩殑涓績鍧愭爣鍜�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 + // 瀵圭綉鏍肩粍鍐呯殑鎵�鏈夌綉鏍艰繘琛岀綉鏍肩粏鍒� + gridCellList.forEach { g -> + if (g == null) return@forEach - // 鍔犲叆缁撴灉闆嗗悎 - newGridCellList.add(newGridCell1) + // 缃戞牸琛屽惊鐜� + for (row in 0 until scale) { + val newGridCell1 = GridCell() - // 缃戞牸鍒楀惊鐜�(浠庣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 + // 纭畾姣忎竴琛岄涓粏鍒嗙綉鏍肩殑涓績鍧愭爣鍜�4涓《鐐瑰潗鏍� + // 宸︿笂瑙掗《鐐规牴鎹墍鍦ㄨ鏁板湪鍘熷缃戞牸椤剁偣鍩虹涓婂鍔犲亸绉婚噺 + newGridCell1.point1Lon = g.point1Lon + dx1 * row.toBigDecimal() + newGridCell1.point1Lat = g.point1Lat + dy1 * row.toBigDecimal() + // 宸︿笅瑙掗《鐐规牴鎹墍鍦ㄨ鏁板湪鍘熷缃戞牸椤剁偣鍩虹涓婂鍔犲亸绉婚噺锛堟瘮宸︿笂瑙掗《鐐瑰涓�涓亸绉伙級 + newGridCell1.point3Lon = g.point1Lon + dx1 * (row + 1).toBigDecimal() + newGridCell1.point3Lat = g.point1Lat + 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(newGridCell) + newGridCell1.groupId = groupId + newGridCell1.cellIndex = ++cellIndex + newGridCell1.fatherCellIndex = g.cellIndex + + // 鍔犲叆缁撴灉闆嗗悎 + 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 + + newGridCell.groupId = groupId + newGridCell.cellIndex = ++cellIndex + newGridCell.fatherCellIndex = g.cellIndex + + newGridCellList.add(newGridCell) + } } } - return newGridCellList } -- Gitblit v1.9.3