| | |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | |
| | | import javax.swing.JDialog; |
| | | import javax.swing.SwingUtilities; |
| | | |
| | | import zhuye.Coordinate; |
| | |
| | | /** |
| | | * 在地图上实时预览正在绘制的障碍物。 |
| | | */ |
| | | public final class yulanzhangaiwu { |
| | | import publicway.Gpstoxuzuobiao; |
| | | |
| | | public class yulanzhangaiwu extends JDialog { |
| | | private static final Object LOCK = new Object(); |
| | | private static final double METERS_PER_DEGREE_LAT = 111320.0d; |
| | | private static final Color PREVIEW_LINE_COLOR = new Color(0, 123, 255, 200); |
| | |
| | | } |
| | | |
| | | private static double parseDMToDecimal(String dmm, String direction) { |
| | | if (dmm == null || dmm.trim().isEmpty()) { |
| | | return Double.NaN; |
| | | } |
| | | try { |
| | | String trimmed = dmm.trim(); |
| | | int dotIndex = trimmed.indexOf('.'); |
| | | if (dotIndex < 2) { |
| | | return Double.NaN; |
| | | } |
| | | int degrees = Integer.parseInt(trimmed.substring(0, dotIndex - 2)); |
| | | double minutes = Double.parseDouble(trimmed.substring(dotIndex - 2)); |
| | | double decimal = degrees + minutes / 60.0; |
| | | if ("S".equalsIgnoreCase(direction) || "W".equalsIgnoreCase(direction)) { |
| | | decimal = -decimal; |
| | | } |
| | | return decimal; |
| | | } catch (NumberFormatException ex) { |
| | | return Double.NaN; |
| | | } |
| | | return Gpstoxuzuobiao.parseDMToDecimal(dmm, direction); |
| | | } |
| | | |
| | | private static double[] convertLatLonToLocal(double lat, double lon, double baseLat, double baseLon) { |
| | | double deltaLat = lat - baseLat; |
| | | double deltaLon = lon - baseLon; |
| | | double meanLatRad = Math.toRadians((baseLat + lat) / 2.0); |
| | | double eastMeters = deltaLon * METERS_PER_DEGREE_LAT * Math.cos(meanLatRad); |
| | | double northMeters = deltaLat * METERS_PER_DEGREE_LAT; |
| | | return new double[]{eastMeters, northMeters}; |
| | | return Gpstoxuzuobiao.convertLatLonToLocal(lat, lon, baseLat, baseLon); |
| | | } |
| | | |
| | | private static CircleState fitCircle(List<double[]> points) { |