Index: applications/editors/josm/plugins/smed2/src/seamap/Map.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/seamap/Map.java	(revision 29153)
+++ applications/editors/josm/plugins/smed2/src/seamap/Map.java	(revision 29156)
@@ -39,5 +39,5 @@
 	public class Feature {
 		public Fflag flag;
-		public ArrayList<Long> refs;
+		public long refs;
 		public Obj type;
 		public EnumMap<Att, AttItem> atts;
@@ -45,10 +45,6 @@
 
 		Feature() {
-			clean();
-		}
-		
-		void clean() {
 			flag = Fflag.UNKN;
-			refs = new ArrayList<Long>();
+			refs = 0;
 			type = Obj.UNKOBJ;
 			atts = new EnumMap<Att, AttItem>(Att.class);
@@ -70,7 +66,8 @@
 	public HashMap<Long, ArrayList<Long>> ways;
 	public HashMap<Long, ArrayList<Long>> mpolys;
-	public ArrayList<Feature> features;
+	public HashMap<Long, Feature> features;
 
 	private Feature feature;
+	private ArrayList<Long> list;
 
 	public Map() {
@@ -79,38 +76,45 @@
 		mpolys = new HashMap<Long, ArrayList<Long>>();
 		feature = new Feature();
-		features = new ArrayList<Feature>();
-		features.add(feature);
+		features = new HashMap<Long, 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);
-		}
+		feature = new Feature();
+		feature.refs = id;
+		feature.flag = Fflag.NODE;
 	}
 
 	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);
+		list = new ArrayList<Long>();
+		ways.put(id, list);
+		feature = new Feature();
+		feature.refs = id;
+		feature.flag = Fflag.WAY;
 	}
 
 	public void addMpoly(long id) {
-		mpolys.put(id, new ArrayList<Long>());
+		list = new ArrayList<Long>();
+		mpolys.put(id, list);
 	}
 
-	public void addToMpoly(long id, long way) {
-		mpolys.get(id).add(way);
+	public void addToWay(long node) {
+		list.add(node);
+	}
+
+	public void addToMpoly(long way, boolean outer) {
+		if (outer)
+			list.add(0, way);
+		else
+			list.add(way);
+	}
+
+	public void tagsDone() {
+		if (feature.type != Obj.UNKOBJ) {
+			if ((feature.flag == Fflag.WAY) && (list.size() > 0) && (list.get(0) == list.get(list.size() - 1))) {
+				feature.flag = Fflag.AREA;
+			}
+			features.put(feature.refs, feature);
+		}
 	}
 
Index: applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java	(revision 29153)
+++ applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java	(revision 29156)
@@ -41,40 +41,40 @@
 		@Override
 		public void dataChanged(DataChangedEvent e) {
-			reMap();
+			// reMap();
 		}
 
 		@Override
 		public void nodeMoved(NodeMovedEvent e) {
-			reMap();
+			// reMap();
 		}
 
 		@Override
 		public void otherDatasetChange(AbstractDatasetChangedEvent e) {
-			reMap();
+			// reMap();
 		}
 
 		@Override
 		public void primitivesAdded(PrimitivesAddedEvent e) {
-			reMap();
+			// reMap();
 		}
 
 		@Override
 		public void primitivesRemoved(PrimitivesRemovedEvent e) {
-			reMap();
+			// reMap();
 		}
 
 		@Override
 		public void relationMembersChanged(RelationMembersChangedEvent e) {
-			reMap();
+			// reMap();
 		}
 
 		@Override
 		public void tagsChanged(TagsChangedEvent e) {
-			reMap();
+			// reMap();
 		}
 
 		@Override
 		public void wayNodesChanged(WayNodesChangedEvent e) {
-			reMap();
+			// reMap();
 		}
 	};
@@ -119,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);
@@ -144,5 +144,5 @@
 			data = newLayer.data.allPrimitives();
 			reMap();
- 		} else {
+		} else {
 			data = null;
 			map = null;
@@ -155,21 +155,30 @@
 
 	}
-	
+
 	void reMap() {
 		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 (Node node : ((Way)osm).getNodes()) {
-					map.addToWay(((Way)osm).getUniqueId(), node.getUniqueId());
+			System.out.println(osm);
+			if ((osm instanceof Node) || (osm instanceof Way)) {
+				if (osm instanceof Node) {
+					map.addNode(((Node) osm).getUniqueId(), ((Node) osm).getCoor().lat(), ((Node) osm).getCoor().lon());
+				} else {
+					map.addWay(((Way) osm).getUniqueId());
+					for (Node node : ((Way) osm).getNodes()) {
+						map.addToWay((node.getUniqueId()));
+					}
+				}
+				for (Entry<String, String> entry : osm.getKeys().entrySet()) {
+					map.addTag(entry.getKey(), entry.getValue());
+				}
+				map.tagsDone();
+			} else if ((osm instanceof Relation) && ((Relation) osm).isMultipolygon()) {
+				map.addMpoly(((Relation) osm).getUniqueId());
+				for (RelationMember mem : ((Relation) osm).getMembers()) {
+					if (mem.getType() == OsmPrimitiveType.WAY)
+						map.addToMpoly(mem.getUniqueId(), (mem.getRole().equals("outer")));
 				}
 			}
-			for (Entry<String, String> entry : osm.getKeys().entrySet()) {
-				map.addTag(entry.getKey(), entry.getValue());
-			}
 		}
-	
 	}
 
