Index: /applications/editors/josm/plugins/smed2/src/s57/S57val.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/s57/S57val.java	(revision 29151)
+++ /applications/editors/josm/plugins/smed2/src/s57/S57val.java	(revision 29152)
@@ -27,7 +27,7 @@
 	
 	public static class AttVal {
-		Att att;
-		Conv conv;
-		Object val;
+		public Att att;
+		public Conv conv;
+		public Object val;
 		AttVal(Att a, Conv c, Object v) {
 			att = a; conv = c; val = v;
Index: /applications/editors/josm/plugins/smed2/src/seamap/Map.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/seamap/Map.java	(revision 29151)
+++ /applications/editors/josm/plugins/smed2/src/seamap/Map.java	(revision 29152)
@@ -14,20 +14,25 @@
 import java.util.HashMap;
 
-import s57.S57att.Att;
-import s57.S57obj.Obj;
-import s57.S57val.Conv;
+import s57.S57att;
+import s57.S57att.*;
+import s57.S57obj;
+import s57.S57obj.*;
+import s57.S57val;
+import s57.S57val.*;
 
 public class Map {
 
-	public enum Fflag { NODE, WAY, AREA	}
+	public enum Fflag {
+		UNKN, NODE, WAY, AREA
+	}
 
 	public class AttItem {
 		Conv conv;
 		Object val;
-	}
 
-	public class ObjItem {
-		int idx;
-		ArrayList<EnumMap<Att, AttItem>> atts;
+		AttItem(Conv iconv, Object ival) {
+			conv = iconv;
+			val = ival;
+		}
 	}
 
@@ -38,45 +43,116 @@
 		public Obj type;
 		public EnumMap<Att, AttItem> atts;
-		public EnumMap<Obj, ArrayList<ObjItem>> objs;
+		public EnumMap<Obj, HashMap<Integer, EnumMap<Att, AttItem>>> objs;
+
+		Feature() {
+			clean();
+		}
+		
+		void clean() {
+			id = 0;
+			flag = Fflag.UNKN;
+			refs = new ArrayList<Long>();
+			type = Obj.UNKOBJ;
+			atts = new EnumMap<Att, AttItem>(Att.class);
+			objs = new EnumMap<Obj, HashMap<Integer, EnumMap<Att, AttItem>>>(Obj.class);
+		}
 	}
-	
+
 	public class Coord {
 		double lat;
 		double lon;
-		Coord (double ilat, double ilon) {
+
+		Coord(double ilat, double ilon) {
 			lat = ilat;
 			lon = ilon;
 		}
 	}
-	
+
 	public HashMap<Long, Coord> nodes;
 	public HashMap<Long, ArrayList<Long>> ways;
 	public HashMap<Long, ArrayList<Long>> mpolys;
 	public ArrayList<Feature> features;
-	
-	public Map () {
+
+	private Feature feature;
+
+	public Map() {
 		nodes = new HashMap<Long, Coord>();
 		ways = new HashMap<Long, ArrayList<Long>>();
 		mpolys = new HashMap<Long, ArrayList<Long>>();
+		feature = new Feature();
 		features = new ArrayList<Feature>();
+		features.add(feature);
 	}
-	
+
 	public void addNode(long id, double lat, double lon) {
 		nodes.put(id, new Coord(lat, lon));
+		if (feature.type == Obj.UNKOBJ) {
+			feature.clean();
+		} else {
+			feature = new Feature();
+			features.add(feature);
+		}
 	}
-	
+
 	public void addWay(long id) {
 		ways.put(id, new ArrayList<Long>());
+		if (feature.type == Obj.UNKOBJ) {
+			feature.clean();
+		} else {
+			feature = new Feature();
+			features.add(feature);
+		}
 	}
-	
+
 	public void addToWay(long way, long node) {
 		ways.get(way).add(node);
 	}
-	public void addRelation(long id) {
+
+	public void addMpoly(long id) {
 		mpolys.put(id, new ArrayList<Long>());
 	}
-	
-	public void addToRelation(long rel, long way) {
-		mpolys.get(rel).add(way);
+
+	public void addToMpoly(long id, long way) {
+		mpolys.get(id).add(way);
+	}
+
+	public void addTag(String key, String val) {
+		String subkeys[] = key.split(":");
+		if ((subkeys.length > 1) && subkeys[0].equals("seamark")) {
+			Obj obj = S57obj.enumType(subkeys[1]);
+			if ((subkeys.length > 2) && (obj != Obj.UNKOBJ)) {
+				int idx = 0;
+				Att att = Att.UNKATT;
+				try {
+					idx = Integer.parseInt(subkeys[2]);
+					if (subkeys.length == 4) {
+						att = s57.S57att.enumAttribute(subkeys[3], obj);
+					}
+				} catch (Exception e) {
+					att = S57att.enumAttribute(subkeys[2], obj);
+				}
+				HashMap<Integer, EnumMap<Att, AttItem>> items = feature.objs.get(obj);
+				if (items == null) {
+					items = new HashMap<Integer, EnumMap<Att, AttItem>>();
+					feature.objs.put(obj, items);
+				}
+				EnumMap<Att, AttItem> atts = items.get(idx);
+				if (atts == null) {
+					atts = new EnumMap<Att, AttItem>(Att.class);
+				}
+				AttVal attval = S57val.convertValue(val, att);
+				atts.put(att, new AttItem(attval.conv, attval.val));
+			} else {
+				if (subkeys[1].equals("type")) {
+					feature.type = S57obj.enumType(val);
+				} else {
+					Att att = S57att.enumAttribute(subkeys[1], Obj.UNKOBJ);
+					if (att != Att.UNKATT) {
+						AttVal attval = S57val.convertValue(val, att);
+						feature.atts.put(att, new AttItem(attval.conv, attval.val));
+					}
+				}
+			}
+		}
 	}
 }
Index: /applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java	(revision 29151)
+++ /applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java	(revision 29152)
@@ -1,11 +1,10 @@
 package smed2;
 
-import java.awt.Dimension;
-import java.awt.event.ActionEvent;
-import java.util.Collection;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.Map.Entry;
 
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-import javax.swing.WindowConstants;
+import javax.swing.*;
 
 import static org.openstreetmap.josm.tools.I18n.tr;
@@ -17,21 +16,10 @@
 import org.openstreetmap.josm.data.SelectionChangedListener;
 import org.openstreetmap.josm.data.imagery.ImageryInfo;
-import org.openstreetmap.josm.data.osm.DataSet;
-import org.openstreetmap.josm.data.osm.Node;
-import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
-import org.openstreetmap.josm.data.osm.event.DataChangedEvent;
-import org.openstreetmap.josm.data.osm.event.DataSetListener;
-import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
-import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
-import org.openstreetmap.josm.data.osm.event.NodeMovedEvent;
-import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent;
-import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent;
-import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent;
-import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
-import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
+import org.openstreetmap.josm.data.osm.*;
+import org.openstreetmap.josm.data.osm.event.*;
 import org.openstreetmap.josm.Main;
 
 import s57.S57dat;
+import seamap.Map;
 
 import panels.PanelMain;
@@ -46,4 +34,5 @@
 	public static PanelMain panelMain = null;
 	public ImageryLayer rendering;
+	public Map map = null;
 	public Collection<OsmPrimitive> data = null;
 
@@ -130,5 +119,5 @@
 		panelS57.setVisible(false);
 		frame.add(panelS57);
-		System.out.println("hello");
+//		System.out.println("hello");
 		rendering = ImageryLayer.create(new ImageryInfo("OpenSeaMap"));
 		Main.main.addLayer(rendering);
@@ -140,4 +129,6 @@
 			frame.setVisible(false);
 			frame.dispose();
+			data = null;
+			map = null;
 		}
 		isOpen = false;
@@ -146,14 +137,24 @@
 	@Override
 	public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) {
-		System.out.println(newLayer);
 		if (oldLayer != null) {
 			oldLayer.data.removeDataSetListener(dataSetListener);
 		}
-
 		if (newLayer != null) {
 			newLayer.data.addDataSetListener(dataSetListener);
 			data = newLayer.data.allPrimitives();
-		} else {
+			map = new Map();
+			for (OsmPrimitive osm : data) {
+				if (osm instanceof Node) {
+					map.addNode(((Node)osm).getId(), ((Node)osm).getCoor().lat(), ((Node)osm).getCoor().lon());
+				} else if (osm instanceof Way) {
+					map.addWay(((Way)osm).getId());
+				}
+				for (Entry<String, String> entry : osm.getKeys().entrySet()) {
+					map.addTag(entry.getKey(), entry.getValue());
+				}
+			}
+ 		} else {
 			data = null;
+			map = null;
 		}
 	}
