diff --git a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java index cc47187f6c..6c5ead8955 100644 --- a/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java +++ b/OsmAnd-java/src/main/java/net/osmand/GPXUtilities.java @@ -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")) { @@ -2226,7 +2233,7 @@ public class GPXUtilities { } return bounds; } - + public static void mergeGPXFileInto(GPXFile to, GPXFile from) { if (from == null) { return; diff --git a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java index 5a5c0fb04e..6e9361ecb7 100644 --- a/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java +++ b/OsmAnd-java/src/main/java/net/osmand/util/Algorithms.java @@ -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) {