Changeset 32033 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-01-31T11:37:54+01:00 (9 years ago)
Author:
nokutu
Message:

[mapillary] Construct images with a LatLon object instead of two doubles representing lat/lon

Location:
applications/editors/josm/plugins/mapillary
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java

    r31983 r32033  
    5151   * Creates a new object in the given position and with the given direction.
    5252   *
    53    * @param lat
    54    *          The latitude where the picture was taken.
    55    * @param lon
    56    *          The longitude where the picture was taken.
    57    * @param ca
    58    *          The direction of the picture (0 means north).
    59    */
    60   protected MapillaryAbstractImage(final double lat, final double lon, final double ca) {
    61     this.latLon = new LatLon(lat, lon);
     53   * @param latLon  The latitude and longitude where the picture was taken.
     54   * @param ca  The direction of the picture (0 means north).
     55   */
     56  protected MapillaryAbstractImage(final LatLon latLon, final double ca) {
     57    this.latLon = latLon;
    6258    this.tempLatLon = this.latLon;
    6359    this.movingLatLon = this.latLon;
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java

    r31882 r32033  
    44import java.util.ArrayList;
    55import java.util.List;
     6
     7import org.openstreetmap.josm.data.coor.LatLon;
    68
    79/**
     
    2527   * Main constructor of the class MapillaryImage
    2628   *
    27    * @param key
    28    *          The unique identifier of the image.
    29    * @param lat
    30    *          The latitude where it is positioned.
    31    * @param lon
    32    *          The longitude where it is positioned.
    33    * @param ca
    34    *          The direction of the images in degrees, meaning 0 north.
     29   * @param key  The unique identifier of the image.
     30   * @param latLon  The latitude and longitude where it is positioned.
     31   * @param ca  The direction of the images in degrees, meaning 0 north.
    3532   */
    36   public MapillaryImage(String key, double lat, double lon, double ca) {
    37     super(lat, lon, ca);
     33  public MapillaryImage(final String key, final LatLon latLon, final double ca) {
     34    super(latLon, ca);
    3835    this.key = key;
    3936  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java

    r31882 r32033  
    99import javax.imageio.ImageIO;
    1010
     11import org.openstreetmap.josm.data.coor.LatLon;
    1112import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    1213
     
    2728   * Using when the EXIF tags doesn't contain that info.
    2829   *
    29    * @param lat
    30    *          Latitude where the picture was taken.
    31    * @param lon
    32    *          Longitude where the picture was taken.
    33    * @param ca
    34    *          Direction of the picture (0 means north).
    35    * @param file
    36    *          The file containing the picture.
     30   * @param latLon  The latitude and longitude where the picture was taken.
     31   * @param ca  Direction of the picture (0 means north).
     32   * @param file  The file containing the picture.
    3733   */
    38   public MapillaryImportedImage(double lat, double lon, double ca, File file) {
    39     this(lat, lon, ca, file, MapillaryUtils.currentDate());
     34  public MapillaryImportedImage(final LatLon latLon, final double ca, final File file) {
     35    this(latLon, ca, file, MapillaryUtils.currentDate());
    4036  }
    4137
     
    4339   * Main constructor of the class.
    4440   *
    45    * @param lat
    46    *          Latitude where the picture was taken.
    47    * @param lon
    48    *          Longitude where the picture was taken.
    49    * @param ca
    50    *          Direction of the picture (0 means north),
    51    * @param file
    52    *          The file containing the picture.
    53    * @param datetimeOriginal
    54    *          The date the picture was taken.
     41   * @param latLon  Latitude and Longitude where the picture was taken.
     42   * @param ca  Direction of the picture (0 means north),
     43   * @param file  The file containing the picture.
     44   * @param datetimeOriginal  The date the picture was taken.
    5545   */
    56   public MapillaryImportedImage(double lat, double lon, double ca, File file,
    57       String datetimeOriginal) {
    58     super(lat, lon, ca);
     46  public MapillaryImportedImage(final LatLon latLon, final double ca, final File file, final String datetimeOriginal) {
     47    super(latLon, ca);
    5948    this.file = file;
    6049    try {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThread.java

    r31909 r32033  
    1616import org.openstreetmap.josm.Main;
    1717import org.openstreetmap.josm.data.Bounds;
     18import org.openstreetmap.josm.data.coor.LatLon;
    1819import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    1920import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
     
    7172        for (int j = 0; j < cas.size(); j++) {
    7273          try {
    73             images.add(new MapillaryImage(keys.getString(j), coords
    74                     .getJsonArray(j).getJsonNumber(1).doubleValue(), coords
    75                     .getJsonArray(j).getJsonNumber(0).doubleValue(), cas
    76                     .getJsonNumber(j).doubleValue()));
     74            images.add(new MapillaryImage(
     75                keys.getString(j),
     76                new LatLon(
     77                    coords.getJsonArray(j).getJsonNumber(1).doubleValue(),
     78                    coords.getJsonArray(j).getJsonNumber(0).doubleValue()
     79                ),
     80                cas.getJsonNumber(j).doubleValue()));
    7781          } catch (IndexOutOfBoundsException e) {
    7882            Main.warn("Mapillary bug at " + MapillaryURL.searchSequenceURL(bounds, page));
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java

    r31983 r32033  
    280280        caValue = ((RationalNumber) ca.getValue()).doubleValue();
    281281      if (datetimeOriginal != null) {
    282         return new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue());
    283       }
    284       return new MapillaryImportedImage(latValue, lonValue, caValue, file);
     282        return new MapillaryImportedImage(new LatLon(latValue, lonValue), caValue, file, datetimeOriginal.getStringValue());
     283      }
     284      return new MapillaryImportedImage(new LatLon(latValue, lonValue), caValue, file);
    285285    }
    286286    throw new IllegalStateException("Invalid format.");
     
    323323                      ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
    324324      if (datetimeOriginal == null) {
    325         return new MapillaryImportedImage(pos.lat(), pos.lon(), 0, file);
     325        return new MapillaryImportedImage(pos, 0, file);
    326326      }
    327327      try {
    328         return new MapillaryImportedImage(pos.lat(), pos.lon(), 0, file, datetimeOriginal.getStringValue());
     328        return new MapillaryImportedImage(pos, 0, file, datetimeOriginal.getStringValue());
    329329      } catch (ImageReadException e) {
    330330        Main.error(e);
    331331      }
    332332    }
    333     return new MapillaryImportedImage(pos.lat(), pos.lon(), 0, file);
     333    return new MapillaryImportedImage(pos, 0, file);
    334334  }
    335335
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java

    r31512 r32033  
    4040  @Test(expected = IIOException.class)
    4141  public void testInvalidFiles() throws IOException {
    42     MapillaryImportedImage img = new MapillaryImportedImage(0, 0, 0, null);
     42    MapillaryImportedImage img = new MapillaryImportedImage(new LatLon(0, 0), 0, null);
    4343    assertEquals(null, img.getImage());
    4444    assertEquals(null, img.getFile());
    4545
    46     img = new MapillaryImportedImage(0, 0, 0, new File(""));
     46    img = new MapillaryImportedImage(new LatLon(0, 0), 0, new File(""));
    4747    assertEquals(new File(""), img.getFile());
    4848    img.getImage();
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImageTest.java

    r31460 r32033  
    1010import org.junit.Test;
    1111import org.openstreetmap.josm.Main;
     12import org.openstreetmap.josm.data.coor.LatLon;
    1213
    1314/**
     
    2324    TimeZone.setDefault(TimeZone.getTimeZone("GMT+0745"));
    2425
    25     MapillaryAbstractImage mai = new MapillaryImportedImage(0, 0, 0, null);
     26    MapillaryAbstractImage mai = new MapillaryImportedImage(new LatLon(0, 0), 0, null);
    2627    mai.setCapturedAt(1044087606000l); // in timezone GMT+0745 this is Saturday, February 1, 2003 16:05:06
    2728
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryDataTest.java

    r31909 r32033  
    99import org.junit.Before;
    1010import org.junit.Test;
     11import org.openstreetmap.josm.data.coor.LatLon;
    1112
    1213/**
     
    3132  @Before
    3233  public void setUp() {
    33     this.img1 = new MapillaryImage("key1", 0.1, 0.1, 90);
    34     this.img2 = new MapillaryImage("key2", 0.2, 0.2, 90);
    35     this.img3 = new MapillaryImage("key3", 0.3, 0.3, 90);
    36     this.img4 = new MapillaryImage("key4", 0.4, 0.4, 90);
     34    this.img1 = new MapillaryImage("key1", new LatLon(0.1, 0.1), 90);
     35    this.img2 = new MapillaryImage("key2", new LatLon(0.2, 0.2), 90);
     36    this.img3 = new MapillaryImage("key3", new LatLon(0.3, 0.3), 90);
     37    this.img4 = new MapillaryImage("key4", new LatLon(0.4, 0.4), 90);
    3738    this.seq = new MapillarySequence();
    3839
     
    7475  public void sizeTest() {
    7576    assertEquals(4, this.data.size());
    76     this.data.add(new MapillaryImage("key5", 0.1, 0.1, 90));
     77    this.data.add(new MapillaryImage("key5", new LatLon(0.1, 0.1), 90));
    7778    assertEquals(5, this.data.size());
    7879  }
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillarySequenceTest.java

    r31460 r32033  
    88import org.junit.Before;
    99import org.junit.Test;
     10import org.openstreetmap.josm.data.coor.LatLon;
    1011
    1112/**
     
    2930  @Before
    3031  public void setUp() {
    31     this.img1 = new MapillaryImage("key1", 0.1, 0.1, 90);
    32     this.img2 = new MapillaryImage("key2", 0.2, 0.2, 90);
    33     this.img3 = new MapillaryImage("key3", 0.3, 0.3, 90);
    34     this.img4 = new MapillaryImage("key4", 0.4, 0.4, 90);
     32    this.img1 = new MapillaryImage("key1", new LatLon(0.1, 0.1), 90);
     33    this.img2 = new MapillaryImage("key2", new LatLon(0.2, 0.2), 90);
     34    this.img3 = new MapillaryImage("key3", new LatLon(0.3, 0.3), 90);
     35    this.img4 = new MapillaryImage("key4", new LatLon(0.4, 0.4), 90);
    3536    this.seq = new MapillarySequence();
    3637
     
    6364    // that is not in the sequence.
    6465    try {
    65       this.seq.next(new MapillaryImage("key5", 0.5, 0.5, 90));
     66      this.seq.next(new MapillaryImage("key5", new LatLon(0.5, 0.5), 90));
    6667      fail();
    6768    } catch (IllegalArgumentException e) {
     
    7273    // image that is not in the sequence.
    7374    try {
    74       this.seq.previous(new MapillaryImage("key5", 0.5, 0.5, 90));
     75      this.seq.previous(new MapillaryImage("key5", new LatLon(0.5, 0.5), 90));
    7576      fail();
    7677    } catch (IllegalArgumentException e) {
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java

    r31909 r32033  
    1111import org.junit.Before;
    1212import org.junit.Test;
     13import org.openstreetmap.josm.data.coor.LatLon;
    1314import org.openstreetmap.josm.plugins.mapillary.AbstractTest;
    1415import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
     
    4344  public void setUp() {
    4445    this.record = new MapillaryRecord();
    45     this.img1 = new MapillaryImage("key1", 0.1, 0.1, 0.1);
    46     this.img2 = new MapillaryImage("key2", 0.2, 0.2, 0.2);
    47     this.img3 = new MapillaryImage("key3", 0.3, 0.3, 0.3);
     46    this.img1 = new MapillaryImage("key1", new LatLon(0.1, 0.1), 0.1);
     47    this.img2 = new MapillaryImage("key2", new LatLon(0.2, 0.2), 0.2);
     48    this.img3 = new MapillaryImage("key3", new LatLon(0.3, 0.3), 0.3);
    4849    MapillaryLayer.getInstance().getData().getImages().clear();
    4950  }
Note: See TracChangeset for help on using the changeset viewer.