如何将文本文件转换为GPX文件?

时间:2012-06-20 11:52:19

标签: java android xml gps gpx

我有一个带有纬度和经度的文本文件,用于以逗号分隔的不同点,如下所示。我想将其转换为GPX文件,以便我可以使用它将此文件中的坐标发送到我的模拟器。怎么能通过java类做到这一点?我的文本文件如下。我通过在此网站上手动标记点来制作此文件 - http://www.findlatitudeandlongitude.com/click-lat-lng-list/#.T-G4i7XztX8

28.499433450096404,77.4095070362091
28.49990488581077,77.40830540657043
28.500376319419054,77.40717887878418
28.50084775092117,77.40605235099792
28.5013191803171,77.40492582321167
28.501790607606893,77.40379929542542
28.502196033391538,77.40259766578674
28.502601457618425,77.40136384963989
28.503138878029674,77.40005493164062
28.503676295703638,77.39874601364136
28.504213710640236,77.39743709564209
28.504751122839448,77.39612817764282
28.505288532301247,77.39481925964355
28.505825939025602,77.39357471466064
28.50636334301247,77.39233016967773
28.506929028462302,77.39105343818665
28.507664415012268,77.39000201225281
28.50853178743081,77.38902568817139
28.509370869179346,77.38827466964722
28.510209944253397,77.38752365112305
28.511049012652865,77.38677263259888
28.51188807437762,77.3860216140747
28.512727129427535,77.38527059555054
28.513566177802456,77.38433718681335
28.51440521950231,77.38340377807617
28.515244254526948,77.38239526748657

2 个答案:

答案 0 :(得分:2)

GPX示例:     

<gpx xmlns="http://www.topografix.com/GPX/1/1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
    version="1.1"
    creator="YourCompanyName">

     <wpt lat="Your latitude" lon="Your longitude">

       <time>Your Time</time>

       <name>Your Location name.</name>

    </wpt>

</gpx>

gpx(GPS交换格式)文件以 .gpx 扩展名结尾

您所要做的就是逐行阅读文本文件并创建标记并将文件另存为.gpx

我希望这会有所帮助

答案 1 :(得分:1)

您自己似乎没有花费太多精力来解决问题。

请参阅GPX format的文档。然后使用Java的XML实用程序从您的数据中写入文件。