Index: /applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/seamap/Renderer.java	(revision 29269)
+++ /applications/editors/josm/plugins/smed2/src/seamap/Renderer.java	(revision 29270)
@@ -173,20 +173,24 @@
 
 	public static void lineVector (Feature feature, LineStyle style) {
-		if (feature.flag != Fflag.POINT) {
-			ArrayList<Long> ways = new ArrayList<Long>();
-//			if (map.outers.containsKey(feature.refs)) {
-//				ways.addAll(map.mpolys.get(map.outers.get(feature.refs)));
-//			} else {
-//				if (map.mpolys.containsKey(feature.refs)) {
-//					ways.addAll(map.mpolys.get(feature.refs));
-//				} else {
-//					ways.add(feature.refs);
-//				}
-//			}
-			Path2D.Double p = new Path2D.Double();
-			p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
+		Path2D.Double p = new Path2D.Double();
+		p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
+		switch (feature.flag) {
+		case LINE:
+			break;
+		case AREA:
+			break;
+/*			ArrayList<Long> ways = new ArrayList<Long>();
+			if (map.outers.containsKey(feature.refs)) {
+				ways.addAll(map.mpolys.get(map.outers.get(feature.refs)));
+			} else {
+				if (map.mpolys.containsKey(feature.refs)) {
+					ways.addAll(map.mpolys.get(feature.refs));
+				} else {
+					ways.add(feature.refs);
+				}
+			}
 			for (long way : ways) {
 				boolean first = true;
-/*				for (long node : map.ways.get(way)) {
+				for (long node : map.ways.get(way)) {
 					Point2D point = helper.getPoint(map.points.get(node));
 					if (first) {
@@ -215,5 +219,5 @@
 				g2.setPaint(style.fill);
 				g2.fill(p);
-*/			}
+			}*/
 		}
 	}
Index: /applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java	(revision 29269)
+++ /applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java	(revision 29270)
@@ -24,5 +24,5 @@
 		ANON, ISOL, CONN
 	}
-	
+
 	public class Snode {
 		public double lat;
@@ -35,4 +35,5 @@
 			lon = 0;
 		}
+
 		public Snode(double ilat, double ilon) {
 			flg = Nflag.ANON;
@@ -40,4 +41,5 @@
 			lon = ilon;
 		}
+
 		public Snode(double ilat, double ilon, Nflag iflg) {
 			lat = ilat;
@@ -46,5 +48,5 @@
 		}
 	}
-	
+
 	public class Edge {
 		public boolean forward;
@@ -52,4 +54,5 @@
 		public long last;
 		public ArrayList<Long> nodes;
+
 		public Edge() {
 			forward = true;
@@ -59,8 +62,9 @@
 		}
 	}
-	
+
 	public class Side {
 		Edge edge;
 		boolean forward;
+
 		public Side(Edge iedge, boolean ifwd) {
 			edge = iedge;
@@ -68,12 +72,14 @@
 		}
 	}
-	
+
 	public class Bound {
 		public boolean outer;
 		ArrayList<Side> sides;
+
 		public Bound() {
 			outer = true;
 			sides = new ArrayList<Side>();
 		}
+
 		public Bound(Side iside, boolean irole) {
 			outer = irole;
@@ -98,5 +104,5 @@
 		}
 	}
-	
+
 	public class AttMap extends EnumMap<Att, AttItem> {
 		public AttMap() {
@@ -104,5 +110,5 @@
 		}
 	}
-	
+
 	public class ObjTab extends HashMap<Integer, AttMap> {
 		public ObjTab() {
@@ -110,5 +116,5 @@
 		}
 	}
-	
+
 	public class ObjMap extends EnumMap<Obj, ObjTab> {
 		public ObjMap() {
@@ -116,5 +122,5 @@
 		}
 	}
-	
+
 	public class NodeTab extends HashMap<Long, Snode> {
 		public NodeTab() {
@@ -122,5 +128,5 @@
 		}
 	}
