Ticket #15701: CorrelateGpxWithImages_newSpeedEle.patch

File CorrelateGpxWithImages_newSpeedEle.patch, 4.9 KB (added by holgermappt, 7 years ago)

Patch file.

  • src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java

     
    455455    }
    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    }
    465468
  • test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java

     
    22package org.openstreetmap.josm.gui.layer.geoimage;
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertTrue;
    57
    68import java.util.Arrays;
    79import java.util.Collections;
     
    5153        assertEquals(1, gpx.tracks.iterator().next().getSegments().size());
    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
    5661        i0.createTmp();
     
    6469        i3.setExifTime(DateUtils.fromString("2016:01:03 12:05:05"));
    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
    7075        assertEquals(new CachedLatLon(47.197319911792874, 8.792139580473304), i3.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
    75102    /**
  • data_nodist/2094047.gpx

     
    3333    <trkseg>
    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>
    3839      <trkpt lat="47.192921955138445" lon="8.797342479228973">
     
    277278      </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>
    282284      <trkpt lat="47.196987261995673" lon="8.795355297625065">