Index: /trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/coor/LatLon.java	(revision 586)
+++ /trunk/src/org/openstreetmap/josm/data/coor/LatLon.java	(revision 587)
@@ -2,4 +2,5 @@
 package org.openstreetmap.josm.data.coor;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.projection.Projection;
@@ -51,4 +52,17 @@
 		return lat() >= b.min.lat() && lat() <= b.max.lat() && lon() > b.min.lon() && lon() < b.max.lon();
 	}
+	
+	/**
+	 * Computes the distance between this lat/lon and another point on the earth.
+	 * Uses spherical law of cosines formula, not Haversine.
+	 * @param other the other point.
+	 * @return distance in metres.
+	 */
+	public int distance(LatLon other) {
+		return (int) (Math.acos(
+			Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) + 
+		    Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) *
+		                  Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135);
+	}
 
 	/**
Index: /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 586)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java	(revision 587)
@@ -72,4 +72,5 @@
 	public GpxData data;
 	private final GpxLayer me;
+	protected static final double PHI = Math.toRadians(15);
 	
 	public GpxLayer(GpxData d) {
@@ -298,4 +299,6 @@
 		
 		boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force");
+		boolean direction = Main.pref.getBoolean("draw.rawgps.direction");
+		int maxLineLength = Integer.parseInt(Main.pref.get("draw.rawgps.max-line-length", "-1"));
 		boolean lines = Main.pref.getBoolean("draw.rawgps.lines");
 		String linesKey = "draw.rawgps.lines.layer "+name;
@@ -305,4 +308,5 @@
 
 		Point old = null;
+		WayPoint oldWp = null;
 		for (GpxTrack trk : data.tracks) {
 			if (!forceLines) {
@@ -315,5 +319,16 @@
 					Point screen = mv.getPoint(trkPnt.eastNorth);
 					if (lines && old != null) {
+						
+						// break out if a maxLineLength is set and the line is longer.
+						if (maxLineLength > -1) 
+							if (trkPnt.latlon.distance(oldWp.latlon) > maxLineLength) continue;
 						g.drawLine(old.x, old.y, screen.x, screen.y);
+
+						if (direction) {
+							double t = Math.atan2(screen.y-old.y, screen.x-old.x) + Math.PI;
+							g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t-PHI)), (int)(screen.y + 10*Math.sin(t-PHI)));
+							g.drawLine(screen.x,screen.y, (int)(screen.x + 10*Math.cos(t+PHI)), (int)(screen.y + 10*Math.sin(t+PHI)));
+						}
+						
 					} else if (!large) {
 						g.drawRect(screen.x, screen.y, 0, 0);
@@ -322,4 +337,5 @@
 						g.fillRect(screen.x-1, screen.y-1, 3, 3);
 					old = screen;
+					oldWp = trkPnt;
 				}
 			}
