Changeset 13256 in josm


Ignore:
Timestamp:
2017-12-28T22:12:45+01:00 (7 years ago)
Author:
Don-vip
Message:

fix #15701 - CorrelateGpxWithImages: Test newGpsData, speed, elevation, gpsTime set by matchGpxTrack() (patch by holgermappt)

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/data_nodist/2094047.gpx

    r9384 r13256  
    3434      <trkpt lat="47.19286847859621" lon="8.79732714034617">
    3535        <ele>471.86000000000001</ele>
     36        <speed>12.399</speed>
    3637        <time>2016-01-03T11:59:58Z</time>
    3738      </trkpt>
     
    278279      <trkpt lat="47.196979885920882" lon="8.79541271366179">
    279280        <ele>489.29000000000002</ele>
     281        <speed>7.38</speed>
    280282        <time>2016-01-03T12:04:01Z</time>
    281283      </trkpt>
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

    r13220 r13256  
    456456
    457457    /**
    458      * Queries whether the GPS data changed.
     458     * Queries whether the GPS data changed. The flag value from the temporary
     459     * copy is returned if that copy exists.
    459460     * @return {@code true} if GPS data changed, {@code false} otherwise
    460461     * @since 6392
    461462     */
    462463    public boolean hasNewGpsData() {
     464        if (tmp != null)
     465            return tmp.isNewGpsData;
    463466        return isNewGpsData;
    464467    }
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java

    r11914 r13256  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertTrue;
    57
    68import java.util.Arrays;
     
    5254        assertEquals(185, gpx.tracks.iterator().next().getSegments().iterator().next().getWayPoints().size());
    5355
     56        final ImageEntry ib = new ImageEntry();
     57        ib.setExifTime(DateUtils.fromString("2016:01:03 11:54:58")); // 5 minutes before start of GPX
     58        ib.createTmp();
    5459        final ImageEntry i0 = new ImageEntry();
    5560        i0.setExifTime(DateUtils.fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX
     
    6570        i3.createTmp();
    6671
    67         assertEquals(4, CorrelateGpxWithImages.matchGpxTrack(Arrays.asList(i0, i1, i2, i3), gpx, 0));
     72        assertEquals(4, CorrelateGpxWithImages.matchGpxTrack(Arrays.asList(ib, i0, i1, i2, i3), gpx, 0));
    6873        assertEquals(new CachedLatLon(47.19286847859621, 8.79732714034617), i0.getPos()); // start of track
    6974        assertEquals(new CachedLatLon(47.196979885920882, 8.79541271366179), i1.getPos()); // exact match
     
    7176        assertEquals(new CachedLatLon((47.197131179273129 + 47.197186248376966) / 2, (8.792974585667253 + 8.792809881269932) / 2),
    7277                i2.getPos()); // interpolated
     78        assertFalse(ib.hasNewGpsData());
     79        assertTrue(i0.hasNewGpsData());
     80        assertTrue(i1.hasNewGpsData());
     81        assertTrue(i2.hasNewGpsData());
     82        assertTrue(i3.hasNewGpsData());
     83        // First waypoint has no speed in matchGpxTrack(). Speed is calculated
     84        // and not taken from GPX track.
     85        assertEquals(null, ib.getSpeed());
     86        assertEquals(null, i0.getSpeed());
     87        assertEquals(new Double(11.675317966018756), i1.getSpeed(), 0.000001);
     88        assertEquals(new Double(24.992418392716967), i2.getSpeed(), 0.000001);
     89        assertEquals(new Double(27.307968754679223), i3.getSpeed(), 0.000001);
     90        assertEquals(null, ib.getElevation());
     91        assertEquals(new Double(471.86), i0.getElevation(), 0.000001);
     92        assertEquals(new Double(489.29), i1.getElevation(), 0.000001);
     93        assertEquals(new Double((490.40 + 489.75) / 2), i2.getElevation(), 0.000001);
     94        assertEquals(new Double(486.368333333), i3.getElevation(), 0.000001);
     95        assertEquals(null, ib.getGpsTime());
     96        assertEquals(DateUtils.fromString("2016:01:03 11:59:54"), i0.getGpsTime()); // original time is kept
     97        assertEquals(DateUtils.fromString("2016:01:03 12:04:01"), i1.getGpsTime());
     98        assertEquals(DateUtils.fromString("2016:01:03 12:04:57"), i2.getGpsTime());
     99        assertEquals(DateUtils.fromString("2016:01:03 12:05:05"), i3.getGpsTime());
    73100    }
    74101
Note: See TracChangeset for help on using the changeset viewer.