Changeset 31311 in osm
- Timestamp:
- 2015-06-25T18:35:15+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 19 added
- 2 deleted
- 9 edited
-
. (modified) (1 prop)
-
.classpath (modified) (1 diff)
-
images/intersection_danger.png (deleted)
-
images/no_entry.png (deleted)
-
images/sign.png (added)
-
images/signs (added)
-
images/signs/intersection_danger.png (added)
-
images/signs/no_entry.png (added)
-
images/signs/only_straight_on.png (added)
-
images/signs/right_of_way.png (added)
-
images/signs/roundabout_right.png (added)
-
images/signs/speed.png (added)
-
images/signs/stop.png (added)
-
src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java (modified) (3 diffs)
-
src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java (modified) (1 diff)
-
src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java (modified) (3 diffs)
-
src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java (modified) (1 diff)
-
src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java (modified) (2 diffs)
-
src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterChooseSigns.java (modified) (7 diffs)
-
src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java (modified) (1 diff)
-
test (added)
-
test/README (added)
-
test/data (added)
-
test/unit (added)
-
test/unit/org (added)
-
test/unit/org/openstreetmap (added)
-
test/unit/org/openstreetmap/josm (added)
-
test/unit/org/openstreetmap/josm/plugins (added)
-
test/unit/org/openstreetmap/josm/plugins/mapillary (added)
-
test/unit/org/openstreetmap/josm/plugins/mapillary/ImportTest.java (added)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary
- Property svn:ignore
-
old new 1 1 build 2 bin
-
- Property svn:ignore
-
applications/editors/josm/plugins/mapillary/.classpath
r31245 r31311 2 2 <classpath> 3 3 <classpathentry kind="src" path="src"/> 4 <classpathentry kind="src" path="test/unit"/> 4 5 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 5 6 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 6 7 <classpathentry combineaccessrules="false" exported="true" kind="src" path="/JOSM-commons-imaging"/> 7 8 <classpathentry exported="true" kind="lib" path="/home/nokutu/josm/dist/commons-imaging.jar"/> 9 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 8 10 <classpathentry kind="output" path="bin"/> 9 11 </classpath> -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31299 r31311 1 1 package org.openstreetmap.josm.plugins.mapillary; 2 2 3 import java. sql.Date;3 import java.util.Date; 4 4 import java.text.ParseException; 5 5 import java.text.SimpleDateFormat; … … 11 11 12 12 /** 13 * Abstract sup perclass for all image objects. At the moment there is just 2,13 * Abstract superclass for all image objects. At the moment there is just 2, 14 14 * {@code MapillaryImportedImage} and {@code MapillaryImage}. 15 15 * … … 21 21 private long capturedAt; 22 22 23 /** Postion of the picture */ 23 /** Position of the picture */ 24 24 public final LatLon latLon; 25 25 /** Direction of the picture */ -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31300 r31311 20 20 */ 21 21 public class MapillaryData implements ICachedLoaderListener { 22 public volatile static MapillaryData INSTANCE; 23 24 private final List<MapillaryAbstractImage> images; 25 private MapillaryAbstractImage selectedImage; 26 private MapillaryAbstractImage hoveredImage; 27 private final List<MapillaryAbstractImage> multiSelectedImages; 28 29 private List<MapillaryDataListener> listeners = new ArrayList<>(); 30 31 public MapillaryData() { 32 images = new CopyOnWriteArrayList<>(); 33 multiSelectedImages = new ArrayList<>(); 34 selectedImage = null; 35 } 36 37 public static MapillaryData getInstance() { 38 if (INSTANCE == null) { 39 INSTANCE = new MapillaryData(); 40 } 41 return INSTANCE; 42 } 43 44 /** 45 * Adds a set of MapillaryImages to the object, and then repaints mapView. 46 * 47 * @param images 48 * The set of images to be added. 49 */ 50 public synchronized void add(List<MapillaryAbstractImage> images) { 51 for (MapillaryAbstractImage image : images) { 52 add(image); 53 } 54 } 55 56 /** 57 * Adds an MapillaryImage to the object, and then repaints mapView. 58 * 59 * @param image 60 * The image to be added. 61 */ 62 public synchronized void add(MapillaryAbstractImage image) { 63 if (!images.contains(image)) { 64 this.images.add(image); 65 } 66 dataUpdated(); 67 fireImagesAdded(); 68 } 69 70 public void addListener(MapillaryDataListener lis) { 71 listeners.add(lis); 72 } 73 74 public void removeListener(MapillaryDataListener lis) { 75 listeners.remove(lis); 76 } 77 78 /** 79 * Adds a set of MapillaryImages to the object, but doesn't repaint mapView. 80 * This is needed for concurrency. 81 * 82 * @param images 83 * The set of images to be added. 84 */ 85 public synchronized void addWithoutUpdate( 86 List<MapillaryAbstractImage> images) { 87 for (MapillaryAbstractImage image : images) { 88 addWithoutUpdate(image); 89 } 90 } 91 92 /** 93 * Sets the image under the mouse cursor. 94 * 95 * @param image 96 */ 97 public void setHoveredImage(MapillaryAbstractImage image) { 98 hoveredImage = image; 99 } 100 101 /** 102 * Returns the image under the mouse cursor. 103 * 104 * @return 105 */ 106 public MapillaryAbstractImage getHoveredImage() { 107 return hoveredImage; 108 } 109 110 /** 111 * Adds a MapillaryImage to the object, but doesn't repaint mapView. This is 112 * needed for concurrency. 113 * 114 * @param image 115 * The image to be added. 116 */ 117 public synchronized void addWithoutUpdate(MapillaryAbstractImage image) { 118 if (!images.contains(image)) { 119 this.images.add(image); 120 } 121 fireImagesAdded(); 122 } 123 124 /** 125 * Repaints mapView object. 126 */ 127 public synchronized void dataUpdated() { 128 Main.map.mapView.repaint(); 129 } 130 131 /** 132 * Returns a List containing all images. 133 * 134 * @return A List object containing all images. 135 */ 136 public List<MapillaryAbstractImage> getImages() { 137 return images; 138 } 139 140 /** 141 * Returns the MapillaryImage object that is currently selected. 142 * 143 * @return The selected MapillaryImage object. 144 */ 145 public MapillaryAbstractImage getSelectedImage() { 146 return selectedImage; 147 } 148 149 private void fireImagesAdded() { 150 if (listeners.isEmpty()) 151 return; 152 for (MapillaryDataListener lis : listeners) 153 lis.imagesAdded(); 154 } 155 156 /** 157 * If the selected MapillaryImage is part of a MapillarySequence then the 158 * following visible MapillaryImage is selected. In case there is none, does 159 * nothing. 160 */ 161 public void selectNext() { 162 if (getSelectedImage() instanceof MapillaryImage) { 163 if (getSelectedImage() == null) 164 return; 165 if (((MapillaryImage) getSelectedImage()).getSequence() == null) 166 return; 167 if (selectedImage instanceof MapillaryImage && ((MapillaryImage) selectedImage).getSequence() != null) { 22 public volatile static MapillaryData INSTANCE; 23 public static boolean TEST_MODE = false; 24 25 private final List<MapillaryAbstractImage> images; 26 private MapillaryAbstractImage selectedImage; 27 private MapillaryAbstractImage hoveredImage; 28 private final List<MapillaryAbstractImage> multiSelectedImages; 29 30 private List<MapillaryDataListener> listeners = new ArrayList<>(); 31 32 public MapillaryData() { 33 images = new CopyOnWriteArrayList<>(); 34 multiSelectedImages = new ArrayList<>(); 35 selectedImage = null; 36 } 37 38 public static MapillaryData getInstance() { 39 if (INSTANCE == null) { 40 INSTANCE = new MapillaryData(); 41 } 42 return INSTANCE; 43 } 44 45 /** 46 * Adds a set of MapillaryImages to the object, and then repaints mapView. 47 * 48 * @param images 49 * The set of images to be added. 50 */ 51 public synchronized void add(List<MapillaryAbstractImage> images) { 52 for (MapillaryAbstractImage image : images) { 53 add(image); 54 } 55 } 56 57 /** 58 * Adds an MapillaryImage to the object, and then repaints mapView. 59 * 60 * @param image 61 * The image to be added. 62 */ 63 public synchronized void add(MapillaryAbstractImage image) { 64 if (!images.contains(image)) { 65 this.images.add(image); 66 } 67 dataUpdated(); 68 fireImagesAdded(); 69 } 70 71 public void addListener(MapillaryDataListener lis) { 72 listeners.add(lis); 73 } 74 75 public void removeListener(MapillaryDataListener lis) { 76 listeners.remove(lis); 77 } 78 79 /** 80 * Adds a set of MapillaryImages to the object, but doesn't repaint mapView. 81 * This is needed for concurrency. 82 * 83 * @param images 84 * The set of images to be added. 85 */ 86 public synchronized void addWithoutUpdate( 87 List<MapillaryAbstractImage> images) { 88 for (MapillaryAbstractImage image : images) { 89 addWithoutUpdate(image); 90 } 91 } 92 93 /** 94 * Sets the image under the mouse cursor. 95 * 96 * @param image 97 */ 98 public void setHoveredImage(MapillaryAbstractImage image) { 99 hoveredImage = image; 100 } 101 102 /** 103 * Returns the image under the mouse cursor. 104 * 105 * @return 106 */ 107 public MapillaryAbstractImage getHoveredImage() { 108 return hoveredImage; 109 } 110 111 /** 112 * Adds a MapillaryImage to the object, but doesn't repaint mapView. This is 113 * needed for concurrency. 114 * 115 * @param image 116 * The image to be added. 117 */ 118 public synchronized void addWithoutUpdate(MapillaryAbstractImage image) { 119 if (!images.contains(image)) { 120 this.images.add(image); 121 } 122 fireImagesAdded(); 123 } 124 125 /** 126 * Repaints mapView object. 127 */ 128 public synchronized void dataUpdated() { 129 if (!TEST_MODE) 130 Main.map.mapView.repaint(); 131 } 132 133 /** 134 * Returns a List containing all images. 135 * 136 * @return A List object containing all images. 137 */ 138 public List<MapillaryAbstractImage> getImages() { 139 return images; 140 } 141 142 /** 143 * Returns the MapillaryImage object that is currently selected. 144 * 145 * @return The selected MapillaryImage object. 146 */ 147 public MapillaryAbstractImage getSelectedImage() { 148 return selectedImage; 149 } 150 151 private void fireImagesAdded() { 152 if (listeners.isEmpty()) 153 return; 154 for (MapillaryDataListener lis : listeners) 155 lis.imagesAdded(); 156 } 157 158 /** 159 * If the selected MapillaryImage is part of a MapillarySequence then the 160 * following visible MapillaryImage is selected. In case there is none, does 161 * nothing. 162 */ 163 public void selectNext() { 164 if (getSelectedImage() instanceof MapillaryImage) { 165 if (getSelectedImage() == null) 166 return; 167 if (((MapillaryImage) getSelectedImage()).getSequence() == null) 168 return; 169 if (selectedImage instanceof MapillaryImage 170 && ((MapillaryImage) selectedImage).getSequence() != null) { 168 171 MapillaryImage tempImage = (MapillaryImage) selectedImage; 169 172 while (tempImage.next() != null) { 170 173 tempImage = tempImage.next(); 171 174 if (tempImage.isVisible()) { 172 setSelectedImage(tempImage, true);175 setSelectedImage(tempImage, true); 173 176 break; 174 177 } 175 178 } 176 179 } 177 } 178 } 179 180 /** 181 * If the selected MapillaryImage is part of a MapillarySequence then the 182 * previous visible MapillaryImage is selected. In case there is none, does nothing. 183 */ 184 public void selectPrevious() { 185 if (getSelectedImage() instanceof MapillaryImage) { 186 if (getSelectedImage() == null) 187 return; 188 if (((MapillaryImage) getSelectedImage()).getSequence() == null) 189 throw new IllegalStateException(); 190 if (selectedImage instanceof MapillaryImage && ((MapillaryImage) selectedImage).getSequence() != null) { 180 } 181 } 182 183 /** 184 * If the selected MapillaryImage is part of a MapillarySequence then the 185 * previous visible MapillaryImage is selected. In case there is none, does 186 * nothing. 187 */ 188 public void selectPrevious() { 189 if (getSelectedImage() instanceof MapillaryImage) { 190 if (getSelectedImage() == null) 191 return; 192 if (((MapillaryImage) getSelectedImage()).getSequence() == null) 193 throw new IllegalStateException(); 194 if (selectedImage instanceof MapillaryImage 195 && ((MapillaryImage) selectedImage).getSequence() != null) { 191 196 MapillaryImage tempImage = (MapillaryImage) selectedImage; 192 197 while (tempImage.previous() != null) { 193 198 tempImage = tempImage.previous(); 194 199 if (tempImage.isVisible()) { 195 setSelectedImage(tempImage, true);200 setSelectedImage(tempImage, true); 196 201 break; 197 202 } 198 203 } 199 204 } 200 }201 }202 203 /**204 * Selects a new image and then starts a new MapillaryImageDownloadThread205 * thread in order to download its surrounding thumbnails. If the user does206 * ctrl+click, this isn't triggered.207 *208 * @param image209 * The MapillaryImage which is going to be selected210 */211 public void setSelectedImage(MapillaryAbstractImage image) {212 setSelectedImage(image, false);213 }214 215 /**216 * Selects a new image and then starts a new MapillaryImageDownloadThread217 * thread in order to download its surrounding thumbnails. If the user does218 * ctrl+click, this isn't triggered. You can choose wheter to center the219 * view on the new image or not.220 *221 * @param image222 * @param zoom223 */224 public void setSelectedImage(MapillaryAbstractImage image, boolean zoom) {225 MapillaryAbstractImage oldImage = selectedImage;226 selectedImage = image;227 multiSelectedImages.clear();228 multiSelectedImages.add(image);229 if (image != null) {230 if (image instanceof MapillaryImage) {231 MapillaryImage mapillaryImage = (MapillaryImage) image;232 if (mapillaryImage.next() != null) {233 new MapillaryCache(mapillaryImage.next().getKey(),234 MapillaryCache.Type.THUMBNAIL).submit(this, false);235 if (mapillaryImage.next().next() != null)236 new MapillaryCache(mapillaryImage.next().next()237 .getKey(), MapillaryCache.Type.THUMBNAIL)238 .submit(this, false);239 }240 if (mapillaryImage.previous() != null) {241 new MapillaryCache(mapillaryImage.previous().getKey(),242 MapillaryCache.Type.THUMBNAIL).submit(this, false);243 if (mapillaryImage.previous().previous() != null)244 new MapillaryCache(mapillaryImage.previous().previous()245 .getKey(), MapillaryCache.Type.THUMBNAIL)246 .submit(this, false);247 }248 }249 }250 if (zoom)251 Main.map.mapView.zoomTo(MapillaryData.getInstance()252 .getSelectedImage().getLatLon());253 if (Main.map != null)254 Main.map.mapView.repaint();255 fireSelectedImageChanged(oldImage, selectedImage);256 }257 258 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage,259 MapillaryAbstractImage newImage) {260 if (listeners.isEmpty())261 return;262 for (MapillaryDataListener lis : listeners)263 lis.selectedImageChanged(oldImage, newImage);264 }265 266 /**267 * Adds a MapillaryImage object to the list of selected images, (when ctrl +268 * click)269 *270 * @param image271 * The MapillaryImage object to be added.272 */273 public void addMultiSelectedImage(MapillaryAbstractImage image) {274 if (!this.multiSelectedImages.contains(image)) {275 if (this.getSelectedImage() != null)276 this.multiSelectedImages.add(image);277 else278 this.setSelectedImage(image);279 }280 Main.map.mapView.repaint();281 }282 283 /**284 * Adds a set of MapillaryImage objects to the list of selected images.285 *286 * @param images287 */288 public void addMultiSelectedImage(List<MapillaryAbstractImage> images) {289 for (MapillaryAbstractImage image : images)290 if (!this.multiSelectedImages.contains(image)) {291 if (this.getSelectedImage() != null)292 this.multiSelectedImages.add(image);293 else294 this.setSelectedImage(image);295 }296 Main.map.mapView.repaint();297 }298 299 /**300 * Returns a list containing all MapillaryImage objects selected with ctrl +301 * click302 *303 * @return304 */305 public List<MapillaryAbstractImage> getMultiSelectedImages() {306 return multiSelectedImages;307 }308 309 /**310 * This is empty because it is used just to make sure that certain images311 * have already been downloaded.312 */313 @Override314 public void loadingFinished(CacheEntry data,315 CacheEntryAttributes attributes, LoadResult result) {316 // DO NOTHING317 }318 319 /**320 * Returns the amount of images contained by this object.321 *322 * @return323 */324 public int size() {325 return images.size();326 }205 } 206 } 207 208 /** 209 * Selects a new image and then starts a new MapillaryImageDownloadThread 210 * thread in order to download its surrounding thumbnails. If the user does 211 * ctrl+click, this isn't triggered. 212 * 213 * @param image 214 * The MapillaryImage which is going to be selected 215 */ 216 public void setSelectedImage(MapillaryAbstractImage image) { 217 setSelectedImage(image, false); 218 } 219 220 /** 221 * Selects a new image and then starts a new MapillaryImageDownloadThread 222 * thread in order to download its surrounding thumbnails. If the user does 223 * ctrl+click, this isn't triggered. You can choose wheter to center the 224 * view on the new image or not. 225 * 226 * @param image 227 * @param zoom 228 */ 229 public void setSelectedImage(MapillaryAbstractImage image, boolean zoom) { 230 MapillaryAbstractImage oldImage = selectedImage; 231 selectedImage = image; 232 multiSelectedImages.clear(); 233 multiSelectedImages.add(image); 234 if (image != null) { 235 if (image instanceof MapillaryImage) { 236 MapillaryImage mapillaryImage = (MapillaryImage) image; 237 if (mapillaryImage.next() != null) { 238 new MapillaryCache(mapillaryImage.next().getKey(), 239 MapillaryCache.Type.THUMBNAIL).submit(this, false); 240 if (mapillaryImage.next().next() != null) 241 new MapillaryCache(mapillaryImage.next().next() 242 .getKey(), MapillaryCache.Type.THUMBNAIL) 243 .submit(this, false); 244 } 245 if (mapillaryImage.previous() != null) { 246 new MapillaryCache(mapillaryImage.previous().getKey(), 247 MapillaryCache.Type.THUMBNAIL).submit(this, false); 248 if (mapillaryImage.previous().previous() != null) 249 new MapillaryCache(mapillaryImage.previous().previous() 250 .getKey(), MapillaryCache.Type.THUMBNAIL) 251 .submit(this, false); 252 } 253 } 254 } 255 if (zoom) 256 Main.map.mapView.zoomTo(MapillaryData.getInstance() 257 .getSelectedImage().getLatLon()); 258 if (Main.map != null) 259 Main.map.mapView.repaint(); 260 fireSelectedImageChanged(oldImage, selectedImage); 261 } 262 263 private void fireSelectedImageChanged(MapillaryAbstractImage oldImage, 264 MapillaryAbstractImage newImage) { 265 if (listeners.isEmpty()) 266 return; 267 for (MapillaryDataListener lis : listeners) 268 lis.selectedImageChanged(oldImage, newImage); 269 } 270 271 /** 272 * Adds a MapillaryImage object to the list of selected images, (when ctrl + 273 * click) 274 * 275 * @param image 276 * The MapillaryImage object to be added. 277 */ 278 public void addMultiSelectedImage(MapillaryAbstractImage image) { 279 if (!this.multiSelectedImages.contains(image)) { 280 if (this.getSelectedImage() != null) 281 this.multiSelectedImages.add(image); 282 else 283 this.setSelectedImage(image); 284 } 285 Main.map.mapView.repaint(); 286 } 287 288 /** 289 * Adds a set of MapillaryImage objects to the list of selected images. 290 * 291 * @param images 292 */ 293 public void addMultiSelectedImage(List<MapillaryAbstractImage> images) { 294 for (MapillaryAbstractImage image : images) 295 if (!this.multiSelectedImages.contains(image)) { 296 if (this.getSelectedImage() != null) 297 this.multiSelectedImages.add(image); 298 else 299 this.setSelectedImage(image); 300 } 301 Main.map.mapView.repaint(); 302 } 303 304 /** 305 * Returns a list containing all MapillaryImage objects selected with ctrl + 306 * click 307 * 308 * @return 309 */ 310 public List<MapillaryAbstractImage> getMultiSelectedImages() { 311 return multiSelectedImages; 312 } 313 314 /** 315 * This is empty because it is used just to make sure that certain images 316 * have already been downloaded. 317 */ 318 @Override 319 public void loadingFinished(CacheEntry data, 320 CacheEntryAttributes attributes, LoadResult result) { 321 // DO NOTHING 322 } 323 324 /** 325 * Returns the amount of images contained by this object. 326 * 327 * @return 328 */ 329 public int size() { 330 return images.size(); 331 } 327 332 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
r31306 r31311 4 4 import java.io.File; 5 5 import java.io.IOException; 6 import java.text.SimpleDateFormat; 7 import java.util.Calendar; 6 8 7 9 import javax.imageio.ImageIO; … … 14 16 protected File file; 15 17 public final long datetimeOriginal; 18 19 public MapillaryImportedImage(double lat, double lon, double ca, File file) { 20 this(lat, lon, ca, file, currentDate()); 21 } 16 22 17 23 public MapillaryImportedImage(double lat, double lon, double ca, File file, … … 47 53 return this.file.hashCode(); 48 54 } 55 56 private static String currentDate() { 57 Calendar cal = Calendar.getInstance(); 58 59 SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); 60 return formatter.format(cal.getTime()); 61 62 } 49 63 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31300 r31311 110 110 Main.map.mapView.setActiveLayer(this); 111 111 createHatchTexture(); 112 Main.map.repaint();112 data.dataUpdated(); 113 113 } 114 114 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
r31278 r31311 7 7 import java.io.File; 8 8 import java.io.IOException; 9 import java.text.SimpleDateFormat;10 import java.util.Calendar;11 9 12 10 import javax.swing.JFileChooser; … … 38 36 public class MapillaryImportAction extends JosmAction { 39 37 40 public JFileChooser chooser;38 public JFileChooser chooser; 41 39 42 /**43 * Amount of pictures without the proper EXIF tags.44 */45 private int noTagsPics = 0;40 /** 41 * Amount of pictures without the proper EXIF tags. 42 */ 43 private int noTagsPics = 0; 46 44 47 public MapillaryImportAction() {48 super(tr("Import pictures"), new ImageProvider("icon24.png"),49 tr("Import local pictures"), Shortcut.registerShortcut(50 "Import Mapillary",51 tr("Import pictures into Mapillary layer"),52 KeyEvent.VK_M, Shortcut.NONE), false,53 "mapillaryImport", false);54 this.setEnabled(false);55 }45 public MapillaryImportAction() { 46 super(tr("Import pictures"), new ImageProvider("icon24.png"), 47 tr("Import local pictures"), Shortcut.registerShortcut( 48 "Import Mapillary", 49 tr("Import pictures into Mapillary layer"), 50 KeyEvent.VK_M, Shortcut.NONE), false, 51 "mapillaryImport", false); 52 this.setEnabled(false); 53 } 56 54 57 @Override58 public void actionPerformed(ActionEvent e) {59 chooser = new JFileChooser();60 chooser.setCurrentDirectory(new java.io.File(System61 .getProperty("user.home")));62 chooser.setDialogTitle(tr("Select pictures"));63 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);64 chooser.setAcceptAllFileFilterUsed(false);65 chooser.addChoosableFileFilter(new FileNameExtensionFilter("images",66 "jpg", "jpeg", "png"));67 chooser.setMultiSelectionEnabled(true);68 if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {69 for (int i = 0; i < chooser.getSelectedFiles().length; i++) {70 File file = chooser.getSelectedFiles()[i];71 if (file.isDirectory()) {55 @Override 56 public void actionPerformed(ActionEvent e) { 57 chooser = new JFileChooser(); 58 chooser.setCurrentDirectory(new java.io.File(System 59 .getProperty("user.home"))); 60 chooser.setDialogTitle(tr("Select pictures")); 61 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 62 chooser.setAcceptAllFileFilterUsed(false); 63 chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", 64 "jpg", "jpeg", "png")); 65 chooser.setMultiSelectionEnabled(true); 66 if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) { 67 for (int i = 0; i < chooser.getSelectedFiles().length; i++) { 68 File file = chooser.getSelectedFiles()[i]; 69 if (file.isDirectory()) { 72 70 73 } else {74 if (file.getPath().substring(file.getPath().length() - 4)75 .equals(".jpg")76 || file.getPath()77 .substring(file.getPath().length() - 5)78 .equals(".jpeg")) {79 try {80 readJPG(file);81 } catch (ImageReadException ex) {82 Main.error(ex);83 } catch (IOException ex) {84 Main.error(ex);85 }86 } else if (file.getPath()87 .substring(file.getPath().length() - 4)88 .equals(".png")) {89 readPNG(file);90 }91 }92 }93 }94 MapillaryLayer.getInstance();95 }71 } else { 72 if (file.getPath().substring(file.getPath().length() - 4) 73 .equals(".jpg") 74 || file.getPath() 75 .substring(file.getPath().length() - 5) 76 .equals(".jpeg")) { 77 try { 78 readJPG(file); 79 } catch (ImageReadException ex) { 80 Main.error(ex); 81 } catch (IOException ex) { 82 Main.error(ex); 83 } 84 } else if (file.getPath() 85 .substring(file.getPath().length() - 4) 86 .equals(".png")) { 87 readPNG(file); 88 } 89 } 90 } 91 } 92 MapillaryLayer.getInstance(); 93 } 96 94 97 /**98 * Reads a jpg pictures that contains the needed GPS information (position99 * and direction) and creates a new icon in that position.100 *101 * @param file102 * @throws ImageReadException103 * @throws IOException104 */105 public void readJPG(File file) throws ImageReadException, IOException {106 final ImageMetadata metadata = Imaging.getMetadata(file);107 if (metadata instanceof JpegImageMetadata) {108 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;109 final TiffField lat_ref = jpegMetadata110 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);111 final TiffField lat = jpegMetadata112 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE);113 final TiffField lon_ref = jpegMetadata114 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);115 final TiffField lon = jpegMetadata116 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE);117 final TiffField ca = jpegMetadata118 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);119 final TiffField datetimeOriginal = jpegMetadata120 .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);121 if (lat_ref == null || lat == null || lon == null122 || lon_ref == null) {123 readNoTags(file);124 }125 double latValue = 0;126 double lonValue = 0;127 double caValue = 0;128 if (lat != null && lat.getValue() instanceof RationalNumber[])129 latValue = DegMinSecToDouble((RationalNumber[]) lat.getValue(),130 lat_ref.getValue().toString());131 if (lon != null && lon.getValue() instanceof RationalNumber[])132 lonValue = DegMinSecToDouble((RationalNumber[]) lon.getValue(),133 lon_ref.getValue().toString());134 if (ca != null && ca.getValue() instanceof RationalNumber)135 caValue = ((RationalNumber) ca.getValue()).doubleValue();136 if (lat_ref.getValue().toString().equals("S"))137 latValue = -latValue;138 if (lon_ref.getValue().toString().equals("W"))139 lonValue = -lonValue;140 if (datetimeOriginal != null)141 MapillaryData.getInstance().add(142 new MapillaryImportedImage(latValue, lonValue, caValue,143 file, datetimeOriginal.getStringValue()));144 else145 MapillaryData.getInstance().add(146 new MapillaryImportedImage(latValue, lonValue, caValue,147 file, currentDate()));148 }149 }95 /** 96 * Reads a jpg pictures that contains the needed GPS information (position 97 * and direction) and creates a new icon in that position. 98 * 99 * @param file 100 * @throws ImageReadException 101 * @throws IOException 102 */ 103 public void readJPG(File file) throws ImageReadException, IOException { 104 final ImageMetadata metadata = Imaging.getMetadata(file); 105 if (metadata instanceof JpegImageMetadata) { 106 final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata; 107 final TiffField lat_ref = jpegMetadata 108 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF); 109 final TiffField lat = jpegMetadata 110 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE); 111 final TiffField lon_ref = jpegMetadata 112 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF); 113 final TiffField lon = jpegMetadata 114 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE); 115 final TiffField ca = jpegMetadata 116 .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION); 117 final TiffField datetimeOriginal = jpegMetadata 118 .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL); 119 if (lat_ref == null || lat == null || lon == null 120 || lon_ref == null) { 121 readNoTags(file); 122 } 123 double latValue = 0; 124 double lonValue = 0; 125 double caValue = 0; 126 if (lat != null && lat.getValue() instanceof RationalNumber[]) 127 latValue = DegMinSecToDouble((RationalNumber[]) lat.getValue(), 128 lat_ref.getValue().toString()); 129 if (lon != null && lon.getValue() instanceof RationalNumber[]) 130 lonValue = DegMinSecToDouble((RationalNumber[]) lon.getValue(), 131 lon_ref.getValue().toString()); 132 if (ca != null && ca.getValue() instanceof RationalNumber) 133 caValue = ((RationalNumber) ca.getValue()).doubleValue(); 134 if (lat_ref.getValue().toString().equals("S")) 135 latValue = -latValue; 136 if (lon_ref.getValue().toString().equals("W")) 137 lonValue = -lonValue; 138 if (datetimeOriginal != null) 139 MapillaryData.getInstance().add( 140 new MapillaryImportedImage(latValue, lonValue, caValue, 141 file, datetimeOriginal.getStringValue())); 142 else 143 MapillaryData.getInstance().add( 144 new MapillaryImportedImage(latValue, lonValue, caValue, 145 file)); 146 } 147 } 150 148 151 /**152 * Reads a image file that doesn't contain the needed GPS information. And153 * creates a new icon in the middle of the map.154 *155 * @param file156 */157 private void readNoTags(File file) {158 double HORIZONTAL_DISTANCE = 0.0001;159 double horDev;160 if (noTagsPics % 2 == 0)161 horDev = HORIZONTAL_DISTANCE * noTagsPics / 2;162 else163 horDev = -HORIZONTAL_DISTANCE * (noTagsPics + 1) / 2;164 LatLon pos = Main.map.mapView.getProjection().eastNorth2latlon(165 Main.map.mapView.getCenter());166 MapillaryData.getInstance().add(167 new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0,168 file, currentDate()));169 noTagsPics++;170 }149 /** 150 * Reads a image file that doesn't contain the needed GPS information. And 151 * creates a new icon in the middle of the map. 152 * 153 * @param file 154 */ 155 private void readNoTags(File file) { 156 double HORIZONTAL_DISTANCE = 0.0001; 157 double horDev; 158 if (noTagsPics % 2 == 0) 159 horDev = HORIZONTAL_DISTANCE * noTagsPics / 2; 160 else 161 horDev = -HORIZONTAL_DISTANCE * (noTagsPics + 1) / 2; 162 LatLon pos = Main.map.mapView.getProjection().eastNorth2latlon( 163 Main.map.mapView.getCenter()); 164 MapillaryData.getInstance().add( 165 new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, 166 file)); 167 noTagsPics++; 168 } 171 169 172 private void readPNG(File file) {173 readNoTags(file);174 }170 private void readPNG(File file) { 171 readNoTags(file); 172 } 175 173 176 private double DegMinSecToDouble(RationalNumber[] degMinSec, String ref) { 177 RationalNumber deg = degMinSec[0]; 178 RationalNumber min = degMinSec[1]; 179 RationalNumber sec = degMinSec[2]; 180 return deg.doubleValue() + min.doubleValue() / 60 + sec.doubleValue() 181 / 3600; 182 } 183 184 private String currentDate() { 185 Calendar cal = Calendar.getInstance(); 186 187 SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); 188 return formatter.format(cal); 189 190 } 174 private double DegMinSecToDouble(RationalNumber[] degMinSec, String ref) { 175 RationalNumber deg = degMinSec[0]; 176 RationalNumber min = degMinSec[1]; 177 RationalNumber sec = degMinSec[2]; 178 return deg.doubleValue() + min.doubleValue() / 60 + sec.doubleValue() 179 / 3600; 180 } 191 181 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterChooseSigns.java
r31306 r31311 39 39 JLabel maxspeedLabel = new JLabel(tr("Speed limit")); 40 40 maxspeedLabel.setIcon(new ImageProvider( 41 "s tyles/standard/vehicle/restriction/speed.png").get());41 "signs/speed.png").get()); 42 42 maxspeedPanel.add(maxspeedLabel); 43 43 maxspeedPanel.add(maxspeed); … … 48 48 JLabel stopLabel = new JLabel(tr("Stop")); 49 49 stopLabel.setIcon(new ImageProvider( 50 "s tyles/standard/vehicle/restriction/stop.png").get());50 "signs/stop.png").get()); 51 51 stopPanel.add(stopLabel); 52 52 stopPanel.add(stop); … … 57 57 JLabel giveWayLabel = new JLabel(tr("Give way")); 58 58 giveWayLabel.setIcon(new ImageProvider( 59 "s tyles/standard/vehicle/restriction/right_of_way.png").get());59 "signs/right_of_way.png").get()); 60 60 giveWayPanel.add(giveWayLabel); 61 61 giveWayPanel.add(giveWay); … … 66 66 JLabel roundaboutLabel = new JLabel(tr("Give way")); 67 67 roundaboutLabel.setIcon(new ImageProvider( 68 "s tyles/standard/vehicle/restriction/roundabout_right.png")68 "signs/roundabout_right.png") 69 69 .get()); 70 70 roundaboutPanel.add(roundaboutLabel); … … 77 77 JLabel noEntryLabel = new JLabel(tr("No entry")); 78 78 noEntryLabel.setIcon(new ImageProvider( 79 "no_entry.png").get()); 79 "signs/no_entry.png").get()); 80 80 noEntryPanel.add(noEntryLabel); 81 81 noEntryPanel.add(access); … … 86 86 JLabel intersectionLabel = new JLabel(tr("Intersection danger")); 87 87 intersectionLabel.setIcon(new ImageProvider( 88 "intersection_danger.png").get()); 88 "signs/intersection_danger.png").get()); 89 89 intersectionPanel.add(intersectionLabel); 90 90 intersectionPanel.add(intersection); … … 95 95 JLabel directionLabel = new JLabel(tr("Mandatory direction (any)")); 96 96 directionLabel.setIcon(new ImageProvider( 97 " /home/nokutu/josm/core/images/styles/standard/vehicle/restriction/turn_restrictions/only_straight_on.png").get());97 "signs/only_straight_on.png").get()); 98 98 directionPanel.add(directionLabel); 99 99 directionPanel.add(direction); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
r31306 r31311 50 50 private final JPanel panel = new JPanel(new GridLayout(ROWS, COLUMNS)); 51 51 52 p rivatefinal JCheckBox imported = new JCheckBox("Imported images");53 p rivatefinal JCheckBox downloaded = new JCheckBox(52 public final JCheckBox imported = new JCheckBox("Imported images"); 53 public final JCheckBox downloaded = new JCheckBox( 54 54 new downloadCheckBoxAction()); 55 p rivatefinal JCheckBox onlySigns = new JCheckBox(new OnlySignsAction());56 p rivatefinal JComboBox<String> time;57 p rivatefinal JTextField user;58 59 p rivatefinal SideButton updateButton = new SideButton(new UpdateAction());60 p rivatefinal SideButton resetButton = new SideButton(new ResetAction());61 p rivatefinal JButton signChooser = new JButton(new SignChooserAction());55 public final JCheckBox onlySigns = new JCheckBox(new OnlySignsAction()); 56 public final JComboBox<String> time; 57 public final JTextField user; 58 59 public final SideButton updateButton = new SideButton(new UpdateAction()); 60 public final SideButton resetButton = new SideButton(new ResetAction()); 61 public final JButton signChooser = new JButton(new SignChooserAction()); 62 62 63 63 public final MapillaryFilterChooseSigns signFilter = MapillaryFilterChooseSigns
Note:
See TracChangeset
for help on using the changeset viewer.
