Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/BooleanConfigurer.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/BooleanConfigurer.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/BooleanConfigurer.java	(revision 5979)
@@ -2,5 +2,5 @@
  * $Id: BooleanConfigurer.java 705 2005-09-15 13:24:50 +0000 (Thu, 15 Sep 2005) rodneykinney $
  *
- * Copyright (c) 2000-2003 by Rodney Kinney
+ * Copyright (c) 2000-2007 by Rodney Kinney, Brent Easton
  *
  * This library is free software; you can redistribute it and/or
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Configurer.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Configurer.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Configurer.java	(revision 5979)
@@ -2,5 +2,5 @@
  * $Id: Configurer.java 2175 2007-06-04 04:19:59 +0000 (Mon, 04 Jun 2007) rodneykinney $
  *
- * Copyright (c) 2000-2003 by Rodney Kinney
+ * Copyright (c) 2000-2007 by Rodney Kinney, Brent Easton
  *
  * This library is free software; you can redistribute it and/or
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/DoubleConfigurer.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/DoubleConfigurer.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/DoubleConfigurer.java	(revision 5979)
@@ -2,5 +2,5 @@
  * $Id: DoubleConfigurer.java 5 2003-10-02 15:11:38 +0000 (Thu, 02 Oct 2003) rodneykinney $
  *
- * Copyright (c) 2000-2003 by Rodney Kinney
+ * Copyright (c) 2000-2007 by Rodney Kinney, Brent Easton
  *
  * This library is free software; you can redistribute it and/or
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/IntConfigurer.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/IntConfigurer.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/IntConfigurer.java	(revision 5979)
@@ -2,5 +2,5 @@
  * $Id: IntConfigurer.java 874 2006-03-15 14:20:56 +0000 (Wed, 15 Mar 2006) rodneykinney $
  *
- * Copyright (c) 2000-2003 by Rodney Kinney
+ * Copyright (c) 2000-2007 by Rodney Kinney, Brent Easton
  *
  * This library is free software; you can redistribute it and/or
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java	(revision 5979)
@@ -12,23 +12,14 @@
 import java.io.File;
 import java.io.InputStreamReader;
-import java.nio.channels.ClosedByInterruptException;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
 import java.util.List;
 
 import javax.swing.JOptionPane;
-import javax.swing.ProgressMonitor;
 
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.command.AddCommand;
-import org.openstreetmap.josm.command.Command;
-import org.openstreetmap.josm.command.SequenceCommand;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Segment;
-import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -109,4 +100,5 @@
     target += " --landsat-res=" + Main.pref.get(LakewalkerPreferences.PREF_LANDSAT_RES, "4000");
     target += " --tilesize=" + Main.pref.get(LakewalkerPreferences.PREF_LANDSAT_SIZE, "2000");
+    target += " --startdir=" + Main.pref.get(LakewalkerPreferences.PREF_START_DIR, "east");
     target += " --josm";
     
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java	(revision 5979)
@@ -17,5 +17,5 @@
 public class LakewalkerPlugin extends Plugin {
 
-  public static final String VERSION = "0.3";
+  public static final String VERSION = "0.4";
   
   protected String name;
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java	(revision 5979)
@@ -13,4 +13,6 @@
 public class LakewalkerPreferences implements PreferenceSetting {
 
+  public static final String[] DIRECTIONS = new String[] {"east", "northeast", "north", "northwest", "west", "southwest", "south", "southeast"};
+
   public static final String PREF_PYTHON = "lakewalker.python";
   public static final String PREF_MAX_SEG = "lakewalker.max_segs_in_way";
@@ -22,5 +24,6 @@
   public static final String PREF_EAST_OFFSET = "lakewalker.east_offset";
   public static final String PREF_NORTH_OFFSET = "lakewalker.north_offset";
-  
+  public static final String PREF_START_DIR = "lakewalker.startdir";
+    
   protected StringConfigurer pythonConfig = new StringConfigurer();
   protected JLabel pythonLabel = new JLabel(tr("Python executable"));
@@ -41,4 +44,6 @@
   protected DoubleConfigurer northOffsetConfig = new DoubleConfigurer();
   protected JLabel northOffsetLabel = new JLabel(tr("Shift all traces to north (degrees)"));
+  protected StringEnumConfigurer startDirConfig = new StringEnumConfigurer(DIRECTIONS);
+  protected JLabel startDirLabel = new JLabel(tr("Direction to search for land"));
   
   public void addGui(PreferenceDialog gui) {
@@ -52,4 +57,5 @@
     eastOffsetConfig.setToolTipText(tr("Offset all points in East direction (degrees). Default 0."));   
     northOffsetConfig.setToolTipText(tr("Offset all points in North direction (degrees). Default 0."));   
+    startDirConfig.setToolTipText(tr("Direction to search for land. Default east."));   
 
     String description = tr("An interlude to the Lakewalker Python module to trace water bodies on Landsat imagery.<br><br>Version: {0}", LakewalkerPlugin.VERSION);
@@ -66,4 +72,5 @@
     eastOffsetConfig.setValue(Main.pref.get(PREF_EAST_OFFSET, "0.0"));
     northOffsetConfig.setValue(Main.pref.get(PREF_NORTH_OFFSET, "0.0"));
+    startDirConfig.setValue(Main.pref.get(PREF_START_DIR, "east"));
   }
   
@@ -90,4 +97,6 @@
     prefPanel.add(northOffsetLabel, labelConstraints);
     prefPanel.add(northOffsetConfig.getControls(), dataConstraints);
+    prefPanel.add(startDirLabel, labelConstraints);
+    prefPanel.add(startDirConfig.getControls(), dataConstraints);
   }
 
@@ -105,4 +114,5 @@
     Main.pref.put(PREF_EAST_OFFSET, eastOffsetConfig.getValueString());
     Main.pref.put(PREF_NORTH_OFFSET, northOffsetConfig.getValueString());
+    Main.pref.put(PREF_START_DIR, startDirConfig.getValueString());
   }
   
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java	(revision 5979)
@@ -19,5 +19,4 @@
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.Segment;
 import org.openstreetmap.josm.data.osm.Way;
 
