From 6799351be12deb2f713f2c0a2b4c467a6d1098c3 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期二, 02 十二月 2025 19:51:00 +0800
Subject: [PATCH] 2025122

---
 src/zhuye/Coordinate.java |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/zhuye/Coordinate.java b/src/zhuye/Coordinate.java
index cb44765..9fa4fc8 100644
--- a/src/zhuye/Coordinate.java
+++ b/src/zhuye/Coordinate.java
@@ -20,6 +20,8 @@
 		Coordinate.isStartSaveGngga = isStartSaveGngga;
 	}
 
+	private static volatile String activeDeviceIdFilter;
+
 	private String latitude;    // 绾害锛堝害鍒嗘牸寮忥級
 	private String latDirection; // 绾害鏂瑰悜
 	private String longitude;   // 缁忓害锛堝害鍒嗘牸寮忥級
@@ -97,6 +99,11 @@
 						continue;
 					}
 
+					String deviceId = fields.length > 15 ? sanitizeDeviceId(fields[15]) : null;
+					if (!isDeviceAccepted(deviceId)) {
+						continue;
+					}
+
 					// 妫�鏌ュ畾浣嶈川閲�
 					String fixQualityStr = fields[6];
 					if (fixQualityStr.isEmpty()) continue;
@@ -144,6 +151,45 @@
 		}	
 	}
 
+	private static boolean isDeviceAccepted(String deviceId) {
+		String filter = activeDeviceIdFilter;
+		if (filter == null || filter.isEmpty()) {
+			return true;
+		}
+		if (deviceId == null || deviceId.isEmpty()) {
+			return false;
+		}
+		return filter.equalsIgnoreCase(deviceId);
+	}
+
+	private static String sanitizeDeviceId(String raw) {
+		if (raw == null) {
+			return null;
+		}
+		String trimmed = raw.trim();
+		if (trimmed.isEmpty()) {
+			return null;
+		}
+		int starIndex = trimmed.indexOf('*');
+		if (starIndex >= 0) {
+			trimmed = trimmed.substring(0, starIndex);
+		}
+		return trimmed;
+	}
+
+	public static void setActiveDeviceIdFilter(String deviceId) {
+		if (deviceId == null) {
+			activeDeviceIdFilter = null;
+			return;
+		}
+		String trimmed = deviceId.trim();
+		activeDeviceIdFilter = trimmed.isEmpty() ? null : trimmed;
+	}
+
+	public static void clearActiveDeviceIdFilter() {
+		activeDeviceIdFilter = null;
+	}
+
 	/**
 	 * 浠庢牴鐩綍鐨凣NGGA.txt鏂囦欢鍔犺浇鏁版嵁骞惰В鏋愪繚瀛樺埌coordinates闆嗗悎涓�
 	 * 

--
Gitblit v1.10.0