- Timestamp:
- 2009-02-17T19:17:26+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r1185 r1425 18 18 public final EastNorth eastNorth; 19 19 public double time; 20 public Color speedLineColor;20 public Color customColoring; 21 21 public boolean drawLine; 22 22 public int dir; -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r1283 r1425 86 86 private int computeCacheMaxLineLengthUsed; 87 87 private Color computeCacheColorUsed; 88 private booleancomputeCacheColored;88 private colorModes computeCacheColored; 89 89 private int computeCacheColorTracksTune; 90 90 … … 369 369 {-ll0,-sl9,-ll0,+sl9} 370 370 }; 371 371 372 // the different color modes 373 enum colorModes { none, velocity, dilution } 374 372 375 @Override public void paint(Graphics g, MapView mv) { 373 376 … … 377 380 // Long startTime = System.currentTimeMillis(); 378 381 Color neutralColor = getColor(name); 379 boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force"); // also draw lines between points belonging to different segments 380 boolean direction = Main.pref.getBoolean("draw.rawgps.direction"); // draw direction arrows on the lines 381 int maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", -1); 382 // also draw lines between points belonging to different segments 383 boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force"); 384 // draw direction arrows on the lines 385 boolean direction = Main.pref.getBoolean("draw.rawgps.direction"); 382 386 // don't draw lines if longer than x meters 383 boolean lines = Main.pref.getBoolean("draw.rawgps.lines"); // draw line between points, global setting 387 int maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", -1); 388 // draw line between points, global setting 389 boolean lines = Main.pref.getBoolean("draw.rawgps.lines"); 384 390 String linesKey = "draw.rawgps.lines.layer "+name; 391 // draw lines, per-layer setting 385 392 if (Main.pref.hasKey(linesKey)) 386 lines = Main.pref.getBoolean(linesKey); // draw lines, per-layer setting 387 boolean large = Main.pref.getBoolean("draw.rawgps.large"); // paint large dots for points 388 boolean colored = Main.pref.getBoolean("draw.rawgps.colors"); // color the lines 389 boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection"); // paint direction arrow with alternate math. may be faster 390 int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0); 393 lines = Main.pref.getBoolean(linesKey); 394 // paint large dots for points 395 boolean large = Main.pref.getBoolean("draw.rawgps.large"); 396 // color the lines 397 colorModes colored = colorModes.none; 398 try { 399 colored = colorModes.values()[Main.pref.getInteger("draw.rawgps.colors", 0)]; 400 } catch(Exception e) { } 401 // paint direction arrow with alternate math. may be faster 402 boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection"); 391 403 // don't draw arrows nearer to each other than this 392 int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45); // allows to tweak line coloring for different speed levels. 404 int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0); 405 // allows to tweak line coloring for different speed levels. 406 int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45); 393 407 /**************************************************************** 394 408 ********** STEP 2a - CHECK CACHE VALIDITY ********************** … … 420 434 continue; 421 435 } 436 trkPnt.customColoring = neutralColor; 422 437 if (oldWp != null) { 423 438 double dist = trkPnt.latlon.greatCircleDistance(oldWp.latlon); 424 double dtime = trkPnt.time - oldWp.time; 425 double vel = dist/dtime; 426 double velColor = vel/colorTracksTune*255; 427 428 if (!colored) { 429 trkPnt.speedLineColor = neutralColor; 430 } else if (dtime <= 0 || vel < 0 || velColor > 255) { // attn: bad case first 431 trkPnt.speedLineColor = colors[255]; 432 } else { 433 trkPnt.speedLineColor = colors[(int) (velColor)]; 439 440 switch(colored) { 441 case velocity: 442 double dtime = trkPnt.time - oldWp.time; 443 double vel = dist/dtime; 444 double velColor = vel/colorTracksTune*255; 445 // Bad case first 446 if (dtime <= 0 || vel < 0 || velColor > 255) 447 trkPnt.customColoring = colors[255]; 448 else 449 trkPnt.customColoring = colors[(int) (velColor)]; 450 break; 451 452 case dilution: 453 if(trkPnt.attr.get("hdop") != null) { 454 float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue(); 455 int hdoplvl = Math.round(hdop * 25); 456 // High hdop is bad, but high values in colors are green. 457 // Therefore inverse the logic 458 int hdopcolor = 255 - (hdoplvl > 255 ? 255 : hdoplvl); 459 trkPnt.customColoring = colors[hdopcolor]; 460 } 461 break; 434 462 } 463 435 464 if (maxLineLength == -1 || dist <= maxLineLength) { 436 465 trkPnt.drawLine = true; … … 440 469 } 441 470 } else { // make sure we reset outdated data 442 trkPnt.speedLineColor = colors[255];443 471 trkPnt.drawLine = false; 444 472 } … … 464 492 // skip points that are on the same screenposition 465 493 if (old != null && ((old.x != screen.x) || (old.y != screen.y))) { 466 g.setColor(trkPnt. speedLineColor);494 g.setColor(trkPnt.customColoring); 467 495 g.drawLine(old.x, old.y, screen.x, screen.y); 468 496 } … … 489 517 // skip points that are on the same screenposition 490 518 if (old != null && (oldA == null || screen.x < oldA.x-delta || screen.x > oldA.x+delta || screen.y < oldA.y-delta || screen.y > oldA.y+delta)) { 491 g.setColor(trkPnt. speedLineColor);519 g.setColor(trkPnt.customColoring); 492 520 double t = Math.atan2(screen.y-old.y, screen.x-old.x) + Math.PI; 493 521 g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t-PHI)), (int)(screen.y … … 519 547 // skip points that are on the same screenposition 520 548 if (old != null && (oldA == null || screen.x < oldA.x-delta || screen.x > oldA.x+delta || screen.y < oldA.y-delta || screen.y > oldA.y+delta)) { 521 g.setColor(trkPnt. speedLineColor);549 g.setColor(trkPnt.customColoring); 522 550 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y + dir[trkPnt.dir][1]); 523 551 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][2], screen.y + dir[trkPnt.dir][3]); … … 542 570 continue; 543 571 Point screen = mv.getPoint(trkPnt.eastNorth); 544 g.fillRect(screen.x-1, screen.y-1, 3, 3); 572 g.setColor(trkPnt.customColoring); 573 g.fillRect(screen.x-1, screen.y-1, 3, 3); 545 574 } // end for trkpnt 546 575 } // end for segment … … 578 607 continue; 579 608 Point screen = mv.getPoint(trkPnt.eastNorth); 609 g.setColor(trkPnt.customColoring); 580 610 g.drawRect(screen.x, screen.y, 0, 0); 581 611 } // end for trkpnt -
trunk/src/org/openstreetmap/josm/gui/preferences/DrawingPreference.java
r1289 r1425 10 10 11 11 import javax.swing.BorderFactory; 12 import javax.swing.ButtonGroup; 12 13 import javax.swing.JCheckBox; 13 14 import javax.swing.JComboBox; 14 15 import javax.swing.JLabel; 16 import javax.swing.JRadioButton; 15 17 import javax.swing.JTextField; 16 18 import javax.swing.JScrollPane; 17 19 import javax.swing.JPanel; 18 20 import javax.swing.Box; 21 import javax.swing.event.ChangeEvent; 22 import javax.swing.event.ChangeListener; 19 23 20 24 import org.openstreetmap.josm.Main; … … 27 31 private JCheckBox forceRawGpsLines = new JCheckBox(tr("Force lines if no segments imported.")); 28 32 private JCheckBox largeGpsPoints = new JCheckBox(tr("Draw large GPS points.")); 29 private JCheckBox colorTracks = new JCheckBox(tr("Color tracks by velocity.")); 30 private JComboBox colorTracksTune = new JComboBox(new String[] {tr("Car"), tr("Bicycle"), tr("Foot")}); 33 private ButtonGroup colorGroup; 34 private JRadioButton colorTypeVelocity = new JRadioButton(tr("Velocity (red = slow, green = fast)")); 35 private JRadioButton colorTypeDilution = new JRadioButton(tr("Dilution of Position (red = high, green = low, if available)")); 36 private JRadioButton colorTypeNone = new JRadioButton(tr("Single Color (can be customized for named layers)")); 37 private JComboBox colorTypeVelocityTune = new JComboBox(new String[] {tr("Car"), tr("Bicycle"), tr("Foot")}); 31 38 private JCheckBox directionHint = new JCheckBox(tr("Draw Direction Arrows")); 32 39 private JCheckBox drawGpsArrows = new JCheckBox(tr("Draw Direction Arrows")); … … 49 56 drawRawGpsLines.addActionListener(new ActionListener(){ 50 57 public void actionPerformed(ActionEvent e) { 51 forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected()); 52 drawRawGpsMaxLineLength.setEnabled(drawRawGpsLines.isSelected()); 53 drawGpsArrows.setEnabled(drawRawGpsLines.isSelected()); 54 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 55 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 56 colorTracks.setEnabled(drawRawGpsLines.isSelected()); 57 colorTracksTune.setEnabled(colorTracks.isSelected() && drawRawGpsLines.isSelected()); 58 forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected()); 59 drawRawGpsMaxLineLength.setEnabled(drawRawGpsLines.isSelected()); 60 drawGpsArrows.setEnabled(drawRawGpsLines.isSelected()); 61 drawGpsArrowsFast.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 62 drawGpsArrowsMinDist.setEnabled(drawGpsArrows.isSelected() && drawGpsArrows.isEnabled()); 58 63 } 59 64 }); … … 100 105 panel.add(drawGpsArrowsMinDist, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 101 106 102 // colorTracks103 colorTracks.addActionListener(new ActionListener(){104 public void actionPerformed(ActionEvent e) {105 colorTracksTune.setEnabled(colorTracks.isSelected() && drawRawGpsLines.isSelected());106 }107 });108 colorTracks.setSelected(Main.pref.getBoolean("draw.rawgps.colors"));109 colorTracks.setToolTipText(tr("Choose the hue for the track color by the velocity at that point."));110 colorTracks.setEnabled(drawRawGpsLines.isSelected());111 panel.add(colorTracks, GBC.std().insets(40,0,0,0));112 113 // color Tracks by Velocity Tune114 int ccts = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45);115 colorTracksTune.setSelectedIndex(ccts==10 ? 2 : (ccts==20 ? 1 : 0));116 colorTracksTune.setToolTipText(tr("Allows to tune the track coloring for different average speeds."));117 colorTracksTune.setEnabled(colorTracks.isSelected() && colorTracks.isEnabled());118 panel.add(colorTracksTune, GBC.eop().insets(5,0,0,5));119 120 107 // largeGpsPoints 121 108 largeGpsPoints.setSelected(Main.pref.getBoolean("draw.rawgps.large")); 122 109 largeGpsPoints.setToolTipText(tr("Draw larger dots for the GPS points.")); 123 110 panel.add(largeGpsPoints, GBC.eop().insets(20,0,0,0)); 111 112 // colorTracks 113 colorGroup = new ButtonGroup(); 114 colorGroup.add(colorTypeNone); 115 colorGroup.add(colorTypeVelocity); 116 colorGroup.add(colorTypeDilution); 117 118 colorTypeVelocity.addChangeListener(new ChangeListener(){ 119 public void stateChanged(ChangeEvent e) { 120 colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected()); 121 } 122 }); 123 124 switch(Main.pref.getInteger("draw.rawgps.colors", 0)) { 125 case 0: 126 colorTypeNone.setSelected(true); 127 break; 128 case 1: 129 colorTypeVelocity.setSelected(true); 130 break; 131 case 2: 132 colorTypeDilution.setSelected(true); 133 break; 134 } 135 136 colorTypeNone.setToolTipText(tr("All points and track segments will have the same color. Can be customized in Layer Manager.")); 137 colorTypeVelocity.setToolTipText(tr("Colors points and track segments by velocity.")); 138 colorTypeDilution.setToolTipText(tr("Colors points and track segments by dilution of position (HDOP). Your capture device needs to logs that information.")); 139 140 // color Tracks by Velocity Tune 141 int ccts = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45); 142 colorTypeVelocityTune.setSelectedIndex(ccts==10 ? 2 : (ccts==20 ? 1 : 0)); 143 colorTypeVelocityTune.setToolTipText(tr("Allows to tune the track coloring for different average speeds.")); 144 colorTypeVelocityTune.setEnabled(colorTypeVelocity.isSelected() && colorTypeVelocity.isEnabled()); 145 146 panel.add(Box.createVerticalGlue(), GBC.eol().insets(0, 20, 0, 0)); 147 148 panel.add(new JLabel(tr("Track and Point Coloring")), GBC.eol().insets(20,0,0,0)); 149 panel.add(colorTypeNone, GBC.eol().insets(40,0,0,0)); 150 panel.add(colorTypeVelocity, GBC.std().insets(40,0,0,0)); 151 panel.add(colorTypeVelocityTune, GBC.eop().insets(5,0,0,5)); 152 panel.add(colorTypeDilution, GBC.eol().insets(40,0,0,0)); 124 153 125 154 panel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); … … 198 227 Main.pref.put("draw.rawgps.alternatedirection", drawGpsArrowsFast.isSelected()); 199 228 Main.pref.put("draw.rawgps.min-arrow-distance", drawGpsArrowsMinDist.getText()); 200 Main.pref.put("draw.rawgps.colors", colorTracks.isSelected()); 201 int ccti=colorTracksTune.getSelectedIndex(); 229 if(colorTypeVelocity.isSelected()) 230 Main.pref.putInteger("draw.rawgps.colors", 1); 231 else if(colorTypeDilution.isSelected()) 232 Main.pref.putInteger("draw.rawgps.colors", 2); 233 else 234 Main.pref.putInteger("draw.rawgps.colors", 0); 235 int ccti=colorTypeVelocityTune.getSelectedIndex(); 202 236 Main.pref.putInteger("draw.rawgps.colorTracksTune", ccti==2 ? 10 : (ccti==1 ? 20 : 45)); 203 237 Main.pref.put("draw.rawgps.large", largeGpsPoints.isSelected()); -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r1169 r1425 224 224 break; 225 225 case wpt: 226 if ( qName.equals("ele")|| qName.equals("magvar")227 || qName.equals("geoidheight") || qName.equals("name")228 || qName.equals("sym") || qName.equals("type")) {226 if ( qName.equals("ele") || qName.equals("magvar") 227 || qName.equals("name") || qName.equals("geoidheight") 228 || qName.equals("type") || qName.equals("sym")) { 229 229 currentWayPoint.attr.put(qName, accumulator.toString()); 230 } else if(qName.equals("hdop") /*|| qName.equals("vdop") || 231 qName.equals("pdop")*/) { 232 try { 233 currentWayPoint.attr.put(qName, Float.parseFloat(accumulator.toString())); 234 } catch(Exception e) { 235 currentWayPoint.attr.put(qName, new Float(0)); 236 } 230 237 } else if (qName.equals("time")) { 231 238 currentWayPoint.attr.put(qName, accumulator.toString()); -
trunk/src/org/openstreetmap/josm/io/NmeaReader.java
r1415 r1425 309 309 // h-dilution 310 310 accu=e[GPGGA.HDOP.position]; 311 if(!accu.equals("")) { 312 Double.parseDouble(accu); 313 currentwp.attr.put("hdop", accu); 314 } 311 if(!accu.equals("")) 312 currentwp.attr.put("hdop", Float.parseFloat(accu)); 315 313 // fix 316 314 accu=e[GPGGA.QUALITY.position]; … … 356 354 // vdop 357 355 accu=e[GPGSA.VDOP.position]; 358 if(!accu.equals("")) { 359 Double.parseDouble(accu); 360 currentwp.attr.put("vdop", accu); 361 } 356 if(!accu.equals("")) 357 currentwp.attr.put("vdop", Float.parseFloat(accu)); 362 358 // hdop 363 359 accu=e[GPGSA.HDOP.position]; 364 if(!accu.equals("")) { 365 Double.parseDouble(accu); 366 currentwp.attr.put("hdop", accu); 367 } 360 if(!accu.equals("")) 361 currentwp.attr.put("hdop", Float.parseFloat(accu)); 368 362 // pdop 369 363 accu=e[GPGSA.PDOP.position]; 370 if(!accu.equals("")) { 371 Double.parseDouble(accu); 372 currentwp.attr.put("pdop", accu); 373 } 364 if(!accu.equals("")) 365 currentwp.attr.put("pdop", Float.parseFloat(accu)); 374 366 } 375 367 else if(e[0].equals("$GPRMC")) { -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r1415 r1425 478 478 * @param ref The dataset that is search in for references first. If 479 479 * the Reference is not found here, Main.ds is searched and a copy of the 480 * eleme t found there is returned.480 * element found there is returned. 481 481 */ 482 482 public static DataSet parseDataSet(InputStream source, DataSet ref, PleaseWaitDialog pleaseWaitDlg) throws SAXException, IOException {
Note:
See TracChangeset
for help on using the changeset viewer.