| | |
| | | String line; |
| | | StringBuilder gnggaData = new StringBuilder(); |
| | | |
| | | System.out.println("开始读取GNGGA文件: " + file.getAbsolutePath()); |
| | | |
| | | while ((line = reader.readLine()) != null) { |
| | | // 清理数据:移除多余的空格和换行 |
| | | line = line.trim(); |
| | |
| | | if (gnggaData.length() > 0) { |
| | | parseGNGGAToCoordinateList(gnggaData.toString()); |
| | | loadedCount = coordinates.size(); |
| | | System.out.println("成功加载 " + loadedCount + " 个坐标点"); |
| | | |
| | | // 输出统计信息 |
| | | if (loadedCount > 0) { |
| | | double[] elevationRange = getElevationRange(); |
| | | double avgElevation = getAverageElevation(); |
| | | System.out.println("海拔统计: 范围=" + String.format("%.2f", elevationRange[0]) + |
| | | " - " + String.format("%.2f", elevationRange[1]) + "米, 平均=" + |
| | | String.format("%.2f", avgElevation) + "米"); |
| | | } |
| | | } else { |
| | | System.out.println("文件中未找到有效的GNGGA数据"); |
| | | } |
| | | |
| | | } catch (IOException e) { |