From b315a6943e6c0d6bdf0d5f7565c570d719154d6c Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 17 十二月 2025 14:56:58 +0800
Subject: [PATCH] 新增了障碍物管理页面

---
 src/zhuye/Coordinate.java |  163 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 98 insertions(+), 65 deletions(-)

diff --git a/src/zhuye/Coordinate.java b/src/zhuye/Coordinate.java
index 9fa4fc8..d15579f 100644
--- a/src/zhuye/Coordinate.java
+++ b/src/zhuye/Coordinate.java
@@ -82,73 +82,106 @@
 	 * 瑙f瀽GNGGA鏁版嵁杩斿洖Coordinate瀵硅薄鍒楄〃锛堝寮虹増锛屽寘鍚珮绋嬫暟鎹級
 	 */
 	public static void parseGNGGAToCoordinateList(String gnggaData) {	
-		if(isStartSaveGngga) {		
-			String[] records = gnggaData.split("\\$GNGGA");
+		if (!isStartSaveGngga || gnggaData == null || gnggaData.isEmpty()) {
+			return;
+		}
 
-			for (String record : records) {
-				try {
-					String trimmedRecord = record.trim();
-					if (trimmedRecord.isEmpty()) continue;
-
-					if (!trimmedRecord.startsWith(",")) {
-						trimmedRecord = "," + trimmedRecord;
-					}
-
-					String[] fields = trimmedRecord.split(",");
-					if (fields.length < 10) { // 妫�鏌ュ瓧娈垫暟閲忥紝闇�瑕佸寘鍚珮绋嬪瓧娈�
-						continue;
-					}
-
-					String deviceId = fields.length > 15 ? sanitizeDeviceId(fields[15]) : null;
-					if (!isDeviceAccepted(deviceId)) {
-						continue;
-					}
-
-					// 妫�鏌ュ畾浣嶈川閲�
-					String fixQualityStr = fields[6];
-					if (fixQualityStr.isEmpty()) continue;
-
-					int fixQuality;
-					try {
-						fixQuality = Integer.parseInt(fixQualityStr);
-					} catch (NumberFormatException e) {
-						continue;
-					}
-
-					if (fixQuality != 4) continue;
-
-					// 鎻愬彇鍧愭爣鏁版嵁
-					String latitudeStr = fields[2];
-					String latDirection = fields[3];
-					String longitudeStr = fields[4];
-					String lonDirection = fields[5];
-
-					// 鎻愬彇娴锋嫈楂樺害锛堢10涓瓧娈碉紝绱㈠紩9锛�
-					double elevation = 0.0;
-					try {
-						String elevationStr = fields[9];
-						if (elevationStr != null && !elevationStr.isEmpty()) {
-							elevation = Double.parseDouble(elevationStr);
-						}
-					} catch (NumberFormatException e) {
-						// 楂樼▼瑙f瀽澶辫触锛屼娇鐢ㄩ粯璁ゅ��0
-						System.err.println("楂樼▼瑙f瀽澶辫触锛屼娇鐢ㄩ粯璁ゅ��0: " + fields[9]);
-					}
-
-					if (latitudeStr.isEmpty() || longitudeStr.isEmpty() || 
-							latDirection.isEmpty() || lonDirection.isEmpty()) {
-						continue;
-					}
-
-					// 鍒涘缓Coordinate瀵硅薄骞舵坊鍔犲埌鍒楄〃锛堝寘鍚珮绋嬫暟鎹級
-					Coordinate coord = new Coordinate(latitudeStr, latDirection, longitudeStr, lonDirection, elevation);
-					coordinates.add(coord);
-
-				} catch (Exception e) {
-					System.err.println("瑙f瀽GNGGA璁板綍澶辫触: " + record);
-				}
+		String[] records = gnggaData.split("\\$GNGGA");
+		for (String record : records) {
+			Coordinate coord = parseSingleGnggaRecord(record, false);
+			if (coord != null) {
+				coordinates.add(coord);
 			}
-		}	
+		}
+	}
+
+	/**
+	 * 涓插彛瀹炴椂鏁版嵁鐩存帴瑙f瀽鍏ュ彛銆�
+	 */
+	public static Coordinate dellchuankougngga(String gnggaData) {
+		if (!isStartSaveGngga || gnggaData == null) {
+			return null;
+		}
+
+		String cleaned = gnggaData.trim();
+		if (cleaned.isEmpty()) {
+			return null;
+		}
+
+		int markerIndex = cleaned.indexOf("$GNGGA");
+		String record = markerIndex >= 0
+				? cleaned.substring(markerIndex + "$GNGGA".length())
+				: cleaned;
+
+		Coordinate coordinate = parseSingleGnggaRecord(record, true);
+		if (coordinate != null) {
+			coordinates.add(coordinate);
+		}
+		return coordinate;
+	}
+
+	private static Coordinate parseSingleGnggaRecord(String record, boolean skipDeviceFilter) {
+		try {
+			String trimmedRecord = record == null ? "" : record.trim();
+			if (trimmedRecord.isEmpty()) {
+				return null;
+			}
+
+			if (!trimmedRecord.startsWith(",")) {
+				trimmedRecord = "," + trimmedRecord;
+			}
+
+			String[] fields = trimmedRecord.split(",");
+			if (fields.length < 10) {
+				return null;
+			}
+
+			String deviceId = fields.length > 15 ? sanitizeDeviceId(fields[15]) : null;
+			if (!skipDeviceFilter && !isDeviceAccepted(deviceId)) {
+				return null;
+			}
+
+			String fixQualityStr = fields[6];
+			if (fixQualityStr.isEmpty()) {
+				return null;
+			}
+
+			int fixQuality;
+			try {
+				fixQuality = Integer.parseInt(fixQualityStr);
+			} catch (NumberFormatException e) {
+				return null;
+			}
+
+			if (fixQuality != 4) {
+				return null;
+			}
+
+			String latitudeStr = fields[2];
+			String latDirection = fields[3];
+			String longitudeStr = fields[4];
+			String lonDirection = fields[5];
+
+			if (latitudeStr.isEmpty() || longitudeStr.isEmpty() ||
+					latDirection.isEmpty() || lonDirection.isEmpty()) {
+				return null;
+			}
+
+			double elevation = 0.0;
+			try {
+				String elevationStr = fields[9];
+				if (elevationStr != null && !elevationStr.isEmpty()) {
+					elevation = Double.parseDouble(elevationStr);
+				}
+			} catch (NumberFormatException e) {
+				System.err.println("楂樼▼瑙f瀽澶辫触锛屼娇鐢ㄩ粯璁ゅ��0: " + fields[9]);
+			}
+
+			return new Coordinate(latitudeStr, latDirection, longitudeStr, lonDirection, elevation);
+		} catch (Exception e) {
+			System.err.println("瑙f瀽GNGGA璁板綍澶辫触: " + record);
+			return null;
+		}
 	}
 
 	private static boolean isDeviceAccepted(String deviceId) {

--
Gitblit v1.10.0