Changeset 9384 in josm
- Timestamp:
- 2016-01-10T13:04:11+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r9375 r9384 435 435 public boolean equals(Object obj) { 436 436 if (this == obj) return true; 437 if ( obj == null || getClass() != obj.getClass()) return false;437 if (!(obj instanceof LatLon)) return false; 438 438 LatLon that = (LatLon) obj; 439 439 return Double.compare(that.x, x) == 0 && -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r9383 r9384 1146 1146 * @return number of matched points 1147 1147 */ 1148 privateint matchGpxTrack(List<ImageEntry> images, GpxData selectedGpx, long offset) {1148 static int matchGpxTrack(List<ImageEntry> images, GpxData selectedGpx, long offset) { 1149 1149 int ret = 0; 1150 1150 … … 1189 1189 } 1190 1190 1191 privateint matchPoints(List<ImageEntry> images, WayPoint prevWp, long prevWpTime,1191 static int matchPoints(List<ImageEntry> images, WayPoint prevWp, long prevWpTime, 1192 1192 WayPoint curWp, long curWpTime, long offset) { 1193 1193 // Time between the track point and the previous one, 5 sec if first point, i.e. photos take -
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 } -
trunk/test/unit/org/openstreetmap/josm/io/GpxReaderTest.java
r9380 r9384 8 8 import java.io.File; 9 9 import java.io.FileInputStream; 10 import java.io.IOException; 10 11 import java.nio.charset.StandardCharsets; 11 12 import java.util.List; … … 23 24 24 25 /** 26 * Parses a GPX file and returns the parsed data 27 * @param filename the GPX file to parse 28 * @return the parsed GPX data 29 * @throws IOException if an error occurs during reading. 30 * @throws SAXException if a SAX error occurs 31 */ 32 public static GpxData parseGpxData(String filename) throws IOException, SAXException { 33 final GpxData result; 34 try (final FileInputStream in = new FileInputStream(new File(filename))) { 35 final GpxReader reader = new GpxReader(in); 36 assertTrue(reader.parse(false)); 37 result = reader.getGpxData(); 38 } 39 return result; 40 } 41 42 /** 25 43 * Tests the {@code munich.gpx} test file. 26 44 * @throws Exception if something goes wrong … … 28 46 @Test 29 47 public void testMunich() throws Exception { 30 final GpxData result; 31 try (final FileInputStream in = new FileInputStream(new File("data_nodist/munich.gpx"))) { 32 final GpxReader reader = new GpxReader(in); 33 assertTrue(reader.parse(false)); 34 result = reader.getGpxData(); 35 } 48 final GpxData result = parseGpxData("data_nodist/munich.gpx"); 36 49 assertEquals(2762, result.tracks.size()); 37 50 assertEquals(0, result.routes.size());
Note:
See TracChangeset
for help on using the changeset viewer.