Ticket #11338: 11338.patch

File 11338.patch, 2.1 KB (added by simon04, 11 years ago)
  • src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    diff --git a/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java b/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java
    index f00c865..30bfe20 100644
    a b  
    1010import java.awt.Point;
    1111import java.awt.RenderingHints;
    1212import java.awt.Stroke;
     13import java.util.ArrayList;
    1314import java.util.Collection;
     15import java.util.Collections;
    1416import java.util.Date;
    1517import java.util.List;
    1618
    public void calculateColors() {  
    223225
    224226        if (colorModeDynamic) {
    225227            if (colored == ColorMode.VELOCITY) {
     228                final List<Double> velocities = new ArrayList<>();
    226229                for (Collection<WayPoint> segment : data.getLinesIterable(null)) {
    227230                    if (!forceLines) {
    228231                        oldWp = null;
    public void calculateColors() {  
    235238                        if (oldWp != null && trkPnt.time > oldWp.time) {
    236239                            double vel = c.greatCircleDistance(oldWp.getCoor())
    237240                                    / (trkPnt.time - oldWp.time);
     241                            velocities.add(vel);
    238242                            if (vel > maxval) {
    239243                                maxval = vel;
    240244                            }
    public void calculateColors() {  
    245249                        oldWp = trkPnt;
    246250                    }
    247251                }
     252                Collections.sort(velocities);
     253                minval = velocities.get(velocities.size() / 20); // 5% percentile
     254                maxval = velocities.get(velocities.size() * 19 / 20); // 95% percentile
    248255                if (minval >= maxval) {
    249256                    velocityScale.setRange(0, 120/3.6);
    250257                } else {
    251                     velocityScale.setRange(minval, maxval);
     258                     velocityScale.setRange(minval, maxval);
    252259                }
    253260            } else if (colored == ColorMode.HDOP) {
    254261                for (Collection<WayPoint> segment : data.getLinesIterable(null)) {