Ignore:
Timestamp:
2013-01-28T14:06:52+01:00 (7 years ago)
Author:
bastiK
Message:

add session support for marker layers (see #4029)

The data is exported to a separate GPX file that contains one waypoint for each marker.
This is not very elegant, because most of the time, all the info is already contained in the original GPX File.
However, when dealing with audio markers, they can be synchronized, or additional markers are added
at certain playback positions. This info must be retained.
Another complication is, that two or more MarkerLayers can be merged to one.

All these problems are avoided by explicitly exporting the markers to a separate file (as done in this commit).

Location:
trunk/src/org/openstreetmap/josm/data/gpx
Files:
3 edited

Legend:

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

    r5681 r5684  
    2828    public static List<String> WPT_KEYS = Arrays.asList("ele", "time", "magvar", "geoidheight",
    2929            "name", "cmt", "desc", "src", META_LINKS, "sym", "number", "type",
    30             "fix", "sat", "hdop", "vdop", "pdop", "ageofdgpsdata", "dgpsid");
     30            "fix", "sat", "hdop", "vdop", "pdop", "ageofdgpsdata", "dgpsid", META_EXTENSIONS);
    3131
    3232}
  • trunk/src/org/openstreetmap/josm/data/gpx/IWithAttributes.java

    r5681 r5684  
    55
    66/**
    7  * Object with attributes.
     7 * Object with attributes (in the context of GPX data).
    88 */
    99public interface IWithAttributes {
     10
     11    /**
     12     * Returns the Object value to which the specified key is mapped,
     13     * or {@code null} if this map contains no mapping for the key.
     14     *
     15     * @param key the key whose associated value is to be returned
     16     * @return the value
     17     */
     18    Object get(String key);
    1019
    1120    /**
     
    1827     */
    1928    String getString(String key);
    20    
     29
    2130    /**
    22      * Returns the Collection value to which the specified key is mapped, 
     31     * Returns the Collection value to which the specified key is mapped,
    2332     * or {@code null} if this map contains no Collection mapping for the key.
    24      * 
     33     *
    2534     * @param key the key whose associated value is to be returned
    26      * @return the Collection value to which the specified key is mapped, 
     35     * @return the Collection value to which the specified key is mapped,
    2736     *         or {@code null} if this map contains no Collection mapping for the key
    2837     * @since 5502
    2938     */
    30     Collection<?> getCollection(String key);
     39    Collection getCollection(String key);
     40
     41    /**
     42     * Put a key / value pair as a new attribute.
     43     *
     44     * Overrides key / value pair with the same key (if present).
     45     *
     46     * @param key the key
     47     * @param value the value
     48     */
     49    void put(String key, Object value);
     50
     51    /**
     52     * Add a key / value pair that is not part of the GPX schema as an extension.
     53     *
     54     * @param key the key
     55     * @param value the value
     56     */
     57    void addExtension(String key, String value);
     58
    3159}
  • trunk/src/org/openstreetmap/josm/data/gpx/WithAttributes.java

    r5681 r5684  
    2020     */
    2121    public Map<String, Object> attr = new HashMap<String, Object>(0);
     22
     23    /**
     24     * Returns the Object value to which the specified key is mapped,
     25     * or {@code null} if this map contains no mapping for the key.
     26     *
     27     * @param key the key whose associated value is to be returned
     28     * @return the value
     29     */
     30    @Override
     31    public Object get(String key) {
     32        return attr.get(key);
     33    }
    2234
    2335    /**
     
    4557     */
    4658    @Override
    47     public Collection<?> getCollection(String key) {
     59    public Collection getCollection(String key) {
    4860        Object value = attr.get(key);
    49         return (value instanceof Collection<?>) ? (Collection<?>)value : null;
     61        return (value instanceof Collection) ? (Collection)value : null;
     62    }
     63
     64    /**
     65     * Put a key / value pair as a new attribute.
     66     *
     67     * Overrides key / value pair with the same key (if present).
     68     *
     69     * @param key the key
     70     * @param value the value
     71     */
     72    @Override
     73    public void put(String key, Object value) {
     74        attr.put(key, value);
     75    }
     76
     77    /**
     78     * Add a key / value pair that is not part of the GPX schema as an extension.
     79     *
     80     * @param key the key
     81     * @param value the value
     82     */
     83    @Override
     84    public void addExtension(String key, String value) {
     85        if (!attr.containsKey(META_EXTENSIONS)) {
     86            attr.put(META_EXTENSIONS, new Extensions());
     87        }
     88        Extensions ext = (Extensions) attr.get(META_EXTENSIONS);
     89        ext.put(key, value);
    5090    }
    5191}
Note: See TracChangeset for help on using the changeset viewer.