Index: /src/org/openstreetmap/josm/actions/DownloadAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 33)
+++ /src/org/openstreetmap/josm/actions/DownloadAction.java	(revision 34)
@@ -61,11 +61,11 @@
 		dlg.add(new JLabel("Bounding box"), GBC.eol());
 
+		dlg.add(new JLabel("min lon"), GBC.std().insets(10,0,5,0));
+		dlg.add(latlon[0], GBC.std());
 		dlg.add(new JLabel("min lat"), GBC.std().insets(10,0,5,0));
-		dlg.add(latlon[0], GBC.std());
+		dlg.add(latlon[1], GBC.eol());
+		dlg.add(new JLabel("max lon"), GBC.std().insets(10,0,5,0));
+		dlg.add(latlon[2], GBC.std());
 		dlg.add(new JLabel("max lat"), GBC.std().insets(10,0,5,0));
-		dlg.add(latlon[1], GBC.eol());
-		dlg.add(new JLabel("min lon"), GBC.std().insets(10,0,5,0));
-		dlg.add(latlon[2], GBC.std());
-		dlg.add(new JLabel("max lon"), GBC.std().insets(10,0,5,0));
 		dlg.add(latlon[3], GBC.eop());
 
@@ -144,6 +144,5 @@
 			return;
 		}
-		OsmServerReader osmReader = new OsmServerReader(Main.pref.osmDataServer,
-				b.latlon[0], b.latlon[1], b.latlon[2], b.latlon[3]);
+		OsmServerReader osmReader = new OsmServerReader(b.latlon[0], b.latlon[1], b.latlon[2], b.latlon[3]);
 		try {
 			String name = latlon[0].getText()+" "+latlon[1].getText()+" x "+
Index: /src/org/openstreetmap/josm/actions/UploadAction.java
===================================================================
--- /src/org/openstreetmap/josm/actions/UploadAction.java	(revision 33)
+++ /src/org/openstreetmap/josm/actions/UploadAction.java	(revision 34)
@@ -15,8 +15,10 @@
 import javax.swing.KeyStroke;
 
+import org.jdom.JDOMException;
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.GBC;
 import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
+import org.openstreetmap.josm.io.OsmServerWriter;
 
 /**
@@ -61,5 +63,15 @@
 			return;
 		
-		JOptionPane.showMessageDialog(Main.main, "not implemented yet.");
+		OsmServerWriter server = new OsmServerWriter();
+		try {
+			Collection<OsmPrimitive> all = new LinkedList<OsmPrimitive>();
+			all.addAll(add);
+			all.addAll(update);
+			all.addAll(delete);
+			server.uploadOsm(all);
+		} catch (JDOMException x) {
+			x.printStackTrace();
+			JOptionPane.showMessageDialog(Main.main, x.getMessage());
+		}
 	}
 	
Index: /src/org/openstreetmap/josm/command/MoveCommand.java
===================================================================
--- /src/org/openstreetmap/josm/command/MoveCommand.java	(revision 33)
+++ /src/org/openstreetmap/josm/command/MoveCommand.java	(revision 34)
@@ -6,4 +6,5 @@
 import java.util.List;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
@@ -38,5 +39,5 @@
 	class OldState
 	{
-		double x,y;
+		double x,y,lat,lon;
 		boolean modified;
 	}
@@ -57,4 +58,6 @@
 			os.x = n.coor.x;
 			os.y = n.coor.y;
+			os.lat = n.coor.lat;
+			os.lon = n.coor.lon;
 			os.modified = n.modified;
 			oldState.add(os);
@@ -85,4 +88,5 @@
 			n.coor.x += x;
 			n.coor.y += y;
+			Main.pref.getProjection().xy2latlon(n.coor);
 		}
 		this.x += x;
@@ -94,4 +98,5 @@
 			n.coor.x += x;
 			n.coor.y += y;
+			Main.pref.getProjection().xy2latlon(n.coor);
 			n.modified = true;
 		}
@@ -104,4 +109,6 @@
 			n.coor.x = os.x;
 			n.coor.y = os.y;
+			n.coor.lat = os.lat;
+			n.coor.lon = os.lon;
 			n.modified = os.modified;
 		}
Index: /src/org/openstreetmap/josm/data/osm/visitor/OsmXmlVisitor.java
===================================================================
--- /src/org/openstreetmap/josm/data/osm/visitor/OsmXmlVisitor.java	(revision 34)
+++ /src/org/openstreetmap/josm/data/osm/visitor/OsmXmlVisitor.java	(revision 34)
@@ -0,0 +1,93 @@
+package org.openstreetmap.josm.data.osm.visitor;
+
+import java.util.Map.Entry;
+
+import org.jdom.Element;
+import org.openstreetmap.josm.data.osm.Key;
+import org.openstreetmap.josm.data.osm.LineSegment;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Track;
+
+
+/**
+ * An visitor which is capable of convert the visited objects to osm xml syntax
+ * using JDOM.
+ *
+ * @author imi
+ */
+public class OsmXmlVisitor implements Visitor {
+
+	private final boolean reference;
+	
+	public Element element;
+
+	/**
+	 * The counter for ids for new objects. 
+	 */
+	private static int newCounter = -1;
+
+	/**
+	 * Specify, which output do you like to have.
+	 * 
+	 * @param reference <code>true</code> means, the xml output is only a reference
+	 * 		containing the id (for deletion and referencing etc).
+	 */
+	public OsmXmlVisitor(boolean reference) {
+		this.reference = reference;
+	}
+
+	
+	public void visit(Node n) {
+		element = new Element("node");
+		addCommon(n);
+		if (!reference) {
+			element.setAttribute("lat", ""+n.coor.lat);
+			element.setAttribute("lon", ""+n.coor.lon);
+		}
+	}
+
+	public void visit(LineSegment ls) {
+		element = new Element("segment");
+		addCommon(ls);
+		if (!reference) {
+			element.setAttribute("from", ""+ls.start.id);
+			element.setAttribute("to", ""+ls.end.id);
+		}
+	}
+
+	@SuppressWarnings("unchecked")
+	public void visit(Track t) {
+		element = new Element("track");
+		addCommon(t);
+		if (!reference) {
+			for (LineSegment ls : t.segments) {
+				OsmXmlVisitor v = new OsmXmlVisitor(true);
+				v.visit(ls);
+				element.getChildren().add(v.element);
+			}
+		}
+	}
+
+	public void visit(Key k) {
+		//TODO
+		throw new RuntimeException("cannot add keys yet.");
+	}
+
+	/**
+	 * Add the common parts of the object.
+	 */
+	private void addCommon(OsmPrimitive osm) {
+		element.setAttribute("uid", ""+(osm.id == 0 ? newCounter-- : osm.id));
+		if (!reference && osm.keys != null) {
+			StringBuilder tags = new StringBuilder();
+			for (Entry<Key, String> e : osm.keys.entrySet()) {
+				tags.append(e.getKey().name);
+				tags.append("=");
+				tags.append(e.getValue());
+				tags.append(";");
+			}
+			element.setAttribute("tags", tags.toString());
+		}
+	}
+}
Index: /src/org/openstreetmap/josm/io/OsmServerReader.java
===================================================================
--- /src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 33)
+++ /src/org/openstreetmap/josm/io/OsmServerReader.java	(revision 34)
@@ -10,4 +10,5 @@
 
 import org.jdom.JDOMException;
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.GeoPoint;
 import org.openstreetmap.josm.data.osm.DataSet;
