Changeset 15560 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2019-12-07T16:38:26+01:00 (5 years ago)
Author:
GerdP
Message:

fix #18389: GPX track with color black is invisible (Patch by Bjoeni)
Show popup that track is not visible because color matches backgroud color. This shows a popup only if

  • background color of all tracks in the file equals background color and
  • no imagery layer is currently visible

"I noticed that Garmin actually uses gpxx:TrackExtension instead of gpxx:TrackExtensions, so the abbreviations don't work and files are sometimes not written according to the standard."

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxConstants.java

    r15496 r15560  
    239239    static Map<String, String> getExtensionAbbreviations() {
    240240        TreeMap<String, String> m = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    241         m.put("gpx:extension:gpxx:TrackExtensions:DisplayColor", "gpxx:DisplayColor");
     241        m.put("gpx:extension:gpxx:TrackExtension:DisplayColor", "gpxx:DisplayColor");
    242242        m.put("gpx:extension:gpxd:color", "gpxd:color");
    243243        return m;
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxExtensionCollection.java

    r15497 r15560  
    148148    /**
    149149     * Adds an extension from a flat chain without prefix, e.g. when converting from OSM
    150      * @param chain the full key chain, e.g. ["extension", "gpxx", "TrackExtensions", "DisplayColor"]
     150     * @param chain the full key chain, e.g. ["extension", "gpxx", "TrackExtension", "DisplayColor"]
    151151     * @param value the value
    152152     */
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java

    r15497 r15560  
    170170                }
    171171                closestGarminColorCache.put(c, colorString);
    172                 getExtensions().addIfNotPresent("gpxx", "TrackExtensions").getExtensions().addOrUpdate("gpxx", "DisplayColor", colorString);
     172                getExtensions().addIfNotPresent("gpxx", "TrackExtension").getExtensions().addOrUpdate("gpxx", "DisplayColor", colorString);
    173173            } else if (cFormat == ColorFormat.GPXD) {
    174174                setColor(c);
  • trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxImporter.java

    r15496 r15560  
    1313import org.openstreetmap.josm.data.gpx.GpxData;
    1414import org.openstreetmap.josm.gui.MainApplication;
     15import org.openstreetmap.josm.gui.Notification;
    1516import org.openstreetmap.josm.gui.layer.GpxLayer;
     17import org.openstreetmap.josm.gui.layer.ImageryLayer;
     18import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1619import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    1720import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    154157            }
    155158        }
     159
     160        final boolean isSameColor = MainApplication.getLayerManager()
     161                .getLayersOfType(ImageryLayer.class)
     162                .stream().noneMatch(ImageryLayer::isVisible)
     163                && data.getTracks().stream().anyMatch(t -> OsmDataLayer.getBackgroundColor().equals(t.getColor()));
     164
    156165        Runnable postLayerTask = () -> {
    157166            if (!parsedProperly) {
     
    166175                JOptionPane.showMessageDialog(null, msg);
    167176            }
     177            if (isSameColor) {
     178                new Notification(tr("The imported track \"{0}\" might not be visible because it has the same color as the background." +
     179                        "<br>You can change this in the context menu of the imported layer.", gpxLayerName))
     180                .setIcon(JOptionPane.WARNING_MESSAGE)
     181                .setDuration(Notification.TIME_LONG)
     182                .show();
     183            }
    168184        };
    169185        return new GpxImporterData(gpxLayer, markerLayer, postLayerTask);
Note: See TracChangeset for help on using the changeset viewer.