Changeset 31456 in osm


Ignore:
Timestamp:
2015-08-05T16:28:26+02:00 (9 years ago)
Author:
nokutu
Message:

Created several utils classes

Location:
applications/editors/josm/plugins/mapillary
Files:
2 added
9 edited
1 copied
1 moved

Legend:

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

    r31451 r31456  
    1111import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode;
    1212import org.openstreetmap.josm.plugins.mapillary.mode.SelectMode;
    13 import org.openstreetmap.josm.plugins.mapillary.utils.PluginState;
     13import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    1414import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.gui.layer.Layer;
     
    151151      Main.map.mapView.addMouseMotionListener(mode);
    152152      NavigatableComponent.addZoomChangeListener(mode);
    153       updateHelpText();
     153      MapillaryUtils.updateHelpText();
    154154    }
    155155  }
     
    583583  public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    584584    if (newLayer == this) {
    585       updateHelpText();
     585      MapillaryUtils.updateHelpText();
    586586      MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, true);
    587587    } else
     
    598598    // Nothing
    599599  }
    600 
    601   /**
    602    * Updates the help text at the bottom of the window.
    603    */
    604   public void updateHelpText() {
    605     String ret = "";
    606     if (PluginState.isDownloading())
    607       ret += tr("Downloading");
    608     else if (this.data.size() > 0)
    609       ret += tr("Total images: {0}", this.data.size());
    610     else
    611       ret += tr("No images found");
    612     if (this.mode != null)
    613       ret += " -- " + tr(this.mode.toString());
    614     if (PluginState.isUploading())
    615       ret += " -- " + PluginState.getUploadString();
    616     Main.map.statusLine.setHelpText(ret);
    617   }
    618600}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java

    r31451 r31456  
    2525import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    2626import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
     27import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    2728import org.openstreetmap.josm.tools.Shortcut;
    2829
     
    153154      double caValue = 0;
    154155      if (lat.getValue() instanceof RationalNumber[])
    155         latValue = degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref
     156        latValue = MapillaryUtils.degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref
    156157            .getValue().toString());
    157158      if (lon.getValue() instanceof RationalNumber[])
    158         lonValue = degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref
     159        lonValue = MapillaryUtils.degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref
    159160            .getValue().toString());
    160161      if (ca != null && ca.getValue() instanceof RationalNumber)
     
    216217    return readNoTags(file);
    217218  }
    218 
    219   /**
    220    * Calculates the decimal degree-value from a degree value given in
    221    * degrees-minutes-seconds-format
    222    *
    223    * @param degMinSec
    224    *          an array of length 3, the values in there are (in this order)
    225    *          degrees, minutes and seconds
    226    * @param ref
    227    *          the latitude or longitude reference determining if the given value
    228    *          is:
    229    *          <ul>
    230    *          <li>north (
    231    *          {@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH}) or
    232    *          south (
    233    *          {@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH}) of
    234    *          the equator</li>
    235    *          <li>east (
    236    *          {@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST}) or
    237    *          west ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST}
    238    *          ) of the equator</li>
    239    *          </ul>
    240    * @return the decimal degree-value for the given input, negative when west of
    241    *         0-meridian or south of equator, positive otherwise
    242    * @throws IllegalArgumentException
    243    *           if {@code degMinSec} doesn't have length 3 or if {@code ref} is
    244    *           not one of the values mentioned above
    245    */
    246   // TODO: Maybe move into a separate utility class?
    247   public static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) {
    248     if (degMinSec == null || degMinSec.length != 3) {
    249       throw new IllegalArgumentException("Array's length must be 3.");
    250     }
    251     for (int i = 0; i < 3; i++)
    252       if (degMinSec[i] == null)
    253         throw new IllegalArgumentException("Null value in array.");
    254 
    255     switch (ref) {
    256       case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH:
    257       case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH:
    258       case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST:
    259       case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST:
    260         break;
    261       default:
    262         throw new IllegalArgumentException("Invalid ref.");
    263     }
    264 
    265     double result = degMinSec[0].doubleValue(); // degrees
    266     result += degMinSec[1].doubleValue() / 60; // minutes
    267     result += degMinSec[2].doubleValue() / 3600; // seconds
    268 
    269     if (GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH.equals(ref)
    270         || GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST.equals(ref)) {
    271       result *= -1;
    272     }
    273 
    274     result = 360 * ((result + 180) / 360 - Math.floor((result + 180) / 360)) - 180;
    275     return result;
    276   }
    277219}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java

    r31451 r31456  
    2929import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    3030import org.openstreetmap.josm.plugins.mapillary.MapillarySequence;
     31import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    3132import org.openstreetmap.josm.tools.Shortcut;
    3233
     
    151152      double caValue = 0;
    152153      if (lat.getValue() instanceof RationalNumber[])
    153         latValue = MapillaryImportAction.degMinSecToDouble(
     154        latValue = MapillaryUtils.degMinSecToDouble(
    154155            (RationalNumber[]) lat.getValue(), lat_ref.getValue().toString());
    155156      if (lon.getValue() instanceof RationalNumber[])
    156         lonValue = MapillaryImportAction.degMinSecToDouble(
     157        lonValue = MapillaryUtils.degMinSecToDouble(
    157158            (RationalNumber[]) lon.getValue(), lon_ref.getValue().toString());
    158159      if (ca != null && ca.getValue() instanceof RationalNumber)
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java

    r31452 r31456  
    1717import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    1818import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryUploadDialog;
    19 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthUtils;
     19import org.openstreetmap.josm.plugins.mapillary.oauth.UploadUtils;
    2020import org.openstreetmap.josm.tools.Shortcut;
    2121
     
    5252        && (int) pane.getValue() == JOptionPane.OK_OPTION) {
    5353      if (dialog.sequence.isSelected()) {
    54         OAuthUtils.uploadSequence(MapillaryLayer.getInstance().getData()
     54        UploadUtils.uploadSequence(MapillaryLayer.getInstance().getData()
    5555            .getSelectedImage().getSequence());
    5656      }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java

    r31451 r31456  
    1111import org.openstreetmap.josm.Main;
    1212import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    13 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    1413import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
    1514import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
     15import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    1616import org.openstreetmap.josm.plugins.mapillary.utils.PluginState;
    1717
     
    6969    try {
    7070      PluginState.startDownload();
    71       MapillaryLayer.getInstance().updateHelpText();
     71      MapillaryUtils.updateHelpText();
    7272      downloadSequences();
    7373      completeImages();
     
    7878    } finally {
    7979      PluginState.finishDownload();
    80       MapillaryLayer.getInstance().updateHelpText();
     80      MapillaryUtils.updateHelpText();
    8181    }
    82     MapillaryLayer.getInstance().updateHelpText();
     82    MapillaryUtils.updateHelpText();
    8383    MapillaryData.dataUpdated();
    8484    MapillaryFilterDialog.getInstance().refresh();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java

    r31455 r31456  
    11package org.openstreetmap.josm.plugins.mapillary.oauth;
    22
    3 import java.io.BufferedOutputStream;
    43import java.io.BufferedReader;
    5 import java.io.ByteArrayOutputStream;
    6 import java.io.File;
    7 import java.io.FileOutputStream;
    84import java.io.IOException;
    95import java.io.InputStreamReader;
    10 import java.io.OutputStream;
    11 import java.io.UnsupportedEncodingException;
    126import java.net.HttpURLConnection;
    137import java.net.URL;
    14 import java.security.InvalidKeyException;
    15 import java.security.NoSuchAlgorithmException;
    16 import java.util.HashMap;
    17 import java.util.List;
    18 import java.util.UUID;
    19 import java.util.concurrent.ArrayBlockingQueue;
    20 import java.util.concurrent.ThreadPoolExecutor;
    21 import java.util.concurrent.TimeUnit;
    228
    23 import javax.imageio.ImageIO;
    249import javax.json.Json;
    2510import javax.json.JsonObject;
    2611
    27 import org.apache.commons.imaging.ImageReadException;
    28 import org.apache.commons.imaging.ImageWriteException;
    29 import org.apache.commons.imaging.Imaging;
    30 import org.apache.commons.imaging.common.ImageMetadata;
    31 import org.apache.commons.imaging.common.RationalNumber;
    32 import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
    33 import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
    34 import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
    35 import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
    36 import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
    37 import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
    38 import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
    39 import org.apache.http.HttpEntity;
    40 import org.apache.http.HttpResponse;
    41 import org.apache.http.client.HttpClient;
    42 import org.apache.http.client.methods.HttpPost;
    43 import org.apache.http.entity.ContentType;
    44 import org.apache.http.entity.mime.MultipartEntityBuilder;
    45 import org.apache.http.entity.mime.content.FileBody;
    46 import org.apache.http.entity.mime.content.StringBody;
    47 import org.apache.http.impl.client.HttpClientBuilder;
    4812import org.openstreetmap.josm.Main;
    49 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    50 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    51 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    52 import org.openstreetmap.josm.plugins.mapillary.MapillarySequence;
    53 import org.openstreetmap.josm.plugins.mapillary.utils.PluginState;
    5413
    5514/**
     
    6019 */
    6120public class OAuthUtils {
    62 
    63   private static final String[] keys = { "key", "AWSAccessKeyId", "acl",
    64       "policy", "signature", "Content-Type" };
    65   private static final String UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images";
    66 
    67   // Count to name temporal files.
    68   private static int c = 0;
    6921
    7022  /**
     
    8840    return Json.createReader(in).readObject();
    8941  }
    90 
    91   /**
    92    * Uploads the given MapillaryImportedImage object.
    93    *
    94    * @param image
    95    *
    96    * @throws NoSuchAlgorithmException
    97    * @throws UnsupportedEncodingException
    98    * @throws InvalidKeyException
    99    *
    100    */
    101   public static void upload(MapillaryImportedImage image)
    102       throws InvalidKeyException, UnsupportedEncodingException,
    103       NoSuchAlgorithmException {
    104     try {
    105       upload(image, UUID.randomUUID());
    106     } catch (IOException e) {
    107       Main.error(e);
    108     }
    109   }
    110 
    111   /**
    112    * @param image
    113    * @param uuid
    114    *          The UUID used to create the sequence.
    115    * @throws NoSuchAlgorithmException
    116    * @throws InvalidKeyException
    117    * @throws IOException
    118    */
    119   public static void upload(MapillaryImportedImage image, UUID uuid)
    120       throws NoSuchAlgorithmException, InvalidKeyException, IOException {
    121     String key = MapillaryUser.getUsername() + "/" + uuid.toString() + "/"
    122         + image.getLatLon().lat() + "_" + image.getLatLon().lon() + "_"
    123         + image.getCa() + "_" + image.datetimeOriginal + ".jpg";
    124 
    125     String policy = null;
    126     String signature = null;
    127     policy = MapillaryUser.getSecrets().get("images_policy");
    128     signature = MapillaryUser.getSecrets().get("images_hash");
    129 
    130     HashMap<String, String> hash = new HashMap<>();
    131     hash.put("key", key);
    132     hash.put("AWSAccessKeyId", "AKIAI2X3BJAT2W75HILA");
    133     hash.put("acl", "private");
    134     hash.put("policy", policy);
    135     hash.put("signature", signature);
    136     hash.put("Content-Type", "image/jpeg");
    137 
    138     try {
    139       uploadFile(updateFile(image), hash);
    140     } catch (ImageReadException | ImageWriteException e) {
    141       Main.error(e);
    142     }
    143 
    144   }
    145 
    146   /**
    147    * @param file
    148    * @param hash
    149    * @throws IOException
    150    */
    151   public static void uploadFile(File file, HashMap<String, String> hash)
    152       throws IOException {
    153     HttpClientBuilder builder = HttpClientBuilder.create();
    154     HttpClient httpClient = builder.build();
    155     HttpPost httpPost = new HttpPost(UPLOAD_URL);
    156 
    157     MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
    158     for (String key : keys) {
    159       entityBuilder.addPart(key, new StringBody(hash.get(key),
    160           ContentType.TEXT_PLAIN));
    161     }
    162     entityBuilder.addPart("file", new FileBody(file));
    163 
    164     HttpEntity entity = entityBuilder.build();
    165     httpPost.setEntity(entity);
    166 
    167     HttpResponse response = httpClient.execute(httpPost);
    168     if (response.getStatusLine().toString().contains("204")) {
    169       PluginState.imageUploaded();
    170     }
    171     file.delete();
    172     MapillaryLayer.getInstance().updateHelpText();
    173   }
    174 
    175   /**
    176    * Uploads the given {@link MapillarySequence}.
    177    *
    178    * @param sequence
    179    *          The sequence to upload. It must contain only
    180    *          {@link MapillaryImportedImage} objects.
    181    */
    182   public static void uploadSequence(MapillarySequence sequence) {
    183     new SequenceUploadThread(sequence.getImages()).start();
    184   }
    185 
    186   private static class SequenceUploadThread extends Thread {
    187     private List<MapillaryAbstractImage> images;
    188     private UUID uuid;
    189     ThreadPoolExecutor ex;
    190 
    191     private SequenceUploadThread(List<MapillaryAbstractImage> images) {
    192       this.images = images;
    193       this.uuid = UUID.randomUUID();
    194       this.ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS,
    195           new ArrayBlockingQueue<Runnable>(5));
    196     }
    197 
    198     @Override
    199     public void run() {
    200       PluginState.startUpload();
    201       PluginState.imagesToUpload(this.images.size());
    202       MapillaryLayer.getInstance().updateHelpText();
    203       for (MapillaryAbstractImage img : this.images) {
    204         if (!(img instanceof MapillaryImportedImage))
    205           throw new IllegalArgumentException(
    206               "The sequence contains downloaded images.");
    207         this.ex.execute(new SingleUploadThread((MapillaryImportedImage) img,
    208             this.uuid));
    209       }
    210       this.ex.shutdown();
    211       PluginState.finishUpload();
    212     }
    213   }
    214 
    215   private static class SingleUploadThread extends Thread {
    216 
    217     private MapillaryImportedImage image;
    218     private UUID uuid;
    219 
    220     private SingleUploadThread(MapillaryImportedImage image, UUID uuid) {
    221       this.image = image;
    222       this.uuid = uuid;
    223     }
    224 
    225     @Override
    226     public void run() {
    227       try {
    228         OAuthUtils.upload(this.image, this.uuid);
    229       } catch (InvalidKeyException | NoSuchAlgorithmException | IOException e) {
    230         Main.error(e);
    231       }
    232     }
    233   }
    234 
    235   /**
    236    * Returns a file containing the picture and an updated version of the EXIF
    237    * tags.
    238    *
    239    * @param image
    240    * @return A File object containing the picture and an updated version of the
    241    *         EXIF tags.
    242    * @throws ImageReadException
    243    * @throws IOException
    244    * @throws ImageWriteException
    245    */
    246   public static File updateFile(MapillaryImportedImage image)
    247       throws ImageReadException, IOException, ImageWriteException {
    248     TiffOutputSet outputSet = null;
    249     TiffOutputDirectory exifDirectory = null;
    250     TiffOutputDirectory gpsDirectory = null;
    251     // If the image is imported, loads the rest of the EXIF data.
    252     ImageMetadata metadata = Imaging.getMetadata(image.getFile());
    253     final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
    254     if (null != jpegMetadata) {
    255       final TiffImageMetadata exif = jpegMetadata.getExif();
    256       if (null != exif) {
    257         outputSet = exif.getOutputSet();
    258       }
    259     }
    260     if (null == outputSet) {
    261       outputSet = new TiffOutputSet();
    262     }
    263     gpsDirectory = outputSet.getOrCreateGPSDirectory();
    264     exifDirectory = outputSet.getOrCreateExifDirectory();
    265 
    266     gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF);
    267     gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF,
    268         GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF_VALUE_TRUE_NORTH);
    269 
    270     gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
    271     gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION,
    272         RationalNumber.valueOf(image.getCa()));
    273 
    274     exifDirectory.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
    275     exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL,
    276         ((MapillaryImportedImage) image).getDate("yyyy/MM/dd hh:mm:ss"));
    277 
    278     outputSet.setGPSInDegrees(image.getLatLon().lon(), image.getLatLon().lat());
    279     File tempFile = new File(c + ".tmp");
    280     c++;
    281     OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile));
    282 
    283     // Transforms the image into a byte array.
    284     ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    285     ImageIO.write(image.getImage(), "jpg", outputStream);
    286     byte[] imageBytes = outputStream.toByteArray();
    287 
    288     new ExifRewriter().updateExifMetadataLossless(imageBytes, os, outputSet);
    289 
    290     return tempFile;
    291   }
    29242}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java

    r31455 r31456  
    22
    33import java.io.BufferedOutputStream;
    4 import java.io.BufferedReader;
    54import java.io.ByteArrayOutputStream;
    65import java.io.File;
    76import java.io.FileOutputStream;
    87import java.io.IOException;
    9 import java.io.InputStreamReader;
    108import java.io.OutputStream;
    119import java.io.UnsupportedEncodingException;
    12 import java.net.HttpURLConnection;
    13 import java.net.URL;
    1410import java.security.InvalidKeyException;
    1511import java.security.NoSuchAlgorithmException;
     
    2218
    2319import javax.imageio.ImageIO;
    24 import javax.json.Json;
    25 import javax.json.JsonObject;
    2620
    2721import org.apache.commons.imaging.ImageReadException;
     
    4943import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    5044import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    51 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    5245import org.openstreetmap.josm.plugins.mapillary.MapillarySequence;
     46import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    5347import org.openstreetmap.josm.plugins.mapillary.utils.PluginState;
    5448
    5549/**
    56  * A set of utilities related to OAuth.
     50 * Upload utilities.
    5751 *
    5852 * @author nokutu
    5953 *
    6054 */
    61 public class OAuthUtils {
     55public class UploadUtils {
    6256
    6357  private static final String[] keys = { "key", "AWSAccessKeyId", "acl",
    6458      "policy", "signature", "Content-Type" };
    6559  private static final String UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images";
    66 
    67   // Count to name temporal files.
     60  /** Count to name temporal files. */
    6861  private static int c = 0;
    69 
    70   /**
    71    * Returns a JsonObject containing the result of making a GET request with the
    72    * authorization header.
    73    *
    74    * @param url
    75    *          The {@link URL} where the request must be made.
    76    * @return A JsonObject containing the result of the GET request.
    77    * @throws IOException
    78    *           Errors relating to the connection.
    79    */
    80   public static JsonObject getWithHeader(URL url) throws IOException {
    81     HttpURLConnection con = (HttpURLConnection) url.openConnection();
    82     con.setRequestMethod("GET");
    83     con.setRequestProperty("Authorization",
    84         "Bearer " + Main.pref.get("mapillary.access-token"));
    85 
    86     BufferedReader in = new BufferedReader(new InputStreamReader(
    87         con.getInputStream()));
    88     return Json.createReader(in).readObject();
    89   }
    9062
    9163  /**
     
    170142    }
    171143    file.delete();
    172     MapillaryLayer.getInstance().updateHelpText();
     144    MapillaryUtils.updateHelpText();
    173145  }
    174146
     
    200172      PluginState.startUpload();
    201173      PluginState.imagesToUpload(this.images.size());
    202       MapillaryLayer.getInstance().updateHelpText();
     174      MapillaryUtils.updateHelpText();
    203175      for (MapillaryAbstractImage img : this.images) {
    204176        if (!(img instanceof MapillaryImportedImage))
     
    226198    public void run() {
    227199      try {
    228         OAuthUtils.upload(this.image, this.uuid);
     200        upload(this.image, this.uuid);
    229201      } catch (InvalidKeyException | NoSuchAlgorithmException | IOException e) {
    230202        Main.error(e);
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/AbstractTest.java

    r31425 r31456  
    22
    33import org.junit.BeforeClass;
    4 import org.openstreetmap.josm.plugins.mapillary.util.TestUtil;
     4import org.openstreetmap.josm.plugins.mapillary.utils.TestUtil;
    55
    66/**
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java

    r31425 r31456  
    1414import org.openstreetmap.josm.data.coor.LatLon;
    1515import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction;
     16import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    1617
    1718/**
     
    6162    num[2] = new RationalNumber(0, 1);
    6263    String ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH;
    63     assertEquals(1, MapillaryImportAction.degMinSecToDouble(num, ref), 0.01);
     64    assertEquals(1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
    6465    ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH;
    65     assertEquals(-1, MapillaryImportAction.degMinSecToDouble(num, ref), 0.01);
     66    assertEquals(-1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
    6667    num[0] = new RationalNumber(180, 1);
    67     assertEquals(-180, MapillaryImportAction.degMinSecToDouble(num, ref), 0.01);
     68    assertEquals(-180, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
    6869    num[0] = new RationalNumber(190, 1);
    69     assertEquals(170, MapillaryImportAction.degMinSecToDouble(num, ref), 0.01);
     70    assertEquals(170, MapillaryUtils.degMinSecToDouble(num, ref), 0.01);
    7071  }
    71 
    7272}
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/UploadTest.java

    r31455 r31456  
    1919import org.openstreetmap.josm.data.coor.LatLon;
    2020import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction;
    21 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthUtils;
     21import org.openstreetmap.josm.plugins.mapillary.oauth.UploadUtils;
     22import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils;
    2223
    2324public class UploadTest extends AbstractTest {
     
    3334    File updatedFile = null;
    3435    try {
    35       updatedFile = OAuthUtils.updateFile(img);
     36      updatedFile = UploadUtils.updateFile(img);
    3637      ImageMetadata metadata = Imaging.getMetadata(updatedFile);
    3738      final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
     
    4849      assertTrue(jpegMetadata
    4950          .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL) != null);
    50       assertEquals(0, MapillaryImportAction.degMinSecToDouble(
     51      assertEquals(0, MapillaryUtils.degMinSecToDouble(
    5152          (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch(
    5253              GpsTagConstants.GPS_TAG_GPS_LATITUDE).getValue(),
     
    5556                  GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF).getValue()
    5657              .toString()), 0.01);
    57       assertEquals(0, MapillaryImportAction.degMinSecToDouble(
     58      assertEquals(0, MapillaryUtils.degMinSecToDouble(
    5859          (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch(
    5960              GpsTagConstants.GPS_TAG_GPS_LONGITUDE).getValue(),
  • applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/TestUtil.java

    r31455 r31456  
    1 package org.openstreetmap.josm.plugins.mapillary.util;
     1package org.openstreetmap.josm.plugins.mapillary.utils;
    22
    33import java.io.File;
Note: See TracChangeset for help on using the changeset viewer.