| | |
| | | Coordinate.isStartSaveGngga = isStartSaveGngga; |
| | | } |
| | | |
| | | private static volatile String activeDeviceIdFilter; |
| | | |
| | | private String latitude; // 纬度(度分格式) |
| | | private String latDirection; // 纬度方向 |
| | | private String longitude; // 经度(度分格式) |
| | |
| | | continue; |
| | | } |
| | | |
| | | String deviceId = fields.length > 15 ? sanitizeDeviceId(fields[15]) : null; |
| | | if (!isDeviceAccepted(deviceId)) { |
| | | continue; |
| | | } |
| | | |
| | | // 检查定位质量 |
| | | String fixQualityStr = fields[6]; |
| | | if (fixQualityStr.isEmpty()) continue; |
| | |
| | | } |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | | * 从根目录的GNGGA.txt文件加载数据并解析保存到coordinates集合中 |
| | | * |