Index: trunk/data_nodist/2094047.gpx
===================================================================
--- trunk/data_nodist/2094047.gpx	(revision 13255)
+++ trunk/data_nodist/2094047.gpx	(revision 13256)
@@ -34,4 +34,5 @@
       <trkpt lat="47.19286847859621" lon="8.79732714034617">
         <ele>471.86000000000001</ele>
+        <speed>12.399</speed>
         <time>2016-01-03T11:59:58Z</time>
       </trkpt>
@@ -278,4 +279,5 @@
       <trkpt lat="47.196979885920882" lon="8.79541271366179">
         <ele>489.29000000000002</ele>
+        <speed>7.38</speed>
         <time>2016-01-03T12:04:01Z</time>
       </trkpt>
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java	(revision 13255)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java	(revision 13256)
@@ -456,9 +456,12 @@
 
     /**
-     * Queries whether the GPS data changed.
+     * Queries whether the GPS data changed. The flag value from the temporary
+     * copy is returned if that copy exists.
      * @return {@code true} if GPS data changed, {@code false} otherwise
      * @since 6392
      */
     public boolean hasNewGpsData() {
+        if (tmp != null)
+            return tmp.isNewGpsData;
         return isNewGpsData;
     }
Index: trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java	(revision 13255)
+++ trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java	(revision 13256)
@@ -3,4 +3,6 @@
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
@@ -52,4 +54,7 @@
         assertEquals(185, gpx.tracks.iterator().next().getSegments().iterator().next().getWayPoints().size());
 
+        final ImageEntry ib = new ImageEntry();
+        ib.setExifTime(DateUtils.fromString("2016:01:03 11:54:58")); // 5 minutes before start of GPX
+        ib.createTmp();
         final ImageEntry i0 = new ImageEntry();
         i0.setExifTime(DateUtils.fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX
@@ -65,5 +70,5 @@
         i3.createTmp();
 
-        assertEquals(4, CorrelateGpxWithImages.matchGpxTrack(Arrays.asList(i0, i1, i2, i3), gpx, 0));
+        assertEquals(4, CorrelateGpxWithImages.matchGpxTrack(Arrays.asList(ib, i0, i1, i2, i3), gpx, 0));
         assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), i0.getPos()); // start of track
         assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); // exact match
@@ -71,4 +76,26 @@
         assertEquals(new CachedLatLon((47.197131179273129 + 47.197186248376966) / 2, (8.792974585667253 + 8.792809881269932) / 2),
                 i2.getPos()); // interpolated
+        assertFalse(ib.hasNewGpsData());
+        assertTrue(i0.hasNewGpsData());
+        assertTrue(i1.hasNewGpsData());
+        assertTrue(i2.hasNewGpsData());
+        assertTrue(i3.hasNewGpsData());
+        // First waypoint has no speed in matchGpxTrack(). Speed is calculated
+        // and not taken from GPX track.
+        assertEquals(null, ib.getSpeed());
+        assertEquals(null, i0.getSpeed());
+        assertEquals(new Double(11.675317966018756), i1.getSpeed(), 0.000001);
+        assertEquals(new Double(24.992418392716967), i2.getSpeed(), 0.000001);
+        assertEquals(new Double(27.307968754679223), i3.getSpeed(), 0.000001);
+        assertEquals(null, ib.getElevation());
+        assertEquals(new Double(471.86), i0.getElevation(), 0.000001);
+        assertEquals(new Double(489.29), i1.getElevation(), 0.000001);
+        assertEquals(new Double((490.40 + 489.75) / 2), i2.getElevation(), 0.000001);
+        assertEquals(new Double(486.368333333), i3.getElevation(), 0.000001);
+        assertEquals(null, ib.getGpsTime());
+        assertEquals(DateUtils.fromString("2016:01:03 11:59:54"), i0.getGpsTime()); // original time is kept
+        assertEquals(DateUtils.fromString("2016:01:03 12:04:01"), i1.getGpsTime());
+        assertEquals(DateUtils.fromString("2016:01:03 12:04:57"), i2.getGpsTime());
+        assertEquals(DateUtils.fromString("2016:01:03 12:05:05"), i3.getGpsTime());
     }
 
