Changeset 9384 in josm for trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage
- Timestamp:
- 2016-01-10T13:04:11+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java
r9383 r9384 2 2 package org.openstreetmap.josm.gui.layer.geoimage; 3 3 4 import static org.junit.Assert. *;4 import static org.junit.Assert.assertEquals; 5 5 6 import java.util.Arrays; 7 import java.util.TimeZone; 8 9 import org.junit.BeforeClass; 6 10 import org.junit.Test; 11 import org.openstreetmap.josm.data.coor.LatLon; 7 12 import org.openstreetmap.josm.data.gpx.GpxData; 8 13 import org.openstreetmap.josm.io.GpxReaderTest; 14 import org.openstreetmap.josm.tools.date.DateUtils; 9 15 16 /** 17 * Unit tests of {@link CorrelateGpxWithImagesTest} class. 18 */ 10 19 public class CorrelateGpxWithImagesTest { 11 20 21 /** 22 * Setup test. 23 */ 24 @BeforeClass 25 public static void setUp() { 26 TimeZone.setDefault(TimeZone.getTimeZone("UTC")); 27 } 28 29 /** 30 * Tests matching of images to a GPX track. 31 * @throws Exception if the track cannot be parsed 32 */ 12 33 @Test 13 34 public void testMatchGpxTrack() throws Exception { 14 final GpxData munich = GpxReaderTest.parseGpxData("data_nodist/munich.gpx"); 35 final GpxData gpx = GpxReaderTest.parseGpxData("data_nodist/2094047.gpx"); 36 assertEquals(4, gpx.tracks.size()); 37 assertEquals(1, gpx.tracks.iterator().next().getSegments().size()); 38 assertEquals(185, gpx.tracks.iterator().next().getSegments().iterator().next().getWayPoints().size()); 39 40 final ImageEntry i0 = new ImageEntry(); 41 i0.setExifTime(DateUtils.fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX 42 i0.createTmp(); 15 43 final ImageEntry i1 = new ImageEntry(); 16 i1.setExifGpsTime(); 17 CorrelateGpxWithImages.matchGpxTrack(null, munich, 0); 44 i1.setExifTime(DateUtils.fromString("2016:01:03 12:04:01")); 45 i1.createTmp(); 46 final ImageEntry i2 = new ImageEntry(); 47 i2.setExifTime(DateUtils.fromString("2016:01:03 12:04:57")); 48 i2.createTmp(); 49 final ImageEntry i3 = new ImageEntry(); 50 i3.setExifTime(DateUtils.fromString("2016:01:03 12:05:05")); 51 i3.createTmp(); 52 53 assertEquals(4, CorrelateGpxWithImages.matchGpxTrack(Arrays.asList(i0, i1, i2, i3), gpx, 0)); 54 assertEquals(new LatLon(47.19286847859621, 8.79732714034617), i0.getPos()); // start of track 55 assertEquals(new LatLon(47.196979885920882, 8.79541271366179), i1.getPos()); // exact match 56 assertEquals(new LatLon(47.197319911792874, 8.792139580473304), i3.getPos()); // exact match 57 assertEquals(new LatLon((47.197131179273129 + 47.197186248376966) / 2, (8.792974585667253 + 8.792809881269932) / 2), 58 i2.getPos()); // interpolated 18 59 } 19 60 }
Note:
See TracChangeset
for help on using the changeset viewer.