gpt4 book ai didi

android - 从 GeoPoints 创建 GPX 文件

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:58:42 24 4
gpt4 key购买 nike

有什么方法可以将 GeoPoints 导出到 GPX 文件中吗?

@Override
public void onLocationChanged(android.location.Location location) {
lat = location.getLatitude();
lon = location.getLongitude();
currGeo = new GeoPoint((int)(lat*1e6),(int)(lon*1e6));

//Store GeoPoint to GPX file
}

我读过 How to parse and plot gpx file has an android MapView ,但我正在寻找更简单的解决方案。

最佳答案

如果您只想从地理点列表生成一个 GPX 文件,最简单的方法就是将字符串压缩到一个文件中。不知道 GPX 的确切格式,我编造了很多细节,但你应该知道你生成的格式。例如,在伪代码中:

// open file handle
OutputStream fout = getFileOutputStream("gpxFile.gpx");
fout.write("<gpx>");
for (GeoPoint gp : listOfGeoPoints) {
fout.write("<gpxPoint>" + getGeoPointAsStringForFile(gp) + "</gpxPoint>");
}
fout.write("</gpx>");
// close file, cleanup, etc

这将需要您实现 getFIleOutputStream() 方法和 getGeoPointAsStringForFile() 方法,但您知道您的目标是什么格式,这样您就可以创建文件,而无需经过大量篮球。

  • 应该注意的是,这是非常脆弱的,所以在上线之前以正确的方式进行,但这是一个简短版本的快速修复。

关于android - 从 GeoPoints 创建 GPX 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12090421/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com