@@ -45,6 +44,4 @@
 
     Way way = new Way();
-    Node lastNode = null;
-    Node firstNode = null;
     String line;
     setStatus("Initializing");
@@ -58,5 +55,6 @@
       
     }
-
+    char option = ' ';
+    
     try {
       while ((line = input.readLine()) != null) {
@@ -65,5 +63,5 @@
         }
         System.out.println(line);
-        char option = line.charAt(0);
+        option = line.charAt(0);
         switch (option) {
         case 'n':
@@ -73,13 +71,5 @@
             Node n = new Node(ll);
             commands.add(new AddCommand(n));
-            if (lastNode != null) {
-              Segment s = new Segment(lastNode, n);
-              commands.add(new AddCommand(s));
-              way.segments.add(s);
-            }
-            else {
-              firstNode = n;
-            }
-            lastNode = n;
+            way.nodes.add(n);
           }
           catch (Exception ex) {
@@ -93,9 +83,11 @@
           
         case 'x':
-          Segment s = new Segment(lastNode, firstNode);
-          commands.add(new AddCommand(s));
-          way.segments.add(s);
           way.put("created_by", "Dshpak_landsat_lakes");
           commands.add(new AddCommand(way));
+          break;
+          
+        case 'e':
+          String error = line.substring(2);
+          cancel = true;
           break;
         }
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringConfigurer.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringConfigurer.java	(revision 4209)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringConfigurer.java	(revision 5979)
@@ -2,5 +2,5 @@
  * $Id: StringConfigurer.java 2073 2007-05-10 14:34:31 +0000 (Thu, 10 May 2007) rodneykinney $
  *
- * Copyright (c) 2000-2003 by Rodney Kinney
+ * Copyright (c) 2000-2007 by Rodney Kinney, Brent Easton
  *
  * This library is free software; you can redistribute it and/or
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringEnumConfigurer.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringEnumConfigurer.java	(revision 5979)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringEnumConfigurer.java	(revision 5979)
@@ -0,0 +1,123 @@
+/*
+ * $Id: StringEnumConfigurer.java 2472 2007-10-01 04:10:19 +0000 (Mon, 01 Oct 2007) rodneykinney $
+ *
+ * Copyright (c) 2000-2007 by Rodney Kinney, Brent Easton
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License (LGPL) as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, copies are available
+ * at http://www.opensource.org.
+ */
+/*
+ * Created by IntelliJ IDEA.
+ * User: rkinney
+ * Date: Jul 20, 2002
+ * Time: 3:52:36 AM
+ * To change template for new class use
+ * Code Style | Class Templates options (Tools | IDE Options).
+ */
+package org.openstreetmap.josm.plugins.lakewalker;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.Box;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+
+/**
+ * A Configurer that returns a String from among a list of possible values
+ */
+public class StringEnumConfigurer extends Configurer {
+  protected String[] validValues;
+  protected JComboBox box;
+  protected Box panel;
+  protected String tooltipText = "";
+ 
+  public StringEnumConfigurer(String key, String name, String[] validValues) {
+    super(key, name);
+    this.validValues = validValues;
+  }
+
+  public StringEnumConfigurer(String[] validValues) {
+    this(null, "", validValues);
+  }
+  
+  public void setToolTipText(String s) {
+    tooltipText = s;
+  }
+  public Component getControls() {
+    if (panel == null) {
+      panel = Box.createHorizontalBox();
+      panel.add(new JLabel(name));
+      box = new JComboBox(validValues);
+      box.setToolTipText(tooltipText);
+      box.setMaximumSize(new Dimension(box.getMaximumSize().width,box.getPreferredSize().height));
+      if (isValidValue(getValue())) {
+        box.setSelectedItem(getValue());
+      }
+      else if (validValues.length > 0) {
+        box.setSelectedIndex(0);
+      }
+      box.addActionListener(new ActionListener() {
+        public void actionPerformed(ActionEvent e) {
+          noUpdate = true;
+          setValue(box.getSelectedItem());
+          noUpdate = false;
+        }
+      });
+      panel.add(box);
+    }
+    return panel;
+  }
+
+  public boolean isValidValue(Object o) {
+    for (int i = 0; i < validValues.length; ++i) {
+      if (validValues[i].equals(o)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  public String[] getValidValues() {
+    return validValues;
+  }
+
+  public void setValidValues(String[] s) {
+  	validValues = s;
+  	if (box == null) {
+  	  getControls();
+  	}
+	box.setModel(new DefaultComboBoxModel(validValues));
+  }
+  
+  public void setValue(Object o) {
+    if (validValues == null
+        || isValidValue(o)) {
+      super.setValue(o);
+      if (!noUpdate && box != null) {
+        box.setSelectedItem(o);
+      }
+    }
+  }
+
+  public String getValueString() {
+    return box != null ? (String) box.getSelectedItem() : validValues[0];
+  }
+
+  public void setValue(String s) {
+    setValue((Object) s);
+  }
+
+}
