# Changeset 1640 in josm

Ignore:
Timestamp:
2009-06-06T14:30:21+02:00 (13 years ago)
Message:

little bit more refactoring of coordinate access - patch by jttt

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

Unmodified
Removed

• ## trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java

 r1212 itnodes.remove(n); for (Node m : itnodes) { double dist = Math.sqrt(n.eastNorth.distance(m.eastNorth)); double dist = Math.sqrt(n.getEastNorth().distance(m.getEastNorth())); if (dist > distance) { nodea = n; // Find out co-ords of A and B double ax = nodea.eastNorth.east(); double ay = nodea.eastNorth.north(); double bx = nodeb.eastNorth.east(); double by = nodeb.eastNorth.north(); double ax = nodea.getEastNorth().east(); double ay = nodea.getEastNorth().north(); double bx = nodeb.getEastNorth().east(); double by = nodeb.getEastNorth().north(); // A list of commands to do for (Node n : nodes) { // Get existing co-ords of node to move double nx = n.eastNorth.east(); double ny = n.eastNorth.north(); double nx = n.getEastNorth().east(); double ny = n.getEastNorth().north(); if (ax == bx) { double c1 = ay - (ax * m1); double m2 = (-1) / m1; double c2 = n.eastNorth.north() - (n.eastNorth.east() * m2); double c2 = n.getEastNorth().north() - (n.getEastNorth().east() * m2); nx = (c2 - c1) / (m1 - m2); // Add the command to move the node to its new position. cmds.add(new MoveCommand(n, nx - n.eastNorth.east(), ny - n.eastNorth.north() )); cmds.add(new MoveCommand(n, nx - n.getEastNorth().east(), ny - n.getEastNorth().north() )); }
• ## trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java

 r1245 // let's get some shorter names Node   n1 = ((Node)nodes.toArray()[0]); double x1 = n1.eastNorth.east(); double y1 = n1.eastNorth.north(); double x1 = n1.getEastNorth().east(); double y1 = n1.getEastNorth().north(); Node   n2 = ((Node)nodes.toArray()[1]); double x2 = n2.eastNorth.east(); double y2 = n2.eastNorth.north(); double x2 = n2.getEastNorth().east(); double y2 = n2.getEastNorth().north(); Node   n3 = ((Node)nodes.toArray()[2]); double x3 = n3.eastNorth.east(); double y3 = n3.eastNorth.north(); double x3 = n3.getEastNorth().east(); double y3 = n3.getEastNorth().north(); // calculate the center (xc/yc)
• ## trunk/src/org/openstreetmap/josm/actions/DistributeAction.java

 r1380 itnodes.remove(n); for (Node m : itnodes) { double dist = Math.sqrt(n.eastNorth.distance(m.eastNorth)); double dist = Math.sqrt(n.getEastNorth().distance(m.getEastNorth())); if (dist > distance) { nodea = n; // Find out co-ords of A and B double ax = nodea.eastNorth.east(); double ay = nodea.eastNorth.north(); double bx = nodeb.eastNorth.east(); double by = nodeb.eastNorth.north(); double ax = nodea.getEastNorth().east(); double ay = nodea.getEastNorth().north(); double bx = nodeb.getEastNorth().east(); double by = nodeb.getEastNorth().north(); // A list of commands to do distance = 0.0; for (Node n : nodes) { double dist = Math.sqrt(nodeb.eastNorth.distance(n.eastNorth)); double dist = Math.sqrt(nodeb.getEastNorth().distance(n.getEastNorth())); if (dist > distance) { s = n; // First move the node to A's position, then move it towards B double dx = ax - s.eastNorth.east() + (bx-ax)*pos/num; double dy = ay - s.eastNorth.north() + (by-ay)*pos/num; double dx = ax - s.getEastNorth().east() + (bx-ax)*pos/num; double dy = ay - s.getEastNorth().north() + (by-ay)*pos/num; cmds.add(new MoveCommand(s, dx, dy));
• ## trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java

 r1218 List wss = Main.map.mapView.getNearestWaySegments( Main.map.mapView.getPoint(node.eastNorth)); Main.map.mapView.getPoint(node.getEastNorth())); HashMap> insertPoints = new HashMap>(); for (WaySegment ws : wss) {
• ## trunk/src/org/openstreetmap/josm/actions/MoveAction.java

 r1169 for (Node n : affectedNodes) { if (n.coor.isOutSideWorld()) { if (n.getCoor().isOutSideWorld()) { // Revert move ((MoveCommand) c).moveAgain(-distx, -disty);

• ## trunk/src/org/openstreetmap/josm/actions/PasteAction.java

 r1636 double maxEast = -1E100, minEast = 1E100, maxNorth = -1E100, minNorth = 1E100; for (Node n : pasteBuffer.nodes) { double east = n.eastNorth.east(); double north = n.eastNorth.north(); double east = n.getEastNorth().east(); double north = n.getEastNorth().north(); if (east > maxEast) { maxEast = east; } if (east < minEast) { minEast = east; } nnew.id = 0; if (Main.main.editLayer() == source) { nnew.setEastNorth(nnew.eastNorth.add(offsetEast, offsetNorth)); nnew.setEastNorth(nnew.getEastNorth().add(offsetEast, offsetNorth)); } map.put(n, nnew);
• ## trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

 r1636 // no node found in clicked area n = new Node(Main.map.mapView.getLatLon(e.getX(), e.getY())); if (n.coor.isOutSideWorld()) { if (n.getCoor().isOutSideWorld()) { JOptionPane.showMessageDialog(Main.parent, tr("Cannot add a node outside of the world.")); // user clicked on node if (selection.isEmpty()) return; currentMouseEastNorth = currentMouseNode.eastNorth; currentMouseEastNorth = currentMouseNode.getEastNorth(); mouseOnExistingNode = currentMouseNode; } else { // find out the distance, in metres, between the base point and the mouse cursor LatLon mouseLatLon = Main.proj.eastNorth2latlon(currentMouseEastNorth); distance = currentBaseNode.coor.greatCircleDistance(mouseLatLon); double hdg = Math.toDegrees(currentBaseNode.coor.heading(mouseLatLon)); distance = currentBaseNode.getCoor().greatCircleDistance(mouseLatLon); double hdg = Math.toDegrees(currentBaseNode.getCoor().heading(mouseLatLon)); if (previousNode != null) { angle = hdg - Math.toDegrees(previousNode.coor.heading(currentBaseNode.coor)); angle = hdg - Math.toDegrees(previousNode.getCoor().heading(currentBaseNode.getCoor())); if (angle < 0) angle += 360; } Iterator> i = segs.iterator(); Pair seg = i.next(); EastNorth A = seg.a.eastNorth; EastNorth B = seg.b.eastNorth; EastNorth A = seg.a.getEastNorth(); EastNorth B = seg.b.getEastNorth(); seg = i.next(); EastNorth C = seg.a.eastNorth; EastNorth D = seg.b.eastNorth; EastNorth C = seg.a.getEastNorth(); EastNorth D = seg.b.getEastNorth(); double u=det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north()); // fall through to default action. // (for semi-parallel lines, intersection might be miles away!) if (Main.map.mapView.getPoint(n.eastNorth).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) { if (Main.map.mapView.getPoint(n.getEastNorth()).distance(Main.map.mapView.getPoint(intersection)) < snapToIntersectionThreshold) { n.setEastNorth(intersection); return; default: EastNorth P = n.eastNorth; EastNorth P = n.getEastNorth(); seg = segs.iterator().next(); A = seg.a.eastNorth; B = seg.b.eastNorth; A = seg.a.getEastNorth(); B = seg.b.getEastNorth(); double a = P.distanceSq(B); double b = P.distanceSq(A); g2.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); GeneralPath b = new GeneralPath(); Point p1=mv.getPoint(currentBaseNode.eastNorth); Point p1=mv.getPoint(currentBaseNode.getEastNorth()); Point p2=mv.getPoint(currentMouseEastNorth);
• ## trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java

 r1422 Node n2 = selectedSegment.way.nodes.get(selectedSegment.lowerIndex + 1); EastNorth en1 = n1.eastNorth; EastNorth en2 = n2.eastNorth; EastNorth en1 = n1.getEastNorth(); EastNorth en2 = n2.getEastNorth(); EastNorth en3 = mv.getEastNorth(mousePos.x, mousePos.y); Node n1 = selectedSegment.way.nodes.get(selectedSegment.lowerIndex); Node n2 = selectedSegment.way.nodes.get(selectedSegment.lowerIndex+1); EastNorth en3 = n2.eastNorth.add(xoff, yoff); EastNorth en3 = n2.getEastNorth().add(xoff, yoff); Node n3 = new Node(Main.proj.eastNorth2latlon(en3)); EastNorth en4 = n1.eastNorth.add(xoff, yoff); EastNorth en4 = n1.getEastNorth().add(xoff, yoff); Node n4 = new Node(Main.proj.eastNorth2latlon(en4)); Way wnew = new Way(selectedSegment.way);
• ## trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

 r1634 for (Node n : affectedNodes) { if (n.coor.isOutSideWorld()) { if (n.getCoor().isOutSideWorld()) { // Revert move ((MoveCommand) c).moveAgain(-dx, -dy); { Way w = (Way)osm; Point p1 = c.getPoint(w.nodes.get(nearestWS.lowerIndex).eastNorth); Point p2 = c.getPoint(w.nodes.get(nearestWS.lowerIndex+1).eastNorth); Point p1 = c.getPoint(w.nodes.get(nearestWS.lowerIndex).getEastNorth()); Point p2 = c.getPoint(w.nodes.get(nearestWS.lowerIndex+1).getEastNorth()); if(SimplePaintVisitor.isLargeSegment(p1, p2, Main.pref.getInteger("mappaint.node.virtual-space", 70))) {
• ## trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

 r1499 if (osm instanceof Node && osm.id != 0) { Node n = (Node) osm; if (!a.contains(n.coor)) { if (!a.contains(n.getCoor())) { JPanel msg = new JPanel(new GridBagLayout()); msg.add(new JLabel(
• ## trunk/src/org/openstreetmap/josm/command/MoveCommand.java

 r1636 for (Node n : this.objects) { OldState os = new OldState(); os.eastNorth = n.eastNorth; os.latlon = n.coor; os.eastNorth = n.getEastNorth(); os.latlon = n.getCoor(); os.modified = n.modified; oldState.add(os); public void moveAgain(double x, double y) { for (Node n : objects) { n.setEastNorth(n.eastNorth.add(x, y)); n.setEastNorth(n.getEastNorth().add(x, y)); } this.x += x; @Override public boolean executeCommand() { for (Node n : objects) { n.setEastNorth(n.eastNorth.add(x, y)); n.setEastNorth(n.getEastNorth().add(x, y)); n.modified = true; }
• ## trunk/src/org/openstreetmap/josm/command/RotateCommand.java

 r1636 for (Node n : this.objects) { MoveCommand.OldState os = new MoveCommand.OldState(); os.eastNorth = n.eastNorth; os.latlon = n.coor; os.eastNorth = n.getEastNorth(); os.latlon = n.getCoor(); os.modified = n.modified; oldState.put(n, os);
• ## trunk/src/org/openstreetmap/josm/data/conflict/PositionConflict.java

 r1636 @Override public boolean hasConflict(OsmPrimitive key, OsmPrimitive value) { return key instanceof Node && !((Node)key).coor.equals(((Node)value).coor); return key instanceof Node && !((Node)key).getCoor().equals(((Node)value).getCoor()); } @Override protected String str(OsmPrimitive osm) { return osm instanceof Node ? ((Node)osm).coor.lat()+", "+((Node)osm).coor.lon() : null; return osm instanceof Node ? ((Node)osm).getCoor().lat()+", "+((Node)osm).getCoor().lon() : null; } @Override public void apply(OsmPrimitive target, OsmPrimitive other) { if (target instanceof Node) { ((Node)target).setEastNorth(((Node)other).eastNorth); ((Node)target).setEastNorth(((Node)other).getEastNorth()); int newversion = Math.max(target.version, other.version); // set version on "other" as well in case user decides to keep local
• ## trunk/src/org/openstreetmap/josm/data/osm/Node.java

 r1636 public LatLon coor; public volatile EastNorth eastNorth; public void setCoor(LatLon coor) { public final void setCoor(LatLon coor) { this.coor = coor; this.eastNorth = Main.proj.latlon2eastNorth(coor); this.eastNorth = Main.proj.latlon2eastNorth(coor); } public void setEastNorth(EastNorth eastNorth) { public final LatLon getCoor() { return coor; } public final void setEastNorth(EastNorth eastNorth) { this.eastNorth = eastNorth; this.coor = Main.proj.eastNorth2latlon(eastNorth); } public void setEastNorth(double east, double north) { public final void setEastNorth(double east, double north) { this.setEastNorth(new EastNorth(east, north)); } public final EastNorth getEastNorth() { return eastNorth; } private static CoordinateFormat mCord; return name; } }
• ## trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

 r1523 public void visit(Node n) { visit(n.eastNorth); visit(n.getEastNorth()); }
• ## trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

 r1635 public void visit(Node n) { /* check, if the node is visible at all */ if((n.eastNorth.east()  > maxEN.east() ) || (n.eastNorth.north() > maxEN.north()) || (n.eastNorth.east()  < minEN.east() ) || (n.eastNorth.north() < minEN.north())) if((n.getEastNorth().east()  > maxEN.east() ) || (n.getEastNorth().north() > maxEN.north()) || (n.getEastNorth().east()  < minEN.east() ) || (n.getEastNorth().north() < minEN.north())) { n.mappaintVisibleCode = viewid; for (Node n : w.nodes) { if(n.eastNorth.east() > maxx) maxx = n.eastNorth.east(); if(n.eastNorth.north() > maxy) maxy = n.eastNorth.north(); if(n.eastNorth.east() < minx) minx = n.eastNorth.east(); if(n.eastNorth.north() < miny) miny = n.eastNorth.north(); if(n.getEastNorth().east() > maxx) maxx = n.getEastNorth().east(); if(n.getEastNorth().north() > maxy) maxy = n.getEastNorth().north(); if(n.getEastNorth().east() < minx) minx = n.getEastNorth().east(); if(n.getEastNorth().north() < miny) miny = n.getEastNorth().north(); } } Point pFrom = nc.getPoint(fromNode.eastNorth); Point pVia = nc.getPoint(viaNode.eastNorth); Point pFrom = nc.getPoint(fromNode.getEastNorth()); Point pVia = nc.getPoint(viaNode.getEastNorth()); //if(restrictionDebug) { for (Node n : w.nodes) { p = nc.getPoint(n.eastNorth); p = nc.getPoint(n.getEastNorth()); poly.addPoint(p.x,p.y); } for (Node n : wInner.nodes) { Point pInner = nc.getPoint(n.eastNorth); Point pInner = nc.getPoint(n.getEastNorth()); polygon.addPoint(pInner.x,pInner.y); } if(!wInner.isClosed()) { Point pInner = nc.getPoint(wInner.nodes.get(0).eastNorth); Point pInner = nc.getPoint(wInner.nodes.get(0).getEastNorth()); polygon.addPoint(pInner.x,pInner.y); } for (Node n : w.nodes) { Point p = nc.getPoint(n.eastNorth); Point p = nc.getPoint(n.getEastNorth()); polygon.addPoint(p.x,p.y); } protected void drawNode(Node n, ImageIcon icon, boolean annotate, Boolean selected) { Point p = nc.getPoint(n.eastNorth); Point p = nc.getPoint(n.getEastNorth()); if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return; displaySegments(col, width, dashed, dashedColor); } Point p1 = nc.getPoint(n1.eastNorth); Point p2 = nc.getPoint(n2.eastNorth); Point p1 = nc.getPoint(n1.getEastNorth()); Point p2 = nc.getPoint(n2.getEastNorth()); if (!isSegmentVisible(p1, p2)) { public void drawNode(Node n, Color color, int size, int radius, boolean fill) { if (isZoomOk(null) && size > 1) { Point p = nc.getPoint(n.eastNorth); Point p = nc.getPoint(n.getEastNorth()); if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) */ protected void drawOrderNumber(Node n1, Node n2, int orderNumber) { Point p1 = nc.getPoint(n1.eastNorth); Point p2 = nc.getPoint(n2.eastNorth); Point p1 = nc.getPoint(n1.getEastNorth()); Point p2 = nc.getPoint(n2.getEastNorth()); drawOrderNumber(p1, p2, orderNumber); }
• ## trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java

 r1567 private static boolean realMatch(Node n1, Node n2) { return n1.coor.equalsEpsilon(n2.coor); return n1.getCoor().equalsEpsilon(n2.getCoor()); }
• ## trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java

 r1523 Iterator it = w.nodes.iterator(); if (it.hasNext()) { Point lastP = nc.getPoint(it.next().eastNorth); Point lastP = nc.getPoint(it.next().getEastNorth()); while(it.hasNext()) { Point p = nc.getPoint(it.next().eastNorth); Point p = nc.getPoint(it.next().getEastNorth()); if(isSegmentVisible(lastP, p) && isLargeSegment(lastP, p, virtualNodeSpace)) { Iterator it = w.nodes.iterator(); if (it.hasNext()) { Point lastP = nc.getPoint(it.next().eastNorth); Point lastP = nc.getPoint(it.next().getEastNorth()); for (int orderNumber = 1; it.hasNext(); orderNumber++) { Point p = nc.getPoint(it.next().eastNorth); Point p = nc.getPoint(it.next().getEastNorth()); drawSegment(lastP, p, wayColor, showOnlyHeadArrowOnly ? !it.hasNext() : showThisDirectionArrow); if (m.member instanceof Node) { Point p = nc.getPoint(((Node) m.member).eastNorth); Point p = nc.getPoint(((Node) m.member).getEastNorth()); if (p.x < 0 || p.y < 0 || p.x > nc.getWidth() || p.y > nc.getHeight()) continue; for (Node n : ((Way) m.member).nodes) { if (n.incomplete || n.deleted) continue; Point p = nc.getPoint(n.eastNorth); Point p = nc.getPoint(n.getEastNorth()); if (first) { path.moveTo(p.x, p.y); public void drawNode(Node n, Color color, int size, int radius, boolean fill) { if (size > 1) { Point p = nc.getPoint(n.eastNorth); Point p = nc.getPoint(n.getEastNorth()); if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight()))
• ## trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

 r1503 if (n.deleted || n.incomplete) continue; Point sp = getPoint(n.eastNorth); Point sp = getPoint(n.getEastNorth()); double dist = p.distanceSq(sp); if (dist < minDistanceSq) { } Point A = getPoint(lastN.eastNorth); Point B = getPoint(n.eastNorth); Point A = getPoint(lastN.getEastNorth()); Point B = getPoint(n.getEastNorth()); double c = A.distanceSq(B); double a = p.distanceSq(B); continue; } Point A = getPoint(lastN.eastNorth); Point B = getPoint(n.eastNorth); Point A = getPoint(lastN.getEastNorth()); Point B = getPoint(n.getEastNorth()); double c = A.distanceSq(B); double a = p.distanceSq(B); for (Node n : getData().nodes) { if (!n.deleted && !n.incomplete && getPoint(n.eastNorth).distanceSq(p) < snapDistance) { && getPoint(n.getEastNorth()).distanceSq(p) < snapDistance) { nearest.add(n); } for (Node n : getData().nodes) { if (!n.deleted && !n.incomplete && getPoint(n.eastNorth).distanceSq(p) < snapDistance) { && getPoint(n.getEastNorth()).distanceSq(p) < snapDistance) { nearest.add(n); }
• ## trunk/src/org/openstreetmap/josm/gui/SelectionManager.java

 r1169 // nodes for (Node n : nc.getData().nodes) { if (!n.deleted && !n.incomplete && r.contains(nc.getPoint(n.eastNorth))) if (!n.deleted && !n.incomplete && r.contains(nc.getPoint(n.getEastNorth()))) selection.add(n); } if (alt) { for (Node n : w.nodes) { if (!n.incomplete && r.contains(nc.getPoint(n.eastNorth))) { if (!n.incomplete && r.contains(nc.getPoint(n.getEastNorth()))) { selection.add(w); break; boolean allIn = true; for (Node n : w.nodes) { if (!n.incomplete && !r.contains(nc.getPoint(n.eastNorth))) { if (!n.incomplete && !r.contains(nc.getPoint(n.getEastNorth()))) { allIn = false; break;
• ## trunk/src/org/openstreetmap/josm/gui/conflict/nodes/NodeListTableCellRenderer.java

 r1631 sb.append(" ("); if (node.coor != null) { sb.append(COORD_FORMATTER.format(node.coor.lat())); if (node.getCoor() != null) { sb.append(COORD_FORMATTER.format(node.getCoor().lat())); sb.append(","); sb.append(COORD_FORMATTER.format(node.coor.lon())); sb.append(COORD_FORMATTER.format(node.getCoor().lon())); } else { sb.append("?,?");
• ## trunk/src/org/openstreetmap/josm/gui/conflict/relation/RelationMemberTableCellRenderer.java

 r1631 Node n = (Node)primitive; sb.append(" ("); if (n.coor != null) { sb.append(COORD_FORMATTER.format(n.coor.lat())); if (n.getCoor() != null) { sb.append(COORD_FORMATTER.format(n.getCoor().lat())); sb.append(","); sb.append(COORD_FORMATTER.format(n.coor.lon())); sb.append(COORD_FORMATTER.format(n.getCoor().lon())); } else { sb.append("?,?");
• ## trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

 r1622 Visitor conflictPainter = new AbstractVisitor(){ public void visit(Node n) { Point p = nc.getPoint(n.eastNorth); Point p = nc.getPoint(n.getEastNorth()); g.drawRect(p.x-1, p.y-1, 2, 2); } public void visit(Node n1, Node n2) { Point p1 = nc.getPoint(n1.eastNorth); Point p2 = nc.getPoint(n2.eastNorth); Point p1 = nc.getPoint(n1.getEastNorth()); Point p2 = nc.getPoint(n2.getEastNorth()); g.drawLine(p1.x, p1.y, p2.x, p2.y); }
• ## trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

 r1558 doneNodes.add(n); } WayPoint wpt = new WayPoint(n.coor); WayPoint wpt = new WayPoint(n.getCoor()); if (!n.isTimestampEmpty()) { for (Node n : data.nodes) { if (n.incomplete || n.deleted || doneNodes.contains(n)) continue; WayPoint wpt = new WayPoint(n.coor); WayPoint wpt = new WayPoint(n.getCoor()); if (!n.isTimestampEmpty()) { wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp()));
• ## trunk/src/org/openstreetmap/josm/io/OsmWriter.java

 r1604 if (n.incomplete) return; addCommon(n, "node"); out.print(" lat='"+n.coor.lat()+"' lon='"+n.coor.lon()+"'"); out.print(" lat='"+n.getCoor().lat()+"' lon='"+n.getCoor().lon()+"'"); if (!withBody) { out.println("/>");
Note: See TracChangeset for help on using the changeset viewer.