-	
+
 	public class EdgeTab extends HashMap<Long, Edge> {
 		public EdgeTab() {
@@ -128,5 +134,5 @@
 		}
 	}
-	
+
 	public class AreaTab extends HashMap<Long, Area> {
 		public AreaTab() {
@@ -134,5 +140,5 @@
 		}
 	}
-	
+
 	public class FtrMap extends EnumMap<Obj, ArrayList<Feature>> {
 		public FtrMap() {
@@ -140,5 +146,5 @@
 		}
 	}
-	
+
 	public class FtrTab extends HashMap<Long, Feature> {
 		public FtrTab() {
@@ -146,9 +152,9 @@
 		}
 	}
-	
+
 	public enum Fflag {
 		UNKN, POINT, LINE, AREA
 	}
-	
+
 	public class Feature {
 		public Fflag flag;
@@ -174,5 +180,5 @@
 	public EdgeTab edges;
 	public AreaTab areas;
-	
+
 	public FtrMap features;
 	public FtrTab index;
@@ -182,4 +188,98 @@
 	private ArrayList<Long> outers;
 	private ArrayList<Long> inners;
+
+	public class EdgeIterator {
+		Edge edge;
+		boolean forward;
+		ListIterator<Long> it;
+
+		public EdgeIterator(Edge iedge, boolean dir) {
+			edge = iedge;
+			forward = dir;
+			it = null;
+		}
+
+		public boolean hasNext() {
+			return (edge != null) && ((it == null) || (forward && it.hasNext()) || (!forward && it.hasPrevious()));
+		}
+
+		public Snode next() {
+			long ref = 0;
+			if (forward) {
+				if (it == null) {
+					ref = edge.first;
+					it = edge.nodes.listIterator();
+				} else {
+					if (it.hasNext()) {
+						ref = it.next();
+					} else {
+						ref = edge.last;
+						edge = null;
+					}
+				}
+			} else {
+				if (it == null) {
+					ref = edge.last;
+					it = edge.nodes.listIterator(edge.nodes.size());
+				} else {
+					if (it.hasPrevious()) {
+						ref = it.previous();
+					} else {
+						ref = edge.first;
+						edge = null;
+					}
+				}
+			}
+			return nodes.get(ref);
+		}
+	}
+
+	public class BoundIterator {
+		Bound bound;
+		Side side;
+		ListIterator<Side> sit;
+		EdgeIterator eit;
+
+		public BoundIterator(Bound ibound) {
+			bound = ibound;
+			sit = bound.sides.listIterator();
+			if (sit.hasNext()) {
+				side = sit.next();
+				eit = new EdgeIterator(side.edge, side.forward);
+			} else {
+				side = null;
+			}
+		}
+
+		public boolean hasNext() {
+			return side != null;
+		}
+
+		public Snode next() {
+			Snode node = null;
+			if (side != null) {
+				if (eit.hasNext()) {
+					node = eit.next();
+				} else {
+					if (sit.hasNext()) {
+						side = sit.next();
+						eit = new EdgeIterator(side.edge, side.forward);
+						node = eit.next();
+					} else {
+						side = null;
+					}
+				}
+			}
+			return node;
+		}
+	}
+	
+	public class AreaIterator {
+		Area area;
+	}
+
+	public class FeatureIterator {
+		Feature feature;
+	}
 
 	public SeaMap() {
@@ -234,5 +334,5 @@
 		}
 	}
-	
+
 	public void addTag(String key, String val) {
 		String subkeys[] = key.split(":");
@@ -261,5 +361,6 @@
 				}
 				AttVal attval = S57val.convertValue(val, att);
-				if (attval.val != null) atts.put(att, new AttItem(attval.conv, attval.val));
+				if (attval.val != null)
+					atts.put(att, new AttItem(attval.conv, attval.val));
 			} else {
 				if (subkeys[1].equals("type")) {
@@ -269,5 +370,6 @@
 					if (att != Att.UNKATT) {
 						AttVal attval = S57val.convertValue(val, att);
-						if (attval.val != null) feature.atts.put(att, new AttItem(attval.conv, attval.val));
+						if (attval.val != null)
+							feature.atts.put(att, new AttItem(attval.conv, attval.val));
 					}
 				}
@@ -311,15 +413,17 @@
 					Bound bound = new Bound(new Side(edge, edge.forward), (role == outers));
 					if (node1 != node2) {
-						for (ListIterator<Long> it = role.listIterator(0); it.hasNext(); ) {
-					    Edge nedge = edges.get(it.next());
-					    if (nedge.first == node2) {
-					    	bound.sides.add(new Side(nedge, true));
-					    	it.remove();
-					    	if (nedge.last == node2) break;
-					    } else if (nedge.last == node2) {
-					    	bound.sides.add(new Side(nedge, false));
-					    	it.remove();
-					    	if (nedge.first == node2) break;
-					    }
+						for (ListIterator<Long> it = role.listIterator(0); it.hasNext();) {
+							Edge nedge = edges.get(it.next());
+							if (nedge.first == node2) {
+								bound.sides.add(new Side(nedge, true));
+								it.remove();
+								if (nedge.last == node2)
+									break;
+							} else if (nedge.last == node2) {
+								bound.sides.add(new Side(nedge, false));
+								it.remove();
+								if (nedge.first == node2)
+									break;
+							}
 						}
 					}
@@ -344,45 +448,12 @@
 		lat = lon = llon = llat = 0;
 		double sigma = 0;
-		ListIterator<Long> it;
-		for (Side side : bound.sides) {
-			if (side.forward) {
-				node = nodes.get(side.edge.first);
-				lat = node.lat;
-				lon = node.lon;
-				it = side.edge.nodes.listIterator();
-				while (it.hasNext()) {
-					llon = lon;
-					llat = lat;
-					node = nodes.get(it.next());
-					lat = node.lat;
-					lon = node.lon;
-					sigma += (lon * Math.sin(llat)) - (llon * Math.sin(lat));
-				}
-				llon = lon;
-				llat = lat;
-				node = nodes.get(side.edge.last);
-				lat = node.lat;
-				lon = node.lon;
-				sigma += (lon * Math.sin(llat)) - (llon * Math.sin(lat));
-			} else {
-				node = nodes.get(side.edge.last);
-				lat = node.lat;
-				lon = node.lon;
-				it = side.edge.nodes.listIterator(side.edge.nodes.size());
-				while (it.hasPrevious()) {
-					llon = lon;
-					llat = lat;
-					node = nodes.get(it.previous());
-					lat = node.lat;
-					lon = node.lon;
-					sigma += (lon * Math.sin(llat)) - (llon * Math.sin(lat));
-				}
-				llon = lon;
-				llat = lat;
-				node = nodes.get(side.edge.first);
-				lat = node.lat;
-				lon = node.lon;
-				sigma += (lon * Math.sin(llat)) - (llon * Math.sin(lat));
-			}
+		BoundIterator it = new BoundIterator(bound);
+		while (it.hasNext()) {
+			llon = lon;
+			llat = lat;
+			node = it.next();
+			lat = node.lat;
+			lon = node.lon;
+			sigma += (lon * Math.sin(llat)) - (llon * Math.sin(lat));
 		}
 		return sigma;
@@ -392,12 +463,12 @@
 		return (signedArea(bound) < 0);
 	}
-	
+
 	public double calcArea(Bound bound) {
-	  return Math.abs(signedArea(bound)) * 3444 * 3444 / 2.0;
+		return Math.abs(signedArea(bound)) * 3444 * 3444 / 2.0;
 	}
 
 	public Snode findCentroid(Feature feature) {
-    double lat, lon, slat, slon, sarc, llat, llon;
-    lat = lon = slat = slon = sarc = llat = llon = 0;
+		double lat, lon, slat, slon, sarc, llat, llon;
+		lat = lon = slat = slon = sarc = llat = llon = 0;
 		switch (feature.flag) {
 		case POINT:
@@ -405,33 +476,26 @@
 		case LINE:
 			Edge edge = edges.get(feature.refs);
-			llat = nodes.get(edge.first).lat;
-			llon = nodes.get(edge.first).lon;
-			for (long id : edge.nodes) {
-				lat = nodes.get(id).lat;
-				lon = nodes.get(id).lon;
-				sarc += (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
+			EdgeIterator eit = new EdgeIterator(edge, true);
+			while (eit.hasNext()) {
+				Snode node = eit.next();
+				lat = node.lat;
+				lon = node.lon;
+				sarc += (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
 				llat = lat;
 				llon = lon;
 			}
-			lat = nodes.get(edge.last).lat;
-			lon = nodes.get(edge.last).lon;
-			sarc += (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
 			double harc = sarc / 2;
 			sarc = 0;
-			llat = nodes.get(edge.first).lat;
-			llon = nodes.get(edge.first).lon;
-			for (long id : edge.nodes) {
-				lat = nodes.get(id).lat;
-				lon = nodes.get(id).lon;
-				sarc = (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
-				if (sarc > harc) break;
+			eit = new EdgeIterator(edge, true);
+			while (eit.hasNext()) {
+				Snode node = eit.next();
+				lat = node.lat;
+				lon = node.lon;
+				sarc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+				if (sarc > harc)
+					break;
 				harc -= sarc;
 				llat = lat;
 				llon = lon;
-			}
-			if (sarc <= harc) {
-				lat = nodes.get(edge.last).lat;
-				lon = nodes.get(edge.last).lon;
-				sarc = (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
 			}
 			double frac = harc / sarc;
@@ -439,63 +503,20 @@
 		case AREA:
 			Bound bound = areas.get(feature.refs).get(0);
-			Snode node;
-			ListIterator<Long> it;
-			for (Side side : bound.sides) {
-				if (side.forward) {
-					node = nodes.get(side.edge.first);
-					lat = node.lat;
-					lon = node.lon;
-					it = side.edge.nodes.listIterator();
-					while (it.hasNext()) {
-						llon = lon;
-						llat = lat;
-						node = nodes.get(it.next());
-						lat = node.lat;
-						lon = node.lon;
-						double arc = (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
-						slat += (lat * arc);
-						slon += (lon * arc);
-						sarc += arc;
-					}
-					llon = lon;
-					llat = lat;
-					node = nodes.get(side.edge.last);
-					lat = node.lat;
-					lon = node.lon;
-					double arc = (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
-					slat += (lat * arc);
-					slon += (lon * arc);
-					sarc += arc;
-				} else {
-					node = nodes.get(side.edge.last);
-					lat = node.lat;
-					lon = node.lon;
-					it = side.edge.nodes.listIterator(side.edge.nodes.size());
-					while (it.hasPrevious()) {
-						llon = lon;
-						llat = lat;
-						node = nodes.get(it.previous());
-						lat = node.lat;
-						lon = node.lon;
-						double arc = (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
-						slat += (lat * arc);
-						slon += (lon * arc);
-						sarc += arc;
-					}
-					llon = lon;
-					llat = lat;
-					node = nodes.get(side.edge.first);
-					lat = node.lat;
-					lon = node.lon;
-					double arc = (Math.acos(Math.cos(lon-llon) * Math.cos(lat-llat)));
-					slat += (lat * arc);
-					slon += (lon * arc);
-					sarc += arc;
-				}
-			}
-			return new Snode((sarc > 0.0 ? slat/sarc : 0.0), (sarc > 0.0 ? slon/sarc : 0.0));
+			BoundIterator bit = new BoundIterator(bound);
+			while (bit.hasNext()) {
+				llon = lon;
+				llat = lat;
+				Snode node = bit.next();
+				lat = node.lat;
+				lon = node.lon;
+				double arc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+				slat += (lat * arc);
+				slon += (lon * arc);
+				sarc += arc;
+			}
+			return new Snode((sarc > 0.0 ? slat / sarc : 0.0), (sarc > 0.0 ? slon / sarc : 0.0));
 		}
 		return null;
 	}
-	
+
 }
