Improve gpx parsing
This commit is contained in:
parent
ec63b4ce11
commit
6aab0d9f0a
2 changed files with 19 additions and 8 deletions
|
@ -2015,14 +2015,21 @@ public class GPXUtilities {
|
||||||
} else if (parse instanceof Track) {
|
} else if (parse instanceof Track) {
|
||||||
if (tag.equals("name")) {
|
if (tag.equals("name")) {
|
||||||
((Track) parse).name = readText(parser, "name");
|
((Track) parse).name = readText(parser, "name");
|
||||||
}
|
} else if (tag.equals("desc")) {
|
||||||
if (tag.equals("desc")) {
|
|
||||||
((Track) parse).desc = readText(parser, "desc");
|
((Track) parse).desc = readText(parser, "desc");
|
||||||
}
|
} else if (tag.equals("trkseg")) {
|
||||||
if (tag.equals("trkseg")) {
|
|
||||||
TrkSegment trkSeg = new TrkSegment();
|
TrkSegment trkSeg = new TrkSegment();
|
||||||
((Track) parse).segments.add(trkSeg);
|
((Track) parse).segments.add(trkSeg);
|
||||||
parserState.push(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) {
|
} else if (parse instanceof TrkSegment) {
|
||||||
if (tag.equals("trkpt") || tag.equals("rpt")) {
|
if (tag.equals("trkpt") || tag.equals("rpt")) {
|
||||||
|
@ -2226,7 +2233,7 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mergeGPXFileInto(GPXFile to, GPXFile from) {
|
public static void mergeGPXFileInto(GPXFile to, GPXFile from) {
|
||||||
if (from == null) {
|
if (from == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -474,9 +474,13 @@ public class Algorithms {
|
||||||
return responseBody;
|
return responseBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String gzipToString(byte[] gzip) throws IOException {
|
public static String gzipToString(byte[] gzip) {
|
||||||
GZIPInputStream gzipIs = new GZIPInputStream(new ByteArrayInputStream(gzip));
|
try {
|
||||||
return readFromInputStream(gzipIs).toString();
|
GZIPInputStream gzipIs = new GZIPInputStream(new ByteArrayInputStream(gzip));
|
||||||
|
return readFromInputStream(gzipIs).toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalStateException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] stringToGzip(String str) {
|
public static byte[] stringToGzip(String str) {
|
||||||
|
|
Loading…
Reference in a new issue