Index: src/org/openstreetmap/josm/actions/OpenGpxAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/OpenGpxAction.java	(revision 17)
+++ src/org/openstreetmap/josm/actions/OpenGpxAction.java	(revision 18)
@@ -37,5 +37,5 @@
 
 	/**
-	 * Create an open action. The name is "&Open GPX".
+	 * Create an open action. The name is "Open GPX".
 	 */
 	public OpenGpxAction() {
Index: src/org/openstreetmap/josm/actions/OpenOsmServerAction.java
===================================================================
--- src/org/openstreetmap/josm/actions/OpenOsmServerAction.java	(revision 18)
+++ src/org/openstreetmap/josm/actions/OpenOsmServerAction.java	(revision 18)
@@ -0,0 +1,108 @@
+package org.openstreetmap.josm.actions;
+
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.openstreetmap.josm.data.GeoPoint;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.GBC;
+import org.openstreetmap.josm.gui.ImageProvider;
+import org.openstreetmap.josm.gui.Main;
+import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.gui.MapView;
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.LayerFactory;
+import org.openstreetmap.josm.io.OsmReader;
+import org.openstreetmap.josm.io.DataReader.ConnectionException;
+import org.openstreetmap.josm.io.DataReader.ParseException;
+
+/**
+ * Action that opens a connection to the osm server.
+ * 
+ * An dialog is displayed asking the user to specify a rectangle to grab.
+ * The url and account settings from the preferences are used.
+ *  
+ * @author imi
+ */
+public class OpenOsmServerAction extends AbstractAction {
+
+	public OpenOsmServerAction() {
+		super("Connect to OSM", ImageProvider.get("connectosm"));
+		putValue(MNEMONIC_KEY, KeyEvent.VK_C);
+		putValue(SHORT_DESCRIPTION, "Open a connection to the OSM server.");
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		JPanel dlg = new JPanel(new GridBagLayout());
+		dlg.add(new JLabel("Bounding box"), GBC.eol());
+
+		JTextField minLat = new JTextField(9);
+		JTextField minLon = new JTextField(9);
+		JTextField maxLat = new JTextField(9);
+		JTextField maxLon = new JTextField(9);
+
+		dlg.add(new JLabel("min lat"), GBC.std().insets(10,0,5,0));
+		dlg.add(minLat, GBC.std());
+		dlg.add(new JLabel("max lat"), GBC.std().insets(10,0,5,0));
+		dlg.add(maxLat, GBC.eol());
+		dlg.add(new JLabel("min lon"), GBC.std().insets(10,0,5,0));
+		dlg.add(minLon, GBC.std());
+		dlg.add(new JLabel("max lon"), GBC.std().insets(10,0,5,0));
+		dlg.add(maxLon, GBC.eol());
+
+		if (Main.main.getMapFrame() != null) {
+			MapView mv = Main.main.getMapFrame().mapView;
+			int w = mv.getWidth();
+			int h = mv.getHeight();
+			GeoPoint bottomLeft = mv.getPoint(0, h, true);
+			GeoPoint topRight = mv.getPoint(w, 0, true);
+			minLat.setText(""+bottomLeft.lat);
+			minLon.setText(""+bottomLeft.lon);
+			maxLat.setText(""+topRight.lat);
+			maxLon.setText(""+topRight.lon);
+			
+			minLat.setCaretPosition(0);
+			minLon.setCaretPosition(0);
+			maxLat.setCaretPosition(0);
+			maxLon.setCaretPosition(0);
+		}
+
+		int r = JOptionPane.showConfirmDialog(Main.main, dlg, "Choose an area", 
+				JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
+		if (r != JOptionPane.OK_OPTION)
+			return;
+
+		OsmReader osmReader = new OsmReader(Main.pref.osmDataServer,
+				Main.pref.osmDataUsername, Main.pref.osmDataPassword,
+				Double.parseDouble(minLat.getText()),
+				Double.parseDouble(minLon.getText()),
+				Double.parseDouble(maxLat.getText()),
+				Double.parseDouble(maxLon.getText()));
+		try {
+			DataSet dataSet = osmReader.parse();
+
+			String name = minLat.getText()+" "+minLon.getText()+" x "+
+					maxLat.getText()+" "+maxLon.getText();
+			
+			Layer layer = LayerFactory.create(dataSet, name, false);
+
+			if (Main.main.getMapFrame() == null)
+				Main.main.setMapFrame(name, new MapFrame(layer));
+			else
+				Main.main.getMapFrame().mapView.addLayer(layer);
+		} catch (ParseException x) {
+			x.printStackTrace();
+			JOptionPane.showMessageDialog(Main.main, x.getMessage());
+		} catch (ConnectionException x) {
+			x.printStackTrace();
+			JOptionPane.showMessageDialog(Main.main, x.getMessage());
+		}
+	}
+}
Index: src/org/openstreetmap/josm/data/GeoPoint.java
===================================================================
--- src/org/openstreetmap/josm/data/GeoPoint.java	(revision 17)
+++ src/org/openstreetmap/josm/data/GeoPoint.java	(revision 18)
@@ -58,10 +58,11 @@
 		return (x-other.x)*(x-other.x)+(y-other.y)*(y-other.y);
 	}
-	
+
 	/**
 	 * @return <code>true</code>, if the other GeoPoint has the same lat/lon values.
 	 */
 	public boolean equalsLatLon(GeoPoint other) {
-		return lat == other.lat && lon == other.lon;
+		return lat == other.lat && lon == other.lon && 
+				!Double.isNaN(lat) && !Double.isNaN(lon);
 	}
 }
