Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java	(revision 6911)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java	(revision 6913)
@@ -103,5 +103,5 @@
 		ArrayList<double[]> nodelist = new ArrayList<double[]>();
 
-		int[] xy = geo_to_xy(lat,lon); 
+		int[] xy = geo_to_xy(lat,lon,this.resolution); 
 		
 		if(!bbox.contains(lat, lon)){
@@ -112,5 +112,5 @@
 		
 		while(true){
-			double[] geo = xy_to_geo(xy[0],xy[1]);
+			double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);
 			if(bbox.contains(geo[0],geo[1])==false){
 				break;
@@ -135,5 +135,5 @@
 		
 		int[] startxy = new int[] {xy[0], xy[1]};
-		double[] startgeo = xy_to_geo(xy[0],xy[1]);
+		double[] startgeo = xy_to_geo(xy[0],xy[1],this.resolution);
 				
 		System.out.println("Found shore at "+startxy[0]+","+startxy[1]);
@@ -158,11 +158,9 @@
 				
 				new_dir = (last_dir + d + 4) % 8;
-				
-				//System.out.println(last_dir+", "+d+" "+new_dir);
-				
+
 				test_x = xy[0] + this.dirslon[new_dir];
 				test_y = xy[1] + this.dirslat[new_dir];
 				
-				double[] geo = xy_to_geo(xy[0],xy[1]);
+				double[] geo = xy_to_geo(test_x,test_y,this.resolution);
 				
 				if(!bbox.contains(geo[0], geo[1])){
@@ -172,5 +170,4 @@
 				
 				v = wms.getPixel(test_x, test_y,0xFF0000FF);
-				//System.out.println(new_dir+" "+test_x+","+test_y+" "+v);
 				if(v > this.threshold){
 					break;
@@ -182,7 +179,5 @@
 				}
 			}
-			
-			//System.out.println("Found empty space");
-			
+
 			// Remember this direction
 			last_dir = new_dir;
@@ -194,5 +189,5 @@
 			}
 			
-			double[] geo = xy_to_geo(xy[0],xy[1]);
+			double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);
 			nodelist.add(geo);
 			System.out.println("Adding node at "+xy[0]+","+xy[1]+" ("+geo[1]+","+geo[0]+")");
@@ -298,19 +293,17 @@
 	}
 	
-	private double[] xy_to_geo(int x, int y){
+	public double[] xy_to_geo(int x, int y, double resolution){
 		double[] geo = new double[2];
-	    geo[0] = y / (double)this.resolution;
-	    geo[1] = x / (double)this.resolution;
+	    geo[0] = y / resolution;
+	    geo[1] = x / resolution;
 	    return geo;
 	}
 	
-	private int[] geo_to_xy(double lat, double lon){
+	public int[] geo_to_xy(double lat, double lon, double resolution){
 		int[] xy = new int[2];
 		
-		xy[0] = (int)Math.floor(lon * this.resolution + 0.5);
-		xy[1] = (int)Math.floor(lat * this.resolution + 0.5);
-		
-		System.out.println("("+lon+","+lat+") maps to ("+xy[0]+","+xy[1]+")");
-		
+		xy[0] = (int)Math.floor(lon * resolution + 0.5);
+		xy[1] = (int)Math.floor(lat * resolution + 0.5);
+				
 		return xy;
 	}
Index: applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java
===================================================================
--- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java	(revision 6911)
+++ applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java	(revision 6913)
@@ -42,6 +42,6 @@
 		
 		int[] bottom_left_xy = new int[2]; 
-		bottom_left_xy[0] = (int)(x / this.tilesize) * this.tilesize;
-		bottom_left_xy[1] = (int)(y / this.tilesize) * this.tilesize;
+		bottom_left_xy[0] = floor(x,this.tilesize);
+		bottom_left_xy[1] = floor(y,this.tilesize);
 		
         int[] top_right_xy = new int[2]; 
@@ -49,6 +49,6 @@
         top_right_xy[1] = (int)bottom_left_xy[1] + this.tilesize;
         
-        double[] topright_geo = xy_to_geo(top_right_xy[0],top_right_xy[1]);
-        double[] bottomleft_geo = xy_to_geo(bottom_left_xy[0],bottom_left_xy[1]);
+        double[] topright_geo = xy_to_geo(top_right_xy[0],top_right_xy[1],this.resolution);
+        double[] bottomleft_geo = xy_to_geo(bottom_left_xy[0],bottom_left_xy[1],this.resolution);
           
 		String filename = this.wmslayer+"/landsat_"+this.resolution+"_"+this.tilesize+
@@ -129,6 +129,4 @@
 	}
 	
-	
-	
 	public int getPixel(int x, int y, int pixcol){
 		
@@ -141,11 +139,13 @@
 			return -1;
 		}
-
-		int tx = (int)(Math.floor(x / this.tilesize) * this.tilesize);
-		int ty = (int)(Math.floor(y / this.tilesize) * this.tilesize);
-		
+	
+		int tx = floor(x,this.tilesize);
+		int ty = floor(y,this.tilesize);
+				
 		int pixel_x = (x-tx);
 		int pixel_y = (this.tilesize-1)-(y-ty);
-				
+					
+		//System.out.println("("+x+","+y+") maps to ("+pixel_x+","+pixel_y+") by ("+tx+", "+ty+")");
+		
 		int rgb = image.getRGB(pixel_x,pixel_y);
 		
@@ -179,4 +179,33 @@
 	}
 
+	public int floor(int num, int precision){
+		double dnum = num/(double)precision;
+		BigDecimal val = new BigDecimal(dnum) ;
+		val = val.setScale(0, BigDecimal.ROUND_FLOOR);
+		return val.intValue()*precision;
+	}
+	
+	public double floor(double num) {
+		BigDecimal val = new BigDecimal(num) ;
+		val = val.setScale(0, BigDecimal.ROUND_FLOOR);
+		return val.doubleValue() ;
+	}
+
+	public double[] xy_to_geo(int x, int y, double resolution){
+		double[] geo = new double[2];
+	    geo[0] = y / resolution;
+	    geo[1] = x / resolution;
+	    return geo;
+	}
+	
+	public int[] geo_to_xy(double lat, double lon, double resolution){
+		int[] xy = new int[2];
+		
+		xy[0] = (int)Math.floor(lon * resolution + 0.5);
+		xy[1] = (int)Math.floor(lat * resolution + 0.5);
+				
+		return xy;
+	}
+	
 	private void printarr(int[] a){
 		for(int i = 0; i<a.length; i++){
@@ -184,4 +213,5 @@
 		}
 	}
+	/*
 	private double[] xy_to_geo(int x, int y){
 		double[] geo = new double[2];
@@ -199,3 +229,4 @@
 		return xy;
 	}
+	*/
 }
