@SuppressWarnings("PMD.NPathComplexity") // external code, do not split
    public void appendTrack(final OsmTrack t) {
        int i;

        final int ourSize = nodes.size();
        if (ourSize > 0 && t.nodes.size() > 1) {
            t.nodes.get(1).origin = nodes.get(ourSize - 1);
        }
        final float t0 = ourSize > 0 ? nodes.get(ourSize - 1).getTime() : 0;
        final float e0 = ourSize > 0 ? nodes.get(ourSize - 1).getEnergy() : 0;
        for (i = 0; i < t.nodes.size(); i++) {
            final OsmPathElement e = t.nodes.get(i);
            if (i == 0 && ourSize > 0 && nodes.get(ourSize - 1).getSElev() == Short.MIN_VALUE) {
                nodes.get(ourSize - 1).setSElev(e.getSElev());
            }
            if (i > 0 || ourSize == 0) {
                e.setTime(e.getTime() + t0);
                e.setEnergy(e.getEnergy() + e0);
                if (e.message != null) {
                    if (!(e.message.lon == e.getILon() && e.message.lat == e.getILat())) {
                        e.message.lon = e.getILon();
                        e.message.lat = e.getILat();
                    }
                }
                nodes.add(e);
            }
        }

        if (t.voiceHints != null) {
            if (ourSize > 0) {
                for (VoiceHint hint : t.voiceHints.list) {
                    hint.indexInTrack = hint.indexInTrack + ourSize - 1;
                }
            }
            if (voiceHints == null) {
                voiceHints = t.voiceHints;
            } else {
                voiceHints.list.addAll(t.voiceHints.list);
            }
        } else {
            if (detourMap == null) {
                //copyDetours( t );
                detourMap = t.detourMap;
            } else {
                addDetours(t);
            }
        }

        distance += t.distance;
        ascend += t.ascend;
        plainAscend += t.plainAscend;
        cost += t.cost;
        energy = (int) nodes.get(nodes.size() - 1).getEnergy();

        showspeed |= t.showspeed;
        showSpeedProfile |= t.showSpeedProfile;
    }
writes the track in binary-format to a file

@param filename the filename to write to
main/src/main/java/cgeo/geocaching/brouter/core/OsmTrack.java