| | |
| | | } |
| | | |
| | | /** |
| | | * 获取距离1 |
| | | * 获取距离 |
| | | */ |
| | | public static double getDistance1(double lon1, double lat1, double lon2, double lat2) { |
| | | public static double getDistance(double x1, double y1, double x2, double y2) { |
| | | GeodeticCalculator geodeticCalculator = new GeodeticCalculator(crs104903); |
| | | geodeticCalculator.setStartingGeographicPoint(x1, y1); |
| | | geodeticCalculator.setDestinationGeographicPoint(x2, y2); |
| | | |
| | | return geodeticCalculator.getOrthodromicDistance(); |
| | | } |
| | | |
| | | /** |
| | | * 获取距离2 |
| | | */ |
| | | public static double getDistance2(double lon1, double lat1, double lon2, double lat2) { |
| | | double radLat1 = Math.toRadians(lat1); |
| | | double radLat2 = Math.toRadians(lat2); |
| | | double a = radLat1 - radLat2; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取距离2 |
| | | */ |
| | | public static double getDistance2(double x1, double y1, double x2, double y2) { |
| | | GeodeticCalculator geodeticCalculator = new GeodeticCalculator(crs104903); |
| | | geodeticCalculator.setStartingGeographicPoint(x1, y1); |
| | | geodeticCalculator.setDestinationGeographicPoint(x2, y2); |
| | | |
| | | return geodeticCalculator.getOrthodromicDistance(); |
| | | } |
| | | |
| | | /** |
| | | * 获取方向角 |
| | | */ |
| | | public static double getBearing(double x1, double y1, double x2, double y2) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取角度1 |
| | | * 获取角度 |
| | | */ |
| | | public static double getAngle1(double x1, double y1, double x2, double y2) { |
| | | public static double getAngle(double x1, double y1, double x2, double y2) { |
| | | DirectPosition2D p1 = new DirectPosition2D(crs104903, x1, y1); |
| | | DirectPosition2D p2 = new DirectPosition2D(crs104903, x2, y2); |
| | | |
| | |
| | | /** |
| | | * 根据距离和角度获取目标点 |
| | | */ |
| | | private static Point2D getPointByDistanceAndAngle(double x, double y, double angle, double distance) { |
| | | public static Point2D getPointByDistanceAndAngle(double x, double y, double angle, double distance) { |
| | | DirectPosition2D p1 = new DirectPosition2D(x, y); |
| | | |
| | | GeodeticCalculator gc = new GeodeticCalculator(); |