@@ -21,7 +22,6 @@
 
 	/**
-	 * The url string of the desired map data.
+	 * The boundings of the desired map data.
 	 */
-	private String urlStr;
 	private final double lat1;
 	private final double lon1;
@@ -32,11 +32,9 @@
 	 * Construct the reader and store the information for attaching
 	 */
-	public OsmServerReader(String server, 
-			double lat1, double lon1, double lat2, double lon2) {
+	public OsmServerReader(double lat1, double lon1, double lat2, double lon2) {
 		this.lon2 = lon2;
 		this.lat2 = lat2;
 		this.lon1 = lon1;
 		this.lat1 = lat1;
-		urlStr = server.endsWith("/") ? server : server+"/";
 	}
 
@@ -49,5 +47,5 @@
 	 */
 	public Collection<Collection<GeoPoint>> parseRawGps() throws IOException, JDOMException {
-		String url = urlStr+"trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
+		String url = Main.pref.osmDataServer+"/trackpoints?bbox="+lon1+","+lat1+","+lon2+","+lat2+"&page=";
 		Collection<Collection<GeoPoint>> data = new LinkedList<Collection<GeoPoint>>();
 		Collection<GeoPoint> list = new LinkedList<GeoPoint>();
@@ -80,5 +78,5 @@
 	 */
 	public DataSet parseOsm() throws JDOMException, IOException {
-		Reader r = getReader(urlStr+"map?bbox="+lon1+","+lat1+","+lon2+","+lat2);
+		Reader r = getReader(Main.pref.osmDataServer+"/map?bbox="+lon1+","+lat1+","+lon2+","+lat2);
 		if (r == null)
 			return null;
@@ -95,4 +93,5 @@
 	private Reader getReader(String urlStr) throws IOException {
 		initAuthentication();
+		System.out.println(urlStr);
 		URL url = new URL(urlStr);
 		HttpURLConnection con = (HttpURLConnection)url.openConnection();
Index: /src/org/openstreetmap/josm/io/OsmServerWriter.java
===================================================================
--- /src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 33)
+++ /src/org/openstreetmap/josm/io/OsmServerWriter.java	(revision 34)
@@ -1,8 +1,26 @@
 package org.openstreetmap.josm.io;
 
+import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Collection;
 
+import org.jdom.Document;
+import org.jdom.Element;
 import org.jdom.JDOMException;
-import org.openstreetmap.josm.data.osm.DataSet;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.Key;
+import org.openstreetmap.josm.data.osm.LineSegment;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Track;
+import org.openstreetmap.josm.data.osm.visitor.OsmXmlVisitor;
+import org.openstreetmap.josm.data.osm.visitor.Visitor;
 
 /**
@@ -15,15 +33,94 @@
  * - All remaining objects with modified flag set are updated.
  * 
+ * This class implements visitor and will perform the correct upload action
+ * on the visited element. 
+ * 
  * @author imi
  */
-public class OsmServerWriter extends OsmConnection {
+public class OsmServerWriter extends OsmConnection implements Visitor {
 
-	
 	/**
 	 * Send the dataset to the server. Ask the user first and does nothing if
 	 * he does not want to send the data.
 	 */
-	public void uploadOsm(DataSet dataSet) throws IOException, JDOMException {
+	public void uploadOsm(Collection<OsmPrimitive> list) throws JDOMException {
 		initAuthentication();
+
+		try {
+//			for (OsmPrimitive osm : list)
+//				osm.visit(this);
+		} catch (RuntimeException e) {
+			throw new JDOMException("An error occoured: ", e);
+		}
+	}
+
+	/**
+	 * Upload a single node.
+	 */
+	@SuppressWarnings("unchecked")
+	public void visit(Node n) {
+		if (n.id == 0) {
+			sendRequest("PUT", "newnode", n);
+		} else if (Main.main.ds.deleted.contains(n)) {
+			sendRequest("DELETE", "node/"+n.id, n);
+		} else {
+			sendRequest("PUT", "node/"+n.id, n);
+		}
+	}
+
+	public void visit(LineSegment ls) {
+	}
+
+	public void visit(Track t) {
+	}
+
+	public void visit(Key k) {
+	}
+
+	/**
+	 * Read an long from the input stream and return it.
+	 */
+	private long readId(InputStream inputStream) throws IOException {
+		BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
+		String s = in.readLine();
+		if (s == null)
+			return 0;
+		try {
+			return Long.parseLong(s);
+		} catch (NumberFormatException e) {
+			return 0;
+		}
+	}
+	
+	@SuppressWarnings("unchecked")
+	private void sendRequest(String requestMethod, String urlSuffix, OsmPrimitive osm) {
+		try {
+			URL url = new URL(Main.pref.osmDataServer + "/" + urlSuffix);
+			HttpURLConnection con = (HttpURLConnection)url.openConnection();
+			con.setConnectTimeout(20000);
+			con.setRequestMethod(requestMethod);
+			con.setDoOutput(true);
+			con.connect();
+
+			OsmXmlVisitor visitor = new OsmXmlVisitor(false);
+			osm.visit(visitor);
+			Element root = new Element("osm");
+			root.setAttribute("version", "0.2");
+			root.getChildren().add(visitor.element);
+			XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
+			OutputStream out = con.getOutputStream();
+			Document doc = new Document(root);
+			xmlOut.output(doc, out);
+			xmlOut.output(doc, System.out);
+			out.close();
+			
+			int retCode = con.getResponseCode();
+			System.out.println(retCode+" "+con.getResponseMessage());
+			if (retCode == 200 && osm.id == 0)
+				osm.id = readId(con.getInputStream());
+			con.disconnect();
+		} catch (Exception e) {
+			throw new RuntimeException(e.getMessage(), e);
+		}
 	}
 }
