Implement new GPX Reader

This commit is contained in:
Victor Shcherb 2011-09-03 01:15:06 +03:00
parent 601ac42e49
commit 24b34ed427
6 changed files with 18 additions and 343 deletions

View file

@ -1,316 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gpx creator="CloudMade" version="1.1" 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">
<metadata>
<author>
<name>CloudMade</name>
<email id="support" domain="cloudmade.com" />
<link href="http://maps.cloudmade.com"></link>
</author>
<copyright author="CloudMade">
<license>http://cloudmade.com/faq#license</license>
</copyright>
<time>2011-08-28T22:39:40</time>
</metadata>
<extensions>
<distance>10164</distance>
<time>556</time>
<start>Неизвестная дорога возле Минск</start>
<end>Неизвестная дорога возле Боровляны</end>
</extensions>
<wpt lat="53.911297" lon="27.579508" />
<wpt lat="53.91172" lon="27.579926" />
<wpt lat="53.911747" lon="27.579847" />
<wpt lat="53.911819" lon="27.579664" />
<wpt lat="53.911938" lon="27.579315" />
<wpt lat="53.912552" lon="27.579935" />
<wpt lat="53.913841" lon="27.581224" />
<wpt lat="53.913975" lon="27.581381" />
<wpt lat="53.91407" lon="27.581509" />
<wpt lat="53.914108" lon="27.581562" />
<wpt lat="53.914986" lon="27.58288" />
<wpt lat="53.91555" lon="27.583744" />
<wpt lat="53.916466" lon="27.585115" />
<wpt lat="53.916599" lon="27.58534" />
<wpt lat="53.916756" lon="27.585676" />
<wpt lat="53.916908" lon="27.586044" />
<wpt lat="53.918388" lon="27.589788" />
<wpt lat="53.919773" lon="27.593138" />
<wpt lat="53.919983" lon="27.593712" />
<wpt lat="53.921032" lon="27.596378" />
<wpt lat="53.921398" lon="27.597338" />
<wpt lat="53.921646" lon="27.598314" />
<wpt lat="53.921936" lon="27.599611" />
<wpt lat="53.922291" lon="27.601025" />
<wpt lat="53.922447" lon="27.602894" />
<wpt lat="53.922512" lon="27.603594" />
<wpt lat="53.922695" lon="27.605644" />
<wpt lat="53.92284" lon="27.60741" />
<wpt lat="53.922871" lon="27.607737" />
<wpt lat="53.922993" lon="27.608934" />
<wpt lat="53.923038" lon="27.6092" />
<wpt lat="53.923077" lon="27.609394" />
<wpt lat="53.923714" lon="27.61199" />
<wpt lat="53.924309" lon="27.614241" />
<wpt lat="53.924568" lon="27.615273" />
<wpt lat="53.924698" lon="27.615744" />
<wpt lat="53.924911" lon="27.616541" />
<wpt lat="53.925529" lon="27.618874" />
<wpt lat="53.925598" lon="27.619146" />
<wpt lat="53.925873" lon="27.620188" />
<wpt lat="53.926109" lon="27.62109" />
<wpt lat="53.927292" lon="27.625641" />
<wpt lat="53.927528" lon="27.62648" />
<wpt lat="53.928188" lon="27.62883" />
<wpt lat="53.92849" lon="27.62993" />
<wpt lat="53.928558" lon="27.63019" />
<wpt lat="53.929111" lon="27.6322" />
<wpt lat="53.929832" lon="27.634825" />
<wpt lat="53.929871" lon="27.63497" />
<wpt lat="53.930943" lon="27.638798" />
<wpt lat="53.931" lon="27.639025" />
<wpt lat="53.931091" lon="27.639357" />
<wpt lat="53.932308" lon="27.643827" />
<wpt lat="53.93256" lon="27.644732" />
<wpt lat="53.933575" lon="27.648359" />
<wpt lat="53.934841" lon="27.652927" />
<wpt lat="53.934895" lon="27.653145" />
<wpt lat="53.935661" lon="27.65589" />
<wpt lat="53.935753" lon="27.656187" />
<wpt lat="53.936111" lon="27.65748" />
<wpt lat="53.937061" lon="27.660999" />
<wpt lat="53.937351" lon="27.662027" />
<wpt lat="53.938129" lon="27.664841" />
<wpt lat="53.938789" lon="27.66703" />
<wpt lat="53.939651" lon="27.669727" />
<wpt lat="53.94006" lon="27.67111" />
<wpt lat="53.940483" lon="27.672497" />
<wpt lat="53.940868" lon="27.673742" />
<wpt lat="53.941471" lon="27.67568" />
<wpt lat="53.941601" lon="27.67606" />
<wpt lat="53.941601" lon="27.676374" />
<wpt lat="53.941601" lon="27.676493" />
<wpt lat="53.94154" lon="27.67675" />
<wpt lat="53.941429" lon="27.67683" />
<wpt lat="53.941299" lon="27.676802" />
<wpt lat="53.941208" lon="27.676691" />
<wpt lat="53.940552" lon="27.675571" />
<wpt lat="53.93985" lon="27.674423" />
<wpt lat="53.93977" lon="27.674229" />
<wpt lat="53.939758" lon="27.674" />
<wpt lat="53.939781" lon="27.67387" />
<wpt lat="53.939823" lon="27.673714" />
<wpt lat="53.940037" lon="27.673569" />
<wpt lat="53.940628" lon="27.673307" />
<wpt lat="53.940788" lon="27.673244" />
<wpt lat="53.941002" lon="27.673157" />
<wpt lat="53.941441" lon="27.672966" />
<wpt lat="53.942101" lon="27.672688" />
<wpt lat="53.942501" lon="27.67248" />
<wpt lat="53.942871" lon="27.672199" />
<wpt lat="53.943474" lon="27.671619" />
<wpt lat="53.943821" lon="27.671207" />
<wpt lat="53.94418" lon="27.67057" />
<wpt lat="53.94474" lon="27.669333" />
<wpt lat="53.944969" lon="27.66872" />
<wpt lat="53.94519" lon="27.668297" />
<wpt lat="53.945419" lon="27.668032" />
<wpt lat="53.945709" lon="27.667965" />
<wpt lat="53.945877" lon="27.668032" />
<wpt lat="53.946007" lon="27.668152" />
<wpt lat="53.946095" lon="27.66824" />
<wpt lat="53.946163" lon="27.668297" />
<wpt lat="53.94651" lon="27.667318" />
<wpt lat="53.946758" lon="27.666662" />
<wpt lat="53.946861" lon="27.666388" />
<wpt lat="53.946987" lon="27.666504" />
<wpt lat="53.94738" lon="27.666912" />
<wpt lat="53.947731" lon="27.66732" />
<wpt lat="53.9482" lon="27.667938" />
<wpt lat="53.948303" lon="27.66818" />
<wpt lat="53.94836" lon="27.668312" />
<wpt lat="53.948509" lon="27.668699" />
<wpt lat="53.948666" lon="27.669155" />
<wpt lat="53.949013" lon="27.670317" />
<wpt lat="53.949516" lon="27.671894" />
<wpt lat="53.949539" lon="27.67197" />
<wpt lat="53.9496" lon="27.672165" />
<wpt lat="53.949776" lon="27.67272" />
<wpt lat="53.949799" lon="27.6728" />
<wpt lat="53.950008" lon="27.673492" />
<wpt lat="53.950375" lon="27.67465" />
<wpt lat="53.950459" lon="27.674915" />
<wpt lat="53.950569" lon="27.67531" />
<wpt lat="53.950745" lon="27.675859" />
<wpt lat="53.95126" lon="27.6775" />
<wpt lat="53.951527" lon="27.678341" />
<wpt lat="53.951672" lon="27.678787" />
<wpt lat="53.95203" lon="27.679934" />
<wpt lat="53.952141" lon="27.680267" />
<wpt lat="53.952465" lon="27.681379" />
<wpt lat="53.95253" lon="27.681583" />
<wpt lat="53.952629" lon="27.681919" />
<wpt lat="53.952686" lon="27.681795" />
<wpt lat="53.952709" lon="27.68173" />
<wpt lat="53.953102" lon="27.680672" />
<wpt lat="53.953133" lon="27.680742" />
<wpt lat="53.953442" lon="27.681711" />
<wpt lat="53.953861" lon="27.681322" />
<wpt lat="53.953857" lon="27.681313" />
<rte>
<rtept lat="53.911297" lon="27.579508">
<desc>Направляйтесь на северо-восток, 55 м</desc>
<extensions>
<distance>55</distance>
<time>20</time>
<offset>0</offset>
<distance-text>55 м</distance-text>
<direction>NE</direction>
<azimuth>30.2</azimuth>
</extensions>
</rtept>
<rtept lat="53.91172" lon="27.579926">
<desc>Поверните налево, 61 м</desc>
<extensions>
<distance>61</distance>
<time>22</time>
<offset>1</offset>
<distance-text>61 м</distance-text>
<direction>NW</direction>
<azimuth>300.7</azimuth>
<turn>TL</turn>
<turn-angle>270.4</turn-angle>
</extensions>
</rtept>
<rtept lat="53.911938" lon="27.579315">
<desc>Поверните направо на просп. Независимости, 3.1 км</desc>
<extensions>
<distance>3050</distance>
<time>146</time>
<offset>4</offset>
<distance-text>3.1 км</distance-text>
<direction>NE</direction>
<azimuth>30.9</azimuth>
<turn>TR</turn>
<turn-angle>91.0</turn-angle>
</extensions>
</rtept>
<rtept lat="53.924698" lon="27.615744">
<desc>Продолжайте движение по просп. Независимости, 3.7 км</desc>
<extensions>
<distance>3736</distance>
<time>179</time>
<offset>35</offset>
<distance-text>3.7 км</distance-text>
<direction>NE</direction>
<azimuth>65.6</azimuth>
<turn>C</turn>
<turn-angle>0.5</turn-angle>
</extensions>
</rtept>
<rtept lat="53.938789" lon="27.66703">
<desc>Продолжайте движение по просп. Независимости, 0.8 км</desc>
<extensions>
<distance>772</distance>
<time>37</time>
<offset>63</offset>
<distance-text>0.8 км</distance-text>
<direction>NE</direction>
<azimuth>61.6</azimuth>
<turn>C</turn>
<turn-angle>358.6</turn-angle>
</extensions>
</rtept>
<rtept lat="53.941601" lon="27.67606">
<desc>Примите вправо, 0.7 км</desc>
<extensions>
<distance>707</distance>
<time>32</time>
<offset>69</offset>
<distance-text>0.7 км</distance-text>
<direction>E</direction>
<azimuth>90.0</azimuth>
<turn>TSLR</turn>
<turn-angle>30.1</turn-angle>
</extensions>
</rtept>
<rtept lat="53.941441" lon="27.672966">
<desc>Продолжайте движение по M9/МКАД, 0.9 км</desc>
<extensions>
<distance>877</distance>
<time>35</time>
<offset>86</offset>
<distance-text>0.9 км</distance-text>
<direction>N</direction>
<azimuth>346.1</azimuth>
<turn>C</turn>
<turn-angle>0.2</turn-angle>
</extensions>
</rtept>
<rtept lat="53.944969" lon="27.66872">
<desc>Примите вправо, 0.2 км</desc>
<extensions>
<distance>164</distance>
<time>7</time>
<offset>94</offset>
<distance-text>0.2 км</distance-text>
<direction>NW</direction>
<azimuth>311.5</azimuth>
<turn>TSLR</turn>
<turn-angle>9.1</turn-angle>
</extensions>
</rtept>
<rtept lat="53.946163" lon="27.668297">
<desc>Поверните налево на Городецкая ул., 0.2 км</desc>
<extensions>
<distance>198</distance>
<time>10</time>
<offset>101</offset>
<distance-text>0.2 км</distance-text>
<direction>NW</direction>
<azimuth>301.3</azimuth>
<turn>TL</turn>
<turn-angle>272.6</turn-angle>
</extensions>
</rtept>
<rtept lat="53.946861" lon="27.666388">
<desc>Поверните направо на ул. Гинтовта, 1.4 км</desc>
<extensions>
<distance>1389</distance>
<time>71</time>
<offset>104</offset>
<distance-text>1.4 км</distance-text>
<direction>NE</direction>
<azimuth>28.2</azimuth>
<turn>TR</turn>
<turn-angle>85.6</turn-angle>
</extensions>
</rtept>
<rtept lat="53.952629" lon="27.681919">
<desc>Поверните налево на Лопатина ул., 0.2 км</desc>
<extensions>
<distance>180</distance>
<time>9</time>
<offset>131</offset>
<distance-text>0.2 км</distance-text>
<direction>NW</direction>
<azimuth>308.0</azimuth>
<turn>TL</turn>
<turn-angle>242.8</turn-angle>
</extensions>
</rtept>
<rtept lat="53.953102" lon="27.680672">
<desc>Поверните направо, 0.3 км</desc>
<extensions>
<distance>258</distance>
<time>93</time>
<offset>134</offset>
<distance-text>0.3 км</distance-text>
<direction>NE</direction>
<azimuth>53.8</azimuth>
<turn>TR</turn>
<turn-angle>111.6</turn-angle>
</extensions>
</rtept>
</rte>
</gpx>

