Changeset 1724 in josm


Ignore:
Timestamp:
Jul 3, 2009 10:19:22 PM (4 years ago)
Author:
stoecker
Message:

some more changes and bug fixes related to new projection stuff - GPX should now work also

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
25 edited

Legend:

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

    r1722 r1724  
    2727    } 
    2828 
     29    public Bounds(LatLon b) { 
     30        this.min = b; 
     31        this.max = b; 
     32    } 
     33 
    2934    @Override public String toString() { 
    3035        return "Bounds["+min.lat()+","+min.lon()+","+max.lat()+","+max.lon()+"]"; 
     
    3439     * @return Center of the bounding box. 
    3540     */ 
    36     public LatLon center() { 
    37         // FIXME: not sure whether this calculation is right; maybe there is some 
    38         // more complex calculation needed to get a center of a spherical 
    39         // dimension? 
    40         return new LatLon((min.lat()+max.lat())/2, (min.lon()+max.lon())/2); 
     41    public LatLon getCenter() 
     42    { 
     43        return min.getCenter(max); 
    4144    } 
    4245 
  • trunk/src/org/openstreetmap/josm/data/ProjectionBounds.java

    r1722 r1724  
    2525        this.max = max; 
    2626    } 
     27    public ProjectionBounds(EastNorth p) { 
     28        this.min = p; 
     29        this.max = p; 
     30    } 
    2731    public ProjectionBounds(EastNorth center, double east, double north) { 
    2832        this.min = new EastNorth(center.east()-east/2.0, center.north()-north/2.0); 
     
    3236    { 
    3337        if (e.east() < min.east() || e.north() < min.north()) 
    34             min = e; 
    35         else if (e.east() > max.east() || e.north() > max.north()) 
    36             max = e; 
     38            min = new EastNorth(Math.min(e.east(), min.east()), Math.min(e.north(), min.north())); 
     39        if (e.east() > max.east() || e.north() > max.north()) 
     40            max = new EastNorth(Math.max(e.east(), max.east()), Math.max(e.north(), max.north())); 
    3741    } 
    3842    public EastNorth getCenter() 
    3943    { 
    40         return  new EastNorth(min.east()/2+max.east()/2, min.north()/2+max.north()/2); 
     44        return min.getCenter(max); 
     45    } 
     46 
     47    @Override public String toString() { 
     48        return "ProjectionBounds["+min.east()+","+min.north()+","+max.east()+","+max.north()+"]"; 
    4149    } 
    4250} 
  • trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java

    r1209 r1724  
    3030        return new EastNorth(this.x + proportion * (en2.x - this.x), 
    3131            this.y + proportion * (en2.y - this.y)); 
     32    } 
     33 
     34    public EastNorth getCenter(EastNorth en2) { 
     35        return new EastNorth((this.x + en2.x)/2.0, (this.y + en2.y)/2.0); 
    3236    } 
    3337 
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r1722 r1724  
    143143    } 
    144144 
     145    public LatLon interpolate(LatLon ll2, double proportion) { 
     146        return new LatLon(this.x + proportion * (ll2.x - this.x), 
     147            this.y + proportion * (ll2.y - this.y)); 
     148    } 
     149 
     150    public LatLon getCenter(LatLon ll2) { 
     151        return new LatLon((this.x + ll2.x)/2.0, (this.y + ll2.y)/2.0); 
     152    } 
     153 
    145154    @Override public String toString() { 
    146155        return "LatLon[lat="+lat()+",lon="+lon()+"]"; 
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r1722 r1724  
    8484        for (WayPoint wpt : waypoints) { 
    8585            if (bounds == null) { 
    86                 bounds = new Bounds(wpt.latlon, wpt.latlon); 
     86                bounds = new Bounds(wpt.getCoor()); 
    8787            } else { 
    88                 bounds.extend(wpt.latlon); 
     88                bounds.extend(wpt.getCoor()); 
    8989            } 
    9090        } 
     
    9292            for (WayPoint wpt : rte.routePoints) { 
    9393                if (bounds == null) { 
    94                     bounds = new Bounds(wpt.latlon, wpt.latlon); 
     94                    bounds = new Bounds(wpt.getCoor()); 
    9595                } else { 
    96                     bounds.extend(wpt.latlon); 
     96                    bounds.extend(wpt.getCoor()); 
    9797                } 
    9898            } 
     
    102102                for (WayPoint wpt : trkseg) { 
    103103                    if (bounds == null) { 
    104                         bounds = new Bounds(wpt.latlon, wpt.latlon); 
     104                        bounds = new Bounds(wpt.getCoor()); 
    105105                    } else { 
    106                         bounds.extend(wpt.latlon); 
     106                        bounds.extend(wpt.getCoor()); 
    107107                    } 
    108108                } 
     
    123123                for (WayPoint tpt : trkseg) { 
    124124                    if(last != null){ 
    125                         result += calcDistance(last.latlon, tpt.latlon); 
     125                        result += last.getCoor().greatCircleDistance(tpt.getCoor()); 
    126126                    } 
    127127                    last = tpt; 
     
    132132        return result; 
    133133    } 
    134  
    135     /** 
    136      * returns the distance in meters between two LatLons 
    137      */ 
    138     public static double calcDistance(LatLon p1, LatLon p2){ 
    139         double lat1, lon1, lat2, lon2; 
    140         double dlon, dlat; 
    141  
    142         lat1 = p1.lat() * Math.PI / 180.0; 
    143         lon1 = p1.lon() * Math.PI / 180.0; 
    144         lat2 = p2.lat() * Math.PI / 180.0; 
    145         lon2 = p2.lon() * Math.PI / 180.0; 
    146  
    147         dlon = lon2 - lon1; 
    148         dlat = lat2 - lat1; 
    149  
    150         double a = (Math.pow(Math.sin(dlat/2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon/2), 2)); 
    151         double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
    152         return 6367000 * c; 
    153     } 
    154  
    155134} 
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r1721 r1724  
    44package org.openstreetmap.josm.data.gpx; 
    55 
    6 import java.text.ParsePosition; 
    7 import java.text.SimpleDateFormat; 
    86import java.util.Date; 
    9 import java.util.regex.Pattern; 
    107import java.awt.Color; 
    118 
    129import org.openstreetmap.josm.Main; 
     10import org.openstreetmap.josm.data.coor.CachedLatLon; 
    1311import org.openstreetmap.josm.data.coor.EastNorth; 
    1412import org.openstreetmap.josm.data.coor.LatLon; 
     13import org.openstreetmap.josm.data.projection.Projection; 
     14import org.openstreetmap.josm.tools.DateUtils; 
    1515 
    1616public class WayPoint extends WithAttributes implements Comparable<WayPoint> 
    1717{ 
    18     public final LatLon latlon; 
    19     public final EastNorth eastNorth; 
    2018    public double time; 
    2119    public Color customColoring; 
     
    2321    public int dir; 
    2422 
     23    private CachedLatLon coor; 
     24 
     25    public final LatLon getCoor() { 
     26        return coor; 
     27    } 
     28 
     29    public final EastNorth getEastNorth() { 
     30        return coor.getEastNorth(); 
     31    } 
     32 
    2533    public WayPoint(LatLon ll) { 
    26         latlon = ll; 
    27         eastNorth = Main.proj.latlon2eastNorth(ll); 
     34        coor = new CachedLatLon(ll); 
    2835    } 
    2936 
    3037    @Override 
    3138    public String toString() { 
    32         return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + latlon.toString() + ", " + attr + ")"; 
     39        return "WayPoint (" + (attr.containsKey("name") ? attr.get("name") + ", " :"") + coor.toString() + ", " + attr + ")"; 
    3340    } 
    3441 
     
    3643     * Convert the time stamp of the waypoint into seconds from the epoch 
    3744     */ 
    38     public final static SimpleDateFormat GPXTIMEFMT = 
    39         new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); 
    40     public final static SimpleDateFormat GPXTIMEFMT_nofrac = 
    41         new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 
    42     public final static SimpleDateFormat GPXTIMEFMT_tz = 
    43         new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); 
    44     public final static SimpleDateFormat GPXTIMEFMT_tz_nofrac = 
    45         new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); 
    46  
    47         private final static Pattern colontz = Pattern.compile(".*[+-][0-9][0-9]:[0-9][0-9]\\z");  
    48         private final static Pattern colontzreplacement = Pattern.compile("([+-][0-9][0-9]):([0-9][0-9])\\z");  
    49  
    50         public void setTime() { 
    51         if (! attr.containsKey("time")) { 
    52             return; 
    53         } 
    54         String timestring = attr.get("time").toString(); 
    55          
    56         /* make the string timzeone be conanonical - unfortunately the allowed timezone in a  
    57          * GPX is Z or +/-hh:mm whereas in simpledateformat it is +/-hhmm only (no colon)  
    58          * If no timezone is given, the time will be interpreted as local time by parse. */ 
    59         if (timestring.substring(timestring.length() - 1).equals("Z")) {  
    60                 timestring = timestring.substring(0, timestring.length() - 1) + "+0000"; 
    61         } else if (colontz.matcher(timestring).matches()) { 
    62                 timestring = colontzreplacement.matcher(timestring).replaceFirst("$1$2"); 
    63         } 
    64         Date d = GPXTIMEFMT_tz.parse(timestring, new ParsePosition(0)); 
    65         if (d == null) { 
    66                 d = GPXTIMEFMT_tz_nofrac.parse(timestring, new ParsePosition(0)); 
    67                 if (d == null) { 
    68                         /* try without a zimezone indication */ 
    69                         d = GPXTIMEFMT.parse(timestring, new ParsePosition(0));                  
    70                         if (d == null) { 
    71                                 d = GPXTIMEFMT_nofrac.parse(timestring, new ParsePosition(0));                   
    72                         } 
    73                 // date has parsed in local time, and been adjusted to UTC by parse 
     45    public void setTime() { 
     46        for(String key : new String[]{"time", "cmt", "desc"}) 
     47        { 
     48            if(attr.containsKey("time")) 
     49            { 
     50                double t = DateUtils.fromString(attr.get("time").toString()).getTime(); 
     51                if(t != 0.0) 
     52                { 
     53                    time = t / 1000.0; /* ms => seconds */ 
     54                    break; 
     55                } 
    7456            } 
    75         } 
    76         if (d != null /* parsing ok */) { 
    77             time = d.getTime() / 1000.0; /* ms => seconds */ 
    78         } 
    79 } 
    80     /** 
    81      * Convert a time stamp of the waypoint from the <cmt> or <desc> field 
    82      * into seconds from the epoch. Handles the date format as it is used by 
    83      * Garmin handhelds. Does not overwrite an existing timestamp (!= 0.0). 
    84      * A value of <time> fields overwrites values set with by method. 
    85      * Does nothing if specified key does not exist or text cannot be parsed. 
    86      * 
    87      * @param key The key that contains the text to convert. 
    88      */ 
    89     public void setGarminCommentTime(String key) { 
    90         // do not overwrite time if already set 
    91         if (time != 0.0) { 
    92             return; 
    93         } 
    94         if (! attr.containsKey(key)) { 
    95             return; 
    96         } 
    97         // example date format "18-AUG-08 13:33:03" 
    98         SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yy HH:mm:ss"); // Garmin wpts have no timezone 
    99         Date d = f.parse(attr.get(key).toString(), new ParsePosition(0)); 
    100         if (d != null /* parsing OK */) { 
    101             time = d.getTime() / 1000.0; /* ms => seconds */ 
    10257        } 
    10358    } 
  • trunk/src/org/openstreetmap/josm/data/osm/Node.java

    r1722 r1724  
    66import org.openstreetmap.josm.Main; 
    77import org.openstreetmap.josm.data.coor.EastNorth; 
     8import org.openstreetmap.josm.data.coor.CachedLatLon; 
    89import org.openstreetmap.josm.data.coor.LatLon; 
    910import org.openstreetmap.josm.data.coor.LatLon.CoordinateFormat; 
     
    1112import org.openstreetmap.josm.data.osm.visitor.Visitor; 
    1213import org.openstreetmap.josm.data.osm.Node; 
    13  
    1414 
    1515/** 
     
    2020public final class Node extends OsmPrimitive { 
    2121 
    22     private LatLon coor; 
    23  
    24     private EastNorth eastNorth; 
    25     private Projection proj; 
    26  
     22    private CachedLatLon coor; 
    2723 
    2824    public final void setCoor(LatLon coor) { 
    29         this.coor = coor; 
    30         proj = null; 
     25        if(this.coor == null) 
     26            this.coor = new CachedLatLon(coor); 
     27        else 
     28            this.coor.setCoor(coor); 
    3129    } 
    3230 
     
    3634 
    3735    public final void setEastNorth(EastNorth eastNorth) { 
    38         proj = Main.proj; 
    39         eastNorth = eastNorth; 
    40         this.coor = proj.eastNorth2latlon(eastNorth); 
     36        coor.setEastNorth(eastNorth); 
    4137    } 
    4238 
    4339    public final EastNorth getEastNorth() { 
    44         if(proj != Main.proj) 
    45         { 
    46             proj = Main.proj; 
    47             eastNorth = proj.latlon2eastNorth(coor); 
    48         } 
    49         return eastNorth; 
     40        return coor.getEastNorth(); 
    5041    } 
    5142 
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r1722 r1724  
    66import org.openstreetmap.josm.data.ProjectionBounds; 
    77import org.openstreetmap.josm.data.coor.EastNorth; 
     8import org.openstreetmap.josm.data.coor.CachedLatLon; 
    89import org.openstreetmap.josm.data.coor.LatLon; 
    910import org.openstreetmap.josm.data.osm.Node; 
     
    4243        if(b != null) 
    4344        { 
    44             visit(Main.proj.latlon2eastNorth(b.min)); 
    45             visit(Main.proj.latlon2eastNorth(b.max)); 
     45            visit(b.min); 
     46            visit(b.max); 
    4647        } 
    4748    } 
     
    4950    public void visit(ProjectionBounds b) { 
    5051        if(b != null) 
    51             bounds = new ProjectionBounds(b.min, b.max); 
     52        { 
     53            visit(b.min); 
     54            visit(b.max); 
     55        } 
     56    } 
     57 
     58    public void visit(LatLon latlon) { 
     59        if(latlon != null) 
     60        { 
     61            if(latlon instanceof CachedLatLon) 
     62                visit(((CachedLatLon)latlon).getEastNorth()); 
     63            else 
     64                visit(Main.proj.latlon2eastNorth(latlon)); 
     65        } 
    5266    } 
    5367 
     
    5569        if (eastNorth != null) { 
    5670            if (bounds == null) 
    57                 bounds = new ProjectionBounds(eastNorth, eastNorth); 
     71                bounds = new ProjectionBounds(eastNorth); 
    5872            else 
    5973                bounds.extend(eastNorth); 
     
    98112        Main.proj.latlon2eastNorth(new LatLon(maxLatlon.lat() + enlargeDegree, maxLatlon.lon() + enlargeDegree))); 
    99113    } 
     114 
     115    @Override public String toString() { 
     116        return "BoundingXYVisitor["+bounds+"]"; 
     117    } 
    100118} 
  • trunk/src/org/openstreetmap/josm/data/projection/Epsg4326.java

    r1722 r1724  
    2525 
    2626    @Override public String toString() { 
    27         return tr("EPSG:4326"); 
     27        return tr("WGS84 Geographisch"); 
    2828    } 
    2929 
     
    3434    public String getCacheDirectoryName() { 
    3535        return "epsg4326"; 
    36     } 
    37  
    38     @Override public boolean equals(Object o) { 
    39         return o instanceof Epsg4326; 
    4036    } 
    4137 
  • trunk/src/org/openstreetmap/josm/data/projection/Lambert.java

    r1722 r1724  
    158158    } 
    159159 
    160     @Override 
    161     public boolean equals(Object o) { 
    162         return o instanceof Lambert; 
    163     } 
    164  
    165160    /** 
    166161     * Initializes from geographic coordinates. Note that reference ellipsoid 
  • trunk/src/org/openstreetmap/josm/data/projection/LambertEST.java

    r1722 r1724  
    107107    } 
    108108 
    109     @Override 
    110     public boolean equals(Object o) { 
    111         return o instanceof LambertEST; 
    112     } 
    113  
    114109    public ProjectionBounds getWorldBounds() 
    115110    { 
  • trunk/src/org/openstreetmap/josm/data/projection/Mercator.java

    r1722 r1724  
    4747    } 
    4848 
    49     @Override public boolean equals(Object o) { 
    50         return o instanceof Mercator; 
    51     } 
    52  
    5349    public ProjectionBounds getWorldBounds() 
    5450    { 
  • trunk/src/org/openstreetmap/josm/data/projection/SwissGrid.java

    r1722 r1724  
    101101    } 
    102102 
    103     @Override 
    104     public boolean equals(Object o) { 
    105         return o instanceof SwissGrid; 
    106     } 
    107  
    108103    public ProjectionBounds getWorldBounds() 
    109104    { 
  • trunk/src/org/openstreetmap/josm/data/projection/UTM.java

    r1722 r1724  
    345345    } 
    346346 
    347     @Override public boolean equals(Object o) { 
    348         return o instanceof UTM; 
    349     } 
    350  
    351347    public ProjectionBounds getWorldBounds() 
    352348    { 
  • trunk/src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java

    r1722 r1724  
    6363import org.openstreetmap.josm.Main; 
    6464import org.openstreetmap.josm.actions.RenameLayerAction; 
    65 import org.openstreetmap.josm.data.coor.EastNorth; 
     65import org.openstreetmap.josm.data.coor.CachedLatLon; 
    6666import org.openstreetmap.josm.data.coor.LatLon; 
    6767import org.openstreetmap.josm.data.gpx.GpxTrack; 
     
    244244        final File image; 
    245245        ImageLoader.Entry icon; 
    246  
    247246        Date time; 
    248         LatLon coor; 
    249         EastNorth pos; 
     247        CachedLatLon pos; 
    250248 
    251249        public ImageEntry(File image) { 
     
    290288                for (Collection<WayPoint> segment : trk.trackSegs) { 
    291289                    for (WayPoint p : segment) { 
     290                        LatLon c = p.getCoor(); 
    292291                        if (!p.attr.containsKey("time")) 
    293                             throw new IOException(tr("No time for point {0} x {1}",p.latlon.lat(),p.latlon.lon())); 
     292                            throw new IOException(tr("No time for point {0} x {1}",c.lat(),c.lon())); 
    294293                        Date d = null; 
    295294                        try { 
    296295                            d = DateParser.parse((String) p.attr.get("time")); 
    297296                        } catch (ParseException e) { 
    298                             throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.attr.get("time"),p.latlon.lat(),p.latlon.lon())); 
     297                            throw new IOException(tr("Cannot read time \"{0}\" from point {1} x {2}",p.attr.get("time"),c.lat(),c.lon())); 
    299298                        } 
    300                         gps.add(new TimedPoint(d, p.eastNorth)); 
     299                        gps.add(new TimedPoint(d, c)); 
    301300                    } 
    302301                } 
     
    364363    private static final class TimedPoint implements Comparable<TimedPoint> { 
    365364        Date time; 
    366         EastNorth pos; 
    367         public TimedPoint(Date time, EastNorth pos) { 
     365        CachedLatLon pos; 
     366 
     367        public TimedPoint(Date time, LatLon pos) { 
    368368            this.time = time; 
    369             this.pos = pos; 
     369            this.pos.setCoor(pos); 
    370370        } 
    371371        public int compareTo(TimedPoint point) { 
     
    404404                    if (e.pos == null) 
    405405                        continue; 
    406                     Point p = Main.map.mapView.getPoint(e.pos); 
     406                    Point p = Main.map.mapView.getPoint(e.pos.getEastNorth()); 
    407407                    Rectangle r = new Rectangle(p.x-ICON_SIZE/2, p.y-ICON_SIZE/2, ICON_SIZE, ICON_SIZE); 
    408408                    if (r.contains(ev.getPoint())) { 
     
    536536 
    537537            if (centerToggle.getModel().isSelected()) 
    538                 Main.map.mapView.zoomTo(currentImageEntry.pos); 
     538                Main.map.mapView.zoomTo(currentImageEntry.pos.getEastNorth()); 
    539539 
    540540            dlg.setTitle(currentImageEntry.image + 
    541                     " (" + currentImageEntry.coor.toDisplayString() + ")"); 
     541                    " (" + currentImageEntry.pos.toDisplayString() + ")"); 
    542542            dlg.setCursor(Cursor.getDefaultCursor()); 
    543543        } 
     
    612612                } 
    613613 
    614                 Point p = mv.getPoint(e.pos); 
     614                Point p = mv.getPoint(e.pos.getEastNorth()); 
    615615                Rectangle r = new Rectangle(p.x-ICON_SIZE / 2, p.y-ICON_SIZE / 2, ICON_SIZE, ICON_SIZE); 
    616616                if (r.contains(mousePosition)) { 
     
    624624            ImageEntry e = data.get(i); 
    625625            if (e.pos != null) { 
    626                 Point p = mv.getPoint(e.pos); 
     626                Point p = mv.getPoint(e.pos.getEastNorth()); 
    627627                Rectangle r = new Rectangle(p.x-ICON_SIZE / 2, p.y-ICON_SIZE / 2, ICON_SIZE, ICON_SIZE); 
    628628                g.drawImage(e.getIcon(), r.x, r.y, null); 
     
    686686                Date time = new Date(tp.time.getTime() - (delta+gpstimezone)); 
    687687                if (time.after(e.time) && lastTP != null) { 
    688                     double x = (lastTP.pos.east()+tp.pos.east())/2; 
    689                     double y = (lastTP.pos.north()+tp.pos.north())/2; 
    690                     e.pos = new EastNorth(x,y); 
     688                    e.pos.setCoor(lastTP.pos.getCenter(tp.pos)); 
    691689                    break; 
    692690                } 
     
    696694                e.pos = gps.getLast().pos; 
    697695            } 
    698             e.coor = Main.proj.eastNorth2latlon(e.pos); 
    699696        } 
    700697    } 
  • trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    r1685 r1724  
    459459                for (Collection<WayPoint> segment : trk.trackSegs) { 
    460460                    for (WayPoint trkPnt : segment) { 
    461                         if (Double.isNaN(trkPnt.latlon.lat()) || Double.isNaN(trkPnt.latlon.lon())) { 
     461                        LatLon c = trkPnt.getCoor(); 
     462                        if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) { 
    462463                            continue; 
    463464                        } 
    464465                        trkPnt.customColoring = neutralColor; 
    465466                        if (oldWp != null) { 
    466                             double dist = trkPnt.latlon.greatCircleDistance(oldWp.latlon); 
     467                            double dist = c.greatCircleDistance(oldWp.getCoor()); 
    467468 
    468469                            switch(colored) { 
     
    495496                            if (maxLineLength == -1 || dist <= maxLineLength) { 
    496497                                trkPnt.drawLine = true; 
    497                                 trkPnt.dir = (int)(Math.atan2(-trkPnt.eastNorth.north()+oldWp.eastNorth.north(), trkPnt.eastNorth.east()-oldWp.eastNorth.east()) / Math.PI * 4 + 3.5); // crude but works 
     498                                trkPnt.dir = (int)oldWp.getCoor().heading(trkPnt.getCoor()); 
    498499                            } else { 
    499500                                trkPnt.drawLine = false; 
     
    517518            for (Collection<WayPoint> segment : trk.trackSegs) { 
    518519                for (WayPoint trkPnt : segment) { 
    519                     if (Double.isNaN(trkPnt.latlon.lat()) || Double.isNaN(trkPnt.latlon.lon())) 
     520                    LatLon c = trkPnt.getCoor(); 
     521                    if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) 
    520522                        continue; 
    521                     Point screen = mv.getPoint(trkPnt.eastNorth); 
     523                    Point screen = mv.getPoint(trkPnt.getEastNorth()); 
    522524                        if (trkPnt.drawLine) { 
    523525                            // skip points that are on the same screenposition 
     
    542544                for (Collection<WayPoint> segment : trk.trackSegs) { 
    543545                    for (WayPoint trkPnt : segment) { 
    544                         if (Double.isNaN(trkPnt.latlon.lat()) || Double.isNaN(trkPnt.latlon.lon())) 
     546                        LatLon c = trkPnt.getCoor(); 
     547                        if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) 
    545548                            continue; 
    546549                        if (trkPnt.drawLine) { 
    547                             Point screen = mv.getPoint(trkPnt.eastNorth); 
     550                            Point screen = mv.getPoint(trkPnt.getEastNorth()); 
    548551                            // skip points that are on the same screenposition 
    549552                            if (old != null && (oldA == null || screen.x < oldA.x-delta || screen.x > oldA.x+delta || screen.y < oldA.y-delta || screen.y > oldA.y+delta)) { 
     
    572575                for (Collection<WayPoint> segment : trk.trackSegs) { 
    573576                    for (WayPoint trkPnt : segment) { 
    574                         if (Double.isNaN(trkPnt.latlon.lat()) || Double.isNaN(trkPnt.latlon.lon())) 
     577                        LatLon c = trkPnt.getCoor(); 
     578                        if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) 
    575579                            continue; 
    576580                        if (trkPnt.drawLine) { 
    577                             Point screen = mv.getPoint(trkPnt.eastNorth); 
     581                            Point screen = mv.getPoint(trkPnt.getEastNorth()); 
    578582                            // skip points that are on the same screenposition 
    579583                            if (old != null && (oldA == null || screen.x < oldA.x-delta || screen.x > oldA.x+delta || screen.y < oldA.y-delta || screen.y > oldA.y+delta)) { 
     
    598602                for (Collection<WayPoint> segment : trk.trackSegs) { 
    599603                    for (WayPoint trkPnt : segment) { 
    600                         if (Double.isNaN(trkPnt.latlon.lat()) || Double.isNaN(trkPnt.latlon.lon())) 
     604                        LatLon c = trkPnt.getCoor(); 
     605                        if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) 
    601606                            continue; 
    602                         Point screen = mv.getPoint(trkPnt.eastNorth); 
     607                        Point screen = mv.getPoint(trkPnt.getEastNorth()); 
    603608                        g.setColor(trkPnt.customColoring); 
    604609                        g.fillRect(screen.x-1, screen.y-1, 3, 3); 
     
    616621                for (Collection<WayPoint> segment : trk.trackSegs) { 
    617622                    for (WayPoint trkPnt : segment) { 
    618                         if (Double.isNaN(trkPnt.latlon.lat()) || Double.isNaN(trkPnt.latlon.lon())) 
     623                        LatLon c = trkPnt.getCoor(); 
     624                        if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) 
    619625                            continue; 
    620626                        if (!trkPnt.drawLine) { 
    621                             Point screen = mv.getPoint(trkPnt.eastNorth); 
     627                            Point screen = mv.getPoint(trkPnt.getEastNorth()); 
    622628                        g.drawRect(screen.x, screen.y, 0, 0); 
    623629                    } 
     
    635641                for (Collection<WayPoint> segment : trk.trackSegs) { 
    636642                    for (WayPoint trkPnt : segment) { 
    637                         if (Double.isNaN(trkPnt.latlon.lat()) || Double.isNaN(trkPnt.latlon.lon())) 
     643                        LatLon c = trkPnt.getCoor(); 
     644                        if (Double.isNaN(c.lat()) || Double.isNaN(c.lon())) 
    638645                            continue; 
    639                         Point screen = mv.getPoint(trkPnt.eastNorth); 
     646                        Point screen = mv.getPoint(trkPnt.getEastNorth()); 
    640647                        g.setColor(trkPnt.customColoring); 
    641648                        g.drawRect(screen.x, screen.y, 0, 0); 
     
    650657 
    651658    @Override public void visitBoundingBox(BoundingXYVisitor v) { 
    652         for (WayPoint p : data.waypoints) 
    653             v.visit(p.eastNorth); 
    654  
    655         for (GpxRoute rte : data.routes) { 
    656             Collection<WayPoint> r = rte.routePoints; 
    657             for (WayPoint p : r) { 
    658                 v.visit(p.eastNorth); 
    659             } 
    660         } 
    661  
    662         for (GpxTrack trk : data.tracks) { 
    663             for (Collection<WayPoint> seg : trk.trackSegs) { 
    664                 for (WayPoint p : seg) { 
    665                     v.visit(p.eastNorth); 
    666                 } 
    667             } 
    668         } 
     659        v.visit(data.recalculateBounds()); 
    669660    } 
    670661 
     
    684675                    Way w = new Way(); 
    685676                    for (WayPoint p : segment) { 
    686                         Node n = new Node(p.latlon); 
     677                        Node n = new Node(p.getCoor()); 
    687678                        String timestr = p.getString("time"); 
    688679                        if(timestr != null) 
     
    748739                for (Collection<WayPoint> segment : trk.trackSegs) { 
    749740                    for (WayPoint p : segment) { 
    750                         latsum += p.latlon.lat(); 
     741                        latsum += p.getCoor().lat(); 
    751742                        latcnt ++; 
    752743                    } 
     
    782773                for (Collection<WayPoint> segment : trk.trackSegs) { 
    783774                    for (WayPoint p : segment) { 
    784                         if (previous == null || p.latlon.greatCircleDistance(previous) > buffer_dist) { 
     775                        LatLon c = p.getCoor(); 
     776                        if (previous == null || c.greatCircleDistance(previous) > buffer_dist) { 
    785777                            // we add a buffer around the point. 
    786                             r.setRect(p.latlon.lon()-buffer_x, p.latlon.lat()-buffer_y, 2*buffer_x, 2*buffer_y); 
     778                            r.setRect(c.lon()-buffer_x, c.lat()-buffer_y, 2*buffer_x, 2*buffer_y); 
    787779                            a.add(new Area(r)); 
    788                             previous = p.latlon; 
     780                            previous = c; 
    789781                        } 
    790782                    } 
     
    917909            for (WayPoint w : data.waypoints) { 
    918910                if (waypoints.contains(w)) { continue; } 
    919                 WayPoint wNear = nearestPointOnTrack(w.eastNorth, snapDistance); 
     911                WayPoint wNear = nearestPointOnTrack(w.getEastNorth(), snapDistance); 
    920912                if (wNear != null) { 
    921                     WayPoint wc = new WayPoint(w.latlon); 
     913                    WayPoint wc = new WayPoint(w.getCoor()); 
    922914                    wc.time = wNear.time; 
    923915                    if (w.attr.containsKey("name")) wc.attr.put("name", w.getString("name")); 
     
    974966                timedMarkersOmitted = true; 
    975967            } else { 
    976                 EastNorth eastNorth = w1.eastNorth.interpolate( 
    977                             w2.eastNorth, 
    978                             (startTime - w1.time)/(w2.time - w1.time)); 
    979                 wayPointFromTimeStamp = new WayPoint(Main.proj.eastNorth2latlon(eastNorth)); 
     968                wayPointFromTimeStamp = new WayPoint(w1.getCoor().interpolate( 
     969                    w2.getCoor(), (startTime - w1.time)/(w2.time - w1.time))); 
    980970                wayPointFromTimeStamp.time = startTime; 
    981971                String name = wavFile.getName(); 
     
    998988                for (Collection<WayPoint> seg : track.trackSegs) { 
    999989                    for (WayPoint w : seg) { 
    1000                         WayPoint wStart = new WayPoint(w.latlon); 
     990                        WayPoint wStart = new WayPoint(w.getCoor()); 
    1001991                        wStart.attr.put("name", "start"); 
    1002992                        wStart.time = w.time; 
     
    10301020            else 
    10311021                name = AudioMarker.inventName(offset); 
    1032             AudioMarker am = AudioMarker.create(w.latlon, 
     1022            AudioMarker am = AudioMarker.create(w.getCoor(), 
    10331023                    name, uri, ml, w.time, offset); 
    10341024            /* timeFromAudio intended for future use to shift markers of this type on synchronization */ 
     
    11041094                for (WayPoint S : seg) { 
    11051095                    if (R == null) { 
     1096                        EastNorth c = R.getEastNorth(); 
    11061097                        R = S; 
    1107                         rx = R.eastNorth.east(); 
    1108                         ry = R.eastNorth.north(); 
     1098                        rx = c.east(); 
     1099                        ry = c.north(); 
    11091100                        x = px - rx; 
    11101101                        y = py - ry; 
     
    11121103                        if (PRsq < PNminsq) { 
    11131104                            PNminsq = PRsq; 
    1114                             bestEN = R.eastNorth; 
     1105                            bestEN = c; 
    11151106                            bestTime = R.time; 
    11161107                        } 
    11171108                    } else { 
    1118                         sx = S.eastNorth.east(); 
    1119                         sy = S.eastNorth.north(); 
     1109                        EastNorth c = S.getEastNorth(); 
     1110                        sx = c.east(); 
     1111                        sy = c.north(); 
    11201112                        double A = sy - ry; 
    11211113                        double B = rx - sx; 
     
    11471139                } 
    11481140                if (R != null) { 
     1141                    EastNorth c = R.getEastNorth(); 
    11491142                    /* if there is only one point in the seg, it will do this twice, but no matter */ 
    1150                     rx = R.eastNorth.east(); 
    1151                     ry = R.eastNorth.north(); 
     1143                    rx = c.east(); 
     1144                    ry = c.north(); 
    11521145                    x = px - rx; 
    11531146                    y = py - ry; 
     
    11551148                    if (PRsq < PNminsq) { 
    11561149                        PNminsq = PRsq; 
    1157                         bestEN = R.eastNorth; 
     1150                        bestEN = c; 
    11581151                        bestTime = R.time; 
    11591152                    } 
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ButtonMarker.java

    r1169 r1724  
    3636 
    3737    @Override public boolean containsPoint(Point p) { 
    38         Point screen = Main.map.mapView.getPoint(eastNorth); 
     38        Point screen = Main.map.mapView.getPoint(getEastNorth()); 
    3939        buttonRectangle.setLocation(screen.x+4, screen.y+2); 
    4040        return buttonRectangle.contains(p); 
     
    4646            return; 
    4747        } 
    48         Point screen = mv.getPoint(eastNorth); 
     48        Point screen = mv.getPoint(getEastNorth()); 
    4949        buttonRectangle.setLocation(screen.x+4, screen.y+2); 
    5050        symbol.paintIcon(mv, g, screen.x+4, screen.y+2); 
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java

    r1601 r1724  
    1515 
    1616import org.openstreetmap.josm.Main; 
     17import org.openstreetmap.josm.data.coor.CachedLatLon; 
    1718import org.openstreetmap.josm.data.coor.EastNorth; 
    1819import org.openstreetmap.josm.data.coor.LatLon; 
     
    5960 */ 
    6061public class Marker implements ActionListener { 
    61  
    62     public EastNorth eastNorth; 
    6362    public final String text; 
    6463    public final Icon symbol; 
    6564    public final MarkerLayer parentLayer; 
    66     public double time; /* avbsolute time of marker since epocj */ 
     65    public double time; /* absolute time of marker since epoch */ 
    6766    public double offset; /* time offset in seconds from the gpx point from which it was derived, 
    6867                             may be adjusted later to sync with other data, so not final */ 
     68 
     69    private CachedLatLon coor; 
     70 
     71    public final void setCoor(LatLon coor) { 
     72        if(this.coor == null) 
     73            this.coor = new CachedLatLon(coor); 
     74        else 
     75            this.coor.setCoor(coor); 
     76    } 
     77 
     78    public final LatLon getCoor() { 
     79        return coor; 
     80    } 
     81 
     82    public final void setEastNorth(EastNorth eastNorth) { 
     83        coor.setEastNorth(eastNorth); 
     84    } 
     85 
     86    public final EastNorth getEastNorth() { 
     87        return coor.getEastNorth(); 
     88    } 
    6989 
    7090    /** 
     
    101121 
    102122                if (uri == null) 
    103                     return new Marker(wpt.latlon, name_desc, wpt.getString("symbol"), parentLayer, time, offset); 
     123                    return new Marker(wpt.getCoor(), name_desc, wpt.getString("symbol"), parentLayer, time, offset); 
    104124                else if (uri.endsWith(".wav")) 
    105                     return AudioMarker.create(wpt.latlon, name_desc, uri, parentLayer, time, offset); 
     125                    return AudioMarker.create(wpt.getCoor(), name_desc, uri, parentLayer, time, offset); 
    106126                else if (uri.endsWith(".png") || uri.endsWith(".jpg") || uri.endsWith(".jpeg") || uri.endsWith(".gif")) 
    107                     return ImageMarker.create(wpt.latlon, uri, parentLayer, time, offset); 
     127                    return ImageMarker.create(wpt.getCoor(), uri, parentLayer, time, offset); 
    108128                else 
    109                     return WebMarker.create(wpt.latlon, uri, parentLayer, time, offset); 
     129                    return WebMarker.create(wpt.getCoor(), uri, parentLayer, time, offset); 
    110130            } 
    111131 
     
    122142 
    123143    public Marker(LatLon ll, String text, String iconName, MarkerLayer parentLayer, double time, double offset) { 
    124         eastNorth = Main.proj.latlon2eastNorth(ll); 
     144        setCoor(ll); 
    125145        this.text = text; 
    126146        this.offset = offset; 
     
    162182     */ 
    163183    public void paint(Graphics g, MapView mv, boolean mousePressed, String show) { 
    164         Point screen = mv.getPoint(eastNorth); 
     184        Point screen = mv.getPoint(getEastNorth()); 
    165185        if (symbol != null && show.equalsIgnoreCase("show")) { 
    166186            symbol.paintIcon(mv, g, screen.x-symbol.getIconWidth()/2, screen.y-symbol.getIconHeight()/2); 
     
    205225 
    206226    public AudioMarker audioMarkerFromMarker(String uri) { 
    207         AudioMarker audioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(this.eastNorth), this.text, uri, this.parentLayer, this.time, this.offset); 
     227        AudioMarker audioMarker = AudioMarker.create(getCoor(), this.text, uri, this.parentLayer, this.time, this.offset); 
    208228        return audioMarker; 
    209229    } 
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java

    r1685 r1724  
    2828import org.openstreetmap.josm.Main; 
    2929import org.openstreetmap.josm.actions.RenameLayerAction; 
    30 import org.openstreetmap.josm.data.coor.EastNorth; 
     30import org.openstreetmap.josm.data.coor.LatLon; 
    3131import org.openstreetmap.josm.data.gpx.GpxData; 
    3232import org.openstreetmap.josm.data.gpx.GpxLink; 
     
    184184    @Override public void visitBoundingBox(BoundingXYVisitor v) { 
    185185        for (Marker mkr : data) 
    186             v.visit(mkr.eastNorth); 
     186            v.visit(mkr.getEastNorth()); 
    187187    } 
    188188 
     
    242242                if (playHeadMarker == null) 
    243243                    return; 
    244                 addAudioMarker(playHeadMarker.time, playHeadMarker.eastNorth); 
     244                addAudioMarker(playHeadMarker.time, playHeadMarker.getCoor()); 
    245245                Main.map.mapView.repaint(); 
    246246            } 
     
    296296    } 
    297297 
    298     public AudioMarker addAudioMarker(double time, EastNorth en) { 
     298    public AudioMarker addAudioMarker(double time, LatLon coor) { 
    299299        // find first audio marker to get absolute start time 
    300300        double offset = 0.0; 
     
    313313 
    314314        // make our new marker 
    315         AudioMarker newAudioMarker = AudioMarker.create(Main.proj.eastNorth2latlon(en), 
     315        AudioMarker newAudioMarker = AudioMarker.create(coor, 
    316316            AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset); 
    317317 
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java

    r1462 r1724  
    4343    static private PlayHeadMarker playHead = null; 
    4444    private MapMode oldMode = null; 
    45     private EastNorth oldEastNorth; 
     45    private LatLon oldCoor; 
    4646    private boolean enabled; 
    4747    private boolean wasPlaying = false; 
     
    7575                     * getting confused with other drag operations (like select) */ 
    7676                    oldMode = Main.map.mapMode; 
    77                     oldEastNorth = eastNorth; 
     77                    oldCoor = getCoor(); 
    7878                    PlayHeadDragMode playHeadDragMode = new PlayHeadDragMode(playHead); 
    7979                    Main.map.selectMapMode(playHeadDragMode); 
     
    8585 
    8686    @Override public boolean containsPoint(Point p) { 
    87         Point screen = Main.map.mapView.getPoint(eastNorth); 
     87        Point screen = Main.map.mapView.getPoint(getEastNorth()); 
    8888        Rectangle r = new Rectangle(screen.x, screen.y, symbol.getIconWidth(), 
    8989        symbol.getIconHeight()); 
     
    106106 
    107107    /** 
    108      * reinstate the old map mode after swuitching temporarily to do a play head drag 
     108     * reinstate the old map mode after switching temporarily to do a play head drag 
    109109     */ 
    110110    private void endDrag(boolean reset) { 
     
    113113            catch (Exception ex) { AudioPlayer.audioMalfunction(ex);} 
    114114        if (reset) 
    115             eastNorth = oldEastNorth; 
     115            setCoor(oldCoor); 
    116116        Main.map.selectMapMode(oldMode); 
    117117        Main.map.mapView.repaint(); 
     
    124124     */ 
    125125    public void drag(EastNorth en) { 
    126         eastNorth = en; 
     126        setEastNorth(en); 
    127127        Main.map.mapView.repaint(); 
    128128    } 
     
    135135     */ 
    136136    public void reposition(EastNorth en) { 
    137         // eastNorth = en; 
    138137        WayPoint cw = null; 
    139138        AudioMarker recent = AudioMarker.recentlyPlayedMarker(); 
     
    167166            endDrag(true); 
    168167        } else { 
    169             eastNorth = cw.eastNorth; 
     168            setCoor(cw.getCoor()); 
    170169            ca.play(cw.time - ca.time); 
    171170            endDrag(false); 
     
    193192            for (Marker m : recent.parentLayer.data) { 
    194193                if (m instanceof AudioMarker) { 
    195                     double distanceSquared = m.eastNorth.distanceSq(en); 
     194                    double distanceSquared = m.getEastNorth().distanceSq(en); 
    196195                    if (distanceSquared < closestAudioMarkerDistanceSquared) { 
    197196                        ca = (AudioMarker) m; 
     
    216215                return; 
    217216            } 
    218             ca = recent.parentLayer.addAudioMarker(cw.time, cw.eastNorth); 
     217            ca = recent.parentLayer.addAudioMarker(cw.time, cw.getCoor()); 
    219218        } 
    220219 
     
    227226        else if (recent.parentLayer.synchronizeAudioMarkers(ca)) { 
    228227            JOptionPane.showMessageDialog(Main.parent, tr("Audio synchronized at point {0}.", ca.text)); 
    229             eastNorth = ca.eastNorth; 
     228            setCoor(ca.getCoor()); 
    230229            endDrag(false); 
    231230        } else { 
     
    237236    public void paint(Graphics g, MapView mv /*, boolean mousePressed */) { 
    238237        if (time < 0.0) return; 
    239         Point screen = mv.getPoint(eastNorth); 
     238        Point screen = mv.getPoint(getEastNorth()); 
    240239        symbol.paintIcon(mv, g, screen.x, screen.y); 
    241240    } 
     
    297296        if (w1 == null) 
    298297            return; 
    299         eastNorth = w2 == null ? 
    300             w1.eastNorth : 
    301             w1.eastNorth.interpolate(w2.eastNorth, 
    302                     (audioTime - w1.time)/(w2.time - w1.time)); 
     298        setEastNorth(w2 == null ? 
     299            w1.getEastNorth() : 
     300            w1.getEastNorth().interpolate(w2.getEastNorth(), 
     301                    (audioTime - w1.time)/(w2.time - w1.time))); 
    303302        time = audioTime; 
    304303        Main.map.mapView.repaint(); 
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r1597 r1724  
    262262                } else if (qName.equals("cmt") || qName.equals("desc")) { 
    263263                    currentWayPoint.attr.put(qName, accumulator.toString()); 
    264                     currentWayPoint.setGarminCommentTime(qName); 
     264                    currentWayPoint.setTime(); 
    265265                } else if (qName.equals("rtept")) { 
    266266                    currentState = states.pop(); 
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r1722 r1724  
    1111 
    1212import org.openstreetmap.josm.data.Bounds; 
     13import org.openstreetmap.josm.data.coor.LatLon; 
    1314import org.openstreetmap.josm.data.gpx.GpxData; 
    1415import org.openstreetmap.josm.data.gpx.GpxLink; 
     
    237238        } 
    238239        if (pnt != null) { 
    239             openAtt(type, "lat=\"" + pnt.latlon.lat() + "\" lon=\"" + pnt.latlon.lon() + "\""); 
     240            LatLon c =pnt.getCoor(); 
     241            openAtt(type, "lat=\"" + c.lat() + "\" lon=\"" + c.lon() + "\""); 
    240242            writeAttr(pnt.attr); 
    241243            closeln(type); 
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r1453 r1724  
    1818import org.openstreetmap.josm.data.gpx.GpxTrack; 
    1919import org.openstreetmap.josm.data.gpx.WayPoint; 
     20import org.openstreetmap.josm.tools.DateUtils; 
    2021 
    2122/** 
     
    285286                    // As this sentence has no complete time only use it 
    286287                    // if there is no time so far 
    287                     String gpxdate = WayPoint.GPXTIMEFMT.format(d); 
    288                     currentwp.attr.put("time", gpxdate); 
     288                    currentwp.attr.put("time", DateUtils.fromDate(d)); 
    289289                } 
    290290                // elevation 
     
    390390                } 
    391391                // time: this sentence has complete time so always use it. 
    392                 String gpxdate = WayPoint.GPXTIMEFMT.format(d); 
    393                 currentwp.attr.put("time", gpxdate); 
     392                currentwp.attr.put("time", DateUtils.fromDate(d)); 
    394393                // speed 
    395394                accu = e[GPRMC.SPEED.position]; 
  • trunk/src/org/openstreetmap/josm/tools/DateUtils.java

    r1499 r1724  
    1919package org.openstreetmap.josm.tools; 
    2020 
     21import java.text.ParsePosition; 
     22import java.text.SimpleDateFormat; 
    2123import java.util.Calendar; 
    2224import java.util.Date; 
     
    6163        // "2007-07-25T09:26:24{Z|{+|-}01:00}" 
    6264        if (checkLayout(str, "xxxx-xx-xxTxx:xx:xxZ") || 
     65                checkLayout(str, "xxxx-xx-xxTxx:xx:xx") || 
    6366                checkLayout(str, "xxxx-xx-xxTxx:xx:xx+xx:00") || 
    6467                checkLayout(str, "xxxx-xx-xxTxx:xx:xx-xx:00")) { 
     
    7881 
    7982            return calendar.getTime(); 
     83        } 
     84        else if(checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxxZ") || 
     85                checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx") || 
     86                checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx+xx:00") || 
     87                checkLayout(str, "xxxx-xx-xxTxx:xx:xx.xxx-xx:00")) { 
     88            calendar.set( 
     89                parsePart(str, 0, 4), 
     90                parsePart(str, 5, 2)-1, 
     91                parsePart(str, 8, 2), 
     92                parsePart(str, 11, 2), 
     93                parsePart(str, 14,2), 
     94                parsePart(str, 17, 2)); 
     95            long millis = parsePart(str, 20, 3); 
     96            if (str.length() == 29) 
     97                millis += parsePart(str, 24, 2) * (str.charAt(23) == '+' ? -3600000 : 3600000); 
     98            calendar.setTimeInMillis(calendar.getTimeInMillis()+millis); 
     99 
     100            return calendar.getTime(); 
     101        } 
     102        else 
     103        { 
     104            // example date format "18-AUG-08 13:33:03" 
     105            SimpleDateFormat f = new SimpleDateFormat("dd-MMM-yy HH:mm:ss"); 
     106            Date d = f.parse(str, new ParsePosition(0)); 
     107            if(d != null) 
     108                return d; 
    80109        } 
    81110 
     
    97126        if (text.length() != pattern.length()) return false; 
    98127        for (int i=0; i<pattern.length(); i++) { 
    99             if (pattern.charAt(i) == 'x') continue; 
    100             if (pattern.charAt(i) != text.charAt(i)) return false; 
     128            char pc = pattern.charAt(i); 
     129            char tc = text.charAt(i); 
     130            if(pc == 'x' && tc >= '0' && tc <= '9') continue; 
     131            else if(pc == 'x' || pc != tc) return false; 
    101132        } 
    102133        return true; 
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r1722 r1724  
    7474    static public String getURL(Bounds b) 
    7575    { 
    76         return getURL(b.center(), getZoom(b)); 
     76        return getURL(b.getCenter(), getZoom(b)); 
    7777    } 
    7878 
Note: See TracChangeset for help on using the changeset viewer.