src/androidTest/java/de/blau/android/gpx/GpxTest.java
/**
     * Check if two tracks are equal, ignores up to two missing points
     * 
     * @param track reference track
     * @param recordedTrack new track
     */
Check if two tracks are equal, ignores up to two missing points


Check if two tracks are equal ignores up to two missing points
private void compareTrack(Track track, List<TrackPoint> recordedTrack) {
        List<TrackPoint> trackPoints = track.getTrackPoints();
        int trackSize = trackPoints.size();
        int recordedTrackSize = recordedTrack.size();
        System.out.println("Track size " + trackSize);
        System.out.println("Recorded track size " + recordedTrackSize);
        assertTrue((recordedTrackSize >= (trackSize - 2)) && (recordedTrackSize <= trackSize));
        int i = 0;
        int offset = 0;
        TrackPoint trackPoint = trackPoints.get(0);
        TrackPoint trackPoint2 = recordedTrack.get(0);
        if (!Util.equals(trackPoint.getLatitude(), trackPoint2.getLatitude(), 0.000001)
                || !Util.equals(trackPoint.getLongitude(), trackPoint2.getLongitude(), 0.000001)) {
            i = 1;
            offset = 1;
        }
        for (; i < Math.min(trackSize, recordedTrackSize); i++) {
            TrackPoint tp = trackPoints.get(i);
            TrackPoint recordedTrackPoint = recordedTrack.get(i - offset);
            assertEquals(tp.getLatitude(), recordedTrackPoint.getLatitude(), 0.000001);
            assertEquals(tp.getLongitude(), recordedTrackPoint.getLongitude(), 0.000001);
        }
    }
private void compareTrack ( Track track , List < TrackPoint > recordedTrack ) { List < TrackPoint > trackPoints = track . getTrackPoints ( ) ; int trackSize = trackPoints . size ( ) ; int recordedTrackSize = recordedTrack . size ( ) ; System . out . println ( "Track size " + trackSize ) ; System . out . println ( "Recorded track size " + recordedTrackSize ) ; assertTrue ( ( recordedTrackSize >= ( trackSize - 2 ) ) && ( recordedTrackSize <= trackSize ) ) ; int i = 0 ; int offset = 0 ; TrackPoint trackPoint = trackPoints . get ( 0 ) ; TrackPoint trackPoint2 = recordedTrack . get ( 0 ) ; if ( ! Util . equals ( trackPoint . getLatitude ( ) , trackPoint2 . getLatitude ( ) , 0.000001 ) || ! Util . equals ( trackPoint . getLongitude ( ) , trackPoint2 . getLongitude ( ) , 0.000001 ) ) { i = 1 ; offset = 1 ; } for ( ; i < Math . min ( trackSize , recordedTrackSize ) ; i ++ ) { TrackPoint tp = trackPoints . get ( i ) ; TrackPoint recordedTrackPoint = recordedTrack . get ( i - offset ) ; assertEquals ( tp . getLatitude ( ) , recordedTrackPoint . getLatitude ( ) , 0.000001 ) ; assertEquals ( tp . getLongitude ( ) , recordedTrackPoint . getLongitude ( ) , 0.000001 ) ; } }
Check if two tracks are equal, ignores up to two missing points
Check if two tracks are equal ignores up to two missing points
// compare with a bit of tolerance // we don't include altitude anymore assertEquals(tp.getAltitude(), recordedTrackPoint.getAltitude(), // 0.000001);