Changeset 31496 in osm for applications


Ignore:
Timestamp:
2015-08-13T00:07:18+02:00 (9 years ago)
Author:
nokutu
Message:

Fixed upload with images taken with the Mapillary app.

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/build.xml

    r31493 r31496  
    55    <property name="plugin.main.version" value="8433"/>
    66    <property name="plugin.canloadatruntime" value="true"/>
    7     <property name="plugin.version" value="0.9.3"/>
     7    <property name="plugin.version" value="0.9.4"/>
    88    <property name="plugin.author" value="nokutu &lt;nokutu@openmailbox.org&gt;"/>
    99    <property name="plugin.class" value="org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin"/>
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java

    r31460 r31496  
    235235   *          The format of the date.
    236236   * @return The date in Epoch format.
    237    */
    238   public static long getEpoch(String date, String format) {
     237   * @throws ParseException
     238   */
     239  public static long getEpoch(String date, String format) throws ParseException {
    239240
    240241    SimpleDateFormat formatter = new SimpleDateFormat(format);
    241     try {
    242       Date dateTime = formatter.parse(date);
    243       return dateTime.getTime();
    244     } catch (ParseException e) {
    245       Main.error(e);
    246     }
    247     return currentTime();
     242    Date dateTime = formatter.parse(date);
     243    return dateTime.getTime();
     244
    248245  }
    249246
     
    253250   * @return The current date in Epoch format.
    254251   */
    255   private static long currentTime() {
     252  protected static long currentTime() {
    256253    Calendar cal = Calendar.getInstance();
    257254    return cal.getTimeInMillis();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java

    r31458 r31496  
    44import java.io.File;
    55import java.io.IOException;
     6import java.text.ParseException;
    67import java.text.SimpleDateFormat;
    78import java.util.Calendar;
     
    2021  protected File file;
    2122  /** The date when the picture was taken. */
    22   public final long datetimeOriginal;
     23  public long datetimeOriginal;
    2324
    2425  /**
     
    5758    super(lat, lon, ca);
    5859    this.file = file;
    59     this.datetimeOriginal = getEpoch(datetimeOriginal, "yyyy:MM:dd hh:mm:ss");
     60    try {
     61      this.datetimeOriginal = getEpoch(datetimeOriginal, "yyyy:MM:dd hh:mm:ss");
     62    } catch (ParseException e) {
     63      try {
     64        this.datetimeOriginal = getEpoch(datetimeOriginal,
     65            "yyyy/MM/dd hh:mm:ss");
     66      } catch (ParseException e1) {
     67        this.datetimeOriginal = currentTime();
     68      }
     69    }
    6070  }
    6171
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31491 r31496  
    2626import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
    2727import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
     28import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
    2829import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
    2930import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
     
    188189        Main.error(e);
    189190      }
    190       System.out.println(this.images.size());
    191191      if (this.delete)
    192         MapillaryRecord.getInstance().addCommand(new CommandDelete(this.images));
     192        MapillaryRecord.getInstance()
     193            .addCommand(new CommandDelete(this.images));
    193194    }
    194195  }
     
    230231    TiffOutputDirectory exifDirectory = null;
    231232    TiffOutputDirectory gpsDirectory = null;
     233    TiffOutputDirectory rootDirectory = null;
     234
    232235    // If the image is imported, loads the rest of the EXIF data.
    233236    JpegImageMetadata jpegMetadata = null;
     
    248251    gpsDirectory = outputSet.getOrCreateGPSDirectory();
    249252    exifDirectory = outputSet.getOrCreateExifDirectory();
     253    rootDirectory = outputSet.getOrCreateRootDirectory();
    250254
    251255    gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF);
     
    260264    exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL,
    261265        ((MapillaryImportedImage) image).getDate("yyyy/MM/dd hh:mm:ss"));
     266
     267    rootDirectory.removeField(TiffTagConstants.TIFF_TAG_IMAGE_DESCRIPTION);
    262268
    263269    outputSet.setGPSInDegrees(image.getLatLon().lon(), image.getLatLon().lat());
Note: See TracChangeset for help on using the changeset viewer.