Changeset 4129 in josm
- Timestamp:
- 2011-06-08T09:07:30+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r4126 r4129 25 25 public boolean drawLine; 26 26 public int dir; 27 28 public WayPoint(WayPoint p) { 29 attr.putAll(p.attr); 30 lat = p.lat; 31 lon = p.lon; 32 east = p.east; 33 north = p.north; 34 time = p.time; 35 customColoring = p.customColoring; 36 drawLine = p.drawLine; 37 dir = p.dir; 38 } 27 39 28 40 public WayPoint(LatLon ll) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r4126 r4129 67 67 visit(((CachedLatLon)latlon).getEastNorth()); 68 68 } else { 69 visit(Main. proj.latlon2eastNorth(latlon));69 visit(Main.getProjection().latlon2eastNorth(latlon)); 70 70 } 71 71 } -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r4126 r4129 461 461 } 462 462 463 Li st<Collection<WayPoint>> visibleSegments = new ArrayList<Collection<WayPoint>>();463 LinkedList<WayPoint> visibleSegments = new LinkedList<WayPoint>(); 464 464 for (GpxTrack trk: data.tracks) { 465 465 for (GpxTrackSegment trkSeg: trk.getSegments()) { 466 if (trkSeg.getBounds() != null && trkSeg.getBounds().intersects(box)) { 467 visibleSegments.add(trkSeg.getWayPoints()); 468 } 469 } 470 } 466 WayPoint last = null; 467 for(WayPoint pt : trkSeg.getWayPoints()) 468 { 469 Bounds b = new Bounds(pt.getCoor()); 470 if(pt.drawLine) // last should never be null when this is true! 471 b.extend(last.getCoor()); 472 if(b.intersects(box)) 473 { 474 if(last != null && (visibleSegments.isEmpty() 475 || visibleSegments.getLast() != last)) { 476 if(last.drawLine) { 477 WayPoint l = new WayPoint(last); 478 l.drawLine = false; 479 visibleSegments.add(l); 480 } else { 481 visibleSegments.add(last); 482 } 483 } 484 visibleSegments.add(pt); 485 } 486 last = pt; 487 } 488 } 489 } 490 if(visibleSegments.isEmpty()) 491 return; 471 492 472 493 /**************************************************************** … … 475 496 if (lines) { 476 497 Point old = null; 477 for (Collection<WayPoint> segment : visibleSegments) { 478 for (WayPoint trkPnt : segment) { 479 LatLon c = trkPnt.getCoor(); 480 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 481 continue; 482 } 483 Point screen = mv.getPoint(trkPnt.getEastNorth()); 484 if (trkPnt.drawLine) { 485 // skip points that are on the same screenposition 486 if (old != null && ((old.x != screen.x) || (old.y != screen.y))) { 487 g.setColor(trkPnt.customColoring); 488 g.drawLine(old.x, old.y, screen.x, screen.y); 489 } 490 } 491 old = screen; 492 } // end for trkpnt 493 } // end for segment 498 for (WayPoint trkPnt : visibleSegments) { 499 LatLon c = trkPnt.getCoor(); 500 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 501 continue; 502 } 503 Point screen = mv.getPoint(trkPnt.getEastNorth()); 504 if (trkPnt.drawLine) { 505 // skip points that are on the same screenposition 506 if (old != null && ((old.x != screen.x) || (old.y != screen.y))) { 507 g.setColor(trkPnt.customColoring); 508 g.drawLine(old.x, old.y, screen.x, screen.y); 509 } 510 } 511 old = screen; 512 } // end for trkpnt 494 513 } // end if lines 495 514 … … 500 519 Point old = null; 501 520 Point oldA = null; // last arrow painted 502 for (Collection<WayPoint> segment : visibleSegments) { 503 for (WayPoint trkPnt : segment) { 504 LatLon c = trkPnt.getCoor(); 505 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 506 continue; 507 } 508 if (trkPnt.drawLine) { 509 Point screen = mv.getPoint(trkPnt.getEastNorth()); 510 // skip points that are on the same screenposition 511 if (old != null 512 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 513 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 514 g.setColor(trkPnt.customColoring); 515 double t = Math.atan2(screen.y - old.y, screen.x - old.x) + Math.PI; 516 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t - PHI)), 517 (int) (screen.y + 10 * Math.sin(t - PHI))); 518 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t + PHI)), 519 (int) (screen.y + 10 * Math.sin(t + PHI))); 520 oldA = screen; 521 } 522 old = screen; 523 } 524 } // end for trkpnt 525 } // end for segment 521 for (WayPoint trkPnt : visibleSegments) { 522 LatLon c = trkPnt.getCoor(); 523 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 524 continue; 525 } 526 if (trkPnt.drawLine) { 527 Point screen = mv.getPoint(trkPnt.getEastNorth()); 528 // skip points that are on the same screenposition 529 if (old != null 530 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 531 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 532 g.setColor(trkPnt.customColoring); 533 double t = Math.atan2(screen.y - old.y, screen.x - old.x) + Math.PI; 534 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t - PHI)), 535 (int) (screen.y + 10 * Math.sin(t - PHI))); 536 g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t + PHI)), 537 (int) (screen.y + 10 * Math.sin(t + PHI))); 538 oldA = screen; 539 } 540 old = screen; 541 } 542 } // end for trkpnt 526 543 } // end if lines 527 544 … … 532 549 Point old = null; 533 550 Point oldA = null; // last arrow painted 534 for (Collection<WayPoint> segment : visibleSegments) { 535 for (WayPoint trkPnt : segment) { 536 LatLon c = trkPnt.getCoor(); 537 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 538 continue; 539 } 540 if (trkPnt.drawLine) { 541 Point screen = mv.getPoint(trkPnt.getEastNorth()); 542 // skip points that are on the same screenposition 543 if (old != null 544 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 545 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 546 g.setColor(trkPnt.customColoring); 547 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y 548 + dir[trkPnt.dir][1]); 549 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][2], screen.y 550 + dir[trkPnt.dir][3]); 551 oldA = screen; 552 } 553 old = screen; 554 } 555 } // end for trkpnt 556 } // end for segment 551 for (WayPoint trkPnt : visibleSegments) { 552 LatLon c = trkPnt.getCoor(); 553 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 554 continue; 555 } 556 if (trkPnt.drawLine) { 557 Point screen = mv.getPoint(trkPnt.getEastNorth()); 558 // skip points that are on the same screenposition 559 if (old != null 560 && (oldA == null || screen.x < oldA.x - delta || screen.x > oldA.x + delta 561 || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) { 562 g.setColor(trkPnt.customColoring); 563 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][0], screen.y 564 + dir[trkPnt.dir][1]); 565 g.drawLine(screen.x, screen.y, screen.x + dir[trkPnt.dir][2], screen.y 566 + dir[trkPnt.dir][3]); 567 oldA = screen; 568 } 569 old = screen; 570 } 571 } // end for trkpnt 557 572 } // end if lines 558 573 … … 562 577 if (large || hdopcircle) { 563 578 g.setColor(neutralColor); 564 for (Collection<WayPoint> segment : visibleSegments) { 565 for (WayPoint trkPnt : segment) { 566 LatLon c = trkPnt.getCoor(); 567 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 568 continue; 569 } 570 Point screen = mv.getPoint(trkPnt.getEastNorth()); 571 g.setColor(trkPnt.customColoring); 572 if (hdopcircle && trkPnt.attr.get("hdop") != null) { 573 // hdop value 574 float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue(); 575 if (hdop < 0) { 576 hdop = 0; 577 } 578 // hdop pixels 579 int hdopp = mv.getPoint(new LatLon(trkPnt.getCoor().lat(), trkPnt.getCoor().lon() + 2*6*hdop*360/40000000)).x - screen.x; 580 g.drawArc(screen.x-hdopp/2, screen.y-hdopp/2, hdopp, hdopp, 0, 360); 581 } 582 if (large) { 583 g.fillRect(screen.x-1, screen.y-1, 3, 3); 584 } 585 } // end for trkpnt 586 } // end for segment 579 for (WayPoint trkPnt : visibleSegments) { 580 LatLon c = trkPnt.getCoor(); 581 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 582 continue; 583 } 584 Point screen = mv.getPoint(trkPnt.getEastNorth()); 585 g.setColor(trkPnt.customColoring); 586 if (hdopcircle && trkPnt.attr.get("hdop") != null) { 587 // hdop value 588 float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue(); 589 if (hdop < 0) { 590 hdop = 0; 591 } 592 // hdop pixels 593 int hdopp = mv.getPoint(new LatLon(trkPnt.getCoor().lat(), trkPnt.getCoor().lon() + 2*6*hdop*360/40000000)).x - screen.x; 594 g.drawArc(screen.x-hdopp/2, screen.y-hdopp/2, hdopp, hdopp, 0, 360); 595 } 596 if (large) { 597 g.fillRect(screen.x-1, screen.y-1, 3, 3); 598 } 599 } // end for trkpnt 587 600 } // end if large || hdopcircle 588 601 … … 592 605 if (!large && lines) { 593 606 g.setColor(neutralColor); 594 for (Collection<WayPoint> segment : visibleSegments) { 595 for (WayPoint trkPnt : segment) { 596 LatLon c = trkPnt.getCoor(); 597 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 598 continue; 599 } 600 if (!trkPnt.drawLine) { 601 Point screen = mv.getPoint(trkPnt.getEastNorth()); 602 g.drawRect(screen.x, screen.y, 0, 0); 603 } 604 } // end for trkpnt 605 } // end for segment 607 for (WayPoint trkPnt : visibleSegments) { 608 LatLon c = trkPnt.getCoor(); 609 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 610 continue; 611 } 612 if (!trkPnt.drawLine) { 613 Point screen = mv.getPoint(trkPnt.getEastNorth()); 614 g.drawRect(screen.x, screen.y, 0, 0); 615 } 616 } // end for trkpnt 606 617 } // end if large 607 618 … … 611 622 if (!large && !lines) { 612 623 g.setColor(neutralColor); 613 for (Collection<WayPoint> segment : visibleSegments) { 614 for (WayPoint trkPnt : segment) { 615 LatLon c = trkPnt.getCoor(); 616 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 617 continue; 618 } 619 Point screen = mv.getPoint(trkPnt.getEastNorth()); 620 g.setColor(trkPnt.customColoring); 621 g.drawRect(screen.x, screen.y, 0, 0); 622 } // end for trkpnt 623 } // end for segment 624 for (WayPoint trkPnt : visibleSegments) { 625 LatLon c = trkPnt.getCoor(); 626 if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 627 continue; 628 } 629 Point screen = mv.getPoint(trkPnt.getEastNorth()); 630 g.setColor(trkPnt.customColoring); 631 g.drawRect(screen.x, screen.y, 0, 0); 632 } // end for trkpnt 624 633 } // end if large 625 634
Note:
See TracChangeset
for help on using the changeset viewer.