Ignore:
Timestamp:
2008-03-21T01:24:05+01:00 (16 years ago)
Author:
framm
Message:
  • new boolean config option draw.rawgps.direction enables arrowheads on lines between GPS points (only if lines are drawn). can currently only be set manually or through expert mode. Fixes #650.
  • new integer config option draw.rawgps.max-line-length can be set to suppress line drawing between GPS points further apart than the configured value (in metres). Beware: Using this option will SLOW THINGS DOWN because distance computation is expensive. can currently only be set manually or through expert mode. Fixes #494.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r582 r587  
    7272        public GpxData data;
    7373        private final GpxLayer me;
     74        protected static final double PHI = Math.toRadians(15);
    7475       
    7576        public GpxLayer(GpxData d) {
     
    298299               
    299300                boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force");
     301                boolean direction = Main.pref.getBoolean("draw.rawgps.direction");
     302                int maxLineLength = Integer.parseInt(Main.pref.get("draw.rawgps.max-line-length", "-1"));
    300303                boolean lines = Main.pref.getBoolean("draw.rawgps.lines");
    301304                String linesKey = "draw.rawgps.lines.layer "+name;
     
    305308
    306309                Point old = null;
     310                WayPoint oldWp = null;
    307311                for (GpxTrack trk : data.tracks) {
    308312                        if (!forceLines) {
     
    315319                                        Point screen = mv.getPoint(trkPnt.eastNorth);
    316320                                        if (lines && old != null) {
     321                                               
     322                                                // break out if a maxLineLength is set and the line is longer.
     323                                                if (maxLineLength > -1)
     324                                                        if (trkPnt.latlon.distance(oldWp.latlon) > maxLineLength) continue;
    317325                                                g.drawLine(old.x, old.y, screen.x, screen.y);
     326
     327                                                if (direction) {
     328                                                        double t = Math.atan2(screen.y-old.y, screen.x-old.x) + Math.PI;
     329                                                        g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t-PHI)), (int)(screen.y + 10*Math.sin(t-PHI)));
     330                                                        g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t+PHI)), (int)(screen.y + 10*Math.sin(t+PHI)));
     331                                                }
     332                                               
    318333                                        } else if (!large) {
    319334                                                g.drawRect(screen.x, screen.y, 0, 0);
     
    322337                                                g.fillRect(screen.x-1, screen.y-1, 3, 3);
    323338                                        old = screen;
     339                                        oldWp = trkPnt;
    324340                                }
    325341                        }
Note: See TracChangeset for help on using the changeset viewer.