Ignore:
Timestamp:
2019-11-02T15:11:34+01:00 (4 years ago)
Author:
Don-vip
Message:

fix #16796 - Rework of GPX track colors / layer preferences (patch by Bjoeni)

File:
1 edited

Legend:

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

    r15419 r15496  
    22package org.openstreetmap.josm.data.gpx;
    33
     4import java.awt.Color;
    45import java.util.Arrays;
    56import java.util.Collection;
    67import java.util.Collections;
    78import java.util.List;
     9import java.util.Map;
     10import java.util.TreeMap;
    811
    912import org.openstreetmap.josm.data.Bounds;
     
    9699     */
    97100    String META_BOUNDS = META_PREFIX + "bounds";
    98     /**
    99      * A constant for the metadata hash map: the extension data. This is a {@link Extensions} object
    100      * @see GpxData#addExtension(String, String)
    101      * @see GpxData#get(String)
    102      */
    103     String META_EXTENSIONS = META_PREFIX + "extensions";
    104 
    105     /**
    106      * A namespace for josm GPX extensions
    107      */
    108     String JOSM_EXTENSIONS_NAMESPACE_URI = Config.getUrls().getXMLBase() + "/gpx-extensions-1.0";
     101
     102    /**
     103     * Namespace for the XSD
     104     */
     105    String XML_URI_XSD = "http://www.w3.org/2001/XMLSchema-instance";
     106
     107    /**
     108     * Namespace for JOSM GPX extensions
     109     */
     110    String XML_URI_EXTENSIONS_JOSM = Config.getUrls().getXMLBase() + "/gpx-extensions-1.1";
     111    /**
     112     * Location of the XSD schema for JOSM GPX extensions
     113     */
     114    String XML_XSD_EXTENSIONS_JOSM = Config.getUrls().getXMLBase() + "/gpx-extensions-1.1.xsd";
     115
     116    /**
     117     * Namespace for GPX drawing extensions
     118     */
     119    String XML_URI_EXTENSIONS_DRAWING = Config.getUrls().getXMLBase() + "/gpx-drawing-extensions-1.0";
     120    /**
     121     * Location of the XSD schema for GPX drawing extensions
     122     */
     123    String XML_XSD_EXTENSIONS_DRAWING = Config.getUrls().getXMLBase() + "/gpx-drawing-extensions-1.0.xsd";
     124
     125    /**
     126     * Namespace for Garmin GPX extensions
     127     */
     128    String XML_URI_EXTENSIONS_GARMIN = "http://www.garmin.com/xmlschemas/GpxExtensions/v3";
     129    /**
     130     * Location of the XSD schema for GPX drawing extensions
     131     */
     132    String XML_XSD_EXTENSIONS_GARMIN = "http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd";
    109133
    110134    /** Elevation (in meters) of the point. */
     
    155179    List<String> WPT_KEYS = Collections.unmodifiableList(Arrays.asList(PT_ELE, PT_TIME, PT_MAGVAR, PT_GEOIDHEIGHT,
    156180            GPX_NAME, GPX_CMT, GPX_DESC, GPX_SRC, META_LINKS, PT_SYM, PT_TYPE,
    157             PT_FIX, PT_SAT, PT_HDOP, PT_VDOP, PT_PDOP, PT_AGEOFDGPSDATA, PT_DGPSID, META_EXTENSIONS));
     181            PT_FIX, PT_SAT, PT_HDOP, PT_VDOP, PT_PDOP, PT_AGEOFDGPSDATA, PT_DGPSID));
    158182
    159183    /**
     
    161185     */
    162186    List<String> RTE_TRK_KEYS = Collections.unmodifiableList(Arrays.asList(
    163             GPX_NAME, GPX_CMT, GPX_DESC, GPX_SRC, META_LINKS, "number", PT_TYPE, META_EXTENSIONS));
     187            GPX_NAME, GPX_CMT, GPX_DESC, GPX_SRC, META_LINKS, "number", PT_TYPE));
     188
     189    /**
     190     * Map with all supported Garmin colors
     191     */
     192    Map<String, Color> GARMIN_COLORS = getGarminColors();
     193
     194    /**
     195     * Helper method for {@link #GARMIN_COLORS}
     196     * @return Map with all supported Garmin colors
     197     */
     198    static Map<String, Color> getGarminColors() {
     199        TreeMap<String, Color> m = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
     200        m.put("Black", Color.BLACK);
     201        m.put("DarkRed", new Color(139, 0, 0));
     202        m.put("DarkGreen", new Color(0, 100, 0));
     203        m.put("DarkYellow", new Color(255, 170, 0));
     204        m.put("DarkBlue", new Color(0, 0, 139));
     205        m.put("DarkMagenta", new Color(139, 0, 139));
     206        m.put("DarkCyan", new Color(0, 139, 139));
     207        m.put("LightGray", Color.LIGHT_GRAY);
     208        m.put("DarkGray", Color.DARK_GRAY);
     209        m.put("Red", Color.RED);
     210        m.put("Green", Color.GREEN);
     211        m.put("Yellow", Color.YELLOW);
     212        m.put("Blue", Color.BLUE);
     213        m.put("Magenta", Color.MAGENTA);
     214        m.put("Cyan", Color.CYAN);
     215        m.put("White", Color.WHITE);
     216        m.put("Transparent", new Color(0, 0, 0, 255));
     217        return Collections.unmodifiableMap(m);
     218    }
     219
     220    /**
     221     * Enum with color formats that can be written by JOSM
     222     */
     223    enum ColorFormat {
     224        /** Drawing extension format */
     225        GPXD,
     226        /** Garmin track extension format */
     227        GPXX
     228    }
     229
     230    /**
     231     * Map with all supported extension abbreviations for easier readability in OSM layers
     232     */
     233    Map<String, String> EXTENSION_ABBREVIATIONS = getExtensionAbbreviations();
     234
     235    /**
     236     * Helper method for {@link #EXTENSION_ABBREVIATIONS}
     237     * @return Map with all supported extension abbreviations
     238     */
     239    static Map<String, String> getExtensionAbbreviations() {
     240        TreeMap<String, String> m = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
     241        m.put("gpx:extension:gpxx:TrackExtensions:DisplayColor", "gpxx:DisplayColor");
     242        m.put("gpx:extension:gpxd:color", "gpxd:color");
     243        return m;
     244    }
    164245
    165246    /**
Note: See TracChangeset for help on using the changeset viewer.