Changeset 71 in josm


Ignore:
Timestamp:
2006-03-25T16:21:09+01:00 (18 years ago)
Author:
imi
Message:
  • refactored GpsPoint to be immutable and added LatLon and NorthEast
  • refactored Bounding Box calculations
  • various other renames
Files:
5 added
1 deleted
54 edited
4 moved

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/Main.java

    r68 r71  
    3535import org.openstreetmap.josm.data.Preferences.PreferencesException;
    3636import org.openstreetmap.josm.data.osm.DataSet;
    37 import org.openstreetmap.josm.gui.BugReportExceptionHandler;
    38 import org.openstreetmap.josm.gui.ImageProvider;
    3937import org.openstreetmap.josm.gui.MapFrame;
    4038import org.openstreetmap.josm.gui.ShowModifiers;
    4139import org.openstreetmap.josm.gui.layer.Layer;
    4240import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     41import org.openstreetmap.josm.tools.BugReportExceptionHandler;
     42import org.openstreetmap.josm.tools.ImageProvider;
    4343
    4444/**
     
    294294        }
    295295
    296         /**
    297          * Set the main's mapframe. If a changed old mapFrame is already set,
    298          * ask the user whether he want to save, discard or abort. If the user
    299          * aborts, nothing happens.
    300          */
     296        //TODO: should be solved better.
    301297        public void setMapFrame(MapFrame mapFrame) {
    302                 //TODO: Check for changes and ask user
    303298                if (this.mapFrame != null)
    304299                        this.mapFrame.setVisible(false);
  • src/org/openstreetmap/josm/actions/AboutAction.java

    r69 r71  
    2121
    2222import org.openstreetmap.josm.Main;
    23 import org.openstreetmap.josm.gui.GBC;
    24 import org.openstreetmap.josm.gui.ImageProvider;
     23import org.openstreetmap.josm.tools.GBC;
     24import org.openstreetmap.josm.tools.ImageProvider;
    2525import org.openstreetmap.josm.tools.UrlLabel;
    2626
  • src/org/openstreetmap/josm/actions/DownloadAction.java

    r68 r71  
    3131import org.openstreetmap.josm.Main;
    3232import org.openstreetmap.josm.data.Bounds;
    33 import org.openstreetmap.josm.data.GeoPoint;
    3433import org.openstreetmap.josm.data.Preferences.PreferencesException;
     34import org.openstreetmap.josm.data.coor.LatLon;
    3535import org.openstreetmap.josm.data.osm.DataSet;
    3636import org.openstreetmap.josm.gui.BookmarkList;
    37 import org.openstreetmap.josm.gui.GBC;
    3837import org.openstreetmap.josm.gui.MapFrame;
    3938import org.openstreetmap.josm.gui.MapView;
     
    4443import org.openstreetmap.josm.gui.layer.RawGpsDataLayer;
    4544import org.openstreetmap.josm.io.OsmServerReader;
     45import org.openstreetmap.josm.tools.GBC;
    4646import org.xml.sax.SAXException;
    4747
     
    114114                        MapView mv = Main.main.getMapFrame().mapView;
    115115                        setEditBounds(new Bounds(
    116                                         mv.getPoint(0, mv.getHeight(), true),
    117                                         mv.getPoint(mv.getWidth(), 0, true)));
     116                                        mv.getLatLon(0, mv.getHeight()),
     117                                        mv.getLatLon(mv.getWidth(), 0)));
    118118                        rawGps.setSelected(mv.getActiveLayer() instanceof RawGpsDataLayer);
    119119                }
     
    168168                                                        double size = 180.0 / Math.pow(2, map.get("zoom"));
    169169                                                        Bounds b = new Bounds(
    170                                                                         new GeoPoint(map.get("lat") - size/2, map.get("lon") - size),
    171                                                                         new GeoPoint(map.get("lat") + size/2, map.get("lon") + size));
     170                                                                        new LatLon(map.get("lat") - size/2, map.get("lon") - size),
     171                                                                        new LatLon(map.get("lat") + size/2, map.get("lon") + size));
    172172                                                        setEditBounds(b);
    173173                                                } catch (Exception x) { // NPE or IAE
     
    310310         */
    311311        private void setEditBounds(Bounds b) {
    312                 GeoPoint bottomLeft = b.min;
    313                 GeoPoint topRight = b.max;
     312                LatLon bottomLeft = b.min;
     313                LatLon topRight = b.max;
    314314                if (bottomLeft.isOutSideWorld())
    315                         bottomLeft = new GeoPoint(-89.999, -179.999); // do not use the Projection constants, since this looks better.
     315                        bottomLeft = new LatLon(-89.999, -179.999); // do not use the Projection constants, since this looks better.
    316316                if (topRight.isOutSideWorld())
    317                         topRight = new GeoPoint(89.999, 179.999);
    318                 latlon[0].setText(""+bottomLeft.lat);
    319                 latlon[1].setText(""+bottomLeft.lon);
    320                 latlon[2].setText(""+topRight.lat);
    321                 latlon[3].setText(""+topRight.lon);
     317                        topRight = new LatLon(89.999, 179.999);
     318                latlon[0].setText(""+bottomLeft.lat());
     319                latlon[1].setText(""+bottomLeft.lon());
     320                latlon[2].setText(""+topRight.lat());
     321                latlon[3].setText(""+topRight.lon());
    322322                for (JTextField f : latlon)
    323323                        f.setCaretPosition(0);
  • src/org/openstreetmap/josm/actions/JosmAction.java

    r68 r71  
    1010
    1111import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.gui.ImageProvider;
     12import org.openstreetmap.josm.tools.ImageProvider;
    1313
    1414/**
  • src/org/openstreetmap/josm/actions/OpenAction.java

    r68 r71  
    1616import org.jdom.JDOMException;
    1717import org.openstreetmap.josm.Main;
    18 import org.openstreetmap.josm.data.GeoPoint;
     18import org.openstreetmap.josm.data.coor.LatLon;
    1919import org.openstreetmap.josm.data.osm.DataSet;
    2020import org.openstreetmap.josm.gui.MapFrame;
     
    7171
    7272                        if (asRawData(fn)) {
    73                                 Collection<Collection<GeoPoint>> data;
     73                                Collection<Collection<LatLon>> data;
    7474                                if (ExtensionFileFilter.filters[ExtensionFileFilter.GPX].acceptName(fn)) {
    7575                                        data = new RawGpsReader(new FileReader(filename)).parse();
    7676                                } else if (ExtensionFileFilter.filters[ExtensionFileFilter.CSV].acceptName(fn)) {
    77                                         data = new LinkedList<Collection<GeoPoint>>();
     77                                        data = new LinkedList<Collection<LatLon>>();
    7878                                        data.add(new RawCsvReader(new FileReader(filename)).parse());
    7979                                } else
  • src/org/openstreetmap/josm/actions/SaveAction.java

    r68 r71  
    2222 * Export the data  as OSM intern xml file.
    2323 *
    24  * TODO: This is very redundant with SaveGpxAction. Merge both actions into one!
    25  * 
    2624 * @author imi
    2725 */
  • src/org/openstreetmap/josm/actions/UploadAction.java

    r68 r71  
    1919import org.openstreetmap.josm.data.Preferences.PreferencesException;
    2020import org.openstreetmap.josm.data.osm.OsmPrimitive;
    21 import org.openstreetmap.josm.gui.GBC;
    2221import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
    2322import org.openstreetmap.josm.io.OsmServerWriter;
     23import org.openstreetmap.josm.tools.GBC;
    2424
    2525/**
  • src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java

    r68 r71  
    162162                g.setColor(Color.BLACK);
    163163                g.setXORMode(Color.WHITE);
    164                 Point firstDrawn = mv.getScreenPoint(first.coor);
    165                 Point secondDrawn = mv.getScreenPoint(second.coor);
     164                Point firstDrawn = mv.getPoint(first.eastNorth);
     165                Point secondDrawn = mv.getPoint(second.eastNorth);
    166166                g.drawLine(firstDrawn.x, firstDrawn.y, secondDrawn.x, secondDrawn.y);
    167167                hintDrawn = !hintDrawn;
  • src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java

    r68 r71  
    2323public class AddNodeAction extends MapMode {
    2424
    25         /**
    26          * Create an AddNodeAction. Mnemonic is 'a'
    27          * @param mapFrame
    28          */
    2925        public AddNodeAction(MapFrame mapFrame) {
    3026                super("Add nodes", "addnode", "Add nodes to the map.", "N", KeyEvent.VK_N, mapFrame);
     
    5046        public void mouseClicked(MouseEvent e) {
    5147                if (e.getButton() == MouseEvent.BUTTON1) {
    52                         Node node = new Node(mv.getPoint(e.getX(), e.getY(), true));
     48                        Node node = new Node(mv.getLatLon(e.getX(), e.getY()));
    5349                        if (node.coor.isOutSideWorld()) {
    5450                                JOptionPane.showMessageDialog(Main.main, "Can not add a node outside of the world.");
  • src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java

    r68 r71  
    9494         * Delete the primitives and everything they references.
    9595         *
    96          * If a node is deleted, the node and all line segments, waies and areas
     96         * If a node is deleted, the node and all line segments, ways and areas
    9797         * the node is part of are deleted as well.
    9898         *
    99          * If a line segment is deleted, all waies the line segment is part of
     99         * If a line segment is deleted, all ways the line segment is part of
    100100         * are deleted as well. No nodes are deleted.
    101101         *
  • src/org/openstreetmap/josm/actions/mapmode/MoveAction.java

    r68 r71  
    1212import org.openstreetmap.josm.command.Command;
    1313import org.openstreetmap.josm.command.MoveCommand;
    14 import org.openstreetmap.josm.data.GeoPoint;
     14import org.openstreetmap.josm.data.coor.EastNorth;
    1515import org.openstreetmap.josm.data.osm.Node;
    1616import org.openstreetmap.josm.data.osm.OsmPrimitive;
     17import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor;
    1718import org.openstreetmap.josm.gui.MapFrame;
    1819
     
    7980                }
    8081
    81                 GeoPoint mouseGeo = mv.getPoint(e.getX(), e.getY(), false);
    82                 GeoPoint mouseStartGeo = mv.getPoint(mousePos.x, mousePos.y, false);
    83                 double dx = mouseGeo.x - mouseStartGeo.x;
    84                 double dy = mouseGeo.y - mouseStartGeo.y;
     82                EastNorth mouseGeo = mv.getEastNorth(e.getX(), e.getY());
     83                EastNorth mouseStartGeo = mv.getEastNorth(mousePos.x, mousePos.y);
     84                double dx = mouseGeo.east() - mouseStartGeo.east();
     85                double dy = mouseGeo.north() - mouseStartGeo.north();
    8586                if (dx == 0 && dy == 0)
    8687                        return;
    8788
    8889                Collection<OsmPrimitive> selection = Main.main.ds.getSelected();
    89                 Collection<Node> affectedNodes = MoveCommand.getAffectedNodes(selection);
     90                Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection);
    9091               
    9192                // check if any coordinate would be outside the world
  • src/org/openstreetmap/josm/actions/mapmode/SelectionAction.java

    r68 r71  
    2727 * If Alt key was hold, select all objects that are touched by the
    2828 * selection rectangle. If the Alt key was not hold, select only those objects
    29  * completly within (e.g. for waies mean: only if all nodes of the way are
     29 * completly within (e.g. for ways mean: only if all nodes of the way are
    3030 * within). 
    3131 *
  • src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java

    r68 r71  
    44import java.awt.event.KeyEvent;
    55
    6 import org.openstreetmap.josm.data.GeoPoint;
     6import org.openstreetmap.josm.data.coor.EastNorth;
    77import org.openstreetmap.josm.gui.MapFrame;
    88import org.openstreetmap.josm.gui.MapView;
     
    5252                if (r.width >= 3 && r.height >= 3) {
    5353                        double scale = mv.getScale() * r.getWidth()/mv.getWidth();
    54                         GeoPoint newCenter = mv.getPoint(r.x+r.width/2, r.y+r.height/2, false);
     54                        EastNorth newCenter = mv.getEastNorth(r.x+r.width/2, r.y+r.height/2);
    5555                        mv.zoomTo(newCenter, scale);
    5656                }
  • src/org/openstreetmap/josm/command/MoveCommand.java

    r34 r71  
    77
    88import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.data.coor.LatLon;
     10import org.openstreetmap.josm.data.coor.EastNorth;
    911import org.openstreetmap.josm.data.osm.Node;
    1012import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    2224         * The objects that should be moved.
    2325         */
    24         public List<Node> objects = new LinkedList<Node>();
     26        public Collection<Node> objects = new LinkedList<Node>();
    2527        /**
    2628         * x difference movement. Coordinates are in northern/eastern
     
    5355                this.x = x;
    5456                this.y = y;
    55                 this.objects = getAffectedNodes(objects);
     57                this.objects = AllNodesVisitor.getAllNodes(objects);
    5658                for (Node n : this.objects) {
    5759                        OldState os = new OldState();
    58                         os.x = n.coor.x;
    59                         os.y = n.coor.y;
    60                         os.lat = n.coor.lat;
    61                         os.lon = n.coor.lon;
     60                        os.x = n.eastNorth.east();
     61                        os.y = n.eastNorth.north();
     62                        os.lat = n.coor.lat();
     63                        os.lon = n.coor.lon();
    6264                        os.modified = n.modified;
    6365                        oldState.add(os);
     
    6567        }
    6668
    67         /**
    68          * @return a list of all nodes that will be moved if using the given set of
    69          * objects.
    70          */
    71         public static List<Node> getAffectedNodes(Collection<OsmPrimitive> objects) {
    72                 AllNodesVisitor visitor = new AllNodesVisitor();
    73                 for (OsmPrimitive osm : objects)
    74                         osm.visit(visitor);
    75                 return new LinkedList<Node>(visitor.nodes);
    76         }
    77        
    7869        /**
    7970         * Move the same set of objects again by the specified vector. The vectors
     
    8677        public void moveAgain(double x, double y) {
    8778                for (Node n : objects) {
    88                         n.coor.x += x;
    89                         n.coor.y += y;
    90                         Main.pref.getProjection().xy2latlon(n.coor);
     79                        n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y);
     80                        n.coor = Main.pref.getProjection().eastNorth2latlon(n.eastNorth);
    9181                }
    9282                this.x += x;
     
    9686        public void executeCommand() {
    9787                for (Node n : objects) {
    98                         n.coor.x += x;
    99                         n.coor.y += y;
    100                         Main.pref.getProjection().xy2latlon(n.coor);
     88                        n.eastNorth = new EastNorth(n.eastNorth.east()+x, n.eastNorth.north()+y);
     89                        n.coor = Main.pref.getProjection().eastNorth2latlon(n.eastNorth);
    10190                        n.modified = true;
    10291                }
     
    10796                for (Node n : objects) {
    10897                        OldState os = it.next();
    109                         n.coor.x = os.x;
    110                         n.coor.y = os.y;
    111                         n.coor.lat = os.lat;
    112                         n.coor.lon = os.lon;
     98                        n.eastNorth = new EastNorth(os.x, os.y);
     99                        n.coor = new LatLon(os.lat, os.lon);
    113100                        n.modified = os.modified;
    114101                }
  • src/org/openstreetmap/josm/data/osm/DataSet.java

    r64 r71  
    55import java.util.LinkedList;
    66
    7 import org.openstreetmap.josm.data.Bounds;
    87import org.openstreetmap.josm.data.SelectionTracker;
    98
     
    2120
    2221        /**
    23          * All nodes goes here, even when included in other data (waies etc).
     22         * All nodes goes here, even when included in other data (ways etc).
    2423         * This enables the instant conversion of the whole DataSet by iterating over
    2524         * this data structure.
     
    3332
    3433        /**
    35          * All waies (Streets etc.) in the DataSet.
     34         * All ways (Streets etc.) in the DataSet.
    3635         *
    3736         * The nodes of the way segments of this way must be objects from
     
    3938         * way list.
    4039         */
    41         public Collection<Way> waies = new LinkedList<Way>();
     40        public Collection<Way> ways = new LinkedList<Way>();
    4241
    4342        /**
     
    4948                o.addAll(nodes);
    5049                o.addAll(lineSegments);
    51                 o.addAll(waies);
     50                o.addAll(ways);
    5251                return o;
    5352        }
     
    6362                return o;
    6463        }
    65        
    66         /**
    67          * Return the bounds of this DataSet, depending on X/Y values.
    68          * The min of the return value is the upper left GeoPoint, the max the lower
    69          * down GeoPoint, regarding to the X/Y values.
    70          *
    71          * Return null, if any point not converted yet or if there are no points at all.
    72          *
    73          * @return Bounding coordinate structure.
    74          */
    75         public Bounds getBoundsXY() {
    76                 if (nodes.isEmpty())
    77                         return null;
    78 
    79                 Node first = nodes.iterator().next();
    80                 Bounds b = new Bounds(first.coor.clone(), first.coor.clone());
    81                 for (Node w : nodes)
    82                 {
    83                         if (Double.isNaN(w.coor.x) || Double.isNaN(w.coor.y))
    84                                 return null;
    85                         if (w.coor.x < b.min.x)
    86                                 b.min.x = w.coor.x;
    87                         if (w.coor.y < b.min.y)
    88                                 b.min.y = w.coor.y;
    89                         if (w.coor.x > b.max.x)
    90                                 b.max.x = w.coor.x;
    91                         if (w.coor.y > b.max.y)
    92                                 b.max.y = w.coor.y;
    93                 }
    94                 return b;
    95         }
    96 
    97         /**
    98          * Return the bounds of this DataSet, depending on lat/lon values.
    99          * The min of the return value is the upper left GeoPoint, the max the lower
    100          * down GeoPoint.
    101          *
    102          * Return null, if any point does not have lat/lon or if there are no
    103          * points at all.
    104          *
    105          * @return Bounding coordinate structure.
    106          */
    107         public Bounds getBoundsLatLon() {
    108                 if (nodes.isEmpty())
    109                         return null;
    110 
    111                 Node first = nodes.iterator().next();
    112                 Bounds b = new Bounds(first.coor.clone(), first.coor.clone());
    113                 for (Node w : nodes)
    114                 {
    115                         if (Double.isNaN(w.coor.lat) || Double.isNaN(w.coor.lon))
    116                                 return null;
    117                         if (w.coor.lat < b.min.lat)
    118                                 b.min.lat = w.coor.lat;
    119                         if (w.coor.lon < b.min.lon)
    120                                 b.min.lon = w.coor.lon;
    121                         if (w.coor.lat > b.max.lat)
    122                                 b.max.lat = w.coor.lat;
    123                         if (w.coor.lon > b.max.lon)
    124                                 b.max.lon = w.coor.lon;
    125                 }
    126                 return b;
    127         }
    12864
    12965        /**
     
    13369                clearSelection(nodes);
    13470                clearSelection(lineSegments);
    135                 clearSelection(waies);
     71                clearSelection(ways);
    13672        }
    13773
     
    14480                Collection<OsmPrimitive> sel = getSelected(nodes);
    14581                sel.addAll(getSelected(lineSegments));
    146                 sel.addAll(getSelected(waies));
     82                sel.addAll(getSelected(ways));
    14783                return sel;
    14884        }
  • src/org/openstreetmap/josm/data/osm/LineSegment.java

    r66 r71  
    11package org.openstreetmap.josm.data.osm;
    22
    3 import org.openstreetmap.josm.data.GeoPoint;
    43import org.openstreetmap.josm.data.osm.visitor.Visitor;
    54
     
    1615         */
    1716        public Node from;
    18        
     17
    1918        /**
    2019         * The ending node of the line segment
     
    4847                visitor.visit(this);
    4948        }
    50        
     49
    5150        /**
    5251         * @return <code>true</code>, if the <code>ls</code> occupy
     
    5756                        return true;
    5857                if (incomplete || ls.incomplete)
    59                         return false;
    60                 GeoPoint s1 = from.coor;
    61                 GeoPoint s2 = ls.from.coor;
    62                 GeoPoint e1 = to.coor;
    63                 GeoPoint e2 = ls.to.coor;
    64                 return ((s1.equalsLatLon(s2) && e1.equalsLatLon(e2)) ||
    65                                 (s1.equalsLatLon(e2) && e1.equalsLatLon(s2)));
     58                        return incomplete == ls.incomplete;
     59                return ((from.coor.equals(ls.from.coor) && to.coor.equals(ls.to.coor)) ||
     60                                (from.coor.equals(ls.to.coor) && to.coor.equals(ls.from.coor)));
    6661        }
    6762
  • src/org/openstreetmap/josm/data/osm/Node.java

    r66 r71  
    11package org.openstreetmap.josm.data.osm;
    22
    3 import org.openstreetmap.josm.data.GeoPoint;
     3import org.openstreetmap.josm.Main;
     4import org.openstreetmap.josm.data.coor.LatLon;
     5import org.openstreetmap.josm.data.coor.EastNorth;
    46import org.openstreetmap.josm.data.osm.visitor.Visitor;
    57
     
    1214public class Node extends OsmPrimitive {
    1315       
    14         /**
    15          * The coordinates of this node.
    16          */
    17         public GeoPoint coor;
     16        public LatLon coor;
     17        public EastNorth eastNorth;
    1818
    19         public Node(GeoPoint coor) {
    20                 this.coor = coor;
     19        public Node(LatLon latlon) {
     20                this.coor = latlon;
     21                eastNorth = Main.pref.getProjection().latlon2eastNorth(latlon);
    2122        }
    2223
     
    2829        @Override
    2930        public String toString() {
    30                 return "{Node id="+id+",lat="+coor.lat+",lon="+coor.lon+"}";
     31                return "{Node id="+id+",lat="+coor.lat()+",lon="+coor.lon()+"}";
    3132        }
    3233
     
    3435        public void cloneFrom(OsmPrimitive osm) {
    3536                super.cloneFrom(osm);
    36                 GeoPoint g = ((Node)osm).coor;
    37                 coor = new GeoPoint(g.lat, g.lon, g.x, g.y); //TODO: Make GeoPoint immutable!
     37                coor = ((Node)osm).coor;
     38                eastNorth = ((Node)osm).eastNorth;
    3839        }
    3940}
  • src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java

    r64 r71  
    3030        }
    3131        public void visit(Way t) {
    32                 ds.waies.add(t);
     32                ds.ways.add(t);
    3333        }
    3434}
  • src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java

    r66 r71  
    4949         * @return All nodes the given primitive has.
    5050         */
    51         public static Collection<Node> getAllNodes(OsmPrimitive osm) {
     51        public static Collection<Node> getAllNodes(Collection<? extends OsmPrimitive> osms) {
    5252                AllNodesVisitor v = new AllNodesVisitor();
    53                 osm.visit(v);
     53                for (OsmPrimitive osm : osms)
     54                        osm.visit(v);
    5455                return v.nodes;
    5556        }
  • src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r66 r71  
    11package org.openstreetmap.josm.data.osm.visitor;
    22
     3import org.openstreetmap.josm.Main;
    34import org.openstreetmap.josm.data.Bounds;
     5import org.openstreetmap.josm.data.coor.EastNorth;
    46import org.openstreetmap.josm.data.osm.LineSegment;
    57import org.openstreetmap.josm.data.osm.Node;
     
    79
    810/**
    9  * Calculates the total bounding rectangle of a serie of OsmPrimitives.
     11 * Calculates the total bounding rectangle of a serie of OsmPrimitives, using the EastNorth values
     12 * as reference.
    1013 * @author imi
    1114 */
    12 public class BoundingVisitor implements Visitor {
     15public class BoundingXYVisitor implements Visitor {
    1316
    14         /**
    15          * The bounding rectangle of all primitives visited so far.
    16          */
    17         public Bounds bounds;
    18 
    19         /**
    20          * Calculate regarding lat/lon or x/y?
    21          */
    22         public static enum Type {LATLON, XY}
    23         private Type type;
    24 
    25 
    26         public BoundingVisitor(Type type) {
    27                 this.type = type;
    28         }
    29        
     17        public EastNorth min, max;
    3018
    3119        public void visit(Node n) {
    32                 if (bounds == null)
    33                         bounds = new Bounds(n.coor.clone(), n.coor.clone());
    34                 else {
    35                         if (type == Type.LATLON) {
    36                                 bounds.min.lat = Math.min(bounds.min.lat, n.coor.lat);
    37                                 bounds.min.lon = Math.min(bounds.min.lon, n.coor.lon);
    38                                 bounds.max.lat = Math.max(bounds.max.lat, n.coor.lat);
    39                                 bounds.max.lon = Math.max(bounds.max.lon, n.coor.lon);
    40                         } else {
    41                                 bounds.min.x = Math.min(bounds.min.x, n.coor.x);
    42                                 bounds.min.y = Math.min(bounds.min.y, n.coor.y);
    43                                 bounds.max.x = Math.max(bounds.max.x, n.coor.x);
    44                                 bounds.max.y = Math.max(bounds.max.y, n.coor.y);
    45                         }
    46                 }
     20                visit(n.eastNorth);
    4721        }
    4822
     
    5832                        visit(ls);
    5933        }
     34
     35        public void visit(EastNorth eastNorth) {
     36                if (eastNorth != null) {
     37                        if (min == null)
     38                                min = eastNorth;
     39                        else if (eastNorth.east() < min.east() || eastNorth.north() < min.north())
     40                                min = new EastNorth(Math.min(min.east(), eastNorth.east()), Math.min(min.north(), eastNorth.north()));
     41                       
     42                        if (max == null)
     43                                max = eastNorth;
     44                        else if (eastNorth.east() > max.east() || eastNorth.north() > max.north())
     45                                max = new EastNorth(Math.max(max.east(), eastNorth.east()), Math.max(max.north(), eastNorth.north()));
     46                }
     47        }
     48
     49        /**
     50         * @return The bounding box or <code>null</code> if no coordinates have passed
     51         */
     52        public Bounds getBounds() {
     53                if (min == null || max == null)
     54                        return null;
     55                return new Bounds(Main.pref.getProjection().eastNorth2latlon(min), Main.pref.getProjection().eastNorth2latlon(max));
     56        }
    6057}
    61 
  • src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java

    r66 r71  
    1111
    1212/**
    13  * Helper that collect all line segments a node is part of, all waies
     13 * Helper that collect all line segments a node is part of, all ways
    1414 * a node or line segment is part of and all areas a node is part of.
    1515 *
     
    3737       
    3838        public void visit(Node n) {
    39                 for (Way t : ds.waies) {
     39                for (Way t : ds.ways) {
    4040                        if (t.isDeleted())
    4141                                continue;
     
    5757        }
    5858        public void visit(LineSegment ls) {
    59                 for (Way t : ds.waies) {
     59                for (Way t : ds.ways) {
    6060                        if (t.isDeleted())
    6161                                continue;
  • src/org/openstreetmap/josm/data/osm/visitor/DeleteVisitor.java

    r64 r71  
    3030        }
    3131        public void visit(Way t) {
    32                 ds.waies.remove(t);
     32                ds.ways.remove(t);
    3333        }
    3434}
  • src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

    r66 r71  
    5858                        if (myNode.modified && !otherNode.modified)
    5959                                return;
    60                         if (!myNode.coor.equalsLatLonEpsilon(otherNode.coor)) {
     60                        if (!myNode.coor.equalsEpsilon(otherNode.coor)) {
    6161                                myNode.coor = otherNode.coor;
    6262                                myNode.modified = otherNode.modified;
     
    104104        public void visit(Way otherWay) {
    105105                Way myWay = null;
    106                 for (Way t : ds.waies) {
     106                for (Way t : ds.ways) {
    107107                        if (match(otherWay, t)) {
    108108                                myWay = t;
     
    111111                }
    112112                if (myWay == null)
    113                         ds.waies.add(otherWay);
     113                        ds.ways.add(otherWay);
    114114                else {
    115115                        mergeCommon(myWay, otherWay);
     
    141141                                ls.to = mergedNodes.get(ls.to);
    142142                }
    143                 for (Way t : ds.waies) {
     143                for (Way t : ds.ways) {
    144144                        boolean replacedSomething = false;
    145145                        LinkedList<LineSegment> newSegments = new LinkedList<LineSegment>();
     
    168168        private boolean match(Node n1, Node n2) {
    169169                if (n1.id == 0 || n2.id == 0)
    170                         return n1.coor.equalsLatLonEpsilon(n2.coor);
     170                        return n1.coor.equalsEpsilon(n2.coor);
    171171                return n1.id == n2.id;
    172172        }
     
    184184
    185185        /**
    186          * @return Whether the waies matches (in sense of "be mergable").
     186         * @return Whether the ways matches (in sense of "be mergable").
    187187         */
    188188        private boolean match(Way t1, Way t2) {
  • src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java

    r66 r71  
    1010import org.openstreetmap.josm.data.osm.Node;
    1111import org.openstreetmap.josm.data.osm.Way;
    12 import org.openstreetmap.josm.gui.ImageProvider;
     12import org.openstreetmap.josm.tools.ImageProvider;
    1313
    1414/**
     
    3636        public void visit(LineSegment ls) {
    3737                name = ls.get("name");
    38                 if (name == null && ls.incomplete)
    39                         name = ""+ls.id;
    40                 if (name == null)
    41                         name = "("+ls.from.coor.lat+","+ls.from.coor.lon+") -> ("+ls.to.coor.lat+","+ls.to.coor.lon+")";
     38                if (name == null) {
     39                        if (ls.incomplete)
     40                                name = ""+ls.id;
     41                        else
     42                                name = ls.id+" ("+ls.from.coor.lat()+","+ls.from.coor.lon()+") -> ("+ls.to.coor.lat()+","+ls.to.coor.lon()+")";
     43                }
    4244                icon = ImageProvider.get("data", "linesegment");
    4345        }
     
    5052                name = n.get("name");
    5153                if (name == null)
    52                         name = "("+n.coor.lat+","+n.coor.lon+")";
     54                        name = n.id+" ("+n.coor.lat()+","+n.coor.lon()+")";
    5355                icon = ImageProvider.get("data", "node");
    5456        }
     
    6163                name = w.get("name");
    6264                if (name == null) {
     65                        AllNodesVisitor.getAllNodes(w.segments);
    6366                        Set<Node> nodes = new HashSet<Node>();
    6467                        for (LineSegment ls : w.segments) {
  • src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

    r66 r71  
    8484         */
    8585        private void drawNode(Node n, Color color) {
    86                 Point p = nc.getScreenPoint(n.coor);
     86                Point p = nc.getPoint(n.eastNorth);
    8787                g.setColor(color);
    8888                g.drawRect(p.x-1, p.y-1, 2, 2);
     
    9898                        col = Color.WHITE;
    9999                g.setColor(col);
    100                 Point p1 = nc.getScreenPoint(ls.from.coor);
    101                 Point p2 = nc.getScreenPoint(ls.to.coor);
     100                Point p1 = nc.getPoint(ls.from.eastNorth);
     101                Point p2 = nc.getPoint(ls.to.eastNorth);
    102102                g.drawLine(p1.x, p1.y, p2.x, p2.y);
    103103        }
  • src/org/openstreetmap/josm/data/projection/Epsg4263.java

    r52 r71  
    11package org.openstreetmap.josm.data.projection;
    22
    3 import org.openstreetmap.josm.data.GeoPoint;
     3import org.openstreetmap.josm.data.coor.LatLon;
     4import org.openstreetmap.josm.data.coor.EastNorth;
    45
    56/**
     
    1011public class Epsg4263 implements Projection {
    1112
    12         public void latlon2xy(GeoPoint p) {
    13                 p.x = p.lon;
    14                 p.y = p.lat;
     13        public EastNorth latlon2eastNorth(LatLon p) {
     14                return new EastNorth(p.lon(), p.lat());
    1515        }
    1616
    17         public void xy2latlon(GeoPoint p) {
    18                 p.lat = p.y;
    19                 p.lon = p.x;
     17        public LatLon eastNorth2latlon(EastNorth p) {
     18                return new LatLon(p.north(), p.east());
    2019        }
    2120
  • src/org/openstreetmap/josm/data/projection/Mercator.java

    r52 r71  
    11package org.openstreetmap.josm.data.projection;
    22
    3 import org.openstreetmap.josm.data.GeoPoint;
     3import org.openstreetmap.josm.data.coor.LatLon;
     4import org.openstreetmap.josm.data.coor.EastNorth;
    45
    56/**
     
    1415public class Mercator implements Projection {
    1516
    16         public void latlon2xy(GeoPoint p) {
    17                 p.x = p.lon*Math.PI/180;
    18                 p.y = Math.log(Math.tan(Math.PI/4+p.lat*Math.PI/360));
     17        public EastNorth latlon2eastNorth(LatLon p) {
     18                return new EastNorth(
     19                        p.lon()*Math.PI/180,
     20                        Math.log(Math.tan(Math.PI/4+p.lat()*Math.PI/360)));
    1921        }
    2022
    21         public void xy2latlon(GeoPoint p) {
    22                 p.lon = p.x*180/Math.PI;
    23                 p.lat = Math.atan(Math.sinh(p.y))*180/Math.PI;
     23        public LatLon eastNorth2latlon(EastNorth p) {
     24                return new LatLon(
     25                        p.east()*180/Math.PI,
     26                        Math.atan(Math.sinh(p.north()))*180/Math.PI);
    2427        }
    2528
  • src/org/openstreetmap/josm/data/projection/Projection.java

    r58 r71  
    11package org.openstreetmap.josm.data.projection;
    22
    3 import org.openstreetmap.josm.data.GeoPoint;
     3import org.openstreetmap.josm.data.coor.LatLon;
     4import org.openstreetmap.josm.data.coor.EastNorth;
    45
    56/**
     
    2021         * @param p             The geo point to convert. x/y members of the point are filled.
    2122         */
    22         void latlon2xy(GeoPoint p);
     23        EastNorth latlon2eastNorth(LatLon p);
    2324       
    2425        /**
     
    2728         * @param p             The geo point to convert. lat/lon members of the point are filled.
    2829         */
    29         void xy2latlon(GeoPoint p);
     30        LatLon eastNorth2latlon(EastNorth p);
    3031
    3132        /**
  • src/org/openstreetmap/josm/gui/BookmarkList.java

    r41 r71  
    1818import org.openstreetmap.josm.Main;
    1919import org.openstreetmap.josm.data.Preferences;
     20import org.openstreetmap.josm.tools.ImageProvider;
    2021
    2122/**
  • src/org/openstreetmap/josm/gui/MapMover.java

    r66 r71  
    88import java.awt.event.MouseWheelListener;
    99
    10 import org.openstreetmap.josm.data.GeoPoint;
     10import org.openstreetmap.josm.data.coor.EastNorth;
    1111
    1212/**
     
    2222         * when moving around started.
    2323         */
    24         private GeoPoint mousePosMove;
     24        private EastNorth mousePosMove;
    2525        /**
    2626         * The map to move around.
     
    5151                        if (mousePosMove == null)
    5252                                startMovement(e);
    53                         GeoPoint center = nc.getCenter();
    54                         GeoPoint mouseCenter = nc.getPoint(e.getX(), e.getY(), false);
    55                         GeoPoint p = new GeoPoint();
    56                         p.x = mousePosMove.x + center.x - mouseCenter.x; 
    57                         p.y = mousePosMove.y + center.y - mouseCenter.y;
     53                        EastNorth center = nc.getCenter();
     54                        EastNorth mouseCenter = nc.getEastNorth(e.getX(), e.getY());
     55                        EastNorth p = new EastNorth(
     56                                        mousePosMove.east() + center.east() - mouseCenter.east(),
     57                                        mousePosMove.north() + center.north() - mouseCenter.north());
    5858                        nc.zoomTo(p, nc.getScale());
    5959                } else
     
    8686         */
    8787        private void startMovement(MouseEvent e) {
    88                 mousePosMove = nc.getPoint(e.getX(), e.getY(), false);
     88                mousePosMove = nc.getEastNorth(e.getX(), e.getY());
    8989                oldCursor = nc.getCursor();
    9090                nc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
     
    108108         */
    109109        public void mouseWheelMoved(MouseWheelEvent e) {
     110                int w = nc.getWidth();
     111                int h = nc.getHeight();
     112
    110113                double zoom = Math.max(0.1, 1 + e.getWheelRotation()/5.0);
    111                 double zoomfactor = (zoom -1)/2+1;
    112                 int newHalfWidth = (int) (nc.getWidth()*zoomfactor - nc.getWidth()/2);
    113                 int centerx = e.getX() - (e.getX()-nc.getWidth()/2)*newHalfWidth*2/nc.getWidth();
    114                 int newHalfHeight = (int) (nc.getHeight()*zoomfactor - nc.getHeight()/2);
    115                 int centery = e.getY() - (e.getY()-nc.getHeight()/2)*newHalfHeight*2/nc.getHeight();
    116                 GeoPoint newCenter = nc.getPoint(centerx, centery, false);
     114                double zoomfactor = (zoom-1)/2+1;
     115
     116                double newHalfWidth = w*zoomfactor - w/2;
     117                double newHalfHeight = h*zoomfactor - h/2;
     118                double centerx = e.getX() - (e.getX()-w/2)*newHalfWidth*2/w;
     119                double centery = e.getY() - (e.getY()-h/2)*newHalfHeight*2/h;
     120                EastNorth newCenter = nc.getEastNorth((int)centerx, (int)centery);
     121               
    117122                nc.zoomTo(newCenter, nc.getScale()*zoom);
    118123        }
  • src/org/openstreetmap/josm/gui/MapStatus.java

    r66 r71  
    2727
    2828import org.openstreetmap.josm.Main;
    29 import org.openstreetmap.josm.data.GeoPoint;
     29import org.openstreetmap.josm.data.coor.LatLon;
    3030import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3131import org.openstreetmap.josm.data.osm.visitor.SelectionComponentVisitor;
     32import org.openstreetmap.josm.tools.GBC;
    3233
    3334/**
     
    205206                                // Do not update the view, if ctrl is pressed.
    206207                                if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) == 0) {
    207                                         GeoPoint p = mv.getPoint(e.getX(),e.getY(),true);
    208                                         positionText.setText(p.lat+" "+p.lon);
     208                                        LatLon p = mv.getLatLon(e.getX(),e.getY());
     209                                        positionText.setText(p.lat()+" "+p.lon());
    209210                                }
    210211                        }
  • src/org/openstreetmap/josm/gui/MapView.java

    r51 r71  
    1818import org.openstreetmap.josm.Main;
    1919import org.openstreetmap.josm.data.Bounds;
    20 import org.openstreetmap.josm.data.GeoPoint;
     20import org.openstreetmap.josm.data.coor.EastNorth;
    2121import org.openstreetmap.josm.data.osm.DataSet;
     22import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    2223import org.openstreetmap.josm.data.projection.Projection;
    2324import org.openstreetmap.josm.gui.layer.Layer;
     
    176177                g.setColor(Color.WHITE);
    177178                Bounds b = new Bounds();
    178                 Point min = getScreenPoint(b.min);
    179                 Point max = getScreenPoint(b.max);
     179                Point min = getPoint(getProjection().latlon2eastNorth(b.min));
     180                Point max = getPoint(getProjection().latlon2eastNorth(b.max));
    180181                int x1 = Math.min(min.x, max.x);
    181182                int y1 = Math.min(min.y, max.y);
     
    217218                                h = 20;
    218219
    219                         Bounds bounds = null;
    220                         for (Layer l : layers) {
    221                                 if (bounds == null)
    222                                         bounds = l.getBoundsXY();
    223                                 else {
    224                                         Bounds lb = l.getBoundsXY();
    225                                         if (lb != null)
    226                                                 bounds = bounds.mergeXY(lb);
    227                                 }
    228                         }
     220                        BoundingXYVisitor v = new BoundingXYVisitor();
     221                        for (Layer l : layers)
     222                                l.visitBoundingBox(v);
    229223
    230224                        boolean oldAutoScale = autoScale;
    231                         GeoPoint oldCenter = center;
     225                        EastNorth oldCenter = center;
    232226                        double oldScale = this.scale;
    233227                       
    234                         if (bounds == null) {
     228                        if (v.min == null || v.max == null) {
    235229                                // no bounds means standard scale and center
    236                                 center = new GeoPoint(51.526447, -0.14746371);
    237                                 getProjection().latlon2xy(center);
     230                                center = new EastNorth(51.526447, -0.14746371);
    238231                                scale = 10;
    239232                        } else {
    240                                 center = bounds.centerXY();
    241                                 getProjection().xy2latlon(center);
    242                                 double scaleX = (bounds.max.x-bounds.min.x)/w;
    243                                 double scaleY = (bounds.max.y-bounds.min.y)/h;
     233                                center = new EastNorth(v.min.east()/2+v.max.east()/2, v.min.north()/2+v.max.north()/2);
     234                                double scaleX = (v.max.east()-v.min.east())/w;
     235                                double scaleY = (v.max.north()-v.min.north())/h;
    244236                                scale = Math.max(scaleX, scaleY); // minimum scale to see all of the screen
    245237                        }
    246238       
    247                         firePropertyChange("center", oldCenter, center);
     239                        if (!center.equals(oldCenter))
     240                                firePropertyChange("center", oldCenter, center);
    248241                        if (oldAutoScale != autoScale)
    249242                                firePropertyChange("autoScale", oldAutoScale, autoScale);
     
    318311         */
    319312        @Override
    320         public void zoomTo(GeoPoint newCenter, double scale) {
     313        public void zoomTo(EastNorth newCenter, double scale) {
    321314                boolean oldAutoScale = autoScale;
    322                 GeoPoint oldCenter = center;
     315                EastNorth oldCenter = center;
    323316                double oldScale = this.scale;
    324317                autoScale = false;
     
    328321                recalculateCenterScale();
    329322               
    330                 firePropertyChange("center", oldCenter, center);
     323                if (!oldCenter.equals(center))
     324                        firePropertyChange("center", oldCenter, center);
    331325                if (oldAutoScale != autoScale)
    332326                        firePropertyChange("autoScale", oldAutoScale, autoScale);
  • src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r66 r71  
    88
    99import org.openstreetmap.josm.Main;
    10 import org.openstreetmap.josm.data.GeoPoint;
     10import org.openstreetmap.josm.data.coor.LatLon;
     11import org.openstreetmap.josm.data.coor.EastNorth;
    1112import org.openstreetmap.josm.data.osm.LineSegment;
    1213import org.openstreetmap.josm.data.osm.Node;
     
    3233         * Center n/e coordinate of the desired screen center.
    3334         */
    34         protected GeoPoint center;
     35        protected EastNorth center;
    3536
    3637        /**
     
    4647         *              change the center by accessing the return value. Use zoomTo instead.
    4748         */
    48         public GeoPoint getCenter() {
    49                 return center.clone();
    50         }
    51 
    52         /**
    53          * Get geographic coordinates from a specific pixel coordination
    54          * on the screen.
    55          *
    56          * If you don't need it, provide false at third parameter to speed
    57          * up the calculation.
    58          * 
     49        public EastNorth getCenter() {
     50                return center;
     51        }
     52
     53        /**
    5954         * @param x X-Pixelposition to get coordinate from
    6055         * @param y Y-Pixelposition to get coordinate from
    61          * @param latlon If set, the return value will also have the
    62          *                               latitude/longitude filled.
    63          *
    64          * @return The geographic coordinate, filled with x/y (northing/easting)
    65          *              settings and, if requested with latitude/longitude.
    66          */
    67         public GeoPoint getPoint(int x, int y, boolean latlon) {
    68                 GeoPoint p = new GeoPoint();
    69                 p.x = center.x + (x - getWidth()/2.0)*scale;
    70                 p.y = center.y - (y - getHeight()/2.0)*scale;
    71                 if (latlon)
    72                         getProjection().xy2latlon(p);
    73                 return p;
    74         }
    75 
    76         /**
    77          * Return the point on the screen where this GeoPoint would be.
     56         *
     57         * @return Geographic coordinates from a specific pixel coordination
     58         *              on the screen.
     59         */
     60        public EastNorth getEastNorth(int x, int y) {
     61                return new EastNorth(
     62                                center.east() + (x - getWidth()/2.0)*scale,
     63                                center.north() - (y - getHeight()/2.0)*scale);
     64        }
     65
     66        /**
     67         * @param x X-Pixelposition to get coordinate from
     68         * @param y Y-Pixelposition to get coordinate from
     69         *
     70         * @return Geographic unprojected coordinates from a specific pixel coordination
     71         *              on the screen.
     72         */
     73        public LatLon getLatLon(int x, int y) {
     74                EastNorth eastNorth = new EastNorth(
     75                                center.east() + (x - getWidth()/2.0)*scale,
     76                                center.north() - (y - getHeight()/2.0)*scale);
     77                return Main.pref.getProjection().eastNorth2latlon(eastNorth);
     78        }
     79
     80        /**
     81         * Return the point on the screen where this Coordinate would be.
    7882         * @param point The point, where this geopoint would be drawn.
    7983         * @return The point on screen where "point" would be drawn, relative
    8084         *              to the own top/left.
    8185         */
    82         public Point getScreenPoint(GeoPoint point) {
    83                 GeoPoint p;
    84                 if (!Double.isNaN(point.x) && !Double.isNaN(point.y))
    85                         p = point;
    86                 else {
    87                         if (Double.isNaN(point.lat) || Double.isNaN(point.lon))
    88                                 throw new IllegalArgumentException("point: Either lat/lon or x/y must be set.");
    89                         p = point.clone();
    90                         getProjection().latlon2xy(p);
    91                 }
    92                 double x = (p.x-center.x)/scale + getWidth()/2;
    93                 double y = (center.y-p.y)/scale + getHeight()/2;
     86        public Point getPoint(EastNorth p) {
     87                double x = (p.east()-center.east())/scale + getWidth()/2;
     88                double y = (center.north()-p.north())/scale + getHeight()/2;
    9489                return new Point((int)x,(int)y);
    9590        }
     
    10196         * @param scale The scale to use.
    10297         */
    103         public void zoomTo(GeoPoint newCenter, double scale) {
    104                 center = newCenter.clone();
    105                 getProjection().xy2latlon(center);
     98        public void zoomTo(EastNorth newCenter, double scale) {
     99                center = newCenter;
     100                getProjection().eastNorth2latlon(center);
    106101                this.scale = scale;
    107102                repaint();
     
    127122         *
    128123         * @param p                              The point on screen.
    129          * @param lsInsteadWay Whether the line segment (true) or only the whole
     124         * @param segmentInsteadWay Whether the line segment (true) or only the whole
    130125         *                                               way should be returned.
    131126         * @return      The primitive, that is nearest to the point p.
    132127         */
    133         public OsmPrimitive getNearest(Point p, boolean lsInsteadWay) {
     128        public OsmPrimitive getNearest(Point p, boolean segmentInsteadWay) {
    134129                double minDistanceSq = Double.MAX_VALUE;
    135130                OsmPrimitive minPrimitive = null;
     
    139134                        if (n.isDeleted())
    140135                                continue;
    141                         Point sp = getScreenPoint(n.coor);
     136                        Point sp = getPoint(n.eastNorth);
    142137                        double dist = p.distanceSq(sp);
    143138                        if (minDistanceSq > dist && dist < 100) {
     
    151146                // for whole ways, try the ways first
    152147                minDistanceSq = Double.MAX_VALUE;
    153                 if (!lsInsteadWay) {
    154                         for (Way w : Main.main.ds.waies) {
     148                if (!segmentInsteadWay) {
     149                        for (Way w : Main.main.ds.ways) {
    155150                                if (w.isDeleted())
    156151                                        continue;
     
    158153                                        if (ls.isDeleted() || ls.incomplete)
    159154                                                continue;
    160                                         Point A = getScreenPoint(ls.from.coor);
    161                                         Point B = getScreenPoint(ls.to.coor);
     155                                        Point A = getPoint(ls.from.eastNorth);
     156                                        Point B = getPoint(ls.to.eastNorth);
    162157                                        double c = A.distanceSq(B);
    163158                                        double a = p.distanceSq(B);
     
    179174                        if (ls.isDeleted() || ls.incomplete)
    180175                                continue;
    181                         Point A = getScreenPoint(ls.from.coor);
    182                         Point B = getScreenPoint(ls.to.coor);
     176                        Point A = getPoint(ls.from.eastNorth);
     177                        Point B = getPoint(ls.to.eastNorth);
    183178                        double c = A.distanceSq(B);
    184179                        double a = p.distanceSq(B);
     
    201196         * If its a node, return all line segments and
    202197         * streets the node is part of, as well as all nodes
    203          * (with their line segments and waies) with the same
     198         * (with their line segments and ways) with the same
    204199         * location.
    205200         *
    206          * If its a line segment, return all waies this segment
     201         * If its a line segment, return all ways this segment
    207202         * belongs to as well as all line segments that are between
    208          * the same nodes (in both direction) with all their waies.
     203         * the same nodes (in both direction) with all their ways.
    209204         *
    210205         * @return A collection of all items or <code>null</code>
     
    221216                        Node node = (Node)osm;
    222217                        for (Node n : Main.main.ds.nodes)
    223                                 if (!n.isDeleted() && n.coor.equalsLatLon(node.coor))
     218                                if (!n.isDeleted() && n.coor.equals(node.coor))
    224219                                        c.add(n);
    225220                        for (LineSegment ls : Main.main.ds.lineSegments)
     
    235230                }
    236231                if (osm instanceof Node || osm instanceof LineSegment) {
    237                         for (Way t : Main.main.ds.waies) {
     232                        for (Way t : Main.main.ds.ways) {
    238233                                if (t.isDeleted())
    239234                                        continue;
  • src/org/openstreetmap/josm/gui/PreferenceDialog.java

    r64 r71  
    3131import org.openstreetmap.josm.data.Preferences.PreferencesException;
    3232import org.openstreetmap.josm.data.projection.Projection;
     33import org.openstreetmap.josm.tools.GBC;
     34import org.openstreetmap.josm.tools.ImageProvider;
    3335
    3436/**
  • src/org/openstreetmap/josm/gui/SelectionManager.java

    r66 r71  
    257257         * @param alt Whether the alt key was pressed, which means select all objects
    258258         *              that are touched, instead those which are completly covered. Also
    259          *              select whole waies instead of line segments.
     259         *              select whole ways instead of line segments.
    260260         */
    261261        public Collection<OsmPrimitive> getObjectsInRectangle(Rectangle r, boolean alt) {
     
    273273                        // nodes
    274274                        for (Node n : Main.main.ds.nodes) {
    275                                 if (r.contains(nc.getScreenPoint(n.coor)))
     275                                if (r.contains(nc.getPoint(n.eastNorth)))
    276276                                        selection.add(n);
    277277                        }
     
    282282                                        selection.add(ls);
    283283
    284                         // waies
    285                         for (Way t : Main.main.ds.waies) {
     284                        // ways
     285                        for (Way t : Main.main.ds.ways) {
    286286                                boolean wholeWaySelected = !t.segments.isEmpty();
    287287                                for (LineSegment ls : t.segments)
     
    312312                        return false;
    313313                if (alt) {
    314                         Point p1 = nc.getScreenPoint(ls.from.coor);
    315                         Point p2 = nc.getScreenPoint(ls.to.coor);
     314                        Point p1 = nc.getPoint(ls.from.eastNorth);
     315                        Point p2 = nc.getPoint(ls.to.eastNorth);
    316316                        if (r.intersectsLine(p1.x, p1.y, p2.x, p2.y))
    317317                                return true;
    318318                } else {
    319                         if (r.contains(nc.getScreenPoint(ls.from.coor))
    320                                         && r.contains(nc.getScreenPoint(ls.to.coor)))
     319                        if (r.contains(nc.getPoint(ls.from.eastNorth))
     320                                        && r.contains(nc.getPoint(ls.to.eastNorth)))
    321321                                return true;
    322322                }
  • src/org/openstreetmap/josm/gui/WorldChooser.java

    r55 r71  
    1919
    2020import org.openstreetmap.josm.Main;
    21 import org.openstreetmap.josm.data.Bounds;
    22 import org.openstreetmap.josm.data.GeoPoint;
     21import org.openstreetmap.josm.data.coor.LatLon;
     22import org.openstreetmap.josm.data.coor.EastNorth;
    2323import org.openstreetmap.josm.data.projection.Projection;
    2424import org.openstreetmap.josm.gui.BookmarkList.Bookmark;
     
    4848         * Mark this rectangle (lat/lon values) when painting.
    4949         */
    50         protected Bounds marker;
     50        private EastNorth markerMin, markerMax;
    5151
    5252        private Projection projection;
     
    5858                URL path = Main.class.getResource("/images/world.jpg");
    5959                world = new ImageIcon(path);
    60                 center = new GeoPoint(0,0,world.getIconWidth()/2, world.getIconHeight()/2);
     60                center = new EastNorth(world.getIconWidth()/2, world.getIconHeight()/2);
    6161                setPreferredSize(new Dimension(200, 100));
    6262                new MapMover(this);
    63                 projection = new Projection(){
    64                         public void latlon2xy(GeoPoint p) {
    65                                 p.x = (p.lon+180) / 360 * world.getIconWidth();
    66                                 p.y = (p.lat+90) / 180 * world.getIconHeight();
    67                         }
    68                         public void xy2latlon(GeoPoint p) {
    69                                 p.lon = p.x*360/world.getIconWidth() - 180;
    70                                 p.lat = p.y*180/world.getIconHeight() - 90;
     63                projection = new Projection() {
     64                        public EastNorth latlon2eastNorth(LatLon p) {
     65                                return new EastNorth(
     66                                                (p.lon()+180) / 360 * world.getIconWidth(),
     67                                                (p.lat()+90) / 180 * world.getIconHeight());
     68                        }
     69                        public LatLon eastNorth2latlon(EastNorth p) {
     70                                return new LatLon(
     71                                                p.east()*360/world.getIconWidth() - 180,
     72                                                p.north()*180/world.getIconHeight() - 90);
    7173                        }
    7274                        @Override
     
    9496        @Override
    9597        public void paint(Graphics g) {
    96                 GeoPoint tl = getPoint(0,0,false);
    97                 GeoPoint br = getPoint(getWidth(),getHeight(),false);
    98                 g.drawImage(world.getImage(),0,0,getWidth(),getHeight(),(int)tl.x,(int)tl.y,(int)br.x,(int)br.y, null);
     98                EastNorth tl = getEastNorth(0,0);
     99                EastNorth br = getEastNorth(getWidth(),getHeight());
     100                g.drawImage(world.getImage(),0,0,getWidth(),getHeight(),(int)tl.east(),(int)tl.north(),(int)br.east(),(int)br.north(), null);
    99101
    100102                // draw marker rect
    101                 if (marker != null) {
    102                         Point p1 = getScreenPoint(marker.min);
    103                         Point p2 = getScreenPoint(marker.max);
     103                if (markerMin != null && markerMax != null) {
     104                        Point p1 = getPoint(markerMin);
     105                        Point p2 = getPoint(markerMax);
    104106                        double x = Math.min(p1.x, p2.x);
    105107                        double y = Math.min(p1.y, p2.y);
     
    117119
    118120        @Override
    119         public void zoomTo(GeoPoint newCenter, double scale) {
     121        public void zoomTo(EastNorth newCenter, double scale) {
    120122                if (getWidth() != 0 && scale > scaleMax)
    121123                        scale = scaleMax;
     
    131133                                Bookmark b = (Bookmark)list.getSelectedValue();
    132134                                if (b != null) {
    133                                         marker = new Bounds(new GeoPoint(b.latlon[0],b.latlon[1]),
    134                                                         new GeoPoint(b.latlon[2],b.latlon[3]));
    135                                 } else
    136                                         marker = null;
     135                                        markerMin = getProjection().latlon2eastNorth(new LatLon(b.latlon[0],b.latlon[1]));
     136                                        markerMax = getProjection().latlon2eastNorth(new LatLon(b.latlon[2],b.latlon[3]));
     137                                } else {
     138                                        markerMin = null;
     139                                        markerMax = null;
     140                                }
    137141                                repaint();
    138142                        }
     
    164168                SelectionEnded selListener = new SelectionEnded(){
    165169                        public void selectionEnded(Rectangle r, boolean alt, boolean shift, boolean ctrl) {
    166                                 GeoPoint min = getPoint(r.x, r.y+r.height, true);
    167                                 GeoPoint max = getPoint(r.x+r.width, r.y, true);
    168                                 marker = new Bounds(min, max);
    169                                 field[0].setText(""+min.lat);
    170                                 field[1].setText(""+min.lon);
    171                                 field[2].setText(""+max.lat);
    172                                 field[3].setText(""+max.lon);
     170                                markerMin = getEastNorth(r.x, r.y+r.height);
     171                                markerMax = getEastNorth(r.x+r.width, r.y);
     172                                LatLon min = getProjection().eastNorth2latlon(markerMin);
     173                                LatLon max = getProjection().eastNorth2latlon(markerMax);
     174                                field[0].setText(""+min.lat());
     175                                field[1].setText(""+min.lon());
     176                                field[2].setText(""+max.lat());
     177                                field[3].setText(""+max.lon());
    173178                                for (JTextField f : field)
    174179                                        f.setCaretPosition(0);
     
    197202                        }
    198203                }
    199 
    200                 marker = new Bounds(new GeoPoint(v[0], v[1]), new GeoPoint(v[2], v[3]));
     204                markerMin = new EastNorth(v[0], v[1]);
     205                markerMax = new EastNorth(v[2], v[3]);
    201206                repaint();
    202207        }
  • src/org/openstreetmap/josm/gui/dialogs/LayerList.java

    r68 r71  
    2525import org.openstreetmap.josm.Main;
    2626import org.openstreetmap.josm.data.osm.DataSet;
    27 import org.openstreetmap.josm.gui.ImageProvider;
    2827import org.openstreetmap.josm.gui.MapFrame;
    2928import org.openstreetmap.josm.gui.MapView;
    3029import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    3130import org.openstreetmap.josm.gui.layer.Layer;
     31import org.openstreetmap.josm.tools.ImageProvider;
    3232
    3333/**
  • src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r68 r71  
    3939import org.openstreetmap.josm.data.SelectionChangedListener;
    4040import org.openstreetmap.josm.data.osm.OsmPrimitive;
    41 import org.openstreetmap.josm.gui.ImageProvider;
    4241import org.openstreetmap.josm.gui.MapFrame;
    4342import org.openstreetmap.josm.gui.MapView;
     43import org.openstreetmap.josm.tools.ImageProvider;
    4444
    4545/**
     
    275275                b.addActionListener(actionListener);
    276276                b.setToolTipText(tooltip);
    277                 //b.setMnemonic(mnemonic); TODO disabled until mapmodes have no Alt in their hotkey.
     277                b.setMnemonic(mnemonic);
    278278                return b;
    279279        }
  • src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r69 r71  
    2323import org.openstreetmap.josm.data.SelectionChangedListener;
    2424import org.openstreetmap.josm.data.osm.OsmPrimitive;
    25 import org.openstreetmap.josm.gui.ImageProvider;
    2625import org.openstreetmap.josm.gui.MapFrame;
    2726import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
     27import org.openstreetmap.josm.tools.ImageProvider;
    2828import org.openstreetmap.josm.tools.SearchCompiler;
    2929
  • src/org/openstreetmap/josm/gui/layer/Layer.java

    r23 r71  
    55import javax.swing.Icon;
    66
    7 import org.openstreetmap.josm.data.Bounds;
     7import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    88import org.openstreetmap.josm.data.projection.Projection;
    99import org.openstreetmap.josm.gui.MapView;
     
    7575        /**
    7676         * @return The bounding rectangle this layer occupies on screen when looking
    77          *              at lat/lon values or <code>null</code>, if infinite area or unknown
    78          *              area is occupied.
    79          */
    80         abstract public Bounds getBoundsLatLon();
    81        
    82         /**
    83          * @return The bounding rectangle this layer occupies on screen when looking
    8477         *              at x/y values or <code>null</code>, if infinite area or unknown
    8578         *              area is occupied.
    8679         */
    87         abstract public Bounds getBoundsXY();
     80        abstract public void visitBoundingBox(BoundingXYVisitor v);
    8881
    8982        /**
  • src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r64 r71  
    1515import org.openstreetmap.josm.Main;
    1616import org.openstreetmap.josm.command.Command;
    17 import org.openstreetmap.josm.data.Bounds;
    1817import org.openstreetmap.josm.data.osm.DataSet;
    1918import org.openstreetmap.josm.data.osm.LineSegment;
     
    2120import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2221import org.openstreetmap.josm.data.osm.Way;
    23 import org.openstreetmap.josm.data.osm.visitor.BoundingVisitor;
     22import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    2423import org.openstreetmap.josm.data.osm.visitor.MergeVisitor;
    2524import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor;
    2625import org.openstreetmap.josm.data.projection.Projection;
    27 import org.openstreetmap.josm.gui.ImageProvider;
    2826import org.openstreetmap.josm.gui.MapView;
     27import org.openstreetmap.josm.tools.ImageProvider;
    2928
    3029/**
     
    8685                                if (evt.getPropertyName().equals("projection"))
    8786                                        for (Node n : OsmDataLayer.this.data.nodes)
    88                                                 ((Projection)evt.getNewValue()).latlon2xy(n.coor);
     87                                                ((Projection)evt.getNewValue()).latlon2eastNorth(n.coor);
    8988                        }
    9089                });
     
    113112                        if (!osm.isDeleted())
    114113                                osm.visit(visitor);
    115                 for (OsmPrimitive osm : data.waies)
     114                for (OsmPrimitive osm : data.ways)
    116115                        if (!osm.isDeleted())
    117116                                osm.visit(visitor);
     
    128127                return undeletedSize(data.nodes)+" nodes, "+
    129128                        undeletedSize(data.lineSegments)+" segments, "+
    130                         undeletedSize(data.waies)+" streets.";
     129                        undeletedSize(data.ways)+" streets.";
    131130        }
    132131
     
    145144
    146145        @Override
    147         public Bounds getBoundsLatLon() {
    148                 BoundingVisitor b = new BoundingVisitor(BoundingVisitor.Type.LATLON);
     146        public void visitBoundingBox(BoundingXYVisitor v) {
    149147                for (Node n : data.nodes)
    150                         b.visit(n);
    151                 return b.bounds != null ? b.bounds : new Bounds();
    152         }
    153 
    154         @Override
    155         public Bounds getBoundsXY() {
    156                 BoundingVisitor b = new BoundingVisitor(BoundingVisitor.Type.XY);
    157                 for (Node n : data.nodes)
    158                         b.visit(n);
    159                 return b.bounds != null ? b.bounds : new Bounds();
     148                        v.visit(n);
    160149        }
    161150
     
    163152        public void init(Projection projection) {
    164153                for (Node n : data.nodes)
    165                         projection.latlon2xy(n.coor);
     154                        projection.latlon2eastNorth(n.coor);
    166155        }
    167156
     
    238227                        for (Iterator<LineSegment> it = data.lineSegments.iterator(); it.hasNext();)
    239228                                cleanIterator(it, processedSet);
    240                         for (Iterator<Way> it = data.waies.iterator(); it.hasNext();)
     229                        for (Iterator<Way> it = data.ways.iterator(); it.hasNext();)
    241230                                cleanIterator(it, processedSet);
    242231                }
  • src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java

    r64 r71  
    77import java.beans.PropertyChangeListener;
    88import java.util.Collection;
     9import java.util.LinkedList;
    910
    1011import javax.swing.Icon;
    1112
    1213import org.openstreetmap.josm.Main;
    13 import org.openstreetmap.josm.data.Bounds;
    14 import org.openstreetmap.josm.data.GeoPoint;
     14import org.openstreetmap.josm.data.coor.LatLon;
     15import org.openstreetmap.josm.data.coor.EastNorth;
     16import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    1517import org.openstreetmap.josm.data.projection.Projection;
    16 import org.openstreetmap.josm.gui.ImageProvider;
    1718import org.openstreetmap.josm.gui.MapView;
     19import org.openstreetmap.josm.tools.ImageProvider;
    1820
    1921/**
     
    2830
    2931        /**
    30          * A list of waies which containing a list of points.
     32         * A list of ways which containing a list of points.
    3133         */
    32         private final Collection<Collection<GeoPoint>> data;
     34        private final Collection<Collection<LatLon>> data;
     35        private Collection<Collection<EastNorth>> eastNorth;
    3336
    34         public RawGpsDataLayer(Collection<Collection<GeoPoint>> data, String name) {
     37        public RawGpsDataLayer(Collection<Collection<LatLon>> data, String name) {
    3538                super(name);
    3639                this.data = data;
     40               
    3741                Main.pref.addPropertyChangeListener(new PropertyChangeListener(){
    3842                        public void propertyChange(PropertyChangeEvent evt) {
     
    6266                g.setColor(Color.GRAY);
    6367                Point old = null;
    64                 for (Collection<GeoPoint> c : data) {
     68                for (Collection<EastNorth> c : eastNorth) {
    6569                        if (!Main.pref.isForceRawGpsLines())
    6670                                old = null;
    67                         for (GeoPoint p : c) {
    68                                 Point screen = mv.getScreenPoint(p);
     71                        for (EastNorth eastNorth : c) {
     72                                Point screen = mv.getPoint(eastNorth);
    6973                                if (Main.pref.isDrawRawGpsLines() && old != null)
    7074                                        g.drawLine(old.x, old.y, screen.x, screen.y);
     
    7882        @Override
    7983        public String getToolTipText() {
    80                 return data.size()+" waies.";
     84                int points = 0;
     85                for (Collection<LatLon> c : data)
     86                        points += c.size();
     87                return data.size()+" ways, "+points+" points.";
    8188        }
    8289
     
    93100
    94101        @Override
    95         public Bounds getBoundsLatLon() {
    96                 GeoPoint min = null;
    97                 GeoPoint max = null;
    98                 for (Collection<GeoPoint> c : data) {
    99                         for (GeoPoint p : c) {
    100                                 if (min == null) {
    101                                         min = p.clone();
    102                                         max = p.clone();
    103                                 } else {
    104                                         min.lat = Math.min(min.lat, p.lat);
    105                                         min.lon = Math.min(min.lon, p.lon);
    106                                         max.lat = Math.max(max.lat, p.lat);
    107                                         max.lon = Math.max(max.lon, p.lon);
    108                                 }
    109                         }
    110                 }
    111                 if (min == null)
    112                         return null;
    113                 return new Bounds(min, max);
    114         }
    115 
    116         @Override
    117         public Bounds getBoundsXY() {
    118                 GeoPoint min = null;
    119                 GeoPoint max = null;
    120                 for (Collection<GeoPoint> c : data) {
    121                         for (GeoPoint p : c) {
    122                                 if (min == null) {
    123                                         min = p.clone();
    124                                         max = p.clone();
    125                                 } else {
    126                                         min.x = Math.min(min.x, p.x);
    127                                         min.y = Math.min(min.y, p.y);
    128                                         max.x = Math.max(max.x, p.x);
    129                                         max.y = Math.max(max.y, p.y);
    130                                 }
    131                         }
    132                 }
    133                 if (min == null)
    134                         return null;
    135                 return new Bounds(min, max);
     102        public void visitBoundingBox(BoundingXYVisitor v) {
     103                for (Collection<EastNorth> c : eastNorth)
     104                        for (EastNorth eastNorth : c)
     105                                v.visit(eastNorth);
    136106        }
    137107
    138108        @Override
    139109        public void init(Projection projection) {
    140                 for (Collection<GeoPoint> c : data)
    141                         for (GeoPoint p : c)
    142                                 projection.latlon2xy(p);
     110                eastNorth = new LinkedList<Collection<EastNorth>>();
     111                for (Collection<LatLon> c : data) {
     112                        Collection<EastNorth> eastNorthList = new LinkedList<EastNorth>();
     113                        for (LatLon ll : c)
     114                                eastNorthList.add(Main.pref.getProjection().latlon2eastNorth(ll));
     115                        this.eastNorth.add(eastNorthList);
     116                }
    143117        }
    144118}
  • src/org/openstreetmap/josm/io/GpxReader.java

    r66 r71  
    1212import org.jdom.JDOMException;
    1313import org.jdom.input.SAXBuilder;
    14 import org.openstreetmap.josm.data.GeoPoint;
     14import org.openstreetmap.josm.data.coor.LatLon;
    1515import org.openstreetmap.josm.data.osm.DataSet;
    1616import org.openstreetmap.josm.data.osm.LineSegment;
     
    7373         */
    7474        private Node parseWaypoint(Element e) {
    75                 Node data = new Node(new GeoPoint(
     75                Node data = new Node(new LatLon(
    7676                        Double.parseDouble(e.getAttributeValue("lat")),
    7777                        Double.parseDouble(e.getAttributeValue("lon"))));
     
    9797        private DataSet parseDataSet(Element e) {
    9898                DataSet data = new DataSet();
    99                 // read waypoints not contained in waies or areas
     99                // read waypoints not contained in ways or areas
    100100                for (Object o : e.getChildren("wpt", GPX)) {
    101101                        Node node = parseWaypoint((Element)o);
     
    103103                }
    104104       
    105                 // read waies (and line segments)
     105                // read ways (and line segments)
    106106                for (Object wayElement : e.getChildren("trk", GPX))
    107107                        parseWay((Element)wayElement, data);
     
    155155                ds.lineSegments.addAll(way.segments);
    156156                if (!realLineSegment)
    157                         ds.waies.add(way);
     157                        ds.ways.add(way);
    158158        }
    159159
     
    170170                if (mergeNodes)
    171171                        for (Node n : data.nodes)
    172                                 if (node.coor.equalsLatLon(n.coor))
     172                                if (node.coor.equals(n.coor))
    173173                                        return n;
    174174                data.nodes.add(node);
  • src/org/openstreetmap/josm/io/GpxWriter.java

    r66 r71  
    106106                LinkedList<LineSegment> unrefLs = new LinkedList<LineSegment>(ds.lineSegments);
    107107
    108                 // waies
    109                 for (Way t : ds.waies) {
     108                // ways
     109                for (Way t : ds.ways) {
    110110                        if (t.isDeleted() && t.id == 0)
    111111                                continue;
     
    135135                }
    136136               
    137                 // encode pending line segments as waies
     137                // encode pending line segments as ways
    138138                for (LineSegment ls : unrefLs) {
    139139                        if (ls.isDeleted() && ls.id == 0)
     
    195195        private Element parseWaypoint(Node n, String name) {
    196196                Element e = new Element(name, GPX);
    197                 e.setAttribute("lat", Double.toString(n.coor.lat));
    198                 e.setAttribute("lon", Double.toString(n.coor.lon));
     197                e.setAttribute("lat", Double.toString(n.coor.lat()));
     198                e.setAttribute("lon", Double.toString(n.coor.lon()));
    199199                HashMap<String, String> keys = null;
    200200                if (n.keys != null) {
  • src/org/openstreetmap/josm/io/OsmConnection.java

    r23 r71  
    1414
    1515import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.gui.GBC;
     16import org.openstreetmap.josm.tools.GBC;
    1717
    1818/**
  • src/org/openstreetmap/josm/io/OsmReader.java

    r66 r71  
    66import java.util.Map;
    77
    8 import org.openstreetmap.josm.data.GeoPoint;
     8import org.openstreetmap.josm.data.coor.LatLon;
    99import org.openstreetmap.josm.data.osm.DataSet;
    1010import org.openstreetmap.josm.data.osm.LineSegment;
     
    7676                                        throw new SAXException("Unknown version: "+atts.getValue("version"));
    7777                        } else if (qName.equals("node")) {
    78                                 Node n = new Node(new GeoPoint(getDouble(atts, "lat"), getDouble(atts, "lon")));
     78                                Node n = new Node(new LatLon(getDouble(atts, "lat"), getDouble(atts, "lon")));
    7979                                current = n;
    8080                                readCommon(atts);
  • src/org/openstreetmap/josm/io/OsmReaderOld.java

    r66 r71  
    99import org.jdom.JDOMException;
    1010import org.jdom.input.SAXBuilder;
    11 import org.openstreetmap.josm.data.GeoPoint;
     11import org.openstreetmap.josm.data.coor.LatLon;
    1212import org.openstreetmap.josm.data.osm.DataSet;
    1313import org.openstreetmap.josm.data.osm.LineSegment;
     
    6262         */
    6363        private Node parseNode(Element e) throws JDOMException {
    64                 Node data = new Node(new GeoPoint(
     64                Node data = new Node(new LatLon(
    6565                        Double.parseDouble(e.getAttributeValue("lat")),
    6666                        Double.parseDouble(e.getAttributeValue("lon"))));
    67                 if (Double.isNaN(data.coor.lat) ||
    68                                 data.coor.lat < -90 || data.coor.lat > 90 ||
    69                                 data.coor.lon < -180 || data.coor.lon > 180)
    70                         throw new JDOMException("Illegal lat or lon value: "+data.coor.lat+"/"+data.coor.lon);
     67                if (Double.isNaN(data.coor.lat()) ||
     68                                data.coor.lat() < -90 || data.coor.lat() > 90 ||
     69                                data.coor.lon() < -180 || data.coor.lon() > 180)
     70                        throw new JDOMException("Illegal lat or lon value: "+data.coor.lat()+"/"+data.coor.lon());
    7171                parseCommon(data, e);
    7272                return data;
     
    221221                        if (osm.id == id)
    222222                                return osm;
    223                 for (OsmPrimitive osm : data.waies)
     223                for (OsmPrimitive osm : data.ways)
    224224                        if (osm.id == id)
    225225                                return osm;
  • src/org/openstreetmap/josm/io/OsmServerReader.java

    r65 r71  
    1111import org.jdom.JDOMException;
    1212import org.openstreetmap.josm.Main;
    13 import org.openstreetmap.josm.data.GeoPoint;
     13import org.openstreetmap.josm.data.coor.LatLon;
    1414import org.openstreetmap.josm.data.osm.DataSet;
    1515import org.xml.sax.SAXException;
     
    4545         * @return A list of all primitives retrieved. Currently, the list of lists
    4646         *              contain only one list, since the server cannot distinguish between
    47          *              waies.
     47         *              ways.
    4848         */
    49         public Collection<Collection<GeoPoint>> parseRawGps() throws IOException, JDOMException {
     49        public Collection<Collection<LatLon>> parseRawGps() throws IOException, JDOMException {
    5050                String url = Main.pref.osmDataServer+"/0.3/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
    51                 Collection<Collection<GeoPoint>> data = new LinkedList<Collection<GeoPoint>>();
    52                 Collection<GeoPoint> list = new LinkedList<GeoPoint>();
     51                Collection<Collection<LatLon>> data = new LinkedList<Collection<LatLon>>();
     52                Collection<LatLon> list = new LinkedList<LatLon>();
    5353               
    5454                for (int i = 0;;++i) {
     
    5757                                break;
    5858                        RawGpsReader gpsReader = new RawGpsReader(r);
    59                         Collection<Collection<GeoPoint>> allWays = gpsReader.parse();
     59                        Collection<Collection<LatLon>> allWays = gpsReader.parse();
    6060                        boolean foundSomething = false;
    61                         for (Collection<GeoPoint> t : allWays) {
     61                        for (Collection<LatLon> t : allWays) {
    6262                                if (!t.isEmpty()) {
    6363                                        foundSomething = true;
     
    101101                HttpURLConnection con = (HttpURLConnection)url.openConnection();
    102102                con.setConnectTimeout(20000);
     103                System.out.println("response: "+con.getResponseCode());
    103104                if (con.getResponseCode() == 401 && isCancelled())
    104105                        return null;
  • src/org/openstreetmap/josm/io/OsmWriter.java

    r66 r71  
    7272                for (LineSegment ls : ds.lineSegments)
    7373                        writer.visit(ls);
    74                 for (Way w : ds.waies)
     74                for (Way w : ds.ways)
    7575                        writer.visit(w);
    7676                writer.out.println("</osm>");
     
    9999        public void visit(Node n) {
    100100                addCommon(n, "node");
    101                 out.print(" lat='"+n.coor.lat+"' lon='"+n.coor.lon+"'");
     101                out.print(" lat='"+n.coor.lat()+"' lon='"+n.coor.lon()+"'");
    102102                addTags(n, "node", true);
    103103        }
  • src/org/openstreetmap/josm/io/RawCsvReader.java

    r38 r71  
    1111import org.jdom.JDOMException;
    1212import org.openstreetmap.josm.Main;
    13 import org.openstreetmap.josm.data.GeoPoint;
     13import org.openstreetmap.josm.data.coor.LatLon;
    1414
    1515/**
     
    2828        }
    2929       
    30         public Collection<GeoPoint> parse() throws JDOMException, IOException {
    31                 Collection<GeoPoint> data = new LinkedList<GeoPoint>();
     30        public Collection<LatLon> parse() throws JDOMException, IOException {
     31                Collection<LatLon> data = new LinkedList<LatLon>();
    3232                String formatStr = Main.pref.csvImportString;
    3333                if (formatStr == null)
     
    6262                                lineNo++;
    6363                                StringTokenizer st = new StringTokenizer(line, delim);
    64                                 GeoPoint p = new GeoPoint();
     64                                double lat = 0, lon = 0;
    6565                                for (String token : format) {
    6666                                        if (token.equals("lat"))
    67                                                 p.lat = Double.parseDouble(st.nextToken());
     67                                                lat = Double.parseDouble(st.nextToken());
    6868                                        else if (token.equals("lon"))
    69                                                 p.lon = Double.parseDouble(st.nextToken());
     69                                                lon = Double.parseDouble(st.nextToken());
    7070                                        else if (token.equals("ignore"))
    7171                                                st.nextToken();
     
    7373                                                throw new JDOMException("Unknown data type: '"+token+"'."+(Main.pref.csvImportString == null ? " Maybe add an format string in preferences." : ""));
    7474                                }
    75                                 data.add(p);
     75                                data.add(new LatLon(lat, lon));
    7676                        }
    7777                } catch (RuntimeException e) {
  • src/org/openstreetmap/josm/io/RawGpsReader.java

    r64 r71  
    1111import org.jdom.Namespace;
    1212import org.jdom.input.SAXBuilder;
    13 import org.openstreetmap.josm.data.GeoPoint;
     13import org.openstreetmap.josm.data.coor.LatLon;
    1414
    1515/**
    16  * Read raw gps data from a gpx file. Only way points with their waies segments
     16 * Read raw gps data from a gpx file. Only way points with their ways segments
    1717 * and waypoints are imported.
    1818 * @author imi
     
    4242         * Parse and return the read data
    4343         */
    44         public Collection<Collection<GeoPoint>> parse() throws JDOMException, IOException {
     44        public Collection<Collection<LatLon>> parse() throws JDOMException, IOException {
    4545                final SAXBuilder builder = new SAXBuilder();
    4646                builder.setValidation(false);
     
    5555         */
    5656        @SuppressWarnings("unchecked")
    57         private Collection<Collection<GeoPoint>> parseData(Element root) throws JDOMException {
    58                 Collection<Collection<GeoPoint>> data = new LinkedList<Collection<GeoPoint>>();
     57        private Collection<Collection<LatLon>> parseData(Element root) throws JDOMException {
     58                Collection<Collection<LatLon>> data = new LinkedList<Collection<LatLon>>();
    5959
    6060                // workaround for bug where the server adds /gpx.asd to the namespace
     
    6262               
    6363                for (Object o : root.getChildren("wpt", GPX)) {
    64                         Collection<GeoPoint> line = new LinkedList<GeoPoint>();
    65                         line.add(new GeoPoint(parseDouble((Element)o, LatLon.lat), parseDouble((Element)o, LatLon.lon)));
     64                        Collection<LatLon> line = new LinkedList<LatLon>();
     65                        line.add(new LatLon(parseDouble((Element)o, LatLonAttr.lat), parseDouble((Element)o, LatLonAttr.lon)));
    6666                        data.add(line);
    6767                }
    6868                for (Object o : root.getChildren("rte", GPX)) {
    69                         Collection<GeoPoint> line = parseLine(((Element)o).getChildren("rtept", GPX));
     69                        Collection<LatLon> line = parseLine(((Element)o).getChildren("rtept", GPX));
    7070                        if (!line.isEmpty())
    7171                                data.add(line);
     
    7373                for (Object o : root.getChildren("trk", GPX)) {
    7474                        for (Object seg : ((Element)o).getChildren("trkseg", GPX)) {
    75                                 Collection<GeoPoint> line = parseLine(((Element)seg).getChildren("trkpt", GPX));
     75                                Collection<LatLon> line = parseLine(((Element)seg).getChildren("trkpt", GPX));
    7676                                if (!line.isEmpty())
    7777                                        data.add(line);
     
    8181        }
    8282
    83         enum LatLon {lat, lon}
     83        private enum LatLonAttr {lat, lon}
    8484        /**
    8585         * Return a parsed float value from the element behind the object o.
     
    8888         * @throws JDOMException If the absolute of the value is out of bound.
    8989         */
    90         private double parseDouble(Element e, LatLon attr) throws JDOMException {
     90        private double parseDouble(Element e, LatLonAttr attr) throws JDOMException {
    9191                double d = Double.parseDouble(e.getAttributeValue(attr.toString()));
    92                 if (Math.abs(d) > (attr == LatLon.lat ? 90 : 180))
     92                if (Math.abs(d) > (attr == LatLonAttr.lat ? 90 : 180))
    9393                        throw new JDOMException("Data error: "+attr+" value '"+d+"' is out of bound.");
    9494                return d;
     
    9999         * points read.
    100100         */
    101         private Collection<GeoPoint> parseLine(List<Element> wpt) throws JDOMException {
    102                 Collection<GeoPoint> data = new LinkedList<GeoPoint>();
     101        private Collection<LatLon> parseLine(List<Element> wpt) throws JDOMException {
     102                Collection<LatLon> data = new LinkedList<LatLon>();
    103103                for (Element e : wpt)
    104                         data.add(new GeoPoint(parseDouble(e, LatLon.lat), parseDouble(e, LatLon.lon)));
     104                        data.add(new LatLon(parseDouble(e, LatLonAttr.lat), parseDouble(e, LatLonAttr.lon)));
    105105                return data;
    106106        }
  • src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java

    r63 r71  
    1 package org.openstreetmap.josm.gui;
     1package org.openstreetmap.josm.tools;
    22
    33import java.awt.GridBagLayout;
  • src/org/openstreetmap/josm/tools/GBC.java

    r63 r71  
    1 package org.openstreetmap.josm.gui;
     1package org.openstreetmap.josm.tools;
    22
    33import java.awt.Component;
  • src/org/openstreetmap/josm/tools/ImageProvider.java

    r64 r71  
    1 package org.openstreetmap.josm.gui;
     1package org.openstreetmap.josm.tools;
    22
    33import java.awt.Graphics;
  • test/org/openstreetmap/josm/test/GpxWriterTest.java

    r64 r71  
    3131        @Bug(47)
    3232        public void testDeleteNewDoesReallyRemove() throws JDOMException, IOException {
    33                 ds.waies.iterator().next().setDeleted(true);
     33                ds.ways.iterator().next().setDeleted(true);
    3434                root = reparse();
    3535                assertEquals("way has vanished and 3 trk (segments) left", 3, root.getChildren("trk", GPX).size());
     
    5656                assertNotNull("way not found in GPX file", realWay);
    5757               
    58                 // the second point of the first segment of the waies has an id
     58                // the second point of the first segment of the ways has an id
    5959                Element trkseg = (Element)realWay.getChildren("trkseg", GPX).get(0);
    6060                Element trkpt = (Element)trkseg.getChildren("trkpt", GPX).get(1);
  • test/org/openstreetmap/josm/test/MergeVisitorTest.java

    r66 r71  
    33import junit.framework.TestCase;
    44
    5 import org.openstreetmap.josm.data.GeoPoint;
     5import org.openstreetmap.josm.data.coor.LatLon;
    66import org.openstreetmap.josm.data.osm.DataSet;
    77import org.openstreetmap.josm.data.osm.LineSegment;
     
    2525                ls1.id = 3;
    2626
    27                 Node newnode = new Node(new GeoPoint(n[1].coor.lat, n[1].coor.lon));
     27                Node newnode = new Node(new LatLon(n[1].coor.lat(), n[1].coor.lon()));
    2828                LineSegment newls = new LineSegment(n[0], newnode);
    2929
     
    4747                DataSet ds2 = new DataSet();
    4848                Node n2[] = createNodes(ds2, 2);
    49                 n2[0].coor = new GeoPoint(n[0].coor.lat, n[0].coor.lon);
     49                n2[0].coor = new LatLon(n[0].coor.lat(), n[0].coor.lon());
    5050                n2[1].id = 42;
    5151                LineSegment ls2 = DataSetTestCaseHelper.createLineSegment(ds, n2[0], n2[1]);
  • test/org/openstreetmap/josm/test/OsmWriterTest.java

    r64 r71  
    5353                reparse();
    5454                assertEquals(42, Long.parseLong(getAttr(osm, "node", 0, "id")));
    55                 assertEquals(n.coor.lat, Double.parseDouble(getAttr(osm, "node", 0, "lat")));
    56                 assertEquals(n.coor.lon, Double.parseDouble(getAttr(osm, "node", 0, "lon")));
     55                assertEquals(n.coor.lat(), Double.parseDouble(getAttr(osm, "node", 0, "lat")));
     56                assertEquals(n.coor.lon(), Double.parseDouble(getAttr(osm, "node", 0, "lon")));
    5757        }
    5858
     
    125125        @Bug(47)
    126126        public void testDeleteNewDoesReallyRemove() throws Exception {
    127                 ds.waies.iterator().next().setDeleted(true);
     127                ds.ways.iterator().next().setDeleted(true);
    128128                reparse();
    129129                //assertEquals(0, deleted.size());
  • test/org/openstreetmap/josm/test/framework/DataSetTestCaseHelper.java

    r66 r71  
    33import java.util.Arrays;
    44
    5 import org.openstreetmap.josm.data.GeoPoint;
     5import org.openstreetmap.josm.data.coor.LatLon;
    66import org.openstreetmap.josm.data.osm.DataSet;
    77import org.openstreetmap.josm.data.osm.LineSegment;
     
    4242                Way t = new Way();
    4343                t.segments.addAll(Arrays.asList(lineSegments));
    44                 ds.waies.add(t);
     44                ds.ways.add(t);
    4545                return t;
    4646        }
     
    5959         */
    6060        public static Node createNode(DataSet ds) {
    61                 Node node = new Node(new GeoPoint(Math.random(), Math.random()));
     61                Node node = new Node(new LatLon(Math.random(), Math.random()));
    6262                ds.nodes.add(node);
    6363                return node;
Note: See TracChangeset for help on using the changeset viewer.