Index: applications/editors/josm/plugins/smed2/src/s57/S57att.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/s57/S57att.java	(revision 30215)
+++ applications/editors/josm/plugins/smed2/src/s57/S57att.java	(revision 30226)
@@ -50,6 +50,6 @@
 		AttS57.put(Att.ORIENT, 117); AttS57.put(Att.PEREND, 118);	AttS57.put(Att.PERSTA, 119); AttS57.put(Att.PICREP, 120);	AttS57.put(Att.PILDST, 121); AttS57.put(Att.PRCTRY, 122);
 		AttS57.put(Att.PRODCT, 123); AttS57.put(Att.PUBREF, 124);	AttS57.put(Att.QUASOU, 125); AttS57.put(Att.RADWAL, 126);	AttS57.put(Att.RADIUS, 127); AttS57.put(Att.RECDAT, 128);
-		AttS57.put(Att.RECIND, 129); AttS57.put(Att.RYRMGV, 130);	AttS57.put(Att.RESTRN, 131);	AttS57.put(Att.SCAMIN, 133);
-		AttS57.put(Att.SECTR1, 136);	AttS57.put(Att.SECTR2, 137); AttS57.put(Att.SHIPAM, 138);
+		AttS57.put(Att.RECIND, 129); AttS57.put(Att.RYRMGV, 130);	AttS57.put(Att.RESTRN, 131); AttS57.put(Att.SCAMAX, 132); AttS57.put(Att.SCAMIN, 133); AttS57.put(Att.SCVAL1, 134);
+		AttS57.put(Att.SCVAL2, 135); AttS57.put(Att.SECTR1, 136);	AttS57.put(Att.SECTR2, 137); AttS57.put(Att.SHIPAM, 138);
 		AttS57.put(Att.SIGFRQ, 139); AttS57.put(Att.SIGGEN, 140);	AttS57.put(Att.SIGGRP, 141); AttS57.put(Att.SIGPER, 142);	AttS57.put(Att.SIGSEQ, 143); AttS57.put(Att.SOUACC, 144);
 		AttS57.put(Att.SDISMX, 145); AttS57.put(Att.SDISMN, 146);	AttS57.put(Att.SORDAT, 147); AttS57.put(Att.SORIND, 148);	AttS57.put(Att.STATUS, 149); AttS57.put(Att.SURATH, 150);
@@ -152,5 +152,5 @@
 		AttStr.put(Att.CATVTR, "category");	AttStr.put(Att.CATTAB, "operation"); AttStr.put(Att.SCHREF, "schedule"); AttStr.put(Att.USESHP, "use"); AttStr.put(Att.CURVHW, "high_velocity");
 		AttStr.put(Att.CURVLW, "low_velocity"); AttStr.put(Att.CURVMW, "mean_velocity"); AttStr.put(Att.CURVOW, "other_velocity"); AttStr.put(Att.APTREF, "passing_time");
-		AttStr.put(Att.CATCOM, "category"); AttStr.put(Att.CATCVR, "category"); AttStr.put(Att.SCAMIN, "scale_minimum");
+		AttStr.put(Att.CATCOM, "category"); AttStr.put(Att.CATCVR, "category");
 		AttStr.put(Att.CATEXS, "category"); AttStr.put(Att.CATWWM, "category"); AttStr.put(Att.SHPTYP, "ship"); AttStr.put(Att.UPDMSG, "message"); AttStr.put(Att.LITRAD, "radius");
 	}
Index: applications/editors/josm/plugins/smed2/src/s57/S57map.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30215)
+++ applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30226)
@@ -319,4 +319,5 @@
 			}
 		}
+		sortGeom();
 	}
 
@@ -450,4 +451,118 @@
 	// Utility methods
 	
