Index: /applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
===================================================================
--- /applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30282)
+++ /applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30283)
@@ -33,8 +33,20 @@
 	public static void main(String[] args) throws IOException {
 
-		in = new FileInputStream("/Users/mherring/boatsw/oseam/josm/plugins/smed2/js57toosm/tst.000");
+		if (args.length < 1) {
+			System.err.println("Usage: java -jar js57toosm.jar S57_filename [types_filename]");
+			System.exit(-1);
+		}
+		in = new FileInputStream(args[0]);
 		out = System.out;
+		ArrayList<Obj> types = new ArrayList<Obj>();
+		if (args.length == 2) {
+			Scanner tin = new Scanner(new FileInputStream(args[1]));
+			while (tin.hasNext()) {
+				types.add(S57obj.enumType(tin.next()));
+			}
+			tin.close();
+		}
+		
 		map = new S57map();
-
 		S57dat.rnum = 0;
 
@@ -57,5 +69,5 @@
 		double minlat = 90, minlon = 180, maxlat = -90, maxlon = -180;
 		
-		HashMap<Long, Boolean> done = new HashMap<Long, Boolean>();
+		ArrayList<Long> done = new ArrayList<Long>();
 
 		while (in.read(leader) == 24) {
@@ -221,5 +233,5 @@
 			Feature feature = map.index.get(id);
 			String type = S57obj.stringType(feature.type);
-			if (!type.isEmpty()) {
+			if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) {
 				if (feature.reln == Rflag.MASTER) {
 					if (feature.geom.prim == Pflag.POINT) {
@@ -228,5 +240,5 @@
 							Snode node;
 							while ((node = map.nodes.get(ref)) != null) {
-								if (!done.containsKey(ref)) {
+								if (!done.contains(ref)) {
 									out.format("  <node id='%d' lat='%.8f' lon='%.8f' version='1'>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon));
 									out.format("    <tag k='seamark:type' v=\"%s\"/>%n", type);
@@ -235,5 +247,5 @@
 									writeAtts(feature, type);
 									out.format("  </node>%n");
-									done.put(ref, true);
+									done.add(ref);
 								}
 								ref++;
@@ -247,5 +259,5 @@
 			Feature feature = map.index.get(id);
 			String type = S57obj.stringType(feature.type);
-			if (!type.isEmpty()) {
+			if (!type.isEmpty() && (types.isEmpty() || types.contains(feature.type))) {
 				if (feature.reln == Rflag.MASTER) {
 					if (feature.geom.prim == Pflag.LINE) {
@@ -258,7 +270,7 @@
 									long ref = git.nextRef();
 									Snode node = map.nodes.get(ref);
-									if (!done.containsKey(ref)) {
+									if (!done.contains(ref)) {
 										out.format("  <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon));
-										done.put(ref, true);
+										done.add(ref);
 									}
 								}
@@ -279,5 +291,5 @@
 							}
 							out.format("  </way>%n");
-							done.put(way, true);
+							done.add(way);
 						}
 					} else if (feature.geom.prim == Pflag.AREA) {
@@ -290,7 +302,7 @@
 									long ref = git.nextRef();
 									Snode node = map.nodes.get(ref);
-									if (!done.containsKey(ref)) {
+									if (!done.contains(ref)) {
 										out.format("  <node id='%d' lat='%.8f' lon='%.8f' version='1'/>%n", -ref, Math.toDegrees(node.lat), Math.toDegrees(node.lon));
-										done.put(ref, true);
+										done.add(ref);
 									}
 								}
@@ -302,5 +314,5 @@
 							while (git.hasEdge()) {
 								long way = git.nextEdge();
-								if (!done.containsKey(way)) {
+								if (!done.contains(way)) {
 									out.format("  <way id='%d' version='1'>%n", -way);
 									while (git.hasNode()) {
@@ -309,5 +321,5 @@
 									}
 									out.format("  </way>%n");
-									done.put(way, true);
+									done.add(way);
 								}
 							}
@@ -317,7 +329,4 @@
 						git = map.new GeomIterator(feature.geom);
 						int outers = feature.geom.refs.get(0).size;
-if (feature.geom.inners != 0){
-	int x=0;
-}
 						while (git.hasComp()) {
 							git.nextComp();
Index: /applications/editors/josm/plugins/smed2/src/s57/S57map.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30282)
+++ /applications/editors/josm/plugins/smed2/src/s57/S57map.java	(revision 30283)
@@ -253,7 +253,10 @@
 		feature = new Feature();
 		Obj obj = S57obj.decodeType(objl);
-		if (obj == Obj.C_AGGR) {
+		if (obj == Obj.BCNWTW)
+			obj = Obj.BCNLAT;
+		if (obj == Obj.BOYWTW)
+			obj = Obj.BOYLAT;
+		if (obj == Obj.C_AGGR)
 			feature.reln = Rflag.AGGR;
-		}
 		feature.geom = new Geom(p);
 		feature.type = obj;
Index: /applications/editors/josm/plugins/smed2/src/s57/S57obj.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/s57/S57obj.java	(revision 30282)
+++ /applications/editors/josm/plugins/smed2/src/s57/S57obj.java	(revision 30283)
@@ -131,6 +131,6 @@
 		ObjStr.put(Obj.TS_FEB, "tidal_stream");	ObjStr.put(Obj.NOTMRK, "notice");	ObjStr.put(Obj.WTWAXS, "waterway_axis"); ObjStr.put(Obj.WTWPRF, "waterway_profile");
 		ObjStr.put(Obj.BRGARE, "bridge_area"); ObjStr.put(Obj.BUNSTA, "bunker_station");	ObjStr.put(Obj.COMARE, "communication_area");	ObjStr.put(Obj.HRBBSN, "harbour_basin");
-		ObjStr.put(Obj.LOKARE, "lock_area"); ObjStr.put(Obj.LKBSPT, "lock_basin_part"); ObjStr.put(Obj.PRTARE, "port_area");	ObjStr.put(Obj.BCNWTW, "beacon_lateral");
-		ObjStr.put(Obj.BOYWTW, "buoy_lateral"); ObjStr.put(Obj.REFDMP, "refuse_dump"); ObjStr.put(Obj.RTPLPT, "route_planning_point"); ObjStr.put(Obj.TERMNL, "terminal");
+		ObjStr.put(Obj.LOKARE, "lock_area"); ObjStr.put(Obj.LKBSPT, "lock_basin_part"); ObjStr.put(Obj.PRTARE, "port_area");	ObjStr.put(Obj.BCNWTW, "beacon_waterway");
+		ObjStr.put(Obj.BOYWTW, "buoy_waterway"); ObjStr.put(Obj.REFDMP, "refuse_dump"); ObjStr.put(Obj.RTPLPT, "route_planning_point"); ObjStr.put(Obj.TERMNL, "terminal");
 		ObjStr.put(Obj.TRNBSN, "turning_basin"); ObjStr.put(Obj.WTWARE, "waterway_area"); ObjStr.put(Obj.WTWGAG, "waterway_gauge"); ObjStr.put(Obj.TISDGE, "time_schedule");
 		ObjStr.put(Obj.VEHTRF, "vehicle_transfer"); ObjStr.put(Obj.EXCNST, "exceptional_structure");
