Android 从地质点创建GPX文件

Android 从地质点创建GPX文件,android,google-maps,android-maps,gpx,Android,Google Maps,Android Maps,Gpx,有没有办法将地质点导出到GPX文件中 @Override public void onLocationChanged(android.location.Location location) { lat = location.getLatitude(); lon = location.getLongitude(); currGeo = new GeoPoint((int)(lat*1e6),(int)(lon*1e6)); //St

有没有办法将
地质点导出到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
    }

我已经读过了,但我正在寻找一个更简单的解决方案。

如果您只想从地质点列表生成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
//打开文件句柄
OutputStream fout=getFileOutputStream(“gpxFile.gpx”);
四、写(“”);
对于(地质点总成:地质点列表){
fout.write(“+getGeoPointAsStringForFile(gp)+”);
}
四、写(“”);
//关闭文件、清理等
这需要您实现getFIleOutputStream()方法和getGeoPointAsStringForFile()方法,但是您知道自己的目标格式,这样您就可以创建文件,而不必经历很多麻烦

  • 应该注意的是,这是难以置信的脆弱,所以在你上线之前要正确地做,但这是一个简短的快速修复版本