Index: /applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java	(revision 29271)
+++ /applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java	(revision 29272)
@@ -201,5 +201,5 @@
 
 		public boolean hasNext() {
-			return (edge != null) && ((it == null) || (forward && it.hasNext()) || (!forward && it.hasPrevious()));
+			return (edge != null) && ((it == null) || (edge.nodes.isEmpty()) || (forward && it.hasNext()) || (!forward && it.hasPrevious()));
 		}
 
@@ -371,11 +371,4 @@
 
 	public void tagsDone(long id) {
-		if ((feature.type != Obj.UNKOBJ) && !((edge != null) && (edge.last == 0))) {
-			index.put(id, feature);
-			if (features.get(feature.type) == null) {
-				features.put(feature.type, new ArrayList<Feature>());
-			}
-			features.get(feature.type).add(feature);
-		}
 		switch (feature.flag) {
 		case POINT:
@@ -432,5 +425,12 @@
 			break;
 		}
-		feature.centre = findCentroid(feature);
+		if ((feature.type != Obj.UNKOBJ) && !((edge != null) && (edge.last == 0))) {
+			index.put(id, feature);
+			if (features.get(feature.type) == null) {
+				features.put(feature.type, new ArrayList<Feature>());
+			}
+			feature.centre = findCentroid(feature);
+			features.get(feature.type).add(feature);
+		}
 	}
 
@@ -461,6 +461,8 @@
 
 	public Snode findCentroid(Feature feature) {
-		double lat, lon, slat, slon, sarc, llat, llon;
-		lat = lon = slat = slon = sarc = llat = llon = 0;
+		double lat, lon, slat, slon, llat, llon;
+		llat = llon = lat = lon = slat = slon = 0;
+		double sarc = 0;
+		boolean first = true;
 		switch (feature.flag) {
 		case POINT:
@@ -473,5 +475,9 @@
 				lat = node.lat;
 				lon = node.lon;
-				sarc += (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+				if (first) {
+					first = false;
+				} else {
+					sarc += (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+				}
 				llat = lat;
 				llon = lon;
@@ -479,4 +485,5 @@
 			double harc = sarc / 2;
 			sarc = 0;
+			first = true;
 			eit = new EdgeIterator(edge, true);
 			while (eit.hasNext()) {
@@ -484,7 +491,11 @@
 				lat = node.lat;
 				lon = node.lon;
-				sarc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
-				if (sarc > harc)
-					break;
+				if (first) {
+					first = false;
+				} else {
+					sarc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+					if (sarc > harc)
+						break;
+				}
 				harc -= sarc;
 				llat = lat;
@@ -497,13 +508,17 @@
 			BoundIterator bit = new BoundIterator(bound);
 			while (bit.hasNext()) {
-				llon = lon;
-				llat = lat;
 				Snode node = bit.next();
 				lat = node.lat;
 				lon = node.lon;
-				double arc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
-				slat += (lat * arc);
-				slon += (lon * arc);
-				sarc += arc;
+				if (first) {
+					first = false;
+				} else {
+					double arc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+					slat += (lat * arc);
+					slon += (lon * arc);
+					sarc += arc;
+				}
+				llon = lon;
+				llat = lat;
 			}
 			return new Snode((sarc > 0.0 ? slat / sarc : 0.0), (sarc > 0.0 ? slon / sarc : 0.0));
Index: /applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
===================================================================
--- /applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java	(revision 29271)
+++ /applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java	(revision 29272)
@@ -35,5 +35,5 @@
 	public MapImage rendering;
 	public SeaMap map = null;
-	public Collection<OsmPrimitive> data = null;
+	public DataSet data = null;
 
 	private final DataSetListener dataSetListener = new DataSetListener() {
@@ -46,7 +46,5 @@
 		@Override
 		public void nodeMoved(NodeMovedEvent e) {
-			if (map != null) {
-				makeMap();
-			}
+			System.out.println("NodeMovedEvent");
 		}
 
@@ -154,5 +152,5 @@
 		if (newLayer != null) {
 			newLayer.data.addDataSetListener(dataSetListener);
-			data = newLayer.data.allPrimitives();
+			data = newLayer.data;
 			makeMap();
 			if (rendering != null) rendering.zoomChanged();
@@ -205,23 +203,33 @@
 		map = new SeaMap();
 		if (data != null) {
-			for (OsmPrimitive osm : data) {
-				if (osm instanceof Node) {
-					map.addNode(((Node) osm).getUniqueId(), ((Node) osm).getCoor().lat(), ((Node) osm).getCoor().lon());
-				} else if (osm instanceof Way) {
-					map.addEdge(((Way) osm).getUniqueId());
-					for (Node node : ((Way) osm).getNodes()) {
-						map.addToEdge((node.getUniqueId()));
-					}
-				} else if ((osm instanceof Relation) && ((Relation) osm).isMultipolygon()) {
-					map.addArea(((Relation) osm).getUniqueId());
-					for (RelationMember mem : ((Relation) osm).getMembers()) {
+			for (Node node : data.getNodes()) {
+				map.addNode(node.getUniqueId(), node.getCoor().lat(), node.getCoor().lon());
+				for (Entry<String, String> entry : node.getKeys().entrySet()) {
+					map.addTag(entry.getKey(), entry.getValue());
+				}
+				map.tagsDone(node.getUniqueId());
+			}
+			for (Way way : data.getWays()) {
+				map.addEdge(way.getUniqueId());
+				for (Node node : way.getNodes()) {
+					map.addToEdge((node.getUniqueId()));
+				}
+				for (Entry<String, String> entry : way.getKeys().entrySet()) {
+					map.addTag(entry.getKey(), entry.getValue());
+				}
+				map.tagsDone(way.getUniqueId());
+			}
+			for (Relation rel : data.getRelations()) {
+				if (rel.isMultipolygon()) {
+					map.addArea(rel.getUniqueId());
+					for (RelationMember mem : rel.getMembers()) {
 						if (mem.getType() == OsmPrimitiveType.WAY)
 							map.addToArea(mem.getUniqueId(), (mem.getRole().equals("outer")));
 					}
 				}
-				for (Entry<String, String> entry : osm.getKeys().entrySet()) {
+				for (Entry<String, String> entry : rel.getKeys().entrySet()) {
 					map.addTag(entry.getKey(), entry.getValue());
 				}
-				map.tagsDone(osm.getUniqueId());
+				map.tagsDone(rel.getUniqueId());
 			}
 		}
