Changeset 34536 in osm for applications/editors/josm/plugins/openvisible/src
- Timestamp:
- 2018-08-18T19:01:57+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/openvisible/src/at/dallermassl/josm/plugin/openvisible
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/openvisible/src/at/dallermassl/josm/plugin/openvisible/OpenVisibleAction.java
r33567 r34536 19 19 import javax.swing.JOptionPane; 20 20 21 import org.openstreetmap.josm.Main;22 21 import org.openstreetmap.josm.actions.JosmAction; 23 22 import org.openstreetmap.josm.data.coor.LatLon; … … 34 33 import org.openstreetmap.josm.io.IllegalDataException; 35 34 import org.openstreetmap.josm.io.OsmReader; 35 import org.openstreetmap.josm.tools.Logging; 36 36 import org.openstreetmap.josm.tools.Shortcut; 37 37 import org.xml.sax.SAXException; 38 39 import at.dallermassl.josm.plugin.openvisible.OsmGpxBounds;40 38 41 39 /** … … 57 55 */ 58 56 @Override 59 public void actionPerformed(ActionEvent e) { 57 public void actionPerformed(ActionEvent event) { 60 58 if(!MainApplication.isDisplayingMapView()) { 61 JOptionPane.showMessageDialog(Main .parent, tr("No view open - cannot determine boundaries!"));59 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("No view open - cannot determine boundaries!")); 62 60 return; 63 61 } … … 76 74 } 77 75 fileChooser.setMultiSelectionEnabled(true); 78 fileChooser.showOpenDialog(Main .parent);76 fileChooser.showOpenDialog(MainApplication.getMainFrame()); 79 77 File[] files = fileChooser.getSelectedFiles(); 80 78 lastDirectory = fileChooser.getCurrentDirectory(); … … 93 91 94 92 } 95 } catch (FileNotFoundException e1) { 96 e1.printStackTrace(); 97 } catch (IOException e1) { 98 e1.printStackTrace(); 99 } catch (SAXException e1) { 100 e1.printStackTrace(); 101 } catch(IllegalDataException e1) { 102 e1.printStackTrace(); 93 } catch (IOException | SAXException | IllegalDataException e) { 94 Logging.error(e); 103 95 } 104 96 } 105 106 97 } 107 98 … … 114 105 } 115 106 else 116 JOptionPane.showMessageDialog(Main .parent, fn+": "+tr("Unknown file extension: {0}", fn.substring(fn.lastIndexOf('.')+1)));107 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), fn+": "+tr("Unknown file extension: {0}", fn.substring(fn.lastIndexOf('.')+1))); 117 108 } 118 109 … … 128 119 if (!r.parse(true)) { 129 120 // input was not properly parsed, abort 130 JOptionPane.showMessageDialog(Main .parent, tr("Parsing file \"{0}\" failed", file));121 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Parsing file \"{0}\" failed", file)); 131 122 throw new IllegalStateException(); 132 123 } -
applications/editors/josm/plugins/openvisible/src/at/dallermassl/josm/plugin/openvisible/OsmGpxBounds.java
r13497 r34536 4 4 package at.dallermassl.josm.plugin.openvisible; 5 5 6 import java.io.BufferedInputStream;7 import java.io.File;8 import java.io.FileInputStream;9 import java.io.FileNotFoundException;10 6 import java.io.IOException; 11 7 import java.io.InputStream; … … 75 71 return ((lat2-lat1) > 0) && ((lon2-lon1) > 0); 76 72 } 77 78 public static void main(String[] args) {79 if(args.length < 5) {80 printHelp();81 return;82 }83 double minLat = Double.parseDouble(args[0]);84 double maxLat = Double.parseDouble(args[1]);85 double minLon = Double.parseDouble(args[2]);86 double maxLon = Double.parseDouble(args[3]);87 String[] files = new String[args.length - 4];88 System.arraycopy(args, 4, files, 0, args.length - 4);89 90 try {91 File file;92 for(String fileName : files) {93 file = new File(fileName);94 if(!file.isDirectory()95 && (file.getName().endsWith("gpx") || file.getName().endsWith("osm"))) {96 OsmGpxBounds parser = new OsmGpxBounds();97 parser.parse(new BufferedInputStream(new FileInputStream(file)));98 if(parser.intersects(minLat, maxLat, minLon, maxLon)) {99 System.out.println(file.getAbsolutePath()); // + "," + parser.minLat + "," + parser.maxLat + "," + parser.minLon + "," + parser.maxLon);100 }101 // System.out.println(parser.intersects(47.0555, 47.09, 15.406, 15.4737));102 }103 }104 } catch (FileNotFoundException e) {105 e.printStackTrace();106 } catch (IOException e) {107 e.printStackTrace();108 } catch (SAXException e) {109 e.printStackTrace();110 }111 }112 113 /**114 *115 */116 private static void printHelp() {117 System.out.println(OsmGpxBounds.class.getName() + " <minLat> <maxLat> <minLon> <maxLon> <files+>");118 119 }120 121 73 }
Note:
See TracChangeset
for help on using the changeset viewer.