Index: utils/josm/plugins/waypoints/build.xml
===================================================================
--- utils/josm/plugins/waypoints/build.xml	(revision 1495)
+++ utils/josm/plugins/waypoints/build.xml	(revision 1495)
@@ -0,0 +1,42 @@
+<project name="waypoints" default="build" basedir=".">
+
+	<!-- point to your JOSM directory -->
+	<property name="josm" location="/home/nick/josm/dist/josm-latest.jar" />
+
+
+
+	<target name="init">
+		<mkdir dir="build"></mkdir>
+		<mkdir dir="dist"></mkdir>
+	</target>
+
+	<target name="compile" depends="init">
+		<javac srcdir="src" classpath="${josm}" destdir="build" debug="true">
+			<include name="**/*.java" />
+		</javac>
+	</target>
+
+	<target name="build" depends="compile">
+			<!--
+		<copy todir="build/images">
+			<fileset dir="images"></fileset>
+		</copy>
+		-->
+		<jar destfile="dist/waypoints.jar" basedir="build">
+			<manifest>
+				<attribute name="Plugin-Class" value="waypoints.WaypointPlugin" />
+				<attribute name="Plugin-Description" value="Automatic conversion of waypoints in a GPX file to OSM nodes." />
+			</manifest>
+		</jar>
+	</target>
+
+	<target name="clean">
+		<delete dir="build" />
+		<delete dir="dist" />
+	</target>
+
+	<target name="install" depends="build">
+		<copy file="dist/waypoints.jar" todir="${user.home}/.josm/plugins"/>
+	</target>
+
+</project>
Index: utils/josm/plugins/waypoints/src/WaypointOpenAction.java
===================================================================
--- utils/josm/plugins/waypoints/src/WaypointOpenAction.java	(revision 1495)
+++ utils/josm/plugins/waypoints/src/WaypointOpenAction.java	(revision 1495)
@@ -0,0 +1,66 @@
+package waypoints; 
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.actions.DiskAccessAction;
+import org.xml.sax.SAXException;
+
+/**
+ * Based on standard JOSM OpenAction 
+ * For opening a waypoint file to convert to nodes.
+ */
+public class WaypointOpenAction extends DiskAccessAction {
+	
+	/**
+	 * Create an open action. The name is "Open a file".
+	 */
+	public WaypointOpenAction() {
+		super(tr("Open waypoints file"), "open", tr("Open a waypoints file."), 
+						KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK);
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		JFileChooser fc = createAndOpenFileChooser(true, true);
+		if (fc == null)
+			return;
+		File[] files = fc.getSelectedFiles();
+		for (int i = files.length; i > 0; --i)
+			openFile(files[i-1]);
+	}
+
+	/**
+	 * Open the given file.
+	 */
+	public void openFile(File file) {
+		String fn = file.getName();
+		try {
+				DataSet dataSet = 
+						WaypointReader.parse(new FileInputStream(file));
+				Main.main.addLayer(new OsmDataLayer(dataSet, file.getName(), 
+										file));
+		} catch (SAXException x) {
+			x.printStackTrace();
+			JOptionPane.showMessageDialog(Main.parent, 
+					tr("Error while parsing {0}",fn)+": "+x.getMessage());
+		} catch (IOException x) {
+			x.printStackTrace();
+			JOptionPane.showMessageDialog(Main.parent, 
+					tr("Could not read \"{0}\"",fn)+"\n"+x.getMessage());
+		}
+	}
+}
Index: utils/josm/plugins/waypoints/src/WaypointPlugin.java
===================================================================
--- utils/josm/plugins/waypoints/src/WaypointPlugin.java	(revision 1495)
+++ utils/josm/plugins/waypoints/src/WaypointPlugin.java	(revision 1495)
@@ -0,0 +1,29 @@
+package waypoints; 
+
+import java.awt.Component;
+import javax.swing.JMenuItem;
+import javax.swing.JSeparator;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.plugins.Plugin;
+
+public class WaypointPlugin extends Plugin  {
+
+
+	public WaypointPlugin() {
+		JMenuItem waypointItem = new JMenuItem(new WaypointOpenAction());
+		int index = findFirstSeparator();
+		Main.main.menu.fileMenu.add(waypointItem,index<0 ? 0: index);
+	}
+
+	private int findFirstSeparator()
+	{
+		Component[] components = Main.main.menu.fileMenu.getMenuComponents();
+		for(int count=0; count<components.length; count++)
+		{
+			if(components[count] instanceof JSeparator)
+				return count;
+		}
+		return -1;
+	}
+}
Index: utils/josm/plugins/waypoints/src/WaypointReader.java
===================================================================
--- utils/josm/plugins/waypoints/src/WaypointReader.java	(revision 1495)
+++ utils/josm/plugins/waypoints/src/WaypointReader.java	(revision 1495)
@@ -0,0 +1,106 @@
+package waypoints; 
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.DataSet; // NW
+import org.openstreetmap.josm.data.osm.Node; // NW
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+import uk.co.wilson.xml.MinML2;
+
+
+/**
+ * Read waypoints from a GPX file and convert to nodes.
+ */
+public class WaypointReader {
+
+	private static class Parser extends MinML2 {
+		/**
+		 * Current track to be read. The last entry is the current trkpt.
+		 * If in wpt-mode, it contain only one GpsPoint.
+		 */
+	    private DataSet dataSet;
+		private LatLon currentLatLon;
+		private String curWptName;
+		private  boolean inName = false;
+
+		// NW start	
+		// data now has two components: the GPS points and an OsmDataLayer.
+		// This is to allow us to convert waypoints straight to nodes.
+		// The way this works is that waypoints with a name not beginning
+		// with 0 - i.e. waypoints specially named - will be loaded in as
+		// nodes, in addition to going into the gpx layer. Other waypoints will
+		// only go into the gpx layer.
+		public Parser()
+		{
+			dataSet = new DataSet();
+		}
+		// NW end
+
+		@Override public void startElement(String namespaceURI, 
+				String localName, String qName, Attributes atts) 
+					throws SAXException {
+			if (qName.equals("wpt")) {
+				try {
+	                double lat = Double.parseDouble(atts.getValue("lat"));
+	                double lon = Double.parseDouble(atts.getValue("lon"));
+	        		if (Math.abs(lat) > 90)
+	        			throw new SAXException
+						(tr("Data error: lat value \"{0}\" is out of bound.", 
+							lat));
+	        		if (Math.abs(lon) > 180)
+	        			throw new SAXException
+						(tr("Data error: lon value \"{0}\" is out of bound.", 
+							lon));
+	                currentLatLon = new LatLon(lat, lon);
+                } catch (NumberFormatException e) {
+                	e.printStackTrace();
+	                throw new SAXException(e);
+                }
+			}
+			else if (qName.equals("name")) {
+				inName = true;
+				curWptName = "";	
+			}	
+		}
+
+		@Override public void characters(char[] ch, int start, int length) {
+			// NW start
+			if (inName) {
+				curWptName = new String (ch,start,length);
+			}
+			// NW end
+		}
+
+		@Override public void endElement(String namespaceURI, String localName,
+					   					String qName) {
+			if (qName.equals("wpt") && curWptName!="") { 
+				// create a new node from the latitude and longitude
+				System.out.println("Found a waypoint to convert to a node: " 
+										+ curWptName);
+				Node node = new Node(currentLatLon);
+				node.put("name",curWptName);
+				dataSet.nodes.add(node);
+			}
+			else if (qName.equals("name")) {
+				inName = false;
+			}
+        }
+	}
+
+	/**
+	 * Parse and return the read data
+	 */
+	public static DataSet parse(InputStream source) 
+			throws SAXException, IOException{
+		Parser parser = new Parser();
+		parser.parse(new InputStreamReader(source, "UTF-8"));
+		return parser.dataSet;
+	}
+}
