Changeset 31456 in osm
- Timestamp:
- 2015-08-05T16:28:26+02:00 (9 years ago)
- 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 11 11 import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode; 12 12 import org.openstreetmap.josm.plugins.mapillary.mode.SelectMode; 13 import org.openstreetmap.josm.plugins.mapillary.utils. PluginState;13 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 14 14 import org.openstreetmap.josm.Main; 15 15 import org.openstreetmap.josm.gui.layer.Layer; … … 151 151 Main.map.mapView.addMouseMotionListener(mode); 152 152 NavigatableComponent.addZoomChangeListener(mode); 153 updateHelpText();153 MapillaryUtils.updateHelpText(); 154 154 } 155 155 } … … 583 583 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 584 584 if (newLayer == this) { 585 updateHelpText();585 MapillaryUtils.updateHelpText(); 586 586 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.JOIN_MENU, true); 587 587 } else … … 598 598 // Nothing 599 599 } 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 else611 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 }618 600 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31451 r31456 25 25 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 26 26 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 27 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 27 28 import org.openstreetmap.josm.tools.Shortcut; 28 29 … … 153 154 double caValue = 0; 154 155 if (lat.getValue() instanceof RationalNumber[]) 155 latValue = degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref156 latValue = MapillaryUtils.degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref 156 157 .getValue().toString()); 157 158 if (lon.getValue() instanceof RationalNumber[]) 158 lonValue = degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref159 lonValue = MapillaryUtils.degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref 159 160 .getValue().toString()); 160 161 if (ca != null && ca.getValue() instanceof RationalNumber) … … 216 217 return readNoTags(file); 217 218 } 218 219 /**220 * Calculates the decimal degree-value from a degree value given in221 * degrees-minutes-seconds-format222 *223 * @param degMinSec224 * an array of length 3, the values in there are (in this order)225 * degrees, minutes and seconds226 * @param ref227 * the latitude or longitude reference determining if the given value228 * is:229 * <ul>230 * <li>north (231 * {@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH}) or232 * south (233 * {@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH}) of234 * the equator</li>235 * <li>east (236 * {@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST}) or237 * 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 of241 * 0-meridian or south of equator, positive otherwise242 * @throws IllegalArgumentException243 * if {@code degMinSec} doesn't have length 3 or if {@code ref} is244 * not one of the values mentioned above245 */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(); // degrees266 result += degMinSec[1].doubleValue() / 60; // minutes267 result += degMinSec[2].doubleValue() / 3600; // seconds268 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 }277 219 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
r31451 r31456 29 29 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 30 30 import org.openstreetmap.josm.plugins.mapillary.MapillarySequence; 31 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 31 32 import org.openstreetmap.josm.tools.Shortcut; 32 33 … … 151 152 double caValue = 0; 152 153 if (lat.getValue() instanceof RationalNumber[]) 153 latValue = Mapillary ImportAction.degMinSecToDouble(154 latValue = MapillaryUtils.degMinSecToDouble( 154 155 (RationalNumber[]) lat.getValue(), lat_ref.getValue().toString()); 155 156 if (lon.getValue() instanceof RationalNumber[]) 156 lonValue = Mapillary ImportAction.degMinSecToDouble(157 lonValue = MapillaryUtils.degMinSecToDouble( 157 158 (RationalNumber[]) lon.getValue(), lon_ref.getValue().toString()); 158 159 if (ca != null && ca.getValue() instanceof RationalNumber) -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
r31452 r31456 17 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 18 18 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryUploadDialog; 19 import org.openstreetmap.josm.plugins.mapillary.oauth. OAuthUtils;19 import org.openstreetmap.josm.plugins.mapillary.oauth.UploadUtils; 20 20 import org.openstreetmap.josm.tools.Shortcut; 21 21 … … 52 52 && (int) pane.getValue() == JOptionPane.OK_OPTION) { 53 53 if (dialog.sequence.isSelected()) { 54 OAuthUtils.uploadSequence(MapillaryLayer.getInstance().getData()54 UploadUtils.uploadSequence(MapillaryLayer.getInstance().getData() 55 55 .getSelectedImage().getSequence()); 56 56 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31451 r31456 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; 13 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;14 13 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog; 15 14 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; 15 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 16 16 import org.openstreetmap.josm.plugins.mapillary.utils.PluginState; 17 17 … … 69 69 try { 70 70 PluginState.startDownload(); 71 Mapillary Layer.getInstance().updateHelpText();71 MapillaryUtils.updateHelpText(); 72 72 downloadSequences(); 73 73 completeImages(); … … 78 78 } finally { 79 79 PluginState.finishDownload(); 80 Mapillary Layer.getInstance().updateHelpText();80 MapillaryUtils.updateHelpText(); 81 81 } 82 Mapillary Layer.getInstance().updateHelpText();82 MapillaryUtils.updateHelpText(); 83 83 MapillaryData.dataUpdated(); 84 84 MapillaryFilterDialog.getInstance().refresh(); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java
r31455 r31456 1 1 package org.openstreetmap.josm.plugins.mapillary.oauth; 2 2 3 import java.io.BufferedOutputStream;4 3 import java.io.BufferedReader; 5 import java.io.ByteArrayOutputStream;6 import java.io.File;7 import java.io.FileOutputStream;8 4 import java.io.IOException; 9 5 import java.io.InputStreamReader; 10 import java.io.OutputStream;11 import java.io.UnsupportedEncodingException;12 6 import java.net.HttpURLConnection; 13 7 import 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;22 8 23 import javax.imageio.ImageIO;24 9 import javax.json.Json; 25 10 import javax.json.JsonObject; 26 11 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;48 12 import 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;54 13 55 14 /** … … 60 19 */ 61 20 public 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;69 21 70 22 /** … … 88 40 return Json.createReader(in).readObject(); 89 41 } 90 91 /**92 * Uploads the given MapillaryImportedImage object.93 *94 * @param image95 *96 * @throws NoSuchAlgorithmException97 * @throws UnsupportedEncodingException98 * @throws InvalidKeyException99 *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 image113 * @param uuid114 * The UUID used to create the sequence.115 * @throws NoSuchAlgorithmException116 * @throws InvalidKeyException117 * @throws IOException118 */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 file148 * @param hash149 * @throws IOException150 */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 sequence179 * The sequence to upload. It must contain only180 * {@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 @Override199 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 @Override226 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 EXIF237 * tags.238 *239 * @param image240 * @return A File object containing the picture and an updated version of the241 * EXIF tags.242 * @throws ImageReadException243 * @throws IOException244 * @throws ImageWriteException245 */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 }292 42 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/UploadUtils.java
r31455 r31456 2 2 3 3 import java.io.BufferedOutputStream; 4 import java.io.BufferedReader;5 4 import java.io.ByteArrayOutputStream; 6 5 import java.io.File; 7 6 import java.io.FileOutputStream; 8 7 import java.io.IOException; 9 import java.io.InputStreamReader;10 8 import java.io.OutputStream; 11 9 import java.io.UnsupportedEncodingException; 12 import java.net.HttpURLConnection;13 import java.net.URL;14 10 import java.security.InvalidKeyException; 15 11 import java.security.NoSuchAlgorithmException; … … 22 18 23 19 import javax.imageio.ImageIO; 24 import javax.json.Json;25 import javax.json.JsonObject;26 20 27 21 import org.apache.commons.imaging.ImageReadException; … … 49 43 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage; 50 44 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage; 51 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;52 45 import org.openstreetmap.josm.plugins.mapillary.MapillarySequence; 46 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 53 47 import org.openstreetmap.josm.plugins.mapillary.utils.PluginState; 54 48 55 49 /** 56 * A set of utilities related to OAuth.50 * Upload utilities. 57 51 * 58 52 * @author nokutu 59 53 * 60 54 */ 61 public class OAuthUtils {55 public class UploadUtils { 62 56 63 57 private static final String[] keys = { "key", "AWSAccessKeyId", "acl", 64 58 "policy", "signature", "Content-Type" }; 65 59 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. */ 68 61 private static int c = 0; 69 70 /**71 * Returns a JsonObject containing the result of making a GET request with the72 * authorization header.73 *74 * @param url75 * The {@link URL} where the request must be made.76 * @return A JsonObject containing the result of the GET request.77 * @throws IOException78 * 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 }90 62 91 63 /** … … 170 142 } 171 143 file.delete(); 172 Mapillary Layer.getInstance().updateHelpText();144 MapillaryUtils.updateHelpText(); 173 145 } 174 146 … … 200 172 PluginState.startUpload(); 201 173 PluginState.imagesToUpload(this.images.size()); 202 Mapillary Layer.getInstance().updateHelpText();174 MapillaryUtils.updateHelpText(); 203 175 for (MapillaryAbstractImage img : this.images) { 204 176 if (!(img instanceof MapillaryImportedImage)) … … 226 198 public void run() { 227 199 try { 228 OAuthUtils.upload(this.image, this.uuid);200 upload(this.image, this.uuid); 229 201 } catch (InvalidKeyException | NoSuchAlgorithmException | IOException e) { 230 202 Main.error(e); -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/AbstractTest.java
r31425 r31456 2 2 3 3 import org.junit.BeforeClass; 4 import org.openstreetmap.josm.plugins.mapillary.util .TestUtil;4 import org.openstreetmap.josm.plugins.mapillary.utils.TestUtil; 5 5 6 6 /** -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java
r31425 r31456 14 14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction; 16 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 16 17 17 18 /** … … 61 62 num[2] = new RationalNumber(0, 1); 62 63 String ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH; 63 assertEquals(1, Mapillary ImportAction.degMinSecToDouble(num, ref), 0.01);64 assertEquals(1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); 64 65 ref = GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH; 65 assertEquals(-1, Mapillary ImportAction.degMinSecToDouble(num, ref), 0.01);66 assertEquals(-1, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); 66 67 num[0] = new RationalNumber(180, 1); 67 assertEquals(-180, Mapillary ImportAction.degMinSecToDouble(num, ref), 0.01);68 assertEquals(-180, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); 68 69 num[0] = new RationalNumber(190, 1); 69 assertEquals(170, Mapillary ImportAction.degMinSecToDouble(num, ref), 0.01);70 assertEquals(170, MapillaryUtils.degMinSecToDouble(num, ref), 0.01); 70 71 } 71 72 72 } -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/UploadTest.java
r31455 r31456 19 19 import org.openstreetmap.josm.data.coor.LatLon; 20 20 import org.openstreetmap.josm.plugins.mapillary.actions.MapillaryImportAction; 21 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthUtils; 21 import org.openstreetmap.josm.plugins.mapillary.oauth.UploadUtils; 22 import org.openstreetmap.josm.plugins.mapillary.utils.MapillaryUtils; 22 23 23 24 public class UploadTest extends AbstractTest { … … 33 34 File updatedFile = null; 34 35 try { 35 updatedFile = OAuthUtils.updateFile(img);36 updatedFile = UploadUtils.updateFile(img); 36 37 ImageMetadata metadata = Imaging.getMetadata(updatedFile); 37 38 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; … … 48 49 assertTrue(jpegMetadata 49 50 .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL) != null); 50 assertEquals(0, Mapillary ImportAction.degMinSecToDouble(51 assertEquals(0, MapillaryUtils.degMinSecToDouble( 51 52 (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch( 52 53 GpsTagConstants.GPS_TAG_GPS_LATITUDE).getValue(), … … 55 56 GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF).getValue() 56 57 .toString()), 0.01); 57 assertEquals(0, Mapillary ImportAction.degMinSecToDouble(58 assertEquals(0, MapillaryUtils.degMinSecToDouble( 58 59 (RationalNumber[]) jpegMetadata.findEXIFValueWithExactMatch( 59 60 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 ;1 package org.openstreetmap.josm.plugins.mapillary.utils; 2 2 3 3 import java.io.File;
Note:
See TracChangeset
for help on using the changeset viewer.