Changeset 38 in josm
- Timestamp:
- 2006-01-02T21:57:25+01:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/actions/OpenAction.java
r32 r38 8 8 import java.io.FileReader; 9 9 import java.io.IOException; 10 import java.io.Reader; 10 11 import java.util.Collection; 12 import java.util.LinkedList; 11 13 12 14 import javax.swing.Box; … … 29 31 import org.openstreetmap.josm.io.GpxReader; 30 32 import org.openstreetmap.josm.io.OsmReader; 33 import org.openstreetmap.josm.io.RawCsvReader; 31 34 import org.openstreetmap.josm.io.RawGpsReader; 32 35 … … 55 58 JCheckBox rawGps = new JCheckBox("Raw GPS data", true); 56 59 rawGps.setToolTipText("Check this, if the data were obtained from a gps device."); 57 JCheckBox newLayer = new JCheckBox("As Layer", true);58 newLayer.setToolTipText("Open as a new layer or replace all current layers.");59 if (Main.main.getMapFrame() == null) {60 newLayer.setEnabled(false);61 newLayer.setSelected(false);62 }63 60 64 61 JPanel p = new JPanel(new GridBagLayout()); 65 62 p.add(new JLabel("Options"), GBC.eop()); 66 63 p.add(rawGps, GBC.eol()); 67 p.add(newLayer, GBC.eol());68 64 p.add(Box.createVerticalGlue(), GBC.eol().fill()); 69 65 fc.setAccessory(p); … … 71 67 if (fc.showOpenDialog(Main.main) != JFileChooser.APPROVE_OPTION) 72 68 return; 73 69 74 70 File filename = fc.getSelectedFile(); 75 71 if (filename == null) … … 78 74 try { 79 75 Layer layer; 76 Reader in = new FileReader(filename); 77 String extension = filename.getName().toLowerCase().substring(filename.getName().lastIndexOf('.')+1); 80 78 if (rawGps.isSelected()) { 81 Collection<Collection<GeoPoint>> data = new RawGpsReader(new FileReader(filename)).parse(); 79 Collection<Collection<GeoPoint>> data; 80 if (extension.equals("gpx")) 81 data = new RawGpsReader(in).parse(); 82 else if (extension.equals("xml") || extension.equals("osm")) { 83 JOptionPane.showMessageDialog(Main.main, "Osm server data import for GPS data is not supported."); 84 return; 85 } else if (extension.equals("csv") || extension.equals("txt")) { 86 data = new LinkedList<Collection<GeoPoint>>(); 87 data.add(new RawCsvReader(in).parse()); 88 } else { 89 JOptionPane.showMessageDialog(Main.main, "Unknown file extension: "+extension); 90 return; 91 } 82 92 layer = new RawGpsDataLayer(data, filename.getName()); 83 93 } else { 84 DataSet dataSet = filename.getName().toLowerCase().endsWith(".gpx") ? 85 new GpxReader(new FileReader(filename)).parse() : 86 new OsmReader(new FileReader(filename)).parse(); 94 DataSet dataSet; 95 if (extension.equals("gpx")) 96 dataSet = new GpxReader(in).parse(); 97 else if (extension.equals("xml") || extension.equals("osm")) 98 dataSet = new OsmReader(in).parse(); 99 else if (extension.equals("csv") || extension.equals("txt")) { 100 JOptionPane.showMessageDialog(Main.main, "CSV Data import for non-GPS data is not implemented yet."); 101 return; 102 } else { 103 JOptionPane.showMessageDialog(Main.main, "Unknown file extension: "+extension); 104 return; 105 } 87 106 layer = new OsmDataLayer(dataSet, filename.getName()); 88 107 } 89 108 90 if (Main.main.getMapFrame() == null || !newLayer.isSelected())109 if (Main.main.getMapFrame() == null) 91 110 Main.main.setMapFrame(filename.getName(), new MapFrame(layer)); 92 111 else -
src/org/openstreetmap/josm/data/Preferences.java
r36 r38 65 65 */ 66 66 public String osmDataPassword = null; 67 /** 68 * The csv input style string or <code>null</code> for auto. The style is a 69 * comma seperated list of identifiers as specified in the tooltip help text 70 * of csvImportString in PreferenceDialog. 71 * 72 * @see org.openstreetmap.josm.gui.PreferenceDialog#csvImportString 73 */ 74 public String csvImportString = null; 67 75 68 76 /** … … 129 137 osmDataUsername = osmServer.getChildText("username"); 130 138 osmDataPassword = osmServer.getChildText("password"); 139 csvImportString = osmServer.getChildText("csvImportString"); 131 140 } 132 141 drawRawGpsLines = root.getChild("drawRawGpsLines") != null; … … 158 167 osmServer.getChildren().add(new Element("username").setText(osmDataUsername)); 159 168 osmServer.getChildren().add(new Element("password").setText(osmDataPassword)); 169 osmServer.getChildren().add(new Element("csvImportString").setText(csvImportString)); 160 170 children.add(osmServer); 161 171 -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r33 r38 59 59 if (Main.pref.osmDataPassword == "") 60 60 Main.pref.osmDataPassword = null; 61 Main.pref.csvImportString = csvImportString.getText(); 61 62 Main.pref.setDrawRawGpsLines(drawRawGpsLines.isSelected()); 62 63 Main.pref.setForceRawGpsLines(forceRawGpsLines.isSelected()); … … 116 117 */ 117 118 JPasswordField osmDataPassword = new JPasswordField(20); 119 /** 120 * Comma seperated import string specifier or <code>null</code> if the first 121 * data line should be interpreted as one. 122 */ 123 JTextField csvImportString = new JTextField(20); 118 124 /** 119 125 * The checkbox stating whether nodes should be merged together. … … 188 194 osmDataUsername.setToolTipText("Login name (email) to the OSM account."); 189 195 osmDataPassword.setToolTipText("Login password to the OSM account. Leave blank to not store any password."); 196 csvImportString.setToolTipText("<html>Import string specification. Currently, only lat/lon pairs are imported.<br>" + 197 "<b>lat</b>: The latitude coordinate<br>" + 198 "<b>lon</b>: The longitude coordinate<br>" + 199 "<b>ignore</b>: Skip this field<br>" + 200 "An example: \"ignore ignore lat lon\" will use ' ' as delimiter, skip the first two values and read then lat/lon.<br>" + 201 "Other example: \"lat,lon\" will just read lat/lon values comma seperated.</html>"); 190 202 drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your track."); 191 203 drawRawGpsLines.setSelected(Main.pref.isDrawRawGpsLines()); … … 197 209 osmDataUsername.setText(Main.pref.osmDataUsername); 198 210 osmDataPassword.setText(Main.pref.osmDataPassword); 211 csvImportString.setText(Main.pref.csvImportString); 199 212 200 213 // Display tab … … 221 234 warning.setFont(warning.getFont().deriveFont(Font.ITALIC)); 222 235 con.add(warning, GBC.eop().fill(GBC.HORIZONTAL)); 223 236 con.add(new JLabel("CSV import specification (empty: read from first line in data)"), GBC.eol()); 237 con.add(csvImportString, GBC.eop().fill(GBC.HORIZONTAL)); 224 238 225 239 // Map tab -
src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java
r23 r38 42 42 } 43 43 if (evt.getPropertyName().equals("drawRawGpsLines") || 44 evt.getPropertyName().equals(" drawRawGpsLines"))44 evt.getPropertyName().equals("forceRawGpsLines")) 45 45 Main.main.getMapFrame().repaint(); 46 46 } … … 67 67 for (GeoPoint p : c) { 68 68 Point screen = mv.getScreenPoint(p); 69 if (Main.pref.isDrawRawGpsLines() && old != null) {69 if (Main.pref.isDrawRawGpsLines() && old != null) 70 70 g.drawLine(old.x, old.y, screen.x, screen.y); 71 } else {71 else 72 72 g.drawRect(screen.x, screen.y, 0, 0); 73 old = screen; 74 } 73 old = screen; 75 74 } 76 75 }
Note:
See TracChangeset
for help on using the changeset viewer.