Changeset 587 in josm


Ignore:
Timestamp:
Mar 21, 2008 1:24:05 AM (5 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.
Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r318 r587  
    22package org.openstreetmap.josm.data.coor; 
    33 
     4import org.openstreetmap.josm.Main; 
    45import org.openstreetmap.josm.data.Bounds; 
    56import org.openstreetmap.josm.data.projection.Projection; 
     
    5152                return lat() >= b.min.lat() && lat() <= b.max.lat() && lon() > b.min.lon() && lon() < b.max.lon(); 
    5253        } 
     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        } 
    5367 
    5468        /** 
  • 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.