Index: src/org/openstreetmap/josm/data/Preferences.java
===================================================================
--- src/org/openstreetmap/josm/data/Preferences.java	(revision 17)
+++ src/org/openstreetmap/josm/data/Preferences.java	(revision 18)
@@ -45,9 +45,26 @@
 	private boolean drawRawGpsLines = false;
 	/**
+	 * Force the drawing of lines between raw gps points if there are no
+	 * lines in the imported document.
+	 */
+	private boolean forceRawGpsLines = false;
+	/**
 	 * Whether nodes on the same place should be considered identical.
 	 */
 	public boolean mergeNodes = true;
-	
-	
+
+	/**
+	 * Base URL to the osm data server
+	 */
+	public String osmDataServer = "http://www.openstreetmap.org/api/0.1";
+	/**
+	 * The username to the osm server
+	 */
+	public String osmDataUsername = "";
+	/**
+	 * The stored password or <code>null</code>, if the password should not be
+	 * stored.
+	 */
+	public String osmDataPassword = null;
 
 	/**
@@ -105,4 +122,10 @@
 			}
 
+			Element osmServer = root.getChild("osm-server");
+			if (osmServer != null) {
+				osmDataServer = osmServer.getChildText("url");
+				osmDataUsername = osmServer.getChildText("username");
+				osmDataPassword = osmServer.getChildText("password");
+			}
 			mergeNodes = root.getChild("mergeNodes") != null;
 			drawRawGpsLines = root.getChild("drawRawGpsLines") != null;
@@ -129,4 +152,9 @@
 		if (drawRawGpsLines)
 			children.add(new Element("drawRawGpsLines"));
+		Element osmServer = new Element("osm-server");
+		osmServer.getChildren().add(new Element("url").setText(osmDataServer));
+		osmServer.getChildren().add(new Element("username").setText(osmDataUsername));
+		osmServer.getChildren().add(new Element("password").setText(osmDataPassword));
+		children.add(osmServer);
 
 		try {
@@ -200,3 +228,11 @@
 		return drawRawGpsLines;
 	}
+	public void setForceRawGpsLines(boolean forceRawGpsLines) {
+		boolean old = this.forceRawGpsLines;
+		this.forceRawGpsLines = forceRawGpsLines;
+		firePropertyChanged("forceRawGpsLines", old, forceRawGpsLines);
+	}
+	public boolean isForceRawGpsLines() {
+		return forceRawGpsLines;
+	}
 }
Index: src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 17)
+++ src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 18)
@@ -3,6 +3,10 @@
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
 
 import org.openstreetmap.josm.data.Bounds;
@@ -196,17 +200,47 @@
 	 */
 	public void mergeFrom(DataSet ds, boolean mergeEqualNodes) {
+		System.out.println(nodes.size()+" "+pendingLineSegments.size()+" "+tracks.size());
 		if (mergeEqualNodes) {
-			LinkedList<Node> nodesToAdd = new LinkedList<Node>();
-			for (Node n : ds.nodes)
-				for (Node mynode : nodes) {
-					if (mynode.coor.equalsLatLon(n.coor))
-						mynode.mergeFrom(n);
-					else
-						nodesToAdd.add(n);
+			Map<Node, Node> mergeMap = new HashMap<Node, Node>();
+			Set<Node> nodesToAdd = new HashSet<Node>();
+			for (Node n : nodes) {
+				for (Iterator<Node> it = ds.nodes.iterator(); it.hasNext();) {
+					Node dsn = it.next();
+					if (n.coor.equalsLatLon(dsn.coor)) {
+						mergeMap.put(dsn, n);
+						n.mergeFrom(dsn);
+						it.remove();
+					} else {
+						nodesToAdd.add(dsn);
+					}
 				}
-		} else
+			}
+			nodes.addAll(nodesToAdd);
+			for (Track t : ds.tracks) {
+				for (LineSegment ls : t.segments()) {
+					Node n = mergeMap.get(ls.getStart());
+					if (n != null)
+						ls.start = n;
+					n = mergeMap.get(ls.getEnd());
+					if (n != null)
+						ls.end = n;
+				}
+			}
+			tracks.addAll(ds.tracks);
+			for (LineSegment ls : ds.pendingLineSegments) {
+				Node n = mergeMap.get(ls.getStart());
+				if (n != null)
+					ls.start = n;
+				n = mergeMap.get(ls.getEnd());
+				if (n != null)
+					ls.end = n;
+			}
+			pendingLineSegments.addAll(ds.pendingLineSegments);
+		} else {
 			nodes.addAll(ds.nodes);
-		tracks.addAll(ds.tracks);
-		pendingLineSegments.addAll(ds.pendingLineSegments);
+			tracks.addAll(ds.tracks);
+			pendingLineSegments.addAll(ds.pendingLineSegments);
+		}
+		System.out.println(nodes.size()+" "+pendingLineSegments.size()+" "+tracks.size());
 	}
 
