Improve gpx parsing

This commit is contained in:
Victor Shcherb 2020-04-13 13:06:29 +02:00
parent ec63b4ce11
commit 6aab0d9f0a
2 changed files with 19 additions and 8 deletions

View file

@ -2015,14 +2015,21 @@ public class GPXUtilities {
} else if (parse instanceof Track) {
if (tag.equals("name")) {
((Track) parse).name = readText(parser, "name");
}
if (tag.equals("desc")) {
} else if (tag.equals("desc")) {
((Track) parse).desc = readText(parser, "desc");
}
if (tag.equals("trkseg")) {
} else if (tag.equals("trkseg")) {
TrkSegment trkSeg = new TrkSegment();
((Track) parse).segments.add(trkSeg);
parserState.push(trkSeg);
} else if (tag.equals("trkpt") || tag.equals("rpt")) {
WptPt wptPt = parseWptAttributes(parser);
int size = ((Track) parse).segments.size();
if (size == 0) {
((Track) parse).segments.add(new TrkSegment());
size++;
}
((Track) parse).segments.get(size - 1).points.add(wptPt);
parserState.push(wptPt);
}
} else if (parse instanceof TrkSegment) {
if (tag.equals("trkpt") || tag.equals("rpt")) {

View file

@ -474,9 +474,13 @@ public class Algorithms {
return responseBody;
}
public static String gzipToString(byte[] gzip) throws IOException {
GZIPInputStream gzipIs = new GZIPInputStream(new ByteArrayInputStream(gzip));
return readFromInputStream(gzipIs).toString();
public static String gzipToString(byte[] gzip) {
try {
GZIPInputStream gzipIs = new GZIPInputStream(new ByteArrayInputStream(gzip));
return readFromInputStream(gzipIs).toString();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
public static byte[] stringToGzip(String str) {