Changeset 31352 in osm for applications/editors
- Timestamp:
- 2015-07-08T17:09:38+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31350 r31352 203 203 SimpleDateFormat formatter = new SimpleDateFormat(format); 204 204 try { 205 Date dateTime = (Date)formatter.parse(date);205 Date dateTime = formatter.parse(date); 206 206 return dateTime.getTime(); 207 207 } catch (ParseException e) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
r31350 r31352 6 6 /** 7 7 * A MapillaryImage object represents each of the images stored in Mapillary. 8 * 8 * 9 9 * @author nokutu 10 10 * @see MapillarySequence … … 33 33 /** 34 34 * Main contructor of the class MapillaryImage 35 * 35 * 36 36 * @param key 37 37 * The unique identifier of the image. … … 51 51 /** 52 52 * Returns the unique identifier of the object. 53 * 53 * 54 54 * @return A String containing the unique identifier of the object. 55 55 */ … … 60 60 /** 61 61 * Adds a new sign to the set of signs. 62 * 62 * 63 63 * @param sign 64 64 * A String that identifies the type of sign. … … 70 70 /** 71 71 * Returns a List containing the signs assigned to this image. 72 * 72 * 73 73 * @return A List object containing the signs assigned to this image. 74 74 */ … … 79 79 /** 80 80 * Sets the username of the person who took the image. 81 * 81 * 82 82 * @param user 83 83 * A String containing the username of the person who took the image. … … 93 93 /** 94 94 * Sets the MapillarySequence object which contains the MapillaryImage. 95 * 95 * 96 96 * @param sequence 97 97 * The MapillarySequence that contains the MapillaryImage. … … 103 103 /** 104 104 * Returns the sequence which contains this image. 105 * 105 * 106 106 * @return The MapillarySequence object that contains this MapillaryImage. 107 107 */ … … 110 110 } 111 111 112 @Override 112 113 public String toString() { 113 114 return "Image[key=" + this.key + ";lat=" + this.latLon.lat() + ";lon=" … … 118 119 * If the MapillaryImage belongs to a MapillarySequence, returns the next 119 120 * MapillarySequence in it. 120 * 121 * 121 122 * @return The following MapillaryImage, or null if there is none. 122 123 */ … … 132 133 * If the MapillaryImage belongs to a MapillarySequence, returns the previous 133 134 * MapillarySequence in it. 134 * 135 * 135 136 * @return The previous MapillaryImage, or null if there is none. 136 137 */ -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31350 r31352 45 45 public MapillaryImportAction() { 46 46 super(tr("Import pictures"), new ImageProvider("icon24.png"), 47 tr("Import local pictures"), Shortcut.registerShortcut( 48 "Import Mapillary", tr("Import pictures into Mapillary layer"), 49 KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryImport", 50 false); 47 tr("Import local pictures"), Shortcut.registerShortcut("Import Mapillary", 48 tr("Import pictures into Mapillary layer"), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), 49 false, "mapillaryImport", false); 51 50 this.setEnabled(false); 52 51 } … … 55 54 public void actionPerformed(ActionEvent e) { 56 55 chooser = new JFileChooser(); 57 chooser.setCurrentDirectory(new java.io.File(System 58 .getProperty("user.home"))); 56 chooser.setCurrentDirectory(new java.io.File(System.getProperty("user.home"))); 59 57 chooser.setDialogTitle(tr("Select pictures")); 60 58 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 61 59 chooser.setAcceptAllFileFilterUsed(false); 62 chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg", 63 "jpeg", "png")); 60 chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg", "jpeg", "png")); 64 61 chooser.setMultiSelectionEnabled(true); 65 62 if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) { 66 63 for (int i = 0; i < chooser.getSelectedFiles().length; i++) { 67 64 File file = chooser.getSelectedFiles()[i]; 68 if (file.isDirectory()) { 69 70 } else { 65 if (!file.isDirectory()) { 71 66 MapillaryLayer.getInstance(); 72 if (file.getPath().substring(file.getPath().length() - 4) 73 .equals(".jpg") 74 || file.getPath().substring(file.getPath().length() - 5) 75 .equals(".jpeg")) { 67 if (file.getPath().substring(file.getPath().length() - 4).equals(".jpg") 68 || file.getPath().substring(file.getPath().length() - 5).equals(".jpeg")) { 76 69 try { 77 70 readJPG(file); … … 81 74 Main.error(ex); 82 75 } 83 } else if (file.getPath().substring(file.getPath().length() - 4) 84 .equals(".png")) { 76 } else if (file.getPath().substring(file.getPath().length() - 4).equals(".png")) { 85 77 readPNG(file); 86 78 } … … 102 94 if (metadata instanceof JpegImageMetadata) { 103 95 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; 104 final TiffField lat_ref = jpegMetadata 105 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); 106 final TiffField lat = jpegMetadata 107 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE); 108 final TiffField lon_ref = jpegMetadata 109 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); 110 final TiffField lon = jpegMetadata 111 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); 112 final TiffField ca = jpegMetadata 113 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); 96 final TiffField lat_ref = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); 97 final TiffField lat = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE); 98 final TiffField lon_ref = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); 99 final TiffField lon = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); 100 final TiffField ca = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); 114 101 final TiffField datetimeOriginal = jpegMetadata 115 102 .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); … … 121 108 double lonValue = 0; 122 109 double caValue = 0; 123 if (lat != null && lat.getValue() instanceof RationalNumber[]) 124 latValue = DegMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref 125 .getValue().toString()); 126 if (lon != null && lon.getValue() instanceof RationalNumber[]) 127 lonValue = DegMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref 128 .getValue().toString()); 110 if (lat.getValue() instanceof RationalNumber[]) 111 latValue = degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue().toString()); 112 if (lon.getValue() instanceof RationalNumber[]) 113 lonValue = degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue().toString()); 129 114 if (ca != null && ca.getValue() instanceof RationalNumber) 130 115 caValue = ((RationalNumber) ca.getValue()).doubleValue(); 131 if (lat_ref.getValue().toString().equals("S"))132 latValue = -latValue;133 if (lon_ref.getValue().toString().equals("W"))134 lonValue = -lonValue;135 116 if (datetimeOriginal != null) 136 MapillaryData.getInstance().add( 137 new MapillaryImportedImage(latValue, lonValue, caValue, file, 138 datetimeOriginal.getStringValue())); 117 MapillaryData.getInstance() 118 .add(new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue())); 139 119 else 140 MapillaryData.getInstance().add( 141 new MapillaryImportedImage(latValue, lonValue, caValue, file)); 120 MapillaryData.getInstance().add(new MapillaryImportedImage(latValue, lonValue, caValue, file)); 142 121 } 143 122 } … … 156 135 else 157 136 horDev = -HORIZONTAL_DISTANCE * ((noTagsPics + 1) / 2); 158 LatLon pos = Main.map.mapView.getProjection().eastNorth2latlon( 159 Main.map.mapView.getCenter()); 160 MapillaryData.getInstance().add( 161 new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, file)); 137 LatLon pos = Main.map.mapView.getProjection().eastNorth2latlon(Main.map.mapView.getCenter()); 138 MapillaryData.getInstance().add(new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, file)); 162 139 noTagsPics++; 163 140 } … … 167 144 } 168 145 169 private double DegMinSecToDouble(RationalNumber[] degMinSec, String ref) { 170 RationalNumber deg = degMinSec[0]; 171 RationalNumber min = degMinSec[1]; 172 RationalNumber sec = degMinSec[2]; 173 return deg.doubleValue() + min.doubleValue() / 60 + sec.doubleValue() 174 / 3600; 146 /** 147 * Calculates the decimal degree-value from a degree value given in degrees-minutes-seconds-format 148 * 149 * @param degMinSec an array of length 3, the values in there are (in this order) degrees, minutes and seconds 150 * @param ref the latitude or longitude reference determining if the given value is: 151 * <ul> 152 * <li>north ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH}) or 153 * south ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH}) of the equator</li> 154 * <li>east ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST}) or 155 * west ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST}) of the equator</li> 156 * </ul> 157 * @return the decimal degree-value for the given input, negative when west of 0-meridian or south of equator, 158 * positive otherwise 159 * @throws IllegalArgumentException if {@code degMinSec} doesn't have length 3 or if {@code ref} is not one of the 160 * values mentioned above 161 */ 162 private static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) { 163 if (degMinSec == null || degMinSec.length != 3) { throw new IllegalArgumentException(); } 164 switch (ref) { 165 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH: 166 case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH: 167 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST: 168 case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST: 169 break; 170 default: 171 throw new IllegalArgumentException(); 172 } 173 174 double result = degMinSec[0].doubleValue(); // degrees 175 result += degMinSec[1].doubleValue() / 60; // minutes 176 result += degMinSec[2].doubleValue() / 3600; // seconds 177 178 if (ref == GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH 179 || ref == GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST) { 180 result *= -1; 181 } 182 183 return result; 175 184 } 176 185 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java
r31350 r31352 11 11 /** 12 12 * Command created when an image's position is changed. 13 * 13 * 14 14 * @author nokutu 15 15 * … … 46 46 } 47 47 48 @Override 48 49 public String toString() { 49 50 return trn("Moved {0} image", "Moved {0} images", images.size(), -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java
r31350 r31352 11 11 /** 12 12 * Command created when an image's direction is changed. 13 * 13 * 14 14 * @author nokutu 15 15 * … … 43 43 } 44 44 45 @Override 45 46 public String toString() { 46 47 return trn("Turned {0} image", "Turned {0} images", this.images.size(), -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java
r31350 r31352 26 26 * {@link ArrayBlockingQueue}. Then it is picked by the first one and written on 27 27 * the selected folder. Each image will be named by its key. 28 * 28 * 29 29 * @author nokutu 30 30 * … … 55 55 /** 56 56 * Constructor used to rewrite imported images. 57 * 57 * 58 58 * @param images 59 59 * @throws IOException … … 106 106 try { 107 107 queue.put(((MapillaryImportedImage) image).getImage()); 108 queueImages.put( (MapillaryImportedImage)image);108 queueImages.put(image); 109 109 } catch (InterruptedException e) { 110 110 Main.error(e); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java
r31350 r31352 36 36 } 37 37 38 @Override 38 39 public void run() { 39 40 try { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
r31350 r31352 46 46 } 47 47 48 @Override 48 49 public void run() { 49 50 try { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
r31350 r31352 16 16 * the Mapillary API has a parameter called page which is needed when the amount 17 17 * of requested images is quite big. 18 * 18 * 19 19 * @author nokutu 20 * 20 * 21 21 * @see MapillaryDownloader 22 22 */ … … 29 29 public boolean imagesAdded = false; 30 30 31 public MapillarySquareDownloadManagerThread(String urlImages, 32 String urlSequences, String urlSigns,MapillaryLayer layer) {31 public MapillarySquareDownloadManagerThread(String urlImages, String urlSequences, String urlSigns, 32 MapillaryLayer layer) { 33 33 this.urlImages = urlImages; 34 34 this.urlSequences = urlSequences; … … 37 37 } 38 38 39 @Override 39 40 public void run() { 40 41 Main.map.statusLine.setHelpText("Downloading images from Mapillary"); … … 52 53 } 53 54 if (layer.data.getImages().size() > 0) 54 Main.map.statusLine.setHelpText(tr("Total images: ") 55 + layer.data.getImages().size()); 55 Main.map.statusLine.setHelpText(tr("Total images: ") + layer.data.getImages().size()); 56 56 else 57 57 Main.map.statusLine.setHelpText(tr("No images found")); … … 62 62 63 63 private void downloadSequences() throws InterruptedException { 64 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, 65 new ArrayBlockingQueue<Runnable>(5)); 64 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); 66 65 int page = 0; 67 66 while (!ex.isShutdown()) { 68 ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences 69 + "&page=" + page + "&limit=10", layer, this)); 67 ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences + "&page=" + page + "&limit=10", layer, this)); 70 68 while (ex.getQueue().remainingCapacity() == 0) 71 69 Thread.sleep(500); … … 77 75 78 76 private void completeImages() throws InterruptedException { 79 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, 80 new ArrayBlockingQueue<Runnable>(5)); 77 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); 81 78 int page = 0; 82 79 while (!ex.isShutdown()) { 83 ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages 84 + "&page=" + page + "&limit=20", layer)); 80 ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages + "&page=" + page + "&limit=20", layer)); 85 81 while (ex.getQueue().remainingCapacity() == 0) 86 82 Thread.sleep(100); … … 91 87 92 88 private void downloadSigns() throws InterruptedException { 93 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, 94 new ArrayBlockingQueue<Runnable>(5)); 89 ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5)); 95 90 int page = 0; 96 91 while (!ex.isShutdown()) { 97 ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page=" 98 + page + "&limit=20", layer)); 92 ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page=" + page + "&limit=20", layer)); 99 93 while (ex.getQueue().remainingCapacity() == 0) 100 94 Thread.sleep(100); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
r31350 r31352 38 38 * Sets the text of the label. 39 39 */ 40 @Override 40 41 public void setText(String text) { 41 42 super … … 46 47 /** 47 48 * Sets a new URL, just pass the key of the image or null if there is none. 48 * 49 * 49 50 * @param key 50 51 */ … … 71 72 * Processes mouse events and responds to clicks. 72 73 */ 74 @Override 73 75 protected void processMouseEvent(MouseEvent evt) { 74 76 super.processMouseEvent(evt); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java
r31350 r31352 26 26 * This object is a responsible JComponent which lets you zoom and drag. It is 27 27 * included in a {@link MapillaryMainDialog} object. 28 * 28 * 29 29 * @author Jorge 30 30 * @see MapillaryImageDisplay … … 341 341 /** 342 342 * Sets a new picture to be displayed. 343 * 343 * 344 344 * @param image 345 345 */ … … 357 357 /** 358 358 * Returns the picture that is being displayerd 359 * 359 * 360 360 * @return 361 361 */ … … 367 367 * Paints the visible part of the picture. 368 368 */ 369 @Override 369 370 public void paintComponent(Graphics g) { 370 371 Image image; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java
r31350 r31352 14 14 /** 15 15 * JPanel used to get the OAuth tokens from Mapillary. 16 * 16 * 17 17 * @author nokutu 18 18 * … … 37 37 System.out.print(">>"); 38 38 Verifier verifier = new Verifier(in.nextLine()); 39 in.close(); 39 40 System.out.println(); 40 41 }
Note:
See TracChangeset
for help on using the changeset viewer.