Index: applications/editors/josm/plugins/seachart/js57toosm/build.xml
===================================================================
--- applications/editors/josm/plugins/seachart/js57toosm/build.xml	(revision 31658)
+++ applications/editors/josm/plugins/seachart/js57toosm/build.xml	(revision 31659)
@@ -3,27 +3,28 @@
   <property name="build" location="build"/>
   <property name="jarfile" location="./js57toosm.jar"/>
-  <property name="ant.build.javac.target" value="1.7"/>
-  <property name="ant.build.javac.source" value="1.7"/>
   <property name="lang.dir" value="/usr/local/bin/commons-lang3-3.4/"/>
-      
+  <path id="classpath">
+    <fileset dir="${lang.dir}" includes="**/commons-lang3-3.4.jar"/>
+  </path>
+  
   <target name="init">
     <mkdir dir="${build}"/>
   </target>
-
-  <target name="compile" depends="init" description="compile the source " >
-    <javac includeantruntime="false" srcdir="${src}" destdir="${build}" encoding="UTF-8"/>
+  
+  <target name="compile" depends="init" description="compile the source">
+    <javac includeantruntime="false" srcdir="${src}" destdir="${build}" classpathref="classpath" encoding="UTF-8" />
   </target>
-
-  <target name="dist" depends="compile" description="generate the distribution" >
+  
+  <target name="dist" depends="compile" description="generate the distribution">
     <jar jarfile="${jarfile}" basedir="${build}" >
       <manifest>
         <attribute name="Main-Class" value="js57toosm.Js57toosm"/>
-        <attribute name="Class-Path" value="$jarfile"/>
+        <attribute name="Class-Path" value="${jarfile}"/>
       </manifest>
       <zipgroupfileset dir="${lang.dir}" includes="**/commons-lang3-3.4.jar" />
     </jar>
   </target>
-
-  <target name="clean" description="clean up" >
+  
+  <target name="clean" description="clean up">
     <delete dir="${build}"/>
     <delete file="${jarfile}"/>
Index: applications/editors/josm/plugins/seachart/js57toosm/src/js57toosm/Js57toosm.java
===================================================================
--- applications/editors/josm/plugins/seachart/js57toosm/src/js57toosm/Js57toosm.java	(revision 31658)
+++ applications/editors/josm/plugins/seachart/js57toosm/src/js57toosm/Js57toosm.java	(revision 31659)
@@ -30,4 +30,8 @@
 	static PrintStream out;
 	static S57map map;
+	static final ArrayList<Att> typatts = new ArrayList<Att>(); static {
+		typatts.add(Att.OBJNAM); typatts.add(Att.NOBJNM); typatts.add(Att.STATUS); typatts.add(Att.INFORM); typatts.add(Att.NINFOM);
+		typatts.add(Att.PEREND); typatts.add(Att.PERSTA); typatts.add(Att.CONDTN); typatts.add(Att.CONRAD); typatts.add(Att.CONVIS);
+	}
 	
 	public static void main(String[] args) throws IOException {
@@ -39,7 +43,19 @@
 			System.exit(-1);
 		}
-		in = new FileInputStream(args[0]);
-		out = new PrintStream(args[2]);
+		try {
+			in = new FileInputStream(args[0]);
+		} catch (IOException e) {
+			System.err.println("Input file: " + e.getMessage());
+			System.exit(-1);
+		}
+		try {
+			out = new PrintStream(args[2]);
+		} catch (IOException e) {
+			System.err.println("Output file: " + e.getMessage());
+			in.close();
+			System.exit(-1);
+		}
 		ArrayList<Obj> types = new ArrayList<Obj>();
+		try {
 			Scanner tin = new Scanner(new FileInputStream(args[1]));
 			while (tin.hasNext()) {
@@ -49,4 +65,10 @@
 			}
 			tin.close();
+		} catch (IOException e) {
+			System.err.println("Types file: " + e.getMessage());
+			in.close();
+			out.close();
+			System.exit(-1);
+		}
 		
 		map = new S57map(true);
@@ -72,5 +94,5 @@
 									if ((feature.type == Obj.SOUNDG) && (node.flg == S57map.Nflag.DPTH))
 										out.format("    <tag k='seamark:sounding:depth' v='%.1f'/>%n", ((Dnode) node).val);
-									writeAtts(feature, type);
+									writeAtts(feature);
 									out.format("  </node>%n");
 									done.add(ref);
@@ -116,5 +138,5 @@
 							}
 							out.format("    <tag k='seamark:type' v='%s'/>%n", type);
-							writeAtts(feature, type);
+							writeAtts(feature);
 							out.format("  </way>%n");
 						}
@@ -161,5 +183,5 @@
 						}
 						out.format("    <tag k='seamark:type' v='%s'/>%n", type);
-						writeAtts(feature, type);
+						writeAtts(feature);
 						out.format("  </relation>%n");
 					}
@@ -172,15 +194,19 @@
 	}
 	