Index: src/org/openstreetmap/josm/data/osm/LineSegment.java
===================================================================
--- src/org/openstreetmap/josm/data/osm/LineSegment.java	(revision 17)
+++ src/org/openstreetmap/josm/data/osm/LineSegment.java	(revision 18)
@@ -18,10 +18,10 @@
 	 * The starting node of the line segment
 	 */
-	private Node start;
+	Node start;
 	
 	/**
 	 * The ending node of the line segment
 	 */
-	private Node end;
+	Node end;
 
 	/**
Index: src/org/openstreetmap/josm/gui/Main.java
===================================================================
--- src/org/openstreetmap/josm/gui/Main.java	(revision 17)
+++ src/org/openstreetmap/josm/gui/Main.java	(revision 18)
@@ -15,4 +15,5 @@
 import org.openstreetmap.josm.actions.ExitAction;
 import org.openstreetmap.josm.actions.OpenGpxAction;
+import org.openstreetmap.josm.actions.OpenOsmServerAction;
 import org.openstreetmap.josm.actions.PreferencesAction;
 import org.openstreetmap.josm.actions.SaveGpxAction;
@@ -63,4 +64,5 @@
 		
 		// creating actions
+		OpenOsmServerAction openServerAction = new OpenOsmServerAction();
 		OpenGpxAction openGpxAction = new OpenGpxAction();
 		SaveGpxAction saveGpxAction = new SaveGpxAction();
@@ -80,4 +82,9 @@
 		mainMenu.add(fileMenu);
 		
+		JMenu connectionMenu = new JMenu("Connection");
+		connectionMenu.setMnemonic('C');
+		connectionMenu.add(openServerAction);
+		mainMenu.add(connectionMenu);
+		
 		JMenu editMenu = new JMenu("Edit");
 		editMenu.setMnemonic('E');
@@ -88,4 +95,5 @@
 		JToolBar toolBar = new JToolBar();
 		toolBar.setFloatable(false);
+		toolBar.add(openServerAction);
 		toolBar.add(openGpxAction);
 		toolBar.add(saveGpxAction);
Index: src/org/openstreetmap/josm/gui/MapMover.java
===================================================================
--- src/org/openstreetmap/josm/gui/MapMover.java	(revision 17)
+++ src/org/openstreetmap/josm/gui/MapMover.java	(revision 18)
@@ -55,5 +55,5 @@
 			GeoPoint p = new GeoPoint();
 			p.x = mousePosMove.x + center.x - mouseCenter.x;  
-			p.y = mousePosMove.y + center.y - mouseCenter.y;  
+			p.y = mousePosMove.y + center.y - mouseCenter.y;
 			mv.zoomTo(p, mv.getScale());
 		} else
Index: src/org/openstreetmap/josm/gui/PreferenceDialog.java
===================================================================
--- src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 17)
+++ src/org/openstreetmap/josm/gui/PreferenceDialog.java	(revision 18)
@@ -21,5 +21,7 @@
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.JPasswordField;
 import javax.swing.JTabbedPane;
+import javax.swing.JTextField;
 import javax.swing.ListCellRenderer;
 import javax.swing.UIManager;
@@ -52,5 +54,11 @@
 			Main.pref.setProjection(projection);
 			Main.pref.mergeNodes = mergeNodes.isSelected();
+			Main.pref.osmDataServer = osmDataServer.getText();
+			Main.pref.osmDataUsername = osmDataUsername.getText();
+			Main.pref.osmDataPassword = String.valueOf(osmDataPassword.getPassword());
+			if (Main.pref.osmDataPassword == "")
+				Main.pref.osmDataPassword = null;
 			Main.pref.setDrawRawGpsLines(drawRawGpsLines.isSelected());
+			Main.pref.setForceRawGpsLines(forceRawGpsLines.isSelected());
 			try {
 				Main.pref.save();
@@ -97,7 +105,23 @@
 
 	/**
+	 * Editfield for the Base url to the REST API from OSM. 
+	 */
+	private JTextField osmDataServer = new JTextField(20);
+	/**
+	 * Editfield for the username to the OSM account.
+	 */
+	private JTextField osmDataUsername = new JTextField(20);
+	/**
+	 * Passwordfield for the userpassword of the REST API.
+	 */
+	private JPasswordField osmDataPassword = new JPasswordField(20);
+	/**
 	 * The checkbox stating whether nodes should be merged together.
 	 */
 	private JCheckBox drawRawGpsLines = new JCheckBox("Draw lines between raw gps points.");
