| | |
| | | return round2(distance); |
| | | } |
| | | |
| | | /** |
| | | * 保留2位小数 |
| | | */ |
| | | public static double round2(double d) { |
| | | return ((long)(d * 100)) / 100D; |
| | | } |
| | | |
| | | /** |
| | | * 保留6位小数 |
| | | */ |
| | | public static double round6(double d) { |
| | | return ((long)(d * 1000000)) / 1000000D; |
| | | } |
| | | |
| | | /** |
| | |
| | | if (lon < 115 || lon > 116) { |
| | | System.out.println("lon is invalid"); |
| | | } |
| | | return lon; |
| | | |
| | | return round6(lon); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (lat < 39 || lat > 40) { |
| | | System.out.println("lat is invalid"); |
| | | } |
| | | return lat; |
| | | |
| | | return round6(lat); |
| | | } |
| | | |
| | | /** |
| | |
| | | direction = direction - 360; |
| | | } |
| | | |
| | | if (direction > 315 && direction < 45) |
| | | return "北"; |
| | | if (direction >= 45 && direction < 135) |
| | | if (direction >= 22.5 && direction < 67.5) |
| | | return "东北"; |
| | | if (direction >= 67.5 && direction < 112.5) |
| | | return "东"; |
| | | if (direction >= 135 && direction < 225) |
| | | if (direction >= 112.5 && direction < 157.5) |
| | | return "东南"; |
| | | if (direction >= 157.5 && direction < 202.5) |
| | | return "南"; |
| | | if (direction >= 202.5 && direction < 247.5) |
| | | return "西南"; |
| | | if (direction >= 247.5 && direction < 292.5) |
| | | return "西"; |
| | | if (direction >= 292.5 && direction < 337.5) |
| | | return "西北"; |
| | | |
| | | return "西"; |
| | | return "北"; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @Description: 计算风速 |
| | | */ |
| | | public static Double getWindSpeed(double v, double u) { |
| | | return Math.sqrt(v * v + u * u); |
| | | return round6(Math.sqrt(v * v + u * u)); |
| | | } |
| | | |
| | | /** |
| | |
| | | } else if (u < 0 && v > 0) { |
| | | result += 360; |
| | | } |
| | | return result; |
| | | |
| | | return round6(result); |
| | | } |
| | | |
| | | /** |