View file

@ -2,7 +2,7 @@
<resources>
<string name="local_index_gpx_info_show">\n\nДлинное нажатие для просмотра на карте</string>
<string name="local_index_gpx_info_speed">\nСредняя скорость : %1$s \nМаксимальная скорость : %2$s</string>
<string name="local_index_gpx_info_elevation">\nСредняя высота : %1$.0f метров\nМинимальная высота : %2$.0f метров\Максимальная высота : %3$.0f метров\nПодъем вверх : %4$.0f метров\nПодъем вниз : %5$.0f метров</string>
<string name="local_index_gpx_info_elevation">\nСредняя высота : %1$.0f метров\nМинимальная высота : %2$.0f метров\nМаксимальная высота : %3$.0f метров\nПодъем вверх : %4$.0f метров\nПодъем вниз : %5$.0f метров</string>
<string name="local_index_gpx_info">Путей : %1$d\nВсего точек : %2$d\nОтмечено точек : %3$d\nВсего расстояние : %4$s
\nНачало : %5$tD %5$tR\nОкончание : %6$tD %6$tR\n</string>
<string name="local_index_installed">Установлено</string>

View file

@ -303,7 +303,7 @@ public class GPXUtilities {
((GPXExtensions) parse).getExtensionsToWrite().put(tag, value);
if (tag.equals("speed") && parse instanceof WptPt) {
try {
((WptPt) parse).speed = Float.parseFloat(parser.getText());
((WptPt) parse).speed = Float.parseFloat(value);
} catch (NumberFormatException e) {
}
}
@ -319,7 +319,7 @@ public class GPXUtilities {
if (parser.getName().equals("trk")) {
Track track = new Track();
((GPXFile) parse).tracks.add(track);
parserState.push(new Track());
parserState.push(track);
}
if (parser.getName().equals("rte")) {
Route route = new Route();
@ -336,7 +336,7 @@ public class GPXUtilities {
((Route) parse).name = readText(parser, "name");
}
if (parser.getName().equals("desc")) {
((Route) parse).name = readText(parser, "desc");
((Route) parse).desc = readText(parser, "desc");
}
if (parser.getName().equals("rtept")) {
WptPt wptPt = parseWptAttributes(parser);
@ -348,7 +348,7 @@ public class GPXUtilities {
((Track) parse).name = readText(parser, "name");
}
if (parser.getName().equals("desc")) {
((Track) parse).name = readText(parser, "desc");
((Track) parse).desc = readText(parser, "desc");
}
if (parser.getName().equals("trkseg")) {
TrkSegment trkSeg = new TrkSegment();
@ -366,7 +366,7 @@ public class GPXUtilities {
if (parser.getName().equals("name")) {
((WptPt) parse).name = readText(parser, "name");
} else if (parser.getName().equals("desc")) {
((WptPt) parse).name = readText(parser, "desc");
((WptPt) parse).desc = readText(parser, "desc");
} else if (parser.getName().equals("ele")) {
String text = readText(parser, "ele");
if (text != null) {
@ -387,11 +387,10 @@ public class GPXUtilities {
String text = readText(parser, "time");
if (text != null) {
try {
((WptPt) parse).time = format.parse(parser.getText()).getTime();
((WptPt) parse).time = format.parse(text).getTime();
} catch (ParseException e) {
}
}
((WptPt) parse).name = readText(parser, "hdop");
}
}
}

View file

@ -132,7 +132,6 @@ public class LocalIndexHelper {
Track subtrack = result.tracks.get(i);
for(TrkSegment segment : subtrack.segments){
totalTracks++;
int distance = 0;
points += segment.points.size();
for (int j = 0; j < segment.points.size(); j++) {
WptPt point = segment.points.get(j);
@ -164,9 +163,8 @@ public class LocalIndexHelper {
diffElevationDown -= diff;
}
}
distance += MapUtils.getDistance(prev.lat, prev.lon, point.lat, point.lon);
totalDistance += MapUtils.getDistance(prev.lat, prev.lon, point.lat, point.lon);
}
totalDistance += distance;
}
}

View file

@ -1259,7 +1259,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
builder.show();
return true;
}
}, true);
}, false);
}
public void contextMenuPoint(final double latitude, final double longitude){

View file

@ -338,7 +338,7 @@ public class MapActivityLayers {
}
return true;
}
}, false);
}, true);
}
private void updateGPXLayer(){
@ -350,7 +350,7 @@ public class MapActivityLayers {
}
}
public void selectGPXFileLayer(final CallbackWithObject<GPXFile> callbackWithObject, boolean forRouting) {
public void selectGPXFileLayer(final CallbackWithObject<GPXFile> callbackWithObject, final boolean convertCloudmade) {
final List<String> list = new ArrayList<String>();
final OsmandSettings settings = getApplication().getSettings();
final File dir = settings.extendOsmandPath(ResourceManager.GPX_PATH);
@ -393,22 +393,16 @@ public class MapActivityLayers {
new Thread(new Runnable() {
@Override
public void run() {
final GPXFile res = GPXUtilities.loadGPXFile(activity, f, true);
if (res.warning != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(activity, res.warning, Toast.LENGTH_LONG).show();
}
});
}
final GPXFile res = GPXUtilities.loadGPXFile(activity, f, convertCloudmade);
dlg.dismiss();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if(res.warning != null){
Toast.makeText(activity, res.warning, Toast.LENGTH_LONG).show();
} else {
callbackWithObject.processResult(res);
}
}
});
}