Index: Way.java
===================================================================
--- Way.java	(revision 2181)
+++ Way.java	(working copy)
@@ -173,6 +173,39 @@
 		return area <= 0;
 	}
 
+	/**
+	 * Test if the way can be used for a boundary area.
+	 * @return false if the way is not a closed polygon or if the area size 
+	 * is much smaller than the size of the bounding box 
+	 */
+	public boolean isUsableForBoundary(){
+		if(points.size() < 3 || !points.get(0).equals(points.get(points.size() - 1)))
+			return false;
+		long area = 0;
+		Coord p1 = points.get(0);
+		for(int i = 1; i < points.size(); ++i) {
+			
+			Coord p2 = points.get(i);
+			area += ((long)p1.getLongitude() * p2.getLatitude() - 
+					 (long)p2.getLongitude() * p1.getLatitude());
+			p1 = p2;
+		}
+		// if the area is very small, compare it with the size of the 
+		// bounding box
+		if (Math.abs(area) < 10){
+			int maxLat = Integer.MIN_VALUE,maxLon= Integer.MIN_VALUE,minLat=Integer.MAX_VALUE,minLon=Integer.MAX_VALUE;
+			for (Coord p: points){
+				if (p.getLatitude() > maxLat ) maxLat = p.getLatitude(); 
+				if (p.getLatitude() < minLat ) minLat = p.getLatitude();
+				if (p.getLongitude() > maxLon ) maxLon = p.getLongitude(); 
+				if (p.getLongitude() < minLon ) minLon = p.getLongitude(); 
+			}
+			long bboxArea = (maxLat-minLat) * (maxLon-minLon);
+			if (bboxArea > 20 * Math.abs(area))
+				return false;
+		}
+		return true;
+	}
 	// simplistic check to see if this way "contains" another - for
 	// speed, all we do is check that all of the other way's points
 	// are inside this way's polygon
