Selaa lähdekoodia

移动目标条带算法修改

wurui 1 kuukausi sitten
vanhempi
sitoutus
6b53bcbe93

+ 2 - 1
orbit-base-biz/base-biz-service/src/main/resources/mapper/SceneTargetPointMapper.xml

@@ -91,10 +91,11 @@
         FROM
             scene_basis_target t
         <where>
+        1=1
             <if test="req.targetName!=null and req.targetName!=''">
                 and t.target_name like concat('%', #{req.targetName}, '%')
             </if>
-            <if test="req.type!=null and req.type!=''">
+            <if test="req.type!=null">
                 and t.type = #{req.type}
             </if>
         </where>

+ 7 - 1
orbit-base-plan/base-plan-service/src/main/java/com/base/plan/service/StripService.java

@@ -834,7 +834,11 @@ public class StripService extends ServiceImpl<StripMapper, StripInfo> {
                 if (targetRelationDTO.getType()==1){
                     //移动点目标
                     //根据 航向 航速 时间进行轨迹推算 取得所需时刻后的目标点位
-                    LaLonUtil.deadReckoning("","","","","");
+                    String startlon=value.get(0).getLongitude() ;
+                    String startlat=value.get(0).getLatitude();
+                    PointRpcDTO pointRpcDTO=LaLonUtil.deadReckoning(startlon,startlat,"10","1","90");
+                    value.get(0).setLatitude(pointRpcDTO.getLatitude());
+                    value.get(0).setLongitude(pointRpcDTO.getLongitude());
                 }
 
                 Map<Integer, List<PointRpcDTO>> PointRpcDTOmapNew=new HashMap<>();
@@ -867,11 +871,13 @@ public class StripService extends ServiceImpl<StripMapper, StripInfo> {
 
                 if (!CollectionUtils.isEmpty(PointRpcDTOmapNew)) {
                     PointRpcDTOmapNew.forEach((key1, value1) -> {
+                        targetRelationDTO.setPointDTOList(value1);
                         count( targetRelationDTO, payloadRpcDTOList, stripCalcResults, primaryKeyGenerator
                         );
                     });
 
                 }else {
+                    targetRelationDTO.setPointDTOList(value);
                     count( targetRelationDTO, payloadRpcDTOList, stripCalcResults, primaryKeyGenerator
                     );
                 }

+ 26 - 4
orbit-base-plan/base-plan-service/src/main/java/com/base/plan/utils/LaLonUtil.java

@@ -6,6 +6,8 @@ import org.geotools.geometry.jts.JTSFactoryFinder;
 import org.locationtech.jts.geom.*;
 import org.locationtech.jts.operation.distance.DistanceOp;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -83,21 +85,41 @@ public class LaLonUtil {
         return pointRpcDTOS;
     }
 
-    public static void deadReckoning(String startlon ,String startlat,String speed,String time,String heading){
+    public static PointRpcDTO deadReckoning(String startlon ,String startlat,String speed,String time,String heading){
         double startlond=Double.valueOf(startlon);
         double startlatd=Double.valueOf(startlat);
         double speedd=Double.valueOf(speed); //公里每小时
         double timed=Double.valueOf(time);//小时
         double headingd=Double.valueOf(heading);//航向 度
 
-        double deltaLat = calculateDeltaLat(speedd, timed, headingd, startlatd);
+/*        double deltaLat = calculateDeltaLat(speedd, timed, headingd, startlatd);
         double deltaLon = calculateDeltaLon(speedd, timed, headingd, startlond);
 
         double nextLatitude = deltaLat + deltaLat;
-        double nextLongitude = deltaLon + deltaLon;
+        double nextLongitude = deltaLon + deltaLon;*/
 
-        System.out.println("下一个点的经纬度是: " + nextLatitude + ", " + nextLongitude);
+        double distance = speedd * timed; // 计算距离,单位可以是米或者千米
+        double nextLatitude = startlatd + distance * Math.sin(Math.toRadians(headingd));
+        double nextLongitude = startlond + distance * Math.cos(Math.toRadians(headingd)) / Math.cos(Math.toRadians(startlatd));
 
+
+/*        BigDecimal nextLongitudeb = new BigDecimal(nextLongitude);
+        nextLongitudeb.setScale(6,BigDecimal.ROUND_HALF_UP);*/
+        String nextLongituden =String.format("%.6f",nextLongitude);
+
+/*        BigDecimal nextLatitudeb = new BigDecimal(nextLatitude);
+        nextLatitudeb.setScale(6, BigDecimal.ROUND_HALF_UP);*/
+        /*String nextLatituden = nextLatitudeb.toPlainString();*/
+        String nextLatituden = String.format("%.6f",nextLatitude);
+
+
+
+        PointRpcDTO pointRpcDTO=new PointRpcDTO();
+        pointRpcDTO.setLongitude(nextLongituden);
+        pointRpcDTO.setLatitude(nextLatituden);
+        System.out.println("下一个点的经纬度是: " + nextLatituden + ", " + nextLongituden);
+
+        return pointRpcDTO;
     }
 
     public static double calculateDeltaLat(double speed, double time, double heading, double currentLatitude) {