+	/**
+	 * The checkbox stating whether raw gps lines should be forced.
+	 */
+	private JCheckBox forceRawGpsLines = new JCheckBox("Force lines if no line segments imported.");
 	/**
 	 * The checkbox stating whether nodes should be merged together.
@@ -155,10 +179,29 @@
 		});
 		
+		// drawRawGpsLines
+		drawRawGpsLines.addActionListener(new ActionListener(){
+			public void actionPerformed(ActionEvent e) {
+				if (!drawRawGpsLines.isSelected())
+					forceRawGpsLines.setSelected(false);
+				forceRawGpsLines.setEnabled(drawRawGpsLines.isSelected());
+			}
+		});
+
+		
 		// tooltips
+		osmDataServer.setToolTipText("The base URL to the OSM server (REST API)");
+		osmDataUsername.setToolTipText("Login name (email) to the OSM account.");
+		osmDataPassword.setToolTipText("Login password to the OSM account. Leave blank to not store any password.");
 		drawRawGpsLines.setToolTipText("If your gps device draw to few lines, select this to draw lines along your track.");
 		drawRawGpsLines.setSelected(Main.pref.isDrawRawGpsLines());
+		forceRawGpsLines.setToolTipText("Force drawing of lines if the imported data contain no line information.");
+		forceRawGpsLines.setSelected(Main.pref.isForceRawGpsLines());
 		mergeNodes.setToolTipText("When importing GPX data, all nodes with exact the same lat/lon are merged.");
 		mergeNodes.setSelected(Main.pref.mergeNodes);
-		
+
+		osmDataServer.setText(Main.pref.osmDataServer);
+		osmDataUsername.setText(Main.pref.osmDataUsername);
+		osmDataPassword.setText(Main.pref.osmDataPassword);
+
 		// Display tab
 		JPanel display = createPreferenceTab("display", "Display Settings", "Various settings that influence the visual representation of the whole program.");
@@ -167,6 +210,23 @@
 		display.add(lafCombo, GBC.eol().fill(GBC.HORIZONTAL));
 		display.add(drawRawGpsLines, GBC.eol().insets(20,0,0,0));
+		display.add(forceRawGpsLines, GBC.eol().insets(40,0,0,0));
 		display.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
 
+		// Connection tab
+		JPanel con = createPreferenceTab("connection", "Connection Settings", "Connection Settings to the OSM server.");
+		con.add(new JLabel("Base Server URL"), GBC.std());
+		con.add(osmDataServer, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
+		con.add(new JLabel("OSM username (email)"), GBC.std());
+		con.add(osmDataUsername, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
+		con.add(new JLabel("OSM password"), GBC.std());
+		con.add(osmDataPassword, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,0));
+		JLabel warning = new JLabel("<html>" +
+				"WARNING: The password is stored in plain text in the preferences file.<br>" +
+				"The password is transfered in plain text to the server, encoded in the url.<br>" +
+				"<b>Do not use a valuable Password.</b></html>");
+		warning.setFont(warning.getFont().deriveFont(Font.ITALIC));
+		con.add(warning, GBC.eop().fill(GBC.HORIZONTAL));
+
+		
 		// Map tab
 		JPanel map = createPreferenceTab("map", "Map Settings", "Settings for the map projection and data interpretation.");
@@ -221,4 +281,5 @@
 
 		tabPane.addTab(null, ImageProvider.get("preferences", icon), p);
+		tabPane.setToolTipTextAt(tabPane.getTabCount()-1, desc);
 		return p;
 	}
Index: src/org/openstreetmap/josm/gui/dialogs/LayerList.java
===================================================================
--- src/org/openstreetmap/josm/gui/dialogs/LayerList.java	(revision 17)
+++ src/org/openstreetmap/josm/gui/dialogs/LayerList.java	(revision 18)
@@ -89,4 +89,10 @@
 					icon = ImageProvider.overlay(icon, invisible, ImageProvider.OverlayPosition.SOUTHEAST);
 				label.setIcon(icon);
+				
+				DataSet ds = layer.getDataSet();
+				if (ds != null) {
+					label.setToolTipText(ds.nodes.size()+" nodes, "+
+							ds.tracks().size()+" tracks");
+				}
 				return label;
 			}
Index: src/org/openstreetmap/josm/gui/engine/RawGpsEngine.java
===================================================================
--- src/org/openstreetmap/josm/gui/engine/RawGpsEngine.java	(revision 17)
+++ src/org/openstreetmap/josm/gui/engine/RawGpsEngine.java	(revision 18)
@@ -2,4 +2,5 @@
 
 import java.awt.Color;
+import java.awt.Graphics;
 import java.awt.Point;
 import java.beans.PropertyChangeEvent;
@@ -10,4 +11,5 @@
 import org.openstreetmap.josm.data.osm.Track;
 import org.openstreetmap.josm.gui.Main;
+import org.openstreetmap.josm.gui.MapView;
 
 /**
@@ -19,4 +21,9 @@
 
 	/**
+	 * Draw a line to this node if forceRawGpsLines is set.
+	 */
+	private Node lastNode;
+	
+	/**
 	 * Create a raw gps engine. The engine will register itself as listener on
 	 * the main preference settings to capture the drawRawGpsLines changes.
@@ -24,4 +31,11 @@
 	public RawGpsEngine() {
 		Main.pref.addPropertyChangeListener(this);
+	}
+
+	
+	@Override
+	public void init(Graphics g, MapView mv) {
+		super.init(g, mv);
+		lastNode = null;
 	}
 
@@ -34,4 +48,9 @@
 		g.setColor(n.isSelected() ? Color.WHITE : Color.GRAY);
 		g.drawRect(p.x, p.y, 0, 0);
+		if (Main.pref.isForceRawGpsLines()) {
+			if (lastNode != null)
+				drawLine(lastNode, n, false, Color.GRAY);
+			lastNode = n;
+		}
 	}
 
@@ -46,5 +65,5 @@
 			return;
 		for (LineSegment ls : t.segments())
-			drawLineSegment(ls, t.isSelected() ? Color.WHITE : Color.GRAY);
+			drawLine(ls.getStart(), ls.getEnd(), ls.isSelected(), t.isSelected() ? Color.WHITE : Color.GRAY);
 	}
 
@@ -54,5 +73,5 @@
 	@Override
 	public void drawPendingLineSegment(LineSegment ls) {
-		drawLineSegment(ls, Color.GRAY);
+		drawLine(ls.getStart(), ls.getEnd(), ls.isSelected(), Color.GRAY);
 	}
 
@@ -62,8 +81,8 @@
 	 * @param color		The color, the line segment should be drawn in.
 	 */
