Changeset 18738 in josm


Ignore:
Timestamp:
2023-05-30T15:39:05+02:00 (11 months ago)
Author:
stoecker
Message:

add NMEA track coloring by reference ID

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

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

    r18494 r18738  
    134134    private ColorScale qualityScale;
    135135    private ColorScale fixScale;
     136    private ColorScale refScale;
    136137    private ColorScale dateScale;
    137138    private ColorScale directionScale;
     
    243244        qualityScale = ColorScale.createFixedScale(rtkLibQualityColors).addTitle(tr("Quality")).addColorBarTitles(rtkLibQualityNames);
    244245        fixScale = ColorScale.createFixedScale(gpsFixQualityColors).addTitle(tr("GPS fix")).addColorBarTitles(gpsFixQualityNames);
     246        refScale = ColorScale.createCyclicScale(1).addTitle(tr("GPS ref"));
    245247        dateScale = ColorScale.createHSBScale(256).addTitle(tr("Time"));
    246248        directionScale = ColorScale.createCyclicScale(256).setIntervalCount(4).addTitle(tr("Direction"));
     
    291293         * Color by GPS fix
    292294         */
    293         FIX;
     295        FIX,
     296        /**
     297         * Color by differential ID
     298         */
     299        REF;
    294300
    295301        static ColorMode fromIndex(final int index) {
     
    393399        qualityScale.setNoDataColor(neutralColor);
    394400        fixScale.setNoDataColor(neutralColor);
     401        refScale.setNoDataColor(neutralColor);
    395402        directionScale.setNoDataColor(neutralColor);
    396403
     
    609616            qualityScale.setRange(1, rtkLibQualityColors.length);
    610617            fixScale.setRange(0, gpsFixQualityColors.length);
     618            refScale.setRange(0, gpsFixQualityColors.length);
    611619        }
    612620        double now = System.currentTimeMillis()/1000.0;
     
    618626        }
    619627
     628        ArrayList<String> refs = new ArrayList<String>();
     629        if(colored == ColorMode.REF) {
     630            for (Line segment : getLinesIterable(null)) {
     631                for (WayPoint trkPnt : segment) {
     632                    if (trkPnt.get(GpxConstants.PT_DGPSID) != null) {
     633                        String refval = trkPnt.get(GpxConstants.PT_DGPSID).toString();
     634                        int i = refs.indexOf(refval);
     635                        if(i < 0) {
     636                            refs.add(refval);
     637                        }
     638                    }
     639                }
     640            }
     641            if(refs.size() > 0) {
     642                Collections.sort(refs);
     643                String[] a = {};
     644                refScale = ColorScale.createCyclicScale(refs.size()).addTitle(tr("GPS ref")).addColorBarTitles(refs.toArray(a));
     645                refScale.setRange(0, refs.size());
     646            }
     647        }
    620648        // Now the colors for all the points will be assigned
    621649        for (Line segment : getLinesIterable(null)) {
     
    641669                        if (fix >= 0) {
    642670                            color = fixScale.getColor(fix);
     671                        }
     672                    }
     673                } else if (colored == ColorMode.REF) {
     674                    if (trkPnt.get(GpxConstants.PT_DGPSID) != null) {
     675                        String refval = trkPnt.get(GpxConstants.PT_DGPSID).toString();
     676                        int i = refs.indexOf(refval);
     677                        if (i >= 0) {
     678                            color = refScale.getColor(i);
    643679                        }
    644680                    }
     
    15721608        } else if (colored == ColorMode.FIX) {
    15731609            fixScale.drawColorBar(g, w-30, 50, 20, 175, 1.0);
     1610        } else if (colored == ColorMode.REF) {
     1611            refScale.drawColorBar(g, w-30, 50, 20, 175, 1.0);
    15741612        } else if (colored == ColorMode.VELOCITY) {
    15751613            SystemOfMeasurement som = SystemOfMeasurement.getSystemOfMeasurement();
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/GPXSettingsPanel.java

    r18396 r18738  
    7272    private final JRadioButton colorTypeQuality = new JRadioButton(tr("Quality (RTKLib only, if available)"));
    7373    private final JRadioButton colorTypeFix = new JRadioButton(tr("GPS fix value"));
     74    private final JRadioButton colorTypeRef = new JRadioButton(tr("GPS reference ID"));
    7475    private final JRadioButton colorTypeTime = new JRadioButton(tr("Track date"));
    7576    private final JRadioButton colorTypeHeatMap = new JRadioButton(tr("Heat Map (dark = few, bright = many)"));
     
    455456        colorGroup.add(colorTypeQuality);
    456457        colorGroup.add(colorTypeFix);
     458        colorGroup.add(colorTypeRef);
    457459        colorGroup.add(colorTypeTime);
    458460        colorGroup.add(colorTypeHeatMap);
     
    466468                tr("Colors points and track segments by RTKLib quality flag (Q). Your capture device needs to log that information."));
    467469        colorTypeFix.setToolTipText(tr("Colors points and track segments by GPS fix value."));
     470        colorTypeRef.setToolTipText(tr("Colors points and track segments by GPS reference ID."));
    468471        colorTypeTime.setToolTipText(tr("Colors points and track segments by its timestamp."));
    469472        colorTypeHeatMap.setToolTipText(tr("Collected points and track segments for a position and displayed as heat map."));
     
    488491        add(colorTypeQuality, GBC.eol().insets(40, 0, 0, 0));
    489492        add(colorTypeFix, GBC.eol().insets(40, 0, 0, 0));
     493        add(colorTypeRef, GBC.eol().insets(40, 0, 0, 0));
    490494        add(colorTypeTime, GBC.eol().insets(40, 0, 0, 0));
    491495        add(colorTypeHeatMap, GBC.std().insets(40, 0, 0, 0));
     
    642646            case 6: colorTypeQuality.setSelected(true); break;
    643647            case 7: colorTypeFix.setSelected(true); break;
     648            case 8: colorTypeRef.setSelected(true); break;
    644649            default: Logging.warn("Unknown color type: " + colorType);
    645650            }
     
    720725        } else if (colorTypeFix.isSelected()) {
    721726            putPref("colormode", 7);
     727        } else if (colorTypeRef.isSelected()) {
     728            putPref("colormode", 8);
    722729        } else {
    723730            putPref("colormode", 0);
  • trunk/src/org/openstreetmap/josm/io/nmea/NmeaReader.java

    r18179 r18738  
    432432                    }
    433433                }
     434                // h-dilution
     435                accu = e[GGA.REF.position];
     436                if (!accu.isEmpty()) {
     437                    currentwp.put(GpxConstants.PT_DGPSID, accu);
     438                }
    434439            } else if (isSentence(e[0], Sentence.VTG)) {
    435440                // COURSE
  • trunk/src/org/openstreetmap/josm/tools/ColorScale.java

    r18396 r18738  
    7373        for (int i = 0; i < sc.colors.length; i++) {
    7474
    75             float angle = i / 256f * 4;
     75            float angle = i * 4f / count;
    7676            int quadrant = (int) angle;
    7777            angle -= quadrant;
     
    236236    public void drawColorBar(Graphics2D g, int x, int y, int w, int h, double valueScale) {
    237237        int n = colors.length;
    238 
    239238        for (int i = 0; i < n; i++) {
    240239            g.setColor(colors[i]);
     
    269268                txt = String.format("%.3f", val*valueScale);
    270269            }
    271             if (w < h) {
     270            if (intervalCount == 0) {
     271                g.drawString(txt, x-fw-3, y+h/2+fh/2);
     272            } else if (w < h) {
    272273                g.drawString(txt, x-fw-3, y+i*h/intervalCount+fh/2);
    273274            } else {
Note: See TracChangeset for help on using the changeset viewer.