-	static void writeAtts(Feature feature, String type) {
+	static void writeAtts(Feature feature) {
 		for (Map.Entry<Att, AttVal<?>> item : feature.atts.entrySet()) {
 			String attstr = S57att.stringAttribute(item.getKey());
 			String valstr = S57val.stringValue(item.getValue(), item.getKey());
-			if (!attstr.isEmpty() && !valstr.isEmpty())
-				out.format("    <tag k='seamark:%s:%s' v='%s'/>%n", type, attstr, StringEscapeUtils.escapeXml10(valstr));
+			if (!attstr.isEmpty() && !valstr.isEmpty()) {
+				if (typatts.contains(item.getKey())) {
+					out.format("    <tag k='seamark:%s' v='%s'/>%n", attstr, StringEscapeUtils.escapeXml10(valstr));
+				} else {
+					out.format("    <tag k='seamark:%s:%s' v='%s'/>%n", S57obj.stringType(feature.type), attstr, StringEscapeUtils.escapeXml10(valstr));
+				}
+			}
 		}
 		for (Obj obj : feature.objs.keySet()) {
 			ObjTab tab = feature.objs.get(obj);
 			for (int ix : tab.keySet()) {
-				type = S57obj.stringType(obj);
 				AttMap atts = tab.get(ix);
 				for (Map.Entry<Att, AttVal<?>> item : atts.entrySet()) {
@@ -189,7 +215,7 @@
 					if (!attstr.isEmpty() && !valstr.isEmpty()) {
 						if ((ix == 0) && (tab.size() == 1)) {
-							out.format("    <tag k='seamark:%s:%s' v='%s'/>%n", type, attstr, StringEscapeUtils.escapeXml10(valstr));
+							out.format("    <tag k='seamark:%s:%s' v='%s'/>%n", S57obj.stringType(obj), attstr, StringEscapeUtils.escapeXml10(valstr));
 						} else {
-							out.format("    <tag k='seamark:%s:%d:%s' v='%s'/>%n", type, ix + 1, attstr, StringEscapeUtils.escapeXml10(valstr));
+							out.format("    <tag k='seamark:%s:%d:%s' v='%s'/>%n", S57obj.stringType(obj), ix + 1, attstr, StringEscapeUtils.escapeXml10(valstr));
 						}
 					}
Index: applications/editors/josm/plugins/seachart/src/s57/S57map.java
===================================================================
--- applications/editors/josm/plugins/seachart/src/s57/S57map.java	(revision 31658)
+++ applications/editors/josm/plugins/seachart/src/s57/S57map.java	(revision 31659)
@@ -767,5 +767,5 @@
 		feature.geom.area = 0;
 		if (feature.geom.prim == Pflag.POINT) { 
-			feature.geom.centre = findCentroid(feature);
+			feature.geom.centre = nodes.get(feature.geom.elems.get(0).id);
 			return true;
 		}	else {
@@ -826,11 +826,24 @@
 		}
 		if (feature.geom.prim == Pflag.AREA) {
-			if (signedArea(feature.geom) < 0.0) {
-				
-			};
-			feature.geom.area = calcArea(feature.geom);
+			int ie = 0;
+			int ic = 0;
+			while (ie < feature.geom.elems.size()) {
+				double area = calcArea(feature.geom, ic);
+				if (ie == 0) feature.geom.area = Math.abs(area) * 3444 * 3444;
+				if (((ie == 0) && (area < 0.0)) || ((ie > 0) && (area >= 0.0))) {
+					ArrayList<Prim> tmp = new ArrayList<Prim>();
+					for (int i = 0; i < feature.geom.comps.get(ic).size; i++) {
+						Prim p = feature.geom.elems.remove(ie);
+						p.forward = !p.forward;
+						tmp.add(0, p);
+					}
+					feature.geom.elems.addAll(ie, tmp);
+				}
+				ie += feature.geom.comps.get(ic).size;
+				ic++;
+			}
 		}
 		feature.geom.length = calcLength(feature.geom);
-		feature.geom.centre = findCentroid(feature);
+		feature.geom.centre = calcCentroid(feature);
 		return true;
 	}
@@ -951,5 +964,5 @@
 	}
 	
-	double signedArea(Geom geom) {
+	double calcArea(Geom geom, int comp) {
 		Snode node;
 		double lat, lon, llon, llat;
@@ -957,17 +970,22 @@
 		double sigma = 0;
 		GeomIterator git = new GeomIterator(geom);
-		if (git.hasComp()) {
-			git.nextComp();
-			while (git.hasEdge()) {
-				git.nextEdge();
-				while (git.hasNode()) {
-					node = git.next();
-					if (node == null) continue;
-					llon = lon;
-					llat = lat;
-					lat = node.lat;
-					lon = node.lon;
-					sigma += (lon * Math.sin(llat)) - (llon * Math.sin(lat));
-				}
+		for (int i = 0; i <= comp; i++) {
+			if (git.hasComp()) {
+				git.nextComp();
+				while (git.hasEdge()) {
+					git.nextEdge();
+					while (git.hasNode()) {
+						node = git.next();
+						if (node == null)
+							continue;
+						llon = lon;
+						llat = lat;
+						lat = node.lat;
+						lon = node.lon;
+						sigma += (lon * Math.sin(llat)) - (llon * Math.sin(lat));
+					}
+				}
+				if (i != comp)
+					sigma = lat = lon = llon = llat = 0;
 			}
 		}
@@ -975,13 +993,5 @@
 	}
 
-	public boolean handOfArea(Geom geom) {
-		return (signedArea(geom) < 0);
-	}
-
-	public double calcArea(Geom geom) {
-		return Math.abs(signedArea(geom)) * 3444 * 3444;
-	}
-
-	public double calcLength(Geom geom) {
+	double calcLength(Geom geom) {
 		Snode node;
 		double lat, lon, llon, llat;
@@ -1013,5 +1023,5 @@
 	}
 
-	public Snode findCentroid(Feature feature) {
+	Snode calcCentroid(Feature feature) {
 		double lat, lon, slat, slon, llat, llon;
 		llat = llon = lat = lon = slat = slon = 0;