-	private void drawLineSegment(LineSegment ls, Color color) {
-		g.setColor(ls.isSelected() ? Color.WHITE : color);
-		Point p1 = mv.getScreenPoint(ls.getStart().coor);
-		Point p2 = mv.getScreenPoint(ls.getEnd().coor);
+	private void drawLine(Node start, Node end, boolean isSelected, Color color) {
+		g.setColor(isSelected ? Color.WHITE : color);
+		Point p1 = mv.getScreenPoint(start.coor);
+		Point p2 = mv.getScreenPoint(end.coor);
 		g.drawLine(p1.x, p1.y, p2.x, p2.y);
 	}
@@ -74,5 +93,5 @@
 	 */
 	public void propertyChange(PropertyChangeEvent e) {
-		if (e.getPropertyName().equals("drawRawGpsLines"))
+		if (e.getPropertyName().equals("drawRawGpsLines") || e.getPropertyName().equals("forceRawGpsLines"))
 			mv.repaint();
 	}
Index: src/org/openstreetmap/josm/io/OsmReader.java
===================================================================
--- src/org/openstreetmap/josm/io/OsmReader.java	(revision 18)
+++ src/org/openstreetmap/josm/io/OsmReader.java	(revision 18)
@@ -0,0 +1,59 @@
+package org.openstreetmap.josm.io;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+
+import org.openstreetmap.josm.data.osm.DataSet;
+
+/**
+ * This DataReader read directly from the REST API of the osm server.
+ * 
+ * @author imi
+ */
+public class OsmReader implements DataReader {
+
+	/**
+	 * The url string of the desired map data.
+	 */
+	private String urlStr;
+
+	/**
+	 * Construct the reader and store the information for attaching
+	 */
+	public OsmReader(String server, final String username, final String password, 
+			double lat1, double lon1, double lat2, double lon2) {
+		urlStr = server.endsWith("/") ? server : server+"/";
+		urlStr += "map?bbox="+lon1+","+lat1+","+lon2+","+lat2;
+		
+		HttpURLConnection.setFollowRedirects(true);
+		Authenticator.setDefault(new Authenticator(){
+			@Override
+			protected PasswordAuthentication getPasswordAuthentication() {
+				return new PasswordAuthentication(username, password.toCharArray());
+			}
+		});
+	}
+
+
+	public DataSet parse() throws ParseException, ConnectionException {
+		Reader in;
+		try {
+			URL url = new URL(urlStr);
+			HttpURLConnection con = (HttpURLConnection)url.openConnection();
+			con.setDoInput(true);
+			con.setConnectTimeout(20000);
+			con.setRequestMethod("GET");
+			con.connect();
+			in = new InputStreamReader(con.getInputStream());
+		} catch (IOException e) {
+			throw new ConnectionException("Failed to open server connection\n"+e.getMessage(), e);
+		}
+		GpxReader reader = new GpxReader(in, false);
+		return reader.parse();
+	}
+}
