/** * @return This method returns a list of gpx entries where the time (in millis) is relative to * the first which is 0. */ public List<GPXEntry> createGPXList() { if (isEmpty()) return Collections.emptyList(); List<GPXEntry> gpxList = new ArrayList<>(); long timeOffset = 0; for (int i = 0; i < size() - 1; i++) { Instruction prevInstr = (i > 0) ? get(i - 1) : null; boolean instrIsFirst = prevInstr == null; Instruction nextInstr = get(i + 1); nextInstr.checkOne(); // current instruction does not contain last point which is equals to first point of next instruction: timeOffset = get(i).fillGPXList(gpxList, timeOffset, prevInstr, nextInstr, instrIsFirst); } Instruction lastI = get(size() - 1); if (lastI.points.size() != 1) throw new IllegalStateException("Last instruction must have exactly one point but was " + lastI.points.size()); double lastLat = lastI.getFirstLat(), lastLon = lastI.getFirstLon(), lastEle = lastI.getPoints().is3D() ? lastI.getFirstEle() : Double.NaN; gpxList.add(new GPXEntry(lastLat, lastLon, lastEle, timeOffset)); return gpxList; }
/** * @return This method returns a list of gpx entries where the time (in millis) is relative to * the first which is 0. */ public List<GPXEntry> createGPXList() { if (isEmpty()) return Collections.emptyList(); List<GPXEntry> gpxList = new ArrayList<>(); long timeOffset = 0; for (int i = 0; i < size() - 1; i++) { Instruction prevInstr = (i > 0) ? get(i - 1) : null; boolean instrIsFirst = prevInstr == null; Instruction nextInstr = get(i + 1); nextInstr.checkOne(); // current instruction does not contain last point which is equals to first point of next instruction: timeOffset = get(i).fillGPXList(gpxList, timeOffset, prevInstr, nextInstr, instrIsFirst); } Instruction lastI = get(size() - 1); if (lastI.points.size() != 1) throw new IllegalStateException("Last instruction must have exactly one point but was " + lastI.points.size()); double lastLat = lastI.getFirstLat(), lastLon = lastI.getFirstLon(), lastEle = lastI.getPoints().is3D() ? lastI.getFirstEle() : Double.NaN; gpxList.add(new GPXEntry(lastLat, lastLon, lastEle, timeOffset)); return gpxList; }
/** * @return This method returns a list of gpx entries where the time (in millis) is relative to * the first which is 0. * <p> */ public List<GPXEntry> createGPXList() { if (isEmpty()) return Collections.emptyList(); List<GPXEntry> gpxList = new ArrayList<GPXEntry>(); long timeOffset = 0; for (int i = 0; i < size() - 1; i++) { Instruction prevInstr = (i > 0) ? get(i - 1) : null; boolean instrIsFirst = prevInstr == null; Instruction nextInstr = get(i + 1); nextInstr.checkOne(); // current instruction does not contain last point which is equals to first point of next instruction: timeOffset = get(i).fillGPXList(gpxList, timeOffset, prevInstr, nextInstr, instrIsFirst); } Instruction lastI = get(size() - 1); if (lastI.points.size() != 1) throw new IllegalStateException("Last instruction must have exactly one point but was " + lastI.points.size()); double lastLat = lastI.getFirstLat(), lastLon = lastI.getFirstLon(), lastEle = lastI.getPoints().is3D() ? lastI.getFirstEle() : Double.NaN; gpxList.add(new GPXEntry(lastLat, lastLon, lastEle, timeOffset)); return gpxList; }
/** * @return This method returns a list of gpx entries where the time (in millis) is relative to * the first which is 0. * <p> */ public List<GPXEntry> createGPXList() { if (isEmpty()) return Collections.emptyList(); List<GPXEntry> gpxList = new ArrayList<GPXEntry>(); long timeOffset = 0; for (int i = 0; i < size() - 1; i++) { Instruction prevInstr = (i > 0) ? get(i - 1) : null; boolean instrIsFirst = prevInstr == null; Instruction nextInstr = get(i + 1); nextInstr.checkOne(); // current instruction does not contain last point which is equals to first point of next instruction: timeOffset = get(i).fillGPXList(gpxList, timeOffset, prevInstr, nextInstr, instrIsFirst); } Instruction lastI = get(size() - 1); if (lastI.points.size() != 1) throw new IllegalStateException("Last instruction must have exactly one point but was " + lastI.points.size()); double lastLat = lastI.getFirstLat(), lastLon = lastI.getFirstLon(), lastEle = lastI.getPoints().is3D() ? lastI.getFirstEle() : Double.NaN; gpxList.add(new GPXEntry(lastLat, lastLon, lastEle, timeOffset)); return gpxList; }