Ignore:
Timestamp:
2014-09-10T02:29:55+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #10489 - Add additional attributes to GPX Export for nodes + GPX code improvements

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

Legend:

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

    r6897 r7518  
    33
    44import java.util.Arrays;
     5import java.util.Collection;
    56import java.util.List;
    67
     
    1112 */
    1213public interface GpxConstants {
     14
     15    /** GPS name of the element. This field will be transferred to and from the GPS.
     16     *  GPX does not place restrictions on the length of this field or the characters contained in it.
     17     *  It is up to the receiving application to validate the field before sending it to the GPS. */
     18    public static final String GPX_NAME = "name";
     19
     20    /** GPS element comment. Sent to GPS as comment. */
     21    public static final String GPX_CMT = "cmt";
     22
     23    /** Text description of the element. Holds additional information about the element intended for the user, not the GPS. */
     24    public static final String GPX_DESC = "desc";
     25
     26    /** Source of data. Included to give user some idea of reliability and accuracy of data. */
     27    public static final String GPX_SRC = "src";
    1328
    1429    public static final String META_PREFIX = "meta.";
     
    2843    public static final String JOSM_EXTENSIONS_NAMESPACE_URI = Main.getXMLBase() + "/gpx-extensions-1.0";
    2944
    30     public static List<String> WPT_KEYS = Arrays.asList("ele", "time", "magvar", "geoidheight",
    31             "name", "cmt", "desc", "src", META_LINKS, "sym", "number", "type",
    32             "fix", "sat", "hdop", "vdop", "pdop", "ageofdgpsdata", "dgpsid", META_EXTENSIONS);
     45    /** Elevation (in meters) of the point. */
     46    public static final String PT_ELE = "ele";
    3347
     48    /** Creation/modification timestamp for the point.
     49     *  Date and time in are in Univeral Coordinated Time (UTC), not local time!
     50     *  Conforms to ISO 8601 specification for date/time representation.
     51     *  Fractional seconds are allowed for millisecond timing in tracklogs. */
     52    public static final String PT_TIME = "time";
     53
     54    /** Magnetic variation (in degrees) at the point. 0.0 <= value < 360.0 */
     55    public static final String PT_MAGVAR = "magvar";
     56
     57    /** Height, in meters, of geoid (mean sea level) above WGS-84 earth ellipsoid. (NMEA GGA message) */
     58    public static final String PT_GEOIDHEIGHT = "geoidheight";
     59
     60    /** Text of GPS symbol name. For interchange with other programs, use the exact spelling of the symbol on the GPS, if known. */
     61    public static final String PT_SYM = "sym";
     62
     63    /** Type (textual classification) of element. */
     64    public static final String PT_TYPE = "type";
     65
     66    /** Type of GPS fix. none means GPS had no fix. Value comes from list: {'none'|'2d'|'3d'|'dgps'|'pps'} */
     67    public static final String PT_FIX = "fix";
     68
     69    /** Number of satellites used to calculate the GPS fix. (not number of satellites in view). */
     70    public static final String PT_SAT = "sat";
     71
     72    /** Horizontal dilution of precision. */
     73    public static final String PT_HDOP = "hdop";
     74
     75    /** Vertical dilution of precision. */
     76    public static final String PT_VDOP = "vdop";
     77
     78    /** Position dilution of precision. */
     79    public static final String PT_PDOP = "pdop";
     80
     81    /** Number of seconds since last DGPS update. */
     82    public static final String PT_AGEOFDGPSDATA = "ageofdgpsdata";
     83
     84    /** Represents a differential GPS station. 0 <= value <= 1023 */
     85    public static final String PT_DGPSID = "dgpsid";
     86
     87    /**
     88     * Ordered list of all possible waypoint keys.
     89     */
     90    public static List<String> WPT_KEYS = Arrays.asList(PT_ELE, PT_TIME, PT_MAGVAR, PT_GEOIDHEIGHT,
     91            GPX_NAME, GPX_CMT, GPX_DESC, GPX_SRC, META_LINKS, PT_SYM, PT_TYPE,
     92            PT_FIX, PT_SAT, PT_HDOP, PT_VDOP, PT_PDOP, PT_AGEOFDGPSDATA, PT_DGPSID, META_EXTENSIONS);
     93
     94    /**
     95     * Ordered list of all possible route and track keys.
     96     */
     97    public static List<String> RTE_TRK_KEYS = Arrays.asList(
     98            GPX_NAME, GPX_CMT, GPX_DESC, GPX_SRC, META_LINKS, "number", PT_TYPE, META_EXTENSIONS);
     99
     100    /**
     101     * Possible fix values.
     102     */
     103    public static Collection<String> FIX_VALUES = Arrays.asList("none","2d","3d","dgps","pps");
    34104}
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r7509 r7518  
    4141            String k = ent.getKey();
    4242            if (k.equals(META_LINKS) && attr.containsKey(META_LINKS)) {
    43                 @SuppressWarnings("unchecked")
    44                 Collection<GpxLink> my = (Collection<GpxLink>) attr.get(META_LINKS);
     43                Collection<GpxLink> my = super.<GpxLink>getCollection(META_LINKS);
    4544                @SuppressWarnings("unchecked")
    4645                Collection<GpxLink> their = (Collection<GpxLink>) ent.getValue();
    4746                my.addAll(their);
    4847            } else {
    49                 attr.put(k, ent.getValue());
     48                put(k, ent.getValue());
    5049            }
    5150        }
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxLink.java

    r6380 r7518  
    22package org.openstreetmap.josm.data.gpx;
    33
     4/**
     5 * A link to an external resource (Web page, digital photo, video clip, etc) with additional information.
     6 * @since 444
     7 */
    48public class GpxLink {
     9
     10    /** External resource URI */
    511    public String uri;
     12
     13    /** Text to display on the hyperlink */
    614    public String text;
     15
     16    /** Link type */
    717    public String type;
    818
     19    /**
     20     * Constructs a new {@code GpxLink}.
     21     * @param uri External resource URI
     22     */
    923    public GpxLink(String uri) {
    1024        this.uri = uri;
  • trunk/src/org/openstreetmap/josm/data/gpx/IWithAttributes.java

    r6142 r7518  
    3737     * @since 5502
    3838     */
    39     Collection<?> getCollection(String key);
     39    <T> Collection<T> getCollection(String key);
    4040
    4141    /**
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r7319 r7518  
    9595    @Override
    9696    public String toString() {
    97         return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + getCoor().toString() + ", " + attr + ")";
     97        return "WayPoint (" + (attr.containsKey(GPX_NAME) ? get(GPX_NAME) + ", " :"") + getCoor().toString() + ", " + attr + ")";
    9898    }
    9999
     
    102102     */
    103103    public void setTime() {
    104         if(attr.containsKey("time")) {
     104        if (attr.containsKey(PT_TIME)) {
    105105            try {
    106                 time = dateParser.get().parse(attr.get("time").toString()).getTime() / 1000.; /* ms => seconds */
     106                time = dateParser.get().parse(get(PT_TIME).toString()).getTime() / 1000.; /* ms => seconds */
    107107            } catch(Exception e) {
    108108                time = 0;
     
    123123    public Object getTemplateValue(String name, boolean special) {
    124124        if (!special)
    125             return attr.get(name);
     125            return get(name);
    126126        else
    127127            return null;
  • trunk/src/org/openstreetmap/josm/data/gpx/WithAttributes.java

    r7005 r7518  
    5656     * @since 5502
    5757     */
     58    @SuppressWarnings("unchecked")
    5859    @Override
    59     public Collection<?> getCollection(String key) {
     60    public <T> Collection<T> getCollection(String key) {
    6061        Object value = attr.get(key);
    61         return (value instanceof Collection) ? (Collection<?>)value : null;
     62        return (value instanceof Collection) ? (Collection<T>)value : null;
    6263    }
    6364
Note: See TracChangeset for help on using the changeset viewer.