- Timestamp:
- 2006-03-25T16:21:09+01:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 5 added
- 1 deleted
- 50 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/Main.java
r68 r71 35 35 import org.openstreetmap.josm.data.Preferences.PreferencesException; 36 36 import org.openstreetmap.josm.data.osm.DataSet; 37 import org.openstreetmap.josm.gui.BugReportExceptionHandler;38 import org.openstreetmap.josm.gui.ImageProvider;39 37 import org.openstreetmap.josm.gui.MapFrame; 40 38 import org.openstreetmap.josm.gui.ShowModifiers; 41 39 import org.openstreetmap.josm.gui.layer.Layer; 42 40 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 41 import org.openstreetmap.josm.tools.BugReportExceptionHandler; 42 import org.openstreetmap.josm.tools.ImageProvider; 43 43 44 44 /** … … 294 294 } 295 295 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. 301 297 public void setMapFrame(MapFrame mapFrame) { 302 //TODO: Check for changes and ask user303 298 if (this.mapFrame != null) 304 299 this.mapFrame.setVisible(false); -
src/org/openstreetmap/josm/actions/AboutAction.java
r69 r71 21 21 22 22 import org.openstreetmap.josm.Main; 23 import org.openstreetmap.josm. gui.GBC;24 import org.openstreetmap.josm. gui.ImageProvider;23 import org.openstreetmap.josm.tools.GBC; 24 import org.openstreetmap.josm.tools.ImageProvider; 25 25 import org.openstreetmap.josm.tools.UrlLabel; 26 26 -
src/org/openstreetmap/josm/actions/DownloadAction.java
r68 r71 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.data.Bounds; 33 import org.openstreetmap.josm.data.GeoPoint;34 33 import org.openstreetmap.josm.data.Preferences.PreferencesException; 34 import org.openstreetmap.josm.data.coor.LatLon; 35 35 import org.openstreetmap.josm.data.osm.DataSet; 36 36 import org.openstreetmap.josm.gui.BookmarkList; 37 import org.openstreetmap.josm.gui.GBC;38 37 import org.openstreetmap.josm.gui.MapFrame; 39 38 import org.openstreetmap.josm.gui.MapView; … … 44 43 import org.openstreetmap.josm.gui.layer.RawGpsDataLayer; 45 44 import org.openstreetmap.josm.io.OsmServerReader; 45 import org.openstreetmap.josm.tools.GBC; 46 46 import org.xml.sax.SAXException; 47 47 … … 114 114 MapView mv = Main.main.getMapFrame().mapView; 115 115 setEditBounds(new Bounds( 116 mv.get Point(0, mv.getHeight(), true),117 mv.get Point(mv.getWidth(), 0, true)));116 mv.getLatLon(0, mv.getHeight()), 117 mv.getLatLon(mv.getWidth(), 0))); 118 118 rawGps.setSelected(mv.getActiveLayer() instanceof RawGpsDataLayer); 119 119 } … … 168 168 double size = 180.0 / Math.pow(2, map.get("zoom")); 169 169 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)); 172 172 setEditBounds(b); 173 173 } catch (Exception x) { // NPE or IAE … … 310 310 */ 311 311 private void setEditBounds(Bounds b) { 312 GeoPointbottomLeft = b.min;313 GeoPointtopRight = b.max;312 LatLon bottomLeft = b.min; 313 LatLon topRight = b.max; 314 314 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. 316 316 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()); 322 322 for (JTextField f : latlon) 323 323 f.setCaretPosition(0); -
src/org/openstreetmap/josm/actions/JosmAction.java
r68 r71 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm. gui.ImageProvider;12 import org.openstreetmap.josm.tools.ImageProvider; 13 13 14 14 /** -
src/org/openstreetmap/josm/actions/OpenAction.java
r68 r71 16 16 import org.jdom.JDOMException; 17 17 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm.data. GeoPoint;18 import org.openstreetmap.josm.data.coor.LatLon; 19 19 import org.openstreetmap.josm.data.osm.DataSet; 20 20 import org.openstreetmap.josm.gui.MapFrame; … … 71 71 72 72 if (asRawData(fn)) { 73 Collection<Collection< GeoPoint>> data;73 Collection<Collection<LatLon>> data; 74 74 if (ExtensionFileFilter.filters[ExtensionFileFilter.GPX].acceptName(fn)) { 75 75 data = new RawGpsReader(new FileReader(filename)).parse(); 76 76 } else if (ExtensionFileFilter.filters[ExtensionFileFilter.CSV].acceptName(fn)) { 77 data = new LinkedList<Collection< GeoPoint>>();77 data = new LinkedList<Collection<LatLon>>(); 78 78 data.add(new RawCsvReader(new FileReader(filename)).parse()); 79 79 } else -
src/org/openstreetmap/josm/actions/SaveAction.java
r68 r71 22 22 * Export the data as OSM intern xml file. 23 23 * 24 * TODO: This is very redundant with SaveGpxAction. Merge both actions into one!25 *26 24 * @author imi 27 25 */ -
src/org/openstreetmap/josm/actions/UploadAction.java
r68 r71 19 19 import org.openstreetmap.josm.data.Preferences.PreferencesException; 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.gui.GBC;22 21 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 23 22 import org.openstreetmap.josm.io.OsmServerWriter; 23 import org.openstreetmap.josm.tools.GBC; 24 24 25 25 /** -
src/org/openstreetmap/josm/actions/mapmode/AddLineSegmentAction.java
r68 r71 162 162 g.setColor(Color.BLACK); 163 163 g.setXORMode(Color.WHITE); 164 Point firstDrawn = mv.get ScreenPoint(first.coor);165 Point secondDrawn = mv.get ScreenPoint(second.coor);164 Point firstDrawn = mv.getPoint(first.eastNorth); 165 Point secondDrawn = mv.getPoint(second.eastNorth); 166 166 g.drawLine(firstDrawn.x, firstDrawn.y, secondDrawn.x, secondDrawn.y); 167 167 hintDrawn = !hintDrawn; -
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r68 r71 23 23 public class AddNodeAction extends MapMode { 24 24 25 /**26 * Create an AddNodeAction. Mnemonic is 'a'27 * @param mapFrame28 */29 25 public AddNodeAction(MapFrame mapFrame) { 30 26 super("Add nodes", "addnode", "Add nodes to the map.", "N", KeyEvent.VK_N, mapFrame); … … 50 46 public void mouseClicked(MouseEvent e) { 51 47 if (e.getButton() == MouseEvent.BUTTON1) { 52 Node node = new Node(mv.get Point(e.getX(), e.getY(), true));48 Node node = new Node(mv.getLatLon(e.getX(), e.getY())); 53 49 if (node.coor.isOutSideWorld()) { 54 50 JOptionPane.showMessageDialog(Main.main, "Can not add a node outside of the world."); -
src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r68 r71 94 94 * Delete the primitives and everything they references. 95 95 * 96 * If a node is deleted, the node and all line segments, wa ies and areas96 * If a node is deleted, the node and all line segments, ways and areas 97 97 * the node is part of are deleted as well. 98 98 * 99 * If a line segment is deleted, all wa ies the line segment is part of99 * If a line segment is deleted, all ways the line segment is part of 100 100 * are deleted as well. No nodes are deleted. 101 101 * -
src/org/openstreetmap/josm/actions/mapmode/MoveAction.java
r68 r71 12 12 import org.openstreetmap.josm.command.Command; 13 13 import org.openstreetmap.josm.command.MoveCommand; 14 import org.openstreetmap.josm.data. GeoPoint;14 import org.openstreetmap.josm.data.coor.EastNorth; 15 15 import org.openstreetmap.josm.data.osm.Node; 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 17 18 import org.openstreetmap.josm.gui.MapFrame; 18 19 … … 79 80 } 80 81 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(); 85 86 if (dx == 0 && dy == 0) 86 87 return; 87 88 88 89 Collection<OsmPrimitive> selection = Main.main.ds.getSelected(); 89 Collection<Node> affectedNodes = MoveCommand.getAffectedNodes(selection);90 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 90 91 91 92 // check if any coordinate would be outside the world -
src/org/openstreetmap/josm/actions/mapmode/SelectionAction.java
r68 r71 27 27 * If Alt key was hold, select all objects that are touched by the 28 28 * selection rectangle. If the Alt key was not hold, select only those objects 29 * completly within (e.g. for wa ies mean: only if all nodes of the way are29 * completly within (e.g. for ways mean: only if all nodes of the way are 30 30 * within). 31 31 * -
src/org/openstreetmap/josm/actions/mapmode/ZoomAction.java
r68 r71 4 4 import java.awt.event.KeyEvent; 5 5 6 import org.openstreetmap.josm.data. GeoPoint;6 import org.openstreetmap.josm.data.coor.EastNorth; 7 7 import org.openstreetmap.josm.gui.MapFrame; 8 8 import org.openstreetmap.josm.gui.MapView; … … 52 52 if (r.width >= 3 && r.height >= 3) { 53 53 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); 55 55 mv.zoomTo(newCenter, scale); 56 56 } -
src/org/openstreetmap/josm/command/MoveCommand.java
r34 r71 7 7 8 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.data.coor.LatLon; 10 import org.openstreetmap.josm.data.coor.EastNorth; 9 11 import org.openstreetmap.josm.data.osm.Node; 10 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 22 24 * The objects that should be moved. 23 25 */ 24 public List<Node> objects = new LinkedList<Node>();26 public Collection<Node> objects = new LinkedList<Node>(); 25 27 /** 26 28 * x difference movement. Coordinates are in northern/eastern … … 53 55 this.x = x; 54 56 this.y = y; 55 this.objects = getAffectedNodes(objects);57 this.objects = AllNodesVisitor.getAllNodes(objects); 56 58 for (Node n : this.objects) { 57 59 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(); 62 64 os.modified = n.modified; 63 65 oldState.add(os); … … 65 67 } 66 68 67 /**68 * @return a list of all nodes that will be moved if using the given set of69 * 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 78 69 /** 79 70 * Move the same set of objects again by the specified vector. The vectors … … 86 77 public void moveAgain(double x, double y) { 87 78 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); 91 81 } 92 82 this.x += x; … … 96 86 public void executeCommand() { 97 87 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); 101 90 n.modified = true; 102 91 } … … 107 96 for (Node n : objects) { 108 97 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); 113 100 n.modified = os.modified; 114 101 } -
src/org/openstreetmap/josm/data/osm/DataSet.java
r64 r71 5 5 import java.util.LinkedList; 6 6 7 import org.openstreetmap.josm.data.Bounds;8 7 import org.openstreetmap.josm.data.SelectionTracker; 9 8 … … 21 20 22 21 /** 23 * All nodes goes here, even when included in other data (wa ies etc).22 * All nodes goes here, even when included in other data (ways etc). 24 23 * This enables the instant conversion of the whole DataSet by iterating over 25 24 * this data structure. … … 33 32 34 33 /** 35 * All wa ies (Streets etc.) in the DataSet.34 * All ways (Streets etc.) in the DataSet. 36 35 * 37 36 * The nodes of the way segments of this way must be objects from … … 39 38 * way list. 40 39 */ 41 public Collection<Way> wa ies = new LinkedList<Way>();40 public Collection<Way> ways = new LinkedList<Way>(); 42 41 43 42 /** … … 49 48 o.addAll(nodes); 50 49 o.addAll(lineSegments); 51 o.addAll(wa ies);50 o.addAll(ways); 52 51 return o; 53 52 } … … 63 62 return o; 64 63 } 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 lower69 * 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 lower100 * down GeoPoint.101 *102 * Return null, if any point does not have lat/lon or if there are no103 * 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 }128 64 129 65 /** … … 133 69 clearSelection(nodes); 134 70 clearSelection(lineSegments); 135 clearSelection(wa ies);71 clearSelection(ways); 136 72 } 137 73 … … 144 80 Collection<OsmPrimitive> sel = getSelected(nodes); 145 81 sel.addAll(getSelected(lineSegments)); 146 sel.addAll(getSelected(wa ies));82 sel.addAll(getSelected(ways)); 147 83 return sel; 148 84 } -
src/org/openstreetmap/josm/data/osm/LineSegment.java
r66 r71 1 1 package org.openstreetmap.josm.data.osm; 2 2 3 import org.openstreetmap.josm.data.GeoPoint;4 3 import org.openstreetmap.josm.data.osm.visitor.Visitor; 5 4 … … 16 15 */ 17 16 public Node from; 18 17 19 18 /** 20 19 * The ending node of the line segment … … 48 47 visitor.visit(this); 49 48 } 50 49 51 50 /** 52 51 * @return <code>true</code>, if the <code>ls</code> occupy … … 57 56 return true; 58 57 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))); 66 61 } 67 62 -
src/org/openstreetmap/josm/data/osm/Node.java
r66 r71 1 1 package org.openstreetmap.josm.data.osm; 2 2 3 import org.openstreetmap.josm.data.GeoPoint; 3 import org.openstreetmap.josm.Main; 4 import org.openstreetmap.josm.data.coor.LatLon; 5 import org.openstreetmap.josm.data.coor.EastNorth; 4 6 import org.openstreetmap.josm.data.osm.visitor.Visitor; 5 7 … … 12 14 public class Node extends OsmPrimitive { 13 15 14 /** 15 * The coordinates of this node. 16 */ 17 public GeoPoint coor; 16 public LatLon coor; 17 public EastNorth eastNorth; 18 18 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); 21 22 } 22 23 … … 28 29 @Override 29 30 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()+"}"; 31 32 } 32 33 … … 34 35 public void cloneFrom(OsmPrimitive osm) { 35 36 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; 38 39 } 39 40 } -
src/org/openstreetmap/josm/data/osm/visitor/AddVisitor.java
r64 r71 30 30 } 31 31 public void visit(Way t) { 32 ds.wa ies.add(t);32 ds.ways.add(t); 33 33 } 34 34 } -
src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java
r66 r71 49 49 * @return All nodes the given primitive has. 50 50 */ 51 public static Collection<Node> getAllNodes( OsmPrimitive osm) {51 public static Collection<Node> getAllNodes(Collection<? extends OsmPrimitive> osms) { 52 52 AllNodesVisitor v = new AllNodesVisitor(); 53 osm.visit(v); 53 for (OsmPrimitive osm : osms) 54 osm.visit(v); 54 55 return v.nodes; 55 56 } -
src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r66 r71 1 1 package org.openstreetmap.josm.data.osm.visitor; 2 2 3 import org.openstreetmap.josm.Main; 3 4 import org.openstreetmap.josm.data.Bounds; 5 import org.openstreetmap.josm.data.coor.EastNorth; 4 6 import org.openstreetmap.josm.data.osm.LineSegment; 5 7 import org.openstreetmap.josm.data.osm.Node; … … 7 9 8 10 /** 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. 10 13 * @author imi 11 14 */ 12 public class Bounding Visitor implements Visitor {15 public class BoundingXYVisitor implements Visitor { 13 16 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; 30 18 31 19 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); 47 21 } 48 22 … … 58 32 visit(ls); 59 33 } 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 } 60 57 } 61 -
src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java
r66 r71 11 11 12 12 /** 13 * Helper that collect all line segments a node is part of, all wa ies13 * Helper that collect all line segments a node is part of, all ways 14 14 * a node or line segment is part of and all areas a node is part of. 15 15 * … … 37 37 38 38 public void visit(Node n) { 39 for (Way t : ds.wa ies) {39 for (Way t : ds.ways) { 40 40 if (t.isDeleted()) 41 41 continue; … … 57 57 } 58 58 public void visit(LineSegment ls) { 59 for (Way t : ds.wa ies) {59 for (Way t : ds.ways) { 60 60 if (t.isDeleted()) 61 61 continue; -
src/org/openstreetmap/josm/data/osm/visitor/DeleteVisitor.java
r64 r71 30 30 } 31 31 public void visit(Way t) { 32 ds.wa ies.remove(t);32 ds.ways.remove(t); 33 33 } 34 34 } -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r66 r71 58 58 if (myNode.modified && !otherNode.modified) 59 59 return; 60 if (!myNode.coor.equals LatLonEpsilon(otherNode.coor)) {60 if (!myNode.coor.equalsEpsilon(otherNode.coor)) { 61 61 myNode.coor = otherNode.coor; 62 62 myNode.modified = otherNode.modified; … … 104 104 public void visit(Way otherWay) { 105 105 Way myWay = null; 106 for (Way t : ds.wa ies) {106 for (Way t : ds.ways) { 107 107 if (match(otherWay, t)) { 108 108 myWay = t; … … 111 111 } 112 112 if (myWay == null) 113 ds.wa ies.add(otherWay);113 ds.ways.add(otherWay); 114 114 else { 115 115 mergeCommon(myWay, otherWay); … … 141 141 ls.to = mergedNodes.get(ls.to); 142 142 } 143 for (Way t : ds.wa ies) {143 for (Way t : ds.ways) { 144 144 boolean replacedSomething = false; 145 145 LinkedList<LineSegment> newSegments = new LinkedList<LineSegment>(); … … 168 168 private boolean match(Node n1, Node n2) { 169 169 if (n1.id == 0 || n2.id == 0) 170 return n1.coor.equals LatLonEpsilon(n2.coor);170 return n1.coor.equalsEpsilon(n2.coor); 171 171 return n1.id == n2.id; 172 172 } … … 184 184 185 185 /** 186 * @return Whether the wa ies matches (in sense of "be mergable").186 * @return Whether the ways matches (in sense of "be mergable"). 187 187 */ 188 188 private boolean match(Way t1, Way t2) { -
src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java
r66 r71 10 10 import org.openstreetmap.josm.data.osm.Node; 11 11 import org.openstreetmap.josm.data.osm.Way; 12 import org.openstreetmap.josm. gui.ImageProvider;12 import org.openstreetmap.josm.tools.ImageProvider; 13 13 14 14 /** … … 36 36 public void visit(LineSegment ls) { 37 37 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 } 42 44 icon = ImageProvider.get("data", "linesegment"); 43 45 } … … 50 52 name = n.get("name"); 51 53 if (name == null) 52 name = "("+n.coor.lat+","+n.coor.lon+")";54 name = n.id+" ("+n.coor.lat()+","+n.coor.lon()+")"; 53 55 icon = ImageProvider.get("data", "node"); 54 56 } … … 61 63 name = w.get("name"); 62 64 if (name == null) { 65 AllNodesVisitor.getAllNodes(w.segments); 63 66 Set<Node> nodes = new HashSet<Node>(); 64 67 for (LineSegment ls : w.segments) { -
src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r66 r71 84 84 */ 85 85 private void drawNode(Node n, Color color) { 86 Point p = nc.get ScreenPoint(n.coor);86 Point p = nc.getPoint(n.eastNorth); 87 87 g.setColor(color); 88 88 g.drawRect(p.x-1, p.y-1, 2, 2); … … 98 98 col = Color.WHITE; 99 99 g.setColor(col); 100 Point p1 = nc.get ScreenPoint(ls.from.coor);101 Point p2 = nc.get ScreenPoint(ls.to.coor);100 Point p1 = nc.getPoint(ls.from.eastNorth); 101 Point p2 = nc.getPoint(ls.to.eastNorth); 102 102 g.drawLine(p1.x, p1.y, p2.x, p2.y); 103 103 } -
src/org/openstreetmap/josm/data/projection/Epsg4263.java
r52 r71 1 1 package org.openstreetmap.josm.data.projection; 2 2 3 import org.openstreetmap.josm.data.GeoPoint; 3 import org.openstreetmap.josm.data.coor.LatLon; 4 import org.openstreetmap.josm.data.coor.EastNorth; 4 5 5 6 /** … … 10 11 public class Epsg4263 implements Projection { 11 12 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()); 15 15 } 16 16 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()); 20 19 } 21 20 -
src/org/openstreetmap/josm/data/projection/Mercator.java
r52 r71 1 1 package org.openstreetmap.josm.data.projection; 2 2 3 import org.openstreetmap.josm.data.GeoPoint; 3 import org.openstreetmap.josm.data.coor.LatLon; 4 import org.openstreetmap.josm.data.coor.EastNorth; 4 5 5 6 /** … … 14 15 public class Mercator implements Projection { 15 16 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))); 19 21 } 20 22 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); 24 27 } 25 28 -
src/org/openstreetmap/josm/data/projection/Projection.java
r58 r71 1 1 package org.openstreetmap.josm.data.projection; 2 2 3 import org.openstreetmap.josm.data.GeoPoint; 3 import org.openstreetmap.josm.data.coor.LatLon; 4 import org.openstreetmap.josm.data.coor.EastNorth; 4 5 5 6 /** … … 20 21 * @param p The geo point to convert. x/y members of the point are filled. 21 22 */ 22 void latlon2xy(GeoPointp);23 EastNorth latlon2eastNorth(LatLon p); 23 24 24 25 /** … … 27 28 * @param p The geo point to convert. lat/lon members of the point are filled. 28 29 */ 29 void xy2latlon(GeoPointp);30 LatLon eastNorth2latlon(EastNorth p); 30 31 31 32 /** -
src/org/openstreetmap/josm/gui/BookmarkList.java
r41 r71 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.data.Preferences; 20 import org.openstreetmap.josm.tools.ImageProvider; 20 21 21 22 /** -
src/org/openstreetmap/josm/gui/MapMover.java
r66 r71 8 8 import java.awt.event.MouseWheelListener; 9 9 10 import org.openstreetmap.josm.data. GeoPoint;10 import org.openstreetmap.josm.data.coor.EastNorth; 11 11 12 12 /** … … 22 22 * when moving around started. 23 23 */ 24 private GeoPointmousePosMove;24 private EastNorth mousePosMove; 25 25 /** 26 26 * The map to move around. … … 51 51 if (mousePosMove == null) 52 52 startMovement(e); 53 GeoPointcenter = 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()); 58 58 nc.zoomTo(p, nc.getScale()); 59 59 } else … … 86 86 */ 87 87 private void startMovement(MouseEvent e) { 88 mousePosMove = nc.get Point(e.getX(), e.getY(), false);88 mousePosMove = nc.getEastNorth(e.getX(), e.getY()); 89 89 oldCursor = nc.getCursor(); 90 90 nc.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); … … 108 108 */ 109 109 public void mouseWheelMoved(MouseWheelEvent e) { 110 int w = nc.getWidth(); 111 int h = nc.getHeight(); 112 110 113 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 117 122 nc.zoomTo(newCenter, nc.getScale()*zoom); 118 123 } -
src/org/openstreetmap/josm/gui/MapStatus.java
r66 r71 27 27 28 28 import org.openstreetmap.josm.Main; 29 import org.openstreetmap.josm.data. GeoPoint;29 import org.openstreetmap.josm.data.coor.LatLon; 30 30 import org.openstreetmap.josm.data.osm.OsmPrimitive; 31 31 import org.openstreetmap.josm.data.osm.visitor.SelectionComponentVisitor; 32 import org.openstreetmap.josm.tools.GBC; 32 33 33 34 /** … … 205 206 // Do not update the view, if ctrl is pressed. 206 207 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()); 209 210 } 210 211 } -
src/org/openstreetmap/josm/gui/MapView.java
r51 r71 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.data.Bounds; 20 import org.openstreetmap.josm.data. GeoPoint;20 import org.openstreetmap.josm.data.coor.EastNorth; 21 21 import org.openstreetmap.josm.data.osm.DataSet; 22 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 22 23 import org.openstreetmap.josm.data.projection.Projection; 23 24 import org.openstreetmap.josm.gui.layer.Layer; … … 176 177 g.setColor(Color.WHITE); 177 178 Bounds b = new Bounds(); 178 Point min = get ScreenPoint(b.min);179 Point max = get ScreenPoint(b.max);179 Point min = getPoint(getProjection().latlon2eastNorth(b.min)); 180 Point max = getPoint(getProjection().latlon2eastNorth(b.max)); 180 181 int x1 = Math.min(min.x, max.x); 181 182 int y1 = Math.min(min.y, max.y); … … 217 218 h = 20; 218 219 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); 229 223 230 224 boolean oldAutoScale = autoScale; 231 GeoPointoldCenter = center;225 EastNorth oldCenter = center; 232 226 double oldScale = this.scale; 233 227 234 if ( bounds== null) {228 if (v.min == null || v.max == null) { 235 229 // 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); 238 231 scale = 10; 239 232 } 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; 244 236 scale = Math.max(scaleX, scaleY); // minimum scale to see all of the screen 245 237 } 246 238 247 firePropertyChange("center", oldCenter, center); 239 if (!center.equals(oldCenter)) 240 firePropertyChange("center", oldCenter, center); 248 241 if (oldAutoScale != autoScale) 249 242 firePropertyChange("autoScale", oldAutoScale, autoScale); … … 318 311 */ 319 312 @Override 320 public void zoomTo( GeoPointnewCenter, double scale) {313 public void zoomTo(EastNorth newCenter, double scale) { 321 314 boolean oldAutoScale = autoScale; 322 GeoPointoldCenter = center;315 EastNorth oldCenter = center; 323 316 double oldScale = this.scale; 324 317 autoScale = false; … … 328 321 recalculateCenterScale(); 329 322 330 firePropertyChange("center", oldCenter, center); 323 if (!oldCenter.equals(center)) 324 firePropertyChange("center", oldCenter, center); 331 325 if (oldAutoScale != autoScale) 332 326 firePropertyChange("autoScale", oldAutoScale, autoScale); -
src/org/openstreetmap/josm/gui/NavigatableComponent.java
r66 r71 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.data.GeoPoint; 10 import org.openstreetmap.josm.data.coor.LatLon; 11 import org.openstreetmap.josm.data.coor.EastNorth; 11 12 import org.openstreetmap.josm.data.osm.LineSegment; 12 13 import org.openstreetmap.josm.data.osm.Node; … … 32 33 * Center n/e coordinate of the desired screen center. 33 34 */ 34 protected GeoPointcenter;35 protected EastNorth center; 35 36 36 37 /** … … 46 47 * change the center by accessing the return value. Use zoomTo instead. 47 48 */ 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 /** 59 54 * @param x X-Pixelposition to get coordinate from 60 55 * @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. 78 82 * @param point The point, where this geopoint would be drawn. 79 83 * @return The point on screen where "point" would be drawn, relative 80 84 * to the own top/left. 81 85 */ 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; 94 89 return new Point((int)x,(int)y); 95 90 } … … 101 96 * @param scale The scale to use. 102 97 */ 103 public void zoomTo( GeoPointnewCenter, 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); 106 101 this.scale = scale; 107 102 repaint(); … … 127 122 * 128 123 * @param p The point on screen. 129 * @param lsInsteadWay Whether the line segment (true) or only the whole124 * @param segmentInsteadWay Whether the line segment (true) or only the whole 130 125 * way should be returned. 131 126 * @return The primitive, that is nearest to the point p. 132 127 */ 133 public OsmPrimitive getNearest(Point p, boolean lsInsteadWay) {128 public OsmPrimitive getNearest(Point p, boolean segmentInsteadWay) { 134 129 double minDistanceSq = Double.MAX_VALUE; 135 130 OsmPrimitive minPrimitive = null; … … 139 134 if (n.isDeleted()) 140 135 continue; 141 Point sp = get ScreenPoint(n.coor);136 Point sp = getPoint(n.eastNorth); 142 137 double dist = p.distanceSq(sp); 143 138 if (minDistanceSq > dist && dist < 100) { … … 151 146 // for whole ways, try the ways first 152 147 minDistanceSq = Double.MAX_VALUE; 153 if (! lsInsteadWay) {154 for (Way w : Main.main.ds.wa ies) {148 if (!segmentInsteadWay) { 149 for (Way w : Main.main.ds.ways) { 155 150 if (w.isDeleted()) 156 151 continue; … … 158 153 if (ls.isDeleted() || ls.incomplete) 159 154 continue; 160 Point A = get ScreenPoint(ls.from.coor);161 Point B = get ScreenPoint(ls.to.coor);155 Point A = getPoint(ls.from.eastNorth); 156 Point B = getPoint(ls.to.eastNorth); 162 157 double c = A.distanceSq(B); 163 158 double a = p.distanceSq(B); … … 179 174 if (ls.isDeleted() || ls.incomplete) 180 175 continue; 181 Point A = get ScreenPoint(ls.from.coor);182 Point B = get ScreenPoint(ls.to.coor);176 Point A = getPoint(ls.from.eastNorth); 177 Point B = getPoint(ls.to.eastNorth); 183 178 double c = A.distanceSq(B); 184 179 double a = p.distanceSq(B); … … 201 196 * If its a node, return all line segments and 202 197 * streets the node is part of, as well as all nodes 203 * (with their line segments and wa ies) with the same198 * (with their line segments and ways) with the same 204 199 * location. 205 200 * 206 * If its a line segment, return all wa ies this segment201 * If its a line segment, return all ways this segment 207 202 * belongs to as well as all line segments that are between 208 * the same nodes (in both direction) with all their wa ies.203 * the same nodes (in both direction) with all their ways. 209 204 * 210 205 * @return A collection of all items or <code>null</code> … … 221 216 Node node = (Node)osm; 222 217 for (Node n : Main.main.ds.nodes) 223 if (!n.isDeleted() && n.coor.equals LatLon(node.coor))218 if (!n.isDeleted() && n.coor.equals(node.coor)) 224 219 c.add(n); 225 220 for (LineSegment ls : Main.main.ds.lineSegments) … … 235 230 } 236 231 if (osm instanceof Node || osm instanceof LineSegment) { 237 for (Way t : Main.main.ds.wa ies) {232 for (Way t : Main.main.ds.ways) { 238 233 if (t.isDeleted()) 239 234 continue; -
src/org/openstreetmap/josm/gui/PreferenceDialog.java
r64 r71 31 31 import org.openstreetmap.josm.data.Preferences.PreferencesException; 32 32 import org.openstreetmap.josm.data.projection.Projection; 33 import org.openstreetmap.josm.tools.GBC; 34 import org.openstreetmap.josm.tools.ImageProvider; 33 35 34 36 /** -
src/org/openstreetmap/josm/gui/SelectionManager.java
r66 r71 257 257 * @param alt Whether the alt key was pressed, which means select all objects 258 258 * that are touched, instead those which are completly covered. Also 259 * select whole wa ies instead of line segments.259 * select whole ways instead of line segments. 260 260 */ 261 261 public Collection<OsmPrimitive> getObjectsInRectangle(Rectangle r, boolean alt) { … … 273 273 // nodes 274 274 for (Node n : Main.main.ds.nodes) { 275 if (r.contains(nc.get ScreenPoint(n.coor)))275 if (r.contains(nc.getPoint(n.eastNorth))) 276 276 selection.add(n); 277 277 } … … 282 282 selection.add(ls); 283 283 284 // wa ies285 for (Way t : Main.main.ds.wa ies) {284 // ways 285 for (Way t : Main.main.ds.ways) { 286 286 boolean wholeWaySelected = !t.segments.isEmpty(); 287 287 for (LineSegment ls : t.segments) … … 312 312 return false; 313 313 if (alt) { 314 Point p1 = nc.get ScreenPoint(ls.from.coor);315 Point p2 = nc.get ScreenPoint(ls.to.coor);314 Point p1 = nc.getPoint(ls.from.eastNorth); 315 Point p2 = nc.getPoint(ls.to.eastNorth); 316 316 if (r.intersectsLine(p1.x, p1.y, p2.x, p2.y)) 317 317 return true; 318 318 } else { 319 if (r.contains(nc.get ScreenPoint(ls.from.coor))320 && r.contains(nc.get ScreenPoint(ls.to.coor)))319 if (r.contains(nc.getPoint(ls.from.eastNorth)) 320 && r.contains(nc.getPoint(ls.to.eastNorth))) 321 321 return true; 322 322 } -
src/org/openstreetmap/josm/gui/WorldChooser.java
r55 r71 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data. Bounds;22 import org.openstreetmap.josm.data. GeoPoint;21 import org.openstreetmap.josm.data.coor.LatLon; 22 import org.openstreetmap.josm.data.coor.EastNorth; 23 23 import org.openstreetmap.josm.data.projection.Projection; 24 24 import org.openstreetmap.josm.gui.BookmarkList.Bookmark; … … 48 48 * Mark this rectangle (lat/lon values) when painting. 49 49 */ 50 pr otected Bounds marker;50 private EastNorth markerMin, markerMax; 51 51 52 52 private Projection projection; … … 58 58 URL path = Main.class.getResource("/images/world.jpg"); 59 59 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); 61 61 setPreferredSize(new Dimension(200, 100)); 62 62 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); 71 73 } 72 74 @Override … … 94 96 @Override 95 97 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); 99 101 100 102 // draw marker rect 101 if (marker != null) {102 Point p1 = get ScreenPoint(marker.min);103 Point p2 = get ScreenPoint(marker.max);103 if (markerMin != null && markerMax != null) { 104 Point p1 = getPoint(markerMin); 105 Point p2 = getPoint(markerMax); 104 106 double x = Math.min(p1.x, p2.x); 105 107 double y = Math.min(p1.y, p2.y); … … 117 119 118 120 @Override 119 public void zoomTo( GeoPointnewCenter, double scale) {121 public void zoomTo(EastNorth newCenter, double scale) { 120 122 if (getWidth() != 0 && scale > scaleMax) 121 123 scale = scaleMax; … … 131 133 Bookmark b = (Bookmark)list.getSelectedValue(); 132 134 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 } 137 141 repaint(); 138 142 } … … 164 168 SelectionEnded selListener = new SelectionEnded(){ 165 169 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()); 173 178 for (JTextField f : field) 174 179 f.setCaretPosition(0); … … 197 202 } 198 203 } 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]); 201 206 repaint(); 202 207 } -
src/org/openstreetmap/josm/gui/dialogs/LayerList.java
r68 r71 25 25 import org.openstreetmap.josm.Main; 26 26 import org.openstreetmap.josm.data.osm.DataSet; 27 import org.openstreetmap.josm.gui.ImageProvider;28 27 import org.openstreetmap.josm.gui.MapFrame; 29 28 import org.openstreetmap.josm.gui.MapView; 30 29 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 31 30 import org.openstreetmap.josm.gui.layer.Layer; 31 import org.openstreetmap.josm.tools.ImageProvider; 32 32 33 33 /** -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r68 r71 39 39 import org.openstreetmap.josm.data.SelectionChangedListener; 40 40 import org.openstreetmap.josm.data.osm.OsmPrimitive; 41 import org.openstreetmap.josm.gui.ImageProvider;42 41 import org.openstreetmap.josm.gui.MapFrame; 43 42 import org.openstreetmap.josm.gui.MapView; 43 import org.openstreetmap.josm.tools.ImageProvider; 44 44 45 45 /** … … 275 275 b.addActionListener(actionListener); 276 276 b.setToolTipText(tooltip); 277 //b.setMnemonic(mnemonic); TODO disabled until mapmodes have no Alt in their hotkey.277 b.setMnemonic(mnemonic); 278 278 return b; 279 279 } -
src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r69 r71 23 23 import org.openstreetmap.josm.data.SelectionChangedListener; 24 24 import org.openstreetmap.josm.data.osm.OsmPrimitive; 25 import org.openstreetmap.josm.gui.ImageProvider;26 25 import org.openstreetmap.josm.gui.MapFrame; 27 26 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 27 import org.openstreetmap.josm.tools.ImageProvider; 28 28 import org.openstreetmap.josm.tools.SearchCompiler; 29 29 -
src/org/openstreetmap/josm/gui/layer/Layer.java
r23 r71 5 5 import javax.swing.Icon; 6 6 7 import org.openstreetmap.josm.data. Bounds;7 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 8 8 import org.openstreetmap.josm.data.projection.Projection; 9 9 import org.openstreetmap.josm.gui.MapView; … … 75 75 /** 76 76 * @return The bounding rectangle this layer occupies on screen when looking 77 * at lat/lon values or <code>null</code>, if infinite area or unknown78 * area is occupied.79 */80 abstract public Bounds getBoundsLatLon();81 82 /**83 * @return The bounding rectangle this layer occupies on screen when looking84 77 * at x/y values or <code>null</code>, if infinite area or unknown 85 78 * area is occupied. 86 79 */ 87 abstract public Bounds getBoundsXY();80 abstract public void visitBoundingBox(BoundingXYVisitor v); 88 81 89 82 /** -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r64 r71 15 15 import org.openstreetmap.josm.Main; 16 16 import org.openstreetmap.josm.command.Command; 17 import org.openstreetmap.josm.data.Bounds;18 17 import org.openstreetmap.josm.data.osm.DataSet; 19 18 import org.openstreetmap.josm.data.osm.LineSegment; … … 21 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 21 import org.openstreetmap.josm.data.osm.Way; 23 import org.openstreetmap.josm.data.osm.visitor.Bounding Visitor;22 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 24 23 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; 25 24 import org.openstreetmap.josm.data.osm.visitor.SimplePaintVisitor; 26 25 import org.openstreetmap.josm.data.projection.Projection; 27 import org.openstreetmap.josm.gui.ImageProvider;28 26 import org.openstreetmap.josm.gui.MapView; 27 import org.openstreetmap.josm.tools.ImageProvider; 29 28 30 29 /** … … 86 85 if (evt.getPropertyName().equals("projection")) 87 86 for (Node n : OsmDataLayer.this.data.nodes) 88 ((Projection)evt.getNewValue()).latlon2 xy(n.coor);87 ((Projection)evt.getNewValue()).latlon2eastNorth(n.coor); 89 88 } 90 89 }); … … 113 112 if (!osm.isDeleted()) 114 113 osm.visit(visitor); 115 for (OsmPrimitive osm : data.wa ies)114 for (OsmPrimitive osm : data.ways) 116 115 if (!osm.isDeleted()) 117 116 osm.visit(visitor); … … 128 127 return undeletedSize(data.nodes)+" nodes, "+ 129 128 undeletedSize(data.lineSegments)+" segments, "+ 130 undeletedSize(data.wa ies)+" streets.";129 undeletedSize(data.ways)+" streets."; 131 130 } 132 131 … … 145 144 146 145 @Override 147 public Bounds getBoundsLatLon() { 148 BoundingVisitor b = new BoundingVisitor(BoundingVisitor.Type.LATLON); 146 public void visitBoundingBox(BoundingXYVisitor v) { 149 147 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); 160 149 } 161 150 … … 163 152 public void init(Projection projection) { 164 153 for (Node n : data.nodes) 165 projection.latlon2 xy(n.coor);154 projection.latlon2eastNorth(n.coor); 166 155 } 167 156 … … 238 227 for (Iterator<LineSegment> it = data.lineSegments.iterator(); it.hasNext();) 239 228 cleanIterator(it, processedSet); 240 for (Iterator<Way> it = data.wa ies.iterator(); it.hasNext();)229 for (Iterator<Way> it = data.ways.iterator(); it.hasNext();) 241 230 cleanIterator(it, processedSet); 242 231 } -
src/org/openstreetmap/josm/gui/layer/RawGpsDataLayer.java
r64 r71 7 7 import java.beans.PropertyChangeListener; 8 8 import java.util.Collection; 9 import java.util.LinkedList; 9 10 10 11 import javax.swing.Icon; 11 12 12 13 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data.Bounds; 14 import org.openstreetmap.josm.data.GeoPoint; 14 import org.openstreetmap.josm.data.coor.LatLon; 15 import org.openstreetmap.josm.data.coor.EastNorth; 16 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 15 17 import org.openstreetmap.josm.data.projection.Projection; 16 import org.openstreetmap.josm.gui.ImageProvider;17 18 import org.openstreetmap.josm.gui.MapView; 19 import org.openstreetmap.josm.tools.ImageProvider; 18 20 19 21 /** … … 28 30 29 31 /** 30 * A list of wa ies which containing a list of points.32 * A list of ways which containing a list of points. 31 33 */ 32 private final Collection<Collection<GeoPoint>> data; 34 private final Collection<Collection<LatLon>> data; 35 private Collection<Collection<EastNorth>> eastNorth; 33 36 34 public RawGpsDataLayer(Collection<Collection< GeoPoint>> data, String name) {37 public RawGpsDataLayer(Collection<Collection<LatLon>> data, String name) { 35 38 super(name); 36 39 this.data = data; 40 37 41 Main.pref.addPropertyChangeListener(new PropertyChangeListener(){ 38 42 public void propertyChange(PropertyChangeEvent evt) { … … 62 66 g.setColor(Color.GRAY); 63 67 Point old = null; 64 for (Collection< GeoPoint> c : data) {68 for (Collection<EastNorth> c : eastNorth) { 65 69 if (!Main.pref.isForceRawGpsLines()) 66 70 old = null; 67 for ( GeoPoint p: c) {68 Point screen = mv.get ScreenPoint(p);71 for (EastNorth eastNorth : c) { 72 Point screen = mv.getPoint(eastNorth); 69 73 if (Main.pref.isDrawRawGpsLines() && old != null) 70 74 g.drawLine(old.x, old.y, screen.x, screen.y); … … 78 82 @Override 79 83 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."; 81 88 } 82 89 … … 93 100 94 101 @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); 136 106 } 137 107 138 108 @Override 139 109 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 } 143 117 } 144 118 } -
src/org/openstreetmap/josm/io/GpxReader.java
r66 r71 12 12 import org.jdom.JDOMException; 13 13 import org.jdom.input.SAXBuilder; 14 import org.openstreetmap.josm.data. GeoPoint;14 import org.openstreetmap.josm.data.coor.LatLon; 15 15 import org.openstreetmap.josm.data.osm.DataSet; 16 16 import org.openstreetmap.josm.data.osm.LineSegment; … … 73 73 */ 74 74 private Node parseWaypoint(Element e) { 75 Node data = new Node(new GeoPoint(75 Node data = new Node(new LatLon( 76 76 Double.parseDouble(e.getAttributeValue("lat")), 77 77 Double.parseDouble(e.getAttributeValue("lon")))); … … 97 97 private DataSet parseDataSet(Element e) { 98 98 DataSet data = new DataSet(); 99 // read waypoints not contained in wa ies or areas99 // read waypoints not contained in ways or areas 100 100 for (Object o : e.getChildren("wpt", GPX)) { 101 101 Node node = parseWaypoint((Element)o); … … 103 103 } 104 104 105 // read wa ies (and line segments)105 // read ways (and line segments) 106 106 for (Object wayElement : e.getChildren("trk", GPX)) 107 107 parseWay((Element)wayElement, data); … … 155 155 ds.lineSegments.addAll(way.segments); 156 156 if (!realLineSegment) 157 ds.wa ies.add(way);157 ds.ways.add(way); 158 158 } 159 159 … … 170 170 if (mergeNodes) 171 171 for (Node n : data.nodes) 172 if (node.coor.equals LatLon(n.coor))172 if (node.coor.equals(n.coor)) 173 173 return n; 174 174 data.nodes.add(node); -
src/org/openstreetmap/josm/io/GpxWriter.java
r66 r71 106 106 LinkedList<LineSegment> unrefLs = new LinkedList<LineSegment>(ds.lineSegments); 107 107 108 // wa ies109 for (Way t : ds.wa ies) {108 // ways 109 for (Way t : ds.ways) { 110 110 if (t.isDeleted() && t.id == 0) 111 111 continue; … … 135 135 } 136 136 137 // encode pending line segments as wa ies137 // encode pending line segments as ways 138 138 for (LineSegment ls : unrefLs) { 139 139 if (ls.isDeleted() && ls.id == 0) … … 195 195 private Element parseWaypoint(Node n, String name) { 196 196 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())); 199 199 HashMap<String, String> keys = null; 200 200 if (n.keys != null) { -
src/org/openstreetmap/josm/io/OsmConnection.java
r23 r71 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm. gui.GBC;16 import org.openstreetmap.josm.tools.GBC; 17 17 18 18 /** -
src/org/openstreetmap/josm/io/OsmReader.java
r66 r71 6 6 import java.util.Map; 7 7 8 import org.openstreetmap.josm.data. GeoPoint;8 import org.openstreetmap.josm.data.coor.LatLon; 9 9 import org.openstreetmap.josm.data.osm.DataSet; 10 10 import org.openstreetmap.josm.data.osm.LineSegment; … … 76 76 throw new SAXException("Unknown version: "+atts.getValue("version")); 77 77 } 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"))); 79 79 current = n; 80 80 readCommon(atts); -
src/org/openstreetmap/josm/io/OsmReaderOld.java
r66 r71 9 9 import org.jdom.JDOMException; 10 10 import org.jdom.input.SAXBuilder; 11 import org.openstreetmap.josm.data. GeoPoint;11 import org.openstreetmap.josm.data.coor.LatLon; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 13 import org.openstreetmap.josm.data.osm.LineSegment; … … 62 62 */ 63 63 private Node parseNode(Element e) throws JDOMException { 64 Node data = new Node(new GeoPoint(64 Node data = new Node(new LatLon( 65 65 Double.parseDouble(e.getAttributeValue("lat")), 66 66 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()); 71 71 parseCommon(data, e); 72 72 return data; … … 221 221 if (osm.id == id) 222 222 return osm; 223 for (OsmPrimitive osm : data.wa ies)223 for (OsmPrimitive osm : data.ways) 224 224 if (osm.id == id) 225 225 return osm; -
src/org/openstreetmap/josm/io/OsmServerReader.java
r65 r71 11 11 import org.jdom.JDOMException; 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data. GeoPoint;13 import org.openstreetmap.josm.data.coor.LatLon; 14 14 import org.openstreetmap.josm.data.osm.DataSet; 15 15 import org.xml.sax.SAXException; … … 45 45 * @return A list of all primitives retrieved. Currently, the list of lists 46 46 * contain only one list, since the server cannot distinguish between 47 * wa ies.47 * ways. 48 48 */ 49 public Collection<Collection< GeoPoint>> parseRawGps() throws IOException, JDOMException {49 public Collection<Collection<LatLon>> parseRawGps() throws IOException, JDOMException { 50 50 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>(); 53 53 54 54 for (int i = 0;;++i) { … … 57 57 break; 58 58 RawGpsReader gpsReader = new RawGpsReader(r); 59 Collection<Collection< GeoPoint>> allWays = gpsReader.parse();59 Collection<Collection<LatLon>> allWays = gpsReader.parse(); 60 60 boolean foundSomething = false; 61 for (Collection< GeoPoint> t : allWays) {61 for (Collection<LatLon> t : allWays) { 62 62 if (!t.isEmpty()) { 63 63 foundSomething = true; … … 101 101 HttpURLConnection con = (HttpURLConnection)url.openConnection(); 102 102 con.setConnectTimeout(20000); 103 System.out.println("response: "+con.getResponseCode()); 103 104 if (con.getResponseCode() == 401 && isCancelled()) 104 105 return null; -
src/org/openstreetmap/josm/io/OsmWriter.java
r66 r71 72 72 for (LineSegment ls : ds.lineSegments) 73 73 writer.visit(ls); 74 for (Way w : ds.wa ies)74 for (Way w : ds.ways) 75 75 writer.visit(w); 76 76 writer.out.println("</osm>"); … … 99 99 public void visit(Node n) { 100 100 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()+"'"); 102 102 addTags(n, "node", true); 103 103 } -
src/org/openstreetmap/josm/io/RawCsvReader.java
r38 r71 11 11 import org.jdom.JDOMException; 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data. GeoPoint;13 import org.openstreetmap.josm.data.coor.LatLon; 14 14 15 15 /** … … 28 28 } 29 29 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>(); 32 32 String formatStr = Main.pref.csvImportString; 33 33 if (formatStr == null) … … 62 62 lineNo++; 63 63 StringTokenizer st = new StringTokenizer(line, delim); 64 GeoPoint p = new GeoPoint();64 double lat = 0, lon = 0; 65 65 for (String token : format) { 66 66 if (token.equals("lat")) 67 p.lat = Double.parseDouble(st.nextToken());67 lat = Double.parseDouble(st.nextToken()); 68 68 else if (token.equals("lon")) 69 p.lon = Double.parseDouble(st.nextToken());69 lon = Double.parseDouble(st.nextToken()); 70 70 else if (token.equals("ignore")) 71 71 st.nextToken(); … … 73 73 throw new JDOMException("Unknown data type: '"+token+"'."+(Main.pref.csvImportString == null ? " Maybe add an format string in preferences." : "")); 74 74 } 75 data.add( p);75 data.add(new LatLon(lat, lon)); 76 76 } 77 77 } catch (RuntimeException e) { -
src/org/openstreetmap/josm/io/RawGpsReader.java
r64 r71 11 11 import org.jdom.Namespace; 12 12 import org.jdom.input.SAXBuilder; 13 import org.openstreetmap.josm.data. GeoPoint;13 import org.openstreetmap.josm.data.coor.LatLon; 14 14 15 15 /** 16 * Read raw gps data from a gpx file. Only way points with their wa ies segments16 * Read raw gps data from a gpx file. Only way points with their ways segments 17 17 * and waypoints are imported. 18 18 * @author imi … … 42 42 * Parse and return the read data 43 43 */ 44 public Collection<Collection< GeoPoint>> parse() throws JDOMException, IOException {44 public Collection<Collection<LatLon>> parse() throws JDOMException, IOException { 45 45 final SAXBuilder builder = new SAXBuilder(); 46 46 builder.setValidation(false); … … 55 55 */ 56 56 @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>>(); 59 59 60 60 // workaround for bug where the server adds /gpx.asd to the namespace … … 62 62 63 63 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))); 66 66 data.add(line); 67 67 } 68 68 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)); 70 70 if (!line.isEmpty()) 71 71 data.add(line); … … 73 73 for (Object o : root.getChildren("trk", GPX)) { 74 74 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)); 76 76 if (!line.isEmpty()) 77 77 data.add(line); … … 81 81 } 82 82 83 enum LatLon{lat, lon}83 private enum LatLonAttr {lat, lon} 84 84 /** 85 85 * Return a parsed float value from the element behind the object o. … … 88 88 * @throws JDOMException If the absolute of the value is out of bound. 89 89 */ 90 private double parseDouble(Element e, LatLon attr) throws JDOMException {90 private double parseDouble(Element e, LatLonAttr attr) throws JDOMException { 91 91 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)) 93 93 throw new JDOMException("Data error: "+attr+" value '"+d+"' is out of bound."); 94 94 return d; … … 99 99 * points read. 100 100 */ 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>(); 103 103 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))); 105 105 return data; 106 106 } -
src/org/openstreetmap/josm/tools/BugReportExceptionHandler.java
r63 r71 1 package org.openstreetmap.josm. gui;1 package org.openstreetmap.josm.tools; 2 2 3 3 import java.awt.GridBagLayout; -
src/org/openstreetmap/josm/tools/GBC.java
r63 r71 1 package org.openstreetmap.josm. gui;1 package org.openstreetmap.josm.tools; 2 2 3 3 import java.awt.Component; -
src/org/openstreetmap/josm/tools/ImageProvider.java
r64 r71 1 package org.openstreetmap.josm. gui;1 package org.openstreetmap.josm.tools; 2 2 3 3 import java.awt.Graphics;
Note:
See TracChangeset
for help on using the changeset viewer.