|
@@ -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) {
|