Changeset 6203 in josm for trunk


Ignore:
Timestamp:
2013-08-28T03:03:40+02:00 (11 years ago)
Author:
Don-vip
Message:

fix #9024 - bbox/bounds memory optimizations (modified patch by shinigami) + javadoc

Location:
trunk/src/org/openstreetmap/josm
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JumpToAction.java

    r5966 r6203  
    127127        Bounds b = OsmUrlToBounds.parse(url.getText());
    128128        if (b != null) {
    129             lat.setText(Double.toString((b.getMin().lat() + b.getMax().lat())/2));
    130             lon.setText(Double.toString((b.getMin().lon() + b.getMax().lon())/2));
     129            lat.setText(Double.toString((b.getMinLat() + b.getMaxLat())/2));
     130            lon.setText(Double.toString((b.getMinLon() + b.getMaxLon())/2));
    131131
    132132            int zoomLvl = 16;
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r6162 r6203  
    99
    1010import org.openstreetmap.josm.data.coor.LatLon;
     11import org.openstreetmap.josm.data.osm.BBox;
    1112import org.openstreetmap.josm.tools.CheckParameterUtil;
    1213
     
    2728    }
    2829
     30    /**
     31     * Returns min latitude of bounds. Efficient shortcut for {@code getMin().lat()}.
     32     *
     33     * @return min latitude of bounds.
     34     * @since 6203
     35     */
     36    public double getMinLat() {
     37        return minLat;
     38    }
     39
     40    /**
     41     * Returns min longitude of bounds. Efficient shortcut for {@code getMin().lon()}.
     42     *
     43     * @return min longitude of bounds.
     44     * @since 6203
     45     */
     46    public double getMinLon() {
     47        return minLon;
     48    }
     49
    2950    public LatLon getMax() {
    3051        return new LatLon(maxLat, maxLon);
     52    }
     53
     54    /**
     55     * Returns max latitude of bounds. Efficient shortcut for {@code getMax().lat()}.
     56     *
     57     * @return max latitude of bounds.
     58     * @since 6203
     59     */
     60    public double getMaxLat() {
     61        return maxLat;
     62    }
     63
     64    /**
     65     * Returns max longitude of bounds. Efficient shortcut for {@code getMax().lon()}.
     66     *
     67     * @return max longitude of bounds.
     68     * @since 6203
     69     */
     70    public double getMaxLon() {
     71        return maxLon;
    3172    }
    3273
     
    3778
    3879    /**
    39      * Construct bounds out of two points
     80     * Construct bounds out of two points. Coords will be rounded.
    4081     */
    4182    public Bounds(LatLon min, LatLon max) {
     
    5192    }
    5293
     94    /**
     95     * Single point Bounds defined by lat/lon {@code b}.
     96     * Coordinates will be rounded to osm precision if {@code roundToOsmPrecision} is true.
     97     *
     98     * @param b lat/lon of given point.
     99     * @param roundToOsmPrecision defines if lat/lon will be rounded.
     100     */
    53101    public Bounds(LatLon b, boolean roundToOsmPrecision) {
     102        this(b.lat(), b.lon(), roundToOsmPrecision);
     103    }
     104   
     105    /**
     106     * Single point Bounds defined by point [lat,lon].
     107     * Coordinates will be rounded to osm precision if {@code roundToOsmPrecision} is true.
     108     *
     109     * @param lat latitude of given point.
     110     * @param lon longitude of given point.
     111     * @param roundToOsmPrecision defines if lat/lon will be rounded.
     112     * @since 6203
     113     */
     114    public Bounds(double lat, double lon, boolean roundToOsmPrecision) {
    54115        // Do not call this(b, b) to avoid GPX performance issue (see #7028) until roundToOsmPrecision() is improved
    55116        if (roundToOsmPrecision) {
    56             this.minLat = LatLon.roundToOsmPrecision(b.lat());
    57             this.minLon = LatLon.roundToOsmPrecision(b.lon());
    58         } else {
    59             this.minLat = b.lat();
    60             this.minLon = b.lon();
     117            this.minLat = LatLon.roundToOsmPrecision(lat);
     118            this.minLon = LatLon.roundToOsmPrecision(lon);
     119        } else {
     120            this.minLat = lat;
     121            this.minLon = lon;
    61122        }
    62123        this.maxLat = this.minLat;
     
    153214    }
    154215
    155     public Bounds(Bounds other) {
    156         this(other.getMin(), other.getMax());
     216    /**
     217     * Creates new {@code Bounds} from an existing one.
     218     * @param other The bounds to copy
     219     */
     220    public Bounds(final Bounds other) {
     221        this(other.minLat, other.minLon, other.maxLat, other.maxLon);
    157222    }
    158223
     
    186251    }
    187252
     253    /**
     254     * Creates BBox with same coordinates.
     255     *
     256     * @return BBox with same coordinates.
     257     * @since 6203
     258     */
     259    public BBox toBBox() {
     260        return new BBox(minLon, minLat, maxLon, maxLat);
     261    }
     262   
    188263    @Override public String toString() {
    189264        return "Bounds["+minLat+","+minLon+","+maxLat+","+maxLon+"]";
     
    203278    public LatLon getCenter()
    204279    {
     280        if (crosses180thMeridian()) {           
     281            double lat = (minLat + maxLat) / 2;
     282            double lon = (minLon + maxLon - 360.0) / 2;
     283            if (lon < -180.0){
     284                lon += 360.0;
     285            }
     286            return new LatLon(lat, lon);
     287        } else {
     288            return new LatLon((minLat + maxLat) / 2, (minLon + maxLon) / 2);
     289        }
     290    }
     291
     292    /**
     293     * Extend the bounds if necessary to include the given point.
     294     * @param ll The point to include into these bounds
     295     */
     296    public void extend(LatLon ll) {
     297        extend(ll.lat(), ll.lon());
     298    }
     299   
     300    /**
     301     * Extend the bounds if necessary to include the given point [lat,lon].
     302     * Good to use if you know coordinates to avoid creation of LatLon object.
     303     * @param lat Latitude of point to include into these bounds
     304     * @param lon Longitude of point to include into these bounds
     305     * @since 6203
     306     */
     307    public void extend(final double lat, final double lon) {
     308        if (lat < minLat) {
     309            minLat = LatLon.roundToOsmPrecision(lat);
     310        }
     311        if (lat > maxLat) {
     312            maxLat = LatLon.roundToOsmPrecision(lat);
     313        }
    205314        if (crosses180thMeridian()) {
    206             LatLon result = new LatLon(minLat, minLon-360.0).getCenter(getMax());
    207             if (result.lon() < -180.0) {
    208                 result = new LatLon(result.lat(), result.lon() + 360.0);
    209             }
    210             return result;
    211         } else {
    212             return getMin().getCenter(getMax());
    213         }
    214     }
    215 
    216     /**
    217      * Extend the bounds if necessary to include the given point.
    218      */
    219     public void extend(LatLon ll) {
    220         if (ll.lat() < minLat) {
    221             minLat = LatLon.roundToOsmPrecision(ll.lat());
    222         }
    223         if (ll.lat() > maxLat) {
    224             maxLat = LatLon.roundToOsmPrecision(ll.lat());
    225         }
    226         if (crosses180thMeridian()) {
    227             if (ll.lon() > maxLon && ll.lon() < minLon) {
    228                 if (Math.abs(ll.lon() - minLon) <= Math.abs(ll.lon() - maxLon)) {
    229                     minLon = LatLon.roundToOsmPrecision(ll.lon());
     315            if (lon > maxLon && lon < minLon) {
     316                if (Math.abs(lon - minLon) <= Math.abs(lon - maxLon)) {
     317                    minLon = LatLon.roundToOsmPrecision(lon);
    230318                } else {
    231                     maxLon = LatLon.roundToOsmPrecision(ll.lon());
     319                    maxLon = LatLon.roundToOsmPrecision(lon);
    232320                }
    233321            }
    234322        } else {
    235             if (ll.lon() < minLon) {
    236                 minLon = LatLon.roundToOsmPrecision(ll.lon());
     323            if (lon < minLon) {
     324                minLon = LatLon.roundToOsmPrecision(lon);
    237325            }
    238             if (ll.lon() > maxLon) {
    239                 maxLon = LatLon.roundToOsmPrecision(ll.lon());
     326            if (lon > maxLon) {
     327                maxLon = LatLon.roundToOsmPrecision(lon);
    240328            }
    241329        }
     
    243331
    244332    public void extend(Bounds b) {
    245         extend(b.getMin());
    246         extend(b.getMax());
    247     }
    248 
    249     /**
    250      * Is the given point within this bounds?
     333        extend(b.minLat, b.minLon);
     334        extend(b.maxLat, b.maxLon);
     335    }
     336
     337    /**
     338     * Determines if the given point {@code ll} is within these bounds.
     339     * @param ll The lat/lon to check
     340     * @return {@code true} if {@code ll} is within these bounds, {@code false} otherwise
    251341     */
    252342    public boolean contains(LatLon ll) {
     
    324414     */
    325415    public boolean isCollapsed() {
    326         return getMin().equals(getMax());
     416        return (minLat == maxLat) && (minLon == maxLon);
    327417    }
    328418
  • trunk/src/org/openstreetmap/josm/data/coor/Coordinate.java

    r6169 r6203  
    33
    44import java.io.Serializable;
     5
     6import org.openstreetmap.josm.data.osm.BBox;
    57
    68/**
     
    8991    }
    9092
     93    /**
     94     * Converts to single point BBox.
     95     *
     96     * @return single point BBox defined by this coordinate.
     97     * @since 6203
     98     */
     99    public BBox toBBox() {
     100        return new BBox(x, y);
     101    }
     102   
     103    /**
     104     * Creates bbox around this coordinate. Coordinate defines
     105     * center of bbox, its edge will be 2*r.
     106     *
     107     * @param r size
     108     * @return BBox around this coordinate
     109     * @since 6203
     110     */
     111    public BBox toBBox(final double r) {
     112        return new BBox(x - r, y - r, x + r, y + r);
     113    }
     114
    91115    @Override
    92116    public int hashCode() {
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r6178 r6203  
    216216    public boolean isOutSideWorld() {
    217217        Bounds b = Main.getProjection().getWorldBoundsLatLon();
    218         return lat() < b.getMin().lat() || lat() > b.getMax().lat() ||
    219                 lon() < b.getMin().lon() || lon() > b.getMax().lon();
     218        return lat() < b.getMinLat() || lat() > b.getMaxLat() ||
     219                lon() < b.getMinLon() || lon() > b.getMaxLon();
    220220    }
    221221
  • trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java

    r6084 r6203  
    5151     * because a lot of GPX waypoints are created when GPS tracks are downloaded from the OSM server.
    5252     */
    53     private double lat = 0;
    54     private double lon = 0;
     53    private final double lat;
     54    private final double lon;
    5555
    5656    /*
  • trunk/src/org/openstreetmap/josm/data/osm/BBox.java

    r6178 r6203  
    44import java.util.Arrays;
    55
    6 import org.openstreetmap.josm.data.Bounds;
    76import org.openstreetmap.josm.data.coor.LatLon;
    87import org.openstreetmap.josm.data.coor.QuadTiling;
     
    1615    private double ymax = Double.NEGATIVE_INFINITY;
    1716
    18     public BBox(Bounds bounds) {
    19         add(bounds.getMin());
    20         add(bounds.getMax());
    21     }
    22 
     17    /**
     18     * Constructs a new {@code BBox} defined by a single point.
     19     *
     20     * @param x X coordinate
     21     * @param y Y coordinate
     22     * @since 6203
     23     */
     24    public BBox(final double x, final double y) {
     25        xmax = xmin = x;
     26        ymax = ymin = y;
     27        sanity();
     28    }
     29
     30    /**
     31     * Constructs a new {@code BBox} defined by points <code>a</code> and <code>b</code>.
     32     * Result is minimal BBox containing both points.
     33     *
     34     * @param a
     35     * @param b
     36     */
    2337    public BBox(LatLon a, LatLon b) {
    24         add(a);
    25         add(b);
    26     }
    27 
     38        this(a.lon(), a.lat(), b.lon(), b.lat());
     39    }
     40
     41    /**
     42     * Constructs a new {@code BBox} from another one.
     43     *
     44     * @param copy the BBox to copy
     45     */
    2846    public BBox(BBox copy) {
    2947        this.xmin = copy.xmin;
     
    3452
    3553    public BBox(double a_x, double a_y, double b_x, double b_y)  {
    36         xmin = Math.min(a_x, b_x);
    37         xmax = Math.max(a_x, b_x);
    38         ymin = Math.min(a_y, b_y);
    39         ymax = Math.max(a_y, b_y);
     54       
     55        if (a_x > b_x) {
     56            xmax = a_x;
     57            xmin = b_x;
     58        } else {
     59            xmax = b_x;
     60            xmin = a_x;
     61        }
     62       
     63        if (a_y > b_y) {
     64            ymax = a_y;
     65            ymin = b_y;
     66        } else {
     67            ymax = b_y;
     68            ymin = a_y;
     69        }
     70       
    4071        sanity();
    4172    }
     
    84115     */
    85116    public void add(double x, double y) {
    86         xmin = Math.min(xmin, x);
    87         xmax = Math.max(xmax, x);
    88         ymin = Math.min(ymin, y);
    89         ymax = Math.max(ymax, y);
     117       
     118        if (x < xmin) {
     119            xmin = x;
     120        } else if (x > xmax) {
     121            xmax = x;
     122        }
     123       
     124        if (y < ymin) {
     125            ymin = y;
     126        } else if (y > ymax) {
     127            ymax = y;
     128        }
     129
    90130        sanity();
    91131    }
    92132
    93133    public void add(BBox box) {
    94         add(box.getTopLeft());
    95         add(box.getBottomRight());
     134        xmin = Math.min(xmin, box.xmin);
     135        xmax = Math.max(xmax, box.xmax);
     136        ymin = Math.min(ymin, box.ymin);
     137        ymax = Math.max(ymax, box.ymax);
     138        sanity();
    96139    }
    97140
     
    151194    }
    152195
     196    /**
     197     * Returns the top-left point.
     198     * @return The top-left point
     199     */
    153200    public LatLon getTopLeft() {
    154201        return new LatLon(ymax, xmin);
    155202    }
    156203
     204    /**
     205     * Returns the latitude of top-left point.
     206     * @return The latitude of top-left point
     207     * @since 6203
     208     */
     209    public double getTopLeftLat() {
     210        return ymax;
     211    }
     212
     213    /**
     214     * Returns the longitude of top-left point.
     215     * @return The longitude of top-left point
     216     * @since 6203
     217     */
     218    public double getTopLeftLon() {
     219        return xmin;
     220    }
     221
     222    /**
     223     * Returns the bottom-right point.
     224     * @return The bottom-right point
     225     */
    157226    public LatLon getBottomRight() {
    158227        return new LatLon(ymin, xmax);
     228    }
     229
     230    /**
     231     * Returns the latitude of bottom-right point.
     232     * @return The latitude of bottom-right point
     233     * @since 6203
     234     */
     235    public double getBottomRightLat() {
     236        return ymin;
     237    }
     238
     239    /**
     240     * Returns the longitude of bottom-right point.
     241     * @return The longitude of bottom-right point
     242     * @since 6203
     243     */
     244    public double getBottomRightLon() {
     245        return xmax;
    159246    }
    160247
  • trunk/src/org/openstreetmap/josm/data/osm/DatasetConsistencyTest.java

    r5356 r6203  
    8181                LatLon c = n.getCoor();
    8282                if (c != null) {
    83                     BBox box = new BBox(new LatLon(c.lat() - 0.0001, c.lon() - 0.0001), new LatLon(c.lat() + 0.0001, c.lon() + 0.0001));
     83                    BBox box = c.toBBox(0.0001);
    8484                    if (!dataSet.searchNodes(box).contains(n)) {
    8585                        printError("SEARCH NODES", "%s not found using Dataset.searchNodes()", n);
  • trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java

    r6181 r6203  
    117117            double lat = bottom_left.lat() + parent.height() / 2;
    118118            double lon = bottom_left.lon() + parent.width() / 2;
    119             LatLon top_right = new LatLon(lat, lon);
    120             return new BBox(bottom_left, top_right);
     119            return new BBox(bottom_left.lon(), bottom_left.lat(), lon, lat);
    121120        }
    122121
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r6172 r6203  
    14041404    public void render(final DataSet data, boolean renderVirtualNodes, Bounds bounds) {
    14051405        //long start = System.currentTimeMillis();
    1406         BBox bbox = new BBox(bounds);
     1406        BBox bbox = bounds.toBBox();
    14071407        getSettings(renderVirtualNodes);
    14081408
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java

    r6113 r6203  
    157157    @Override
    158158    public void render(DataSet data, boolean virtual, Bounds bounds) {
    159         BBox bbox = new BBox(bounds);
     159        BBox bbox = bounds.toBBox();
    160160        this.ds = data;
    161161        getSettings(virtual);
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r6142 r6203  
    124124            proj = new Mercator();
    125125            bounds = new Bounds(
    126                     new LatLon(-85.05112877980659, -180.0),
    127                     new LatLon(85.05112877980659, 180.0), true);
     126                    -85.05112877980659, -180.0,
     127                    85.05112877980659, 180.0, true);
    128128        } else {
    129129            Map<String, String> parameters = parseParameterList(pref);
  • trunk/src/org/openstreetmap/josm/gui/BookmarkList.java

    r6084 r6203  
    184184            array[0] = b.getName();
    185185            Bounds area = b.getArea();
    186             array[1] = String.valueOf(area.getMin().lat());
    187             array[2] = String.valueOf(area.getMin().lon());
    188             array[3] = String.valueOf(area.getMax().lat());
    189             array[4] = String.valueOf(area.getMax().lon());
     186            array[1] = String.valueOf(area.getMinLat());
     187            array[2] = String.valueOf(area.getMinLon());
     188            array[3] = String.valueOf(area.getMaxLat());
     189            array[4] = String.valueOf(area.getMaxLon());
    190190            coll.add(Arrays.asList(array));
    191191        }
     
    217217            StringBuffer sb = new StringBuffer();
    218218            sb.append("<html>min[latitude,longitude]=<strong>[")
    219             .append(area.getMin().lat()).append(",").append(area.getMin().lon()).append("]</strong>")
     219            .append(area.getMinLat()).append(",").append(area.getMinLon()).append("]</strong>")
    220220            .append("<br>")
    221221            .append("max[latitude,longitude]=<strong>[")
    222             .append(area.getMax().lat()).append(",").append(area.getMax().lon()).append("]</strong>")
     222            .append(area.getMaxLat()).append(",").append(area.getMaxLon()).append("]</strong>")
    223223            .append("</html>");
    224224            return sb.toString();
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r6107 r6203  
    636636        tempG.setColor(Color.WHITE);
    637637        Bounds b = getProjection().getWorldBoundsLatLon();
    638         double lat = b.getMin().lat();
    639         double lon = b.getMin().lon();
     638        double lat = b.getMinLat();
     639        double lon = b.getMinLon();
    640640
    641641        Point p = getPoint(b.getMin());
     
    656656            path.lineTo(p.x, p.y);
    657657        }
    658         lon = max; max = b.getMin().lat();
     658        lon = max; max = b.getMinLat();
    659659        for(; lat >= max; lat -= 1.0)
    660660        {
     
    662662            path.lineTo(p.x, p.y);
    663663        }
    664         lat = max; max = b.getMin().lon();
     664        lat = max; max = b.getMinLon();
    665665        for(; lon >= max; lon -= 1.0)
    666666        {
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r6142 r6203  
    201201    private EastNorth calculateDefaultCenter() {
    202202        Bounds b = Main.getProjection().getWorldBoundsLatLon();
    203         double lat = (b.getMax().lat() + b.getMin().lat())/2;
    204         double lon = (b.getMax().lon() + b.getMin().lon())/2;
    205 
     203        double lat = (b.getMaxLat() + b.getMinLat())/2;
     204        double lon = (b.getMaxLon() + b.getMinLon())/2;
     205        // FIXME is it correct? b.getCenter() makes some adjustments...
    206206        return Main.getProjection().latlon2eastNorth(new LatLon(lat, lon));
    207207    }
     
    401401        double lat = cl.lat();
    402402        double lon = cl.lon();
    403         if(lat < b.getMin().lat()) {changed = true; lat = b.getMin().lat(); }
    404         else if(lat > b.getMax().lat()) {changed = true; lat = b.getMax().lat(); }
    405         if(lon < b.getMin().lon()) {changed = true; lon = b.getMin().lon(); }
    406         else if(lon > b.getMax().lon()) {changed = true; lon = b.getMax().lon(); }
     403        if(lat < b.getMinLat()) {changed = true; lat = b.getMinLat(); }
     404        else if(lat > b.getMaxLat()) {changed = true; lat = b.getMaxLat(); }
     405        if(lon < b.getMinLon()) {changed = true; lon = b.getMinLon(); }
     406        else if(lon > b.getMaxLon()) {changed = true; lon = b.getMaxLon(); }
    407407        if(changed) {
    408408            newCenter = Projections.project(new LatLon(lat,lon));
     
    410410        int width = getWidth()/2;
    411411        int height = getHeight()/2;
    412         LatLon l1 = new LatLon(b.getMin().lat(), lon);
    413         LatLon l2 = new LatLon(b.getMax().lat(), lon);
     412        LatLon l1 = new LatLon(b.getMinLat(), lon);
     413        LatLon l2 = new LatLon(b.getMaxLat(), lon);
    414414        EastNorth e1 = getProjection().latlon2eastNorth(l1);
    415415        EastNorth e2 = getProjection().latlon2eastNorth(l2);
     
    418418        {
    419419            double newScaleH = d/height;
    420             e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMin().lon()));
    421             e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMax().lon()));
     420            e1 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMinLon()));
     421            e2 = getProjection().latlon2eastNorth(new LatLon(lat, b.getMaxLon()));
    422422            d = e2.east() - e1.east();
    423423            if(d < width*newScale) {
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r6084 r6203  
    353353    @Override
    354354    public void setBoundingBox(Bounds bbox) {
    355         if (bbox == null || (bbox.getMin().lat() == 0.0 && bbox.getMin().lon() == 0.0
    356                 && bbox.getMax().lat() == 0.0 && bbox.getMax().lon() == 0.0)) {
     355        if (bbox == null || (bbox.getMinLat() == 0.0 && bbox.getMinLon() == 0.0
     356                && bbox.getMaxLat() == 0.0 && bbox.getMaxLon() == 0.0)) {
    357357            this.bbox = null;
    358358            iSelectionRectStart = null;
     
    363363
    364364        this.bbox = bbox;
    365         double minLon = bbox.getMin().lon();
    366         double maxLon = bbox.getMax().lon();
     365        double minLon = bbox.getMinLon();
     366        double maxLon = bbox.getMaxLon();
    367367
    368368        if (bbox.crosses180thMeridian()) {
     
    370370        }
    371371
    372         int y1 = OsmMercator.LatToY(bbox.getMin().lat(), MAX_ZOOM);
    373         int y2 = OsmMercator.LatToY(bbox.getMax().lat(), MAX_ZOOM);
     372        int y1 = OsmMercator.LatToY(bbox.getMinLat(), MAX_ZOOM);
     373        int y2 = OsmMercator.LatToY(bbox.getMaxLat(), MAX_ZOOM);
    374374        int x1 = OsmMercator.LonToX(minLon, MAX_ZOOM);
    375375        int x2 = OsmMercator.LonToX(maxLon, MAX_ZOOM);
     
    379379
    380380        // calc the screen coordinates for the new selection rectangle
    381         MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMin().lat(), bbox.getMin().lon());
    382         MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMax().lat(), bbox.getMax().lon());
     381        MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMinLat(), bbox.getMinLon());
     382        MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMaxLat(), bbox.getMaxLon());
    383383
    384384        Vector<MapMarker> marker = new Vector<MapMarker>(2);
  • trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java

    r6087 r6203  
    153153
    154154        // calc the screen coordinates for the new selection rectangle
    155         MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMin().lat(), bbox.getMin().lon());
    156         MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMax().lat(), bbox.getMax().lon());
     155        MapMarkerDot xmin_ymin = new MapMarkerDot(bbox.getMinLat(), bbox.getMinLon());
     156        MapMarkerDot xmax_ymax = new MapMarkerDot(bbox.getMaxLat(), bbox.getMaxLon());
    157157
    158158        Vector<MapMarker> marker = new Vector<MapMarker>(2);
     
    342342            tb.zoomLevel = (Integer) spZoomLevel.getValue();
    343343            tb.min = new Point(
    344                     Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMin().lon())),
    345                     Math.max(0,latToTileY(tb.zoomLevel, bbox.getMax().lat()-.00001))
     344                    Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMinLon())),
     345                    Math.max(0,latToTileY(tb.zoomLevel, bbox.getMaxLat() - 0.00001))
    346346            );
    347347            tb.max = new Point(
    348                     Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMax().lon())),
    349                     Math.max(0,latToTileY(tb.zoomLevel, bbox.getMin().lat()-.00001))
     348                    Math.max(0,lonToTileX(tb.zoomLevel, bbox.getMaxLon())),
     349                    Math.max(0,latToTileY(tb.zoomLevel, bbox.getMinLat() - 0.00001))
    350350            );
    351351            doFireTileBoundChanged = false;
     
    682682                max = null;
    683683            } else {
    684                 int y1 = OsmMercator.LatToY(bbox.getMin().lat(), MAX_ZOOM);
    685                 int y2 = OsmMercator.LatToY(bbox.getMax().lat(), MAX_ZOOM);
    686                 int x1 = OsmMercator.LonToX(bbox.getMin().lon(), MAX_ZOOM);
    687                 int x2 = OsmMercator.LonToX(bbox.getMax().lon(), MAX_ZOOM);
     684                int y1 = OsmMercator.LatToY(bbox.getMinLat(), MAX_ZOOM);
     685                int y2 = OsmMercator.LatToY(bbox.getMaxLat(), MAX_ZOOM);
     686                int x1 = OsmMercator.LonToX(bbox.getMinLon(), MAX_ZOOM);
     687                int x2 = OsmMercator.LonToX(bbox.getMaxLon(), MAX_ZOOM);
    688688
    689689                min = new Point(Math.min(x1, x2), Math.min(y1, y2));
  • trunk/src/org/openstreetmap/josm/gui/download/BookmarkSelection.java

    r6087 r6203  
    2323import org.openstreetmap.josm.Main;
    2424import org.openstreetmap.josm.data.Bounds;
    25 import org.openstreetmap.josm.data.osm.BBox;
    2625import org.openstreetmap.josm.gui.BookmarkList;
    2726import org.openstreetmap.josm.gui.BookmarkList.Bookmark;
     
    154153        } else {
    155154            lblCurrentDownloadArea.setText(tr("<html><strong>Current download area</strong> (minlon, minlat, maxlon, maxlat): </html>"));
    156             bboxDisplay.setText(new BBox(currentArea).toStringCSV(","));
     155            bboxDisplay.setText(currentArea.toBBox().toStringCSV(","));
    157156        }
    158157    }
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r6084 r6203  
    242242                    String[] bbox = atts.getValue("boundingbox").split(",");
    243243                    currentResult.bounds = new Bounds(
    244                             new LatLon(Double.parseDouble(bbox[0]), Double.parseDouble(bbox[2])),
    245                             new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[3])));
     244                            Double.parseDouble(bbox[0]), Double.parseDouble(bbox[2]),
     245                            Double.parseDouble(bbox[1]), Double.parseDouble(bbox[3]));
    246246                    data.add(currentResult);
    247247                }
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r6104 r6203  
    399399                            if (!mapRectangles.containsKey(i)) {
    400400                                // Add new map rectangle
    401                                 Coordinate topLeft = new Coordinate(bounds.getMax().lat(), bounds.getMin().lon());
    402                                 Coordinate bottomRight = new Coordinate(bounds.getMin().lat(), bounds.getMax().lon());
     401                                Coordinate topLeft = new Coordinate(bounds.getMaxLat(), bounds.getMinLon());
     402                                Coordinate bottomRight = new Coordinate(bounds.getMinLat(), bounds.getMaxLon());
    403403                                MapRectangle rectangle = new MapRectangleImpl(topLeft, bottomRight);
    404404                                mapRectangles.put(i, rectangle);
  • trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

    r6070 r6203  
    2626
    2727    public BoundingBoxDownloader(Bounds downloadArea) {
    28         this.lat1 = downloadArea.getMin().lat();
    29         this.lon1 = downloadArea.getMin().lon();
    30         this.lat2 = downloadArea.getMax().lat();
    31         this.lon2 = downloadArea.getMax().lon();
     28        this.lat1 = downloadArea.getMinLat();
     29        this.lon1 = downloadArea.getMinLon();
     30        this.lat2 = downloadArea.getMaxLat();
     31        this.lon2 = downloadArea.getMaxLon();
    3232        this.crosses180th = downloadArea.crosses180thMeridian();
    3333    }
  • trunk/src/org/openstreetmap/josm/io/GpxWriter.java

    r6142 r6203  
    157157        Bounds bounds = data.recalculateBounds();
    158158        if (bounds != null) {
    159             String b = "minlat=\"" + bounds.getMin().lat() + "\" minlon=\"" + bounds.getMin().lon() +
    160             "\" maxlat=\"" + bounds.getMax().lat() + "\" maxlon=\"" + bounds.getMax().lon() + "\"" ;
     159            String b = "minlat=\"" + bounds.getMinLat() + "\" minlon=\"" + bounds.getMinLon() +
     160            "\" maxlat=\"" + bounds.getMaxLat() + "\" maxlon=\"" + bounds.getMaxLon() + "\"" ;
    161161            inline("bounds", b);
    162162        }
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r6070 r6203  
    163163        for (DataSource s : ds.dataSources) {
    164164            out.println("  <bounds minlat='"
    165                     + s.bounds.getMin().lat()+"' minlon='"
    166                     + s.bounds.getMin().lon()+"' maxlat='"
    167                     + s.bounds.getMax().lat()+"' maxlon='"
    168                     + s.bounds.getMax().lon()
     165                    + s.bounds.getMinLat()+"' minlon='"
     166                    + s.bounds.getMinLon()+"' maxlat='"
     167                    + s.bounds.getMaxLat()+"' maxlon='"
     168                    + s.bounds.getMaxLon()
    169169                    +"' origin='"+XmlWriter.encode(s.origin)+"' />");
    170170        }
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java

    r6091 r6203  
    159159        }
    160160
    161         final Bounds bbox = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));
     161        final Bounds bbox = new Bounds(minlat, minlon, maxlat, maxlon);
    162162        if (args.containsKey("select") && PermissionPrefWithDefault.CHANGE_SELECTION.isAllowed()) {
    163163            // select objects after downloading, zoom to selection.
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r6155 r6203  
    5050                String[] bbox = map.get("bbox").split(",");
    5151                b = new Bounds(
    52                         new LatLon(Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0])),
    53                         new LatLon(Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2])));
     52                        Double.parseDouble(bbox[1]), Double.parseDouble(bbox[0]),
     53                        Double.parseDouble(bbox[3]), Double.parseDouble(bbox[2]));
    5454            } else if (map.containsKey("minlat")) {
    55                 String s = map.get("minlat");
    56                 Double minlat = Double.parseDouble(s);
    57                 s = map.get("minlon");
    58                 Double minlon = Double.parseDouble(s);
    59                 s = map.get("maxlat");
    60                 Double maxlat = Double.parseDouble(s);
    61                 s = map.get("maxlon");
    62                 Double maxlon = Double.parseDouble(s);
    63                 b = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));
     55                double minlat = Double.parseDouble(map.get("minlat"));
     56                double minlon = Double.parseDouble(map.get("minlon"));
     57                double maxlat = Double.parseDouble(map.get("maxlat"));
     58                double maxlon = Double.parseDouble(map.get("maxlon"));
     59                b = new Bounds(minlat, minlon, maxlat, maxlon);
    6460            } else {
    6561                String z = map.get("zoom");
     
    234230    static public int getZoom(Bounds b) {
    235231        // convert to mercator (for calculation of zoom only)
    236         double latMin = Math.log(Math.tan(Math.PI/4.0+b.getMin().lat()/180.0*Math.PI/2.0))*180.0/Math.PI;
    237         double latMax = Math.log(Math.tan(Math.PI/4.0+b.getMax().lat()/180.0*Math.PI/2.0))*180.0/Math.PI;
    238         double size = Math.max(Math.abs(latMax-latMin), Math.abs(b.getMax().lon()-b.getMin().lon()));
     232        double latMin = Math.log(Math.tan(Math.PI/4.0+b.getMinLat()/180.0*Math.PI/2.0))*180.0/Math.PI;
     233        double latMax = Math.log(Math.tan(Math.PI/4.0+b.getMaxLat()/180.0*Math.PI/2.0))*180.0/Math.PI;
     234        double size = Math.max(Math.abs(latMax-latMin), Math.abs(b.getMaxLon()-b.getMinLon()));
    239235        int zoom = 0;
    240236        while (zoom <= 20) {
Note: See TracChangeset for help on using the changeset viewer.