Ignore:
Timestamp:
2009-07-03T22:19:22+02:00 (15 years ago)
Author:
stoecker
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.