+	public void sortGeom() {
+		for (long id : index.keySet()) {
+			feature = index.get(id);
+			Geom geom = feature.geom;
+			Geom sort = new Geom(geom.prim);
+			long first = 0;
+			long last = 0;
+			boolean next = true;
+			if ((geom.prim == Pflag.LINE) || (geom.prim == Pflag.AREA)) {
+				int sweep = geom.elems.size();
+				while (!geom.elems.isEmpty()) {
+					Prim prim = geom.elems.remove(0);
+					Edge edge = edges.get(prim.id);
+					if (next == true) {
+						next = false;
+						if (prim.forward) {
+							first = edge.first;
+							last = edge.last;
+						} else {
+							first = edge.last;
+							last = edge.first;
+						}
+						sort.elems.add(prim);
+					} else {
+						if (prim.forward) {
+							if (edge.first == last) {
+								sort.elems.add(prim);
+								last = edge.last;
+							} else if (edge.last == first) {
+								sort.elems.add(0, prim);
+								first = edge.first;
+							} else {
+								geom.elems.add(prim);
+							}
+						} else {
+							if (edge.last == last) {
+								sort.elems.add(prim);
+								last = edge.first;
+							} else if (edge.first == first) {
+								sort.elems.add(0, prim);
+								first = edge.last;
+							} else {
+								geom.elems.add(prim);
+							}
+						}
+					}
+					if (--sweep == 0) {
+						next = true;
+						sweep = geom.elems.size();
+					}
+				}
+				feature.geom = sort;
+			} 
+			if (geom.prim == Pflag.AREA) {
+				ArrayList<Prim> outers = new ArrayList<Prim>();
+				ArrayList<Prim> inners = new ArrayList<Prim>();
+				for (Prim prim : feature.geom.elems) {
+					if (prim.outer) {
+						outers.add(prim);
+					} else {
+						inners.add(prim);
+					}
+				}
+				ArrayList<Prim> sorting = outers;
+				ArrayList<Prim> closed = null;
+				sort = new Geom(geom.prim);
+				next = true;
+				while (!sorting.isEmpty()) {
+					Prim prim = sorting.remove(0);
+					Edge edge = edges.get(prim.id);
+					if (next == true) {
+						next = false;
+						closed = new ArrayList<Prim>();
+						closed.add(prim);
+						if (prim.forward) {
+							first = edge.first;
+							last = edge.last;
+						} else {
+							first = edge.last;
+							last = edge.first;
+						}
+					} else {
+						if (prim.forward) {
+							if (edge.first == last) {
+								last = edge.last;
+								closed.add(prim);
+							} else {
+								sorting.add(0, prim);
+								next = true;
+							}
+						} else {
+							if (edge.last == last) {
+								last = edge.first;
+								closed.add(prim);
+							} else {
+								sorting.add(0, prim);
+								next = true;
+							}
+						}
+					}
+					if (first == last) {
+						sort.elems.addAll(closed);
+						next = true;
+					}
+					if (sorting.isEmpty() && sorting == outers) {
+						sorting = inners;
+						next = true;
+					}
+				}
+				feature.geom = sort;
+			}
+		}
+	}
+	
 	public class EdgeIterator {
 		Edge edge;
@@ -465,5 +580,5 @@
 		}
 
-		public Snode next() {
+		public long nextRef() {
 			long ref = 0;
 			if (forward) {
@@ -492,5 +607,9 @@
 				}
 			}
-			return nodes.get(ref);
+			return ref;
+		}
+		
+		public Snode next() {
+			return nodes.get(nextRef());
 		}
 	}
@@ -501,11 +620,12 @@
 		EdgeIterator eit;
 		ListIterator<S57map.Prim> it;
-		Snode first;
-		Snode last;
+		long first;
+		long last;
 		
 		public GeomIterator(Geom g) {
 			geom = g;
 			eit = null;
-			first = last = null;
+			first = 0;
+			last = -1;
 			if ((geom.prim != Pflag.NOSP) && (geom.prim != Pflag.POINT)) {
 				it = geom.elems.listIterator();
@@ -522,4 +642,5 @@
 			if ((it != null) && it.hasNext()) {
 				prim = it.next();
+				eit = new EdgeIterator(edges.get(prim.id), prim.forward);
 				return prim.outer;
 			}
@@ -528,18 +649,30 @@
 		
 		public boolean hasNext() {
-			return (first != last) && (eit.hasNext() || it.hasNext());
+			return (first != last) && (it.hasNext() || eit.hasNext());
 		}
 		
-		public Snode next() {
-			if (!eit.hasNext()) {
+		public long nextRef() {
+			if ((eit == null) || !eit.hasNext()) {
 				if (it.hasNext()) {
 					prim = it.next();
 					eit = new EdgeIterator(edges.get(prim.id), prim.forward);
 				} else {
-					return null;
-				}
-			}
-			last = eit.next();
-			return last;
+					return 0;
+				}
+			}
+			long ref = eit.nextRef();
+			if (ref == last)
+				ref = eit.nextRef();
+			if (first == 0) {
+				first = ref;
+				last = 0;
+			} else {
+				last = ref;
+			}
+			return ref;
+		}
+		
+		public Snode next() {
+			return nodes.get(nextRef());
 		}
 	}
Index: applications/editors/josm/plugins/smed2/src/symbols/Symbols.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/symbols/Symbols.java	(revision 30215)
+++ applications/editors/josm/plugins/smed2/src/symbols/Symbols.java	(revision 30226)
@@ -68,4 +68,8 @@
 			col = new ArrayList<Color>();
 			col.add(icol);
+		}
+		public Scheme() {
+			pat = new ArrayList<Patt>();
+			col = new ArrayList<Color>();
 		}
 	}
