- Timestamp:
- 2008-03-21T01:24:05+01:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r318 r587 2 2 package org.openstreetmap.josm.data.coor; 3 3 4 import org.openstreetmap.josm.Main; 4 5 import org.openstreetmap.josm.data.Bounds; 5 6 import org.openstreetmap.josm.data.projection.Projection; … … 51 52 return lat() >= b.min.lat() && lat() <= b.max.lat() && lon() > b.min.lon() && lon() < b.max.lon(); 52 53 } 54 55 /** 56 * Computes the distance between this lat/lon and another point on the earth. 57 * Uses spherical law of cosines formula, not Haversine. 58 * @param other the other point. 59 * @return distance in metres. 60 */ 61 public int distance(LatLon other) { 62 return (int) (Math.acos( 63 Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) + 64 Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) * 65 Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135); 66 } 53 67 54 68 /** -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r582 r587 72 72 public GpxData data; 73 73 private final GpxLayer me; 74 protected static final double PHI = Math.toRadians(15); 74 75 75 76 public GpxLayer(GpxData d) { … … 298 299 299 300 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")); 300 303 boolean lines = Main.pref.getBoolean("draw.rawgps.lines"); 301 304 String linesKey = "draw.rawgps.lines.layer "+name; … … 305 308 306 309 Point old = null; 310 WayPoint oldWp = null; 307 311 for (GpxTrack trk : data.tracks) { 308 312 if (!forceLines) { … … 315 319 Point screen = mv.getPoint(trkPnt.eastNorth); 316 320 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; 317 325 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 318 333 } else if (!large) { 319 334 g.drawRect(screen.x, screen.y, 0, 0); … … 322 337 g.fillRect(screen.x-1, screen.y-1, 3, 3); 323 338 old = screen; 339 oldWp = trkPnt; 324 340 } 325 341 }
Note:
See TracChangeset
for help on using the changeset viewer.