Ignore:
Timestamp:
2011-11-06T15:00:56+01:00 (12 years ago)
Author:
Don-vip
Message:

see #2212 - Allow JOSM to download data crossing the 180th meridian

File:
1 edited

Legend:

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

    r4574 r4580  
    7777                return isValidLat(lat()) && isValidLon(lon());
    7878        }
     79       
     80    public static double toIntervalLat(double value) {
     81        if (value < -90)
     82            return -90;
     83        if (value > 90)
     84            return 90;
     85        return value;
     86    }
     87
     88    /**
     89     * Returns a valid OSM longitude [-180,+180] for the given extended longitude value.
     90     * For example, a value of -181 will return +179, a value of +181 will return -179.
     91     * @param lon A longitude value not restricted to the [-180,+180] range.
     92     */
     93    public static double toIntervalLon(double value) {
     94        if (isValidLon(value)) {
     95            return value;
     96        } else {
     97            int n = (int) (value + Math.signum(value)*180.0) / 360;
     98            return value - n*360.0;
     99        }
     100    }
    79101       
    80102    /**
     
    165187     */
    166188    public boolean isWithin(Bounds b) {
    167         return lat() >= b.getMin().lat() && lat() <= b.getMax().lat() && lon() > b.getMin().lon() && lon() < b.getMax().lon();
     189        return b.contains(this);
    168190    }
    169191
Note: See TracChangeset for help on using the changeset viewer.