有没有办法将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,但我正在寻找一种更简单的解决方案。
发布于 2012-11-08 01:56:23
如果你只想从一个地理位置列表中生成一个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()方法,但是您知道目标格式是什么,这样您就可以创建文件,而不必经历很多麻烦。
https://stackoverflow.com/questions/12090421
复制相似问题