Index: applications/editors/josm/plugins/smed2/jharbour/Jharbour.java
===================================================================
--- applications/editors/josm/plugins/smed2/jharbour/Jharbour.java	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jharbour/Jharbour.java	(revision 30184)
@@ -0,0 +1,257 @@
+/* Copyright 2013 Malcolm Herring
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class Jharbour {
+
+	static class Node {
+		public double lat;
+		public double lon;
+		
+		public Node() {
+			lat = 0.0;
+			lon = 0.0;
+		}
+		public Node(double iLat, double iLon) {
+			lat = iLat;
+			lon = iLon;
+		}
+	}
+
+	static HashMap<Long, Node> nodes = new HashMap<Long, Node>();
+	static HashMap<Long, ArrayList<Long>> ways = new HashMap<Long, ArrayList<Long>>();
+
+	public static void main(String[] args) throws IOException {
+
+//BufferedReader in = new BufferedReader(new FileReader("/Users/mherring/boatsw/oseam/openseamap/renderer/work/tst.osm"));
+		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+		PrintStream out = System.out;
+
+		ArrayList<String> tags = null;
+		ArrayList<Long> refs = null;
+		ArrayList<Long> outers = null;
+
+		boolean inOsm = false;
+		boolean inNode = false;
+		boolean inWay = false;
+		boolean inRel = false;
+		boolean isHarbour = false;
+		long id = 0;
+
+		String ln;
+		while ((ln = in.readLine()) != null) {
+			if (inOsm) {
+				if (ln.contains("</osm")) {
+					inOsm = false;
+					out.println("</harbours>");
+				} else if (inNode) {
+					if (ln.contains("</node")) {
+						inNode = false;
+						if (isHarbour) {
+							out.println(String.format("  <harbour node=\"%d\" lat=\"%f\" lon=\"%f\">", id, nodes.get(id).lat, nodes.get(id).lon));
+							for (String tag : tags) {
+								out.println(tag);
+							}
+							out.println("  </harbour>");
+						}
+					} else if (ln.contains("<tag")) {
+						tags.add(ln);
+						if (ln.contains("seamark:type") && (ln.contains("harbour") || ln.contains("anchorage"))) {
+							isHarbour = true;
+						}
+					}
+				} else if (inWay) {
+					if (ln.contains("</way")) {
+						inWay = false;
+						ways.put(id, refs);
+						if (isHarbour) {
+							Node node = findCentroid(refs);
+							out.println(String.format("  <harbour way=\"%d\" lat=\"%f\" lon=\"%f\">", id, node.lat, node.lon));
+							for (String tag : tags) {
+								out.println(tag);
+							}
+							out.println("  </harbour>");
+						}
+					} else if (ln.contains("<nd")) {
+						for (String token : ln.split("[ ]+")) {
+							if (token.matches("^ref=.+")) {
+								refs.add(Long.parseLong(token.split("[\"\']")[1]));
+							}
+						}
+					} else if (ln.contains("<tag")) {
+						tags.add(ln);
+						if (ln.contains("seamark:type") && (ln.contains("harbour") || ln.contains("anchorage"))) {
+							isHarbour = true;
+						}
+					}
+				} else if (inRel) {
+					if (ln.contains("</relation")) {
+						inRel = false;
+						if (isHarbour) {
+							refs = new ArrayList<Long>();
+							long first = 0;
+							long last = 0;
+							int sweep = outers.size();
+							while (!outers.isEmpty() && (sweep > 0)) {
+								long way = outers.remove(0);
+								if (refs.isEmpty()) {
+									refs.addAll(ways.get(way));
+									first = refs.get(0);
+									last = refs.get(refs.size()-1);
+								} else {
+									ArrayList<Long> nway = ways.get(way);
+									if (nway.get(0) == last) {
+										refs.addAll(nway);
+										last = refs.get(refs.size()-1);
+										sweep = outers.size();
+									} else if (nway.get(nway.size()-1) == last) {
+										Collections.reverse(nway);
+										refs.addAll(nway);
+										last = refs.get(refs.size()-1);
+										sweep = outers.size();
+									} else {
+										outers.add(way);
+										sweep--;
+									}
+								}
+								if (first == last) {
+									Node node = findCentroid(refs);
+									out.println(String.format("  <harbour rel=\"%d\" lat=\"%f\" lon=\"%f\">", id, node.lat, node.lon));
+									for (String tag : tags) {
+										out.println(tag);
+									}
+									out.println("  </harbour>");
+									refs = new ArrayList<Long>();
+									sweep = outers.size();
+								}
+							}
+						}
+					} else if (ln.contains("<member") && ln.contains("way") && ln.contains("outer")) {
+						for (String token : ln.split("[ ]+")) {
+							if (token.matches("^ref=.+")) {
+								outers.add(Long.parseLong(token.split("[\"\']")[1]));
+							}
+						}
+					} else if (ln.contains("<tag")) {
+						tags.add(ln);
+						if (ln.contains("seamark:type") && (ln.contains("harbour") || ln.contains("anchorage"))) {
+							isHarbour = true;
+						}
+					}
+				} else if (ln.contains("<node")) {
+					inNode = true;
+					isHarbour = false;
+					tags = new ArrayList<String>();
+					Node node = new Node();
+					for (String token : ln.split("[ ]+")) {
+						if (token.matches("^id=.+")) {
+							id = Long.parseLong(token.split("[\"\']")[1]);
+							nodes.put(id, node);
+						} else if (token.matches("^lat=.+")) {
+							node.lat = Double.parseDouble(token.split("[\"\']")[1]);
+						} else if (token.matches("^lon=.+")) {
+							node.lon = Double.parseDouble(token.split("[\"\']")[1]);
+						}
+					}
+					if (ln.contains("/>")) {
+						inNode = false;
+					}
+				} else if (ln.contains("<way")) {
+					inWay = true;
+					isHarbour = false;
+					tags = new ArrayList<String>();
+					refs = new ArrayList<Long>();
+					for (String token : ln.split("[ ]+")) {
+						if (token.matches("^id=.+")) {
+							id = Long.parseLong(token.split("[\"\']")[1]);
+						}
+					}
+					if (ln.contains("/>")) {
+						inWay = false;
+					}
+				} else if (ln.contains("<relation")) {
+					inRel = true;
+					isHarbour = false;
+					tags = new ArrayList<String>();
+					outers = new ArrayList<Long>();
+					for (String token : ln.split("[ ]+")) {
+						if (token.matches("^id=.+")) {
+							id = Long.parseLong(token.split("[\"\']")[1]);
+						}
+					}
+					if (ln.contains("/>")) {
+						inRel = false;
+					}
+				}
+			} else {
+				if (ln.contains("<osm")) {
+					inOsm = true;
+					out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+					out.println("<harbours>");
+				}
+			}
+		}
+	}
+
+	static Node findCentroid(ArrayList<Long> refs) {
+		double lat, lon, slat, slon, llat, llon, sarc;
+		boolean first = true;
+		slat = slon = sarc = lat = lon = llat = llon = 0.0;
+		if (refs.get(0).equals(refs.get(refs.size() - 1))) {
+			for (Long ref : refs) {
+				lat = nodes.get(ref).lat;
+				lon = nodes.get(ref).lon;
+				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 Node((sarc > 0.0 ? slat / sarc : 0.0), (sarc > 0.0 ? slon / sarc : 0.0));
+		} else {
+			for (Long ref : refs) {
+				lat = nodes.get(ref).lat;
+				lon = nodes.get(ref).lon;
+				if (first) {
+					first = false;
+				} else {
+					sarc += (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+				}
+				llat = lat;
+				llon = lon;
+			}
+			double harc = sarc / 2;
+			sarc = 0.0;
+			first = true;
+			for (Long ref : refs) {
+				lat = nodes.get(ref).lat;
+				lon = nodes.get(ref).lon;
+				if (first) {
+					first = false;
+				} else {
+					sarc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+					if (sarc > harc)
+						break;
+				}
+				harc -= sarc;
+				llat = lat;
+				llon = lon;
+			}
+			return new Node(llat + ((lat - llat) * harc / sarc), llon + ((lon - llon) * harc / sarc));
+		}
+	}
+
+}
Index: applications/editors/josm/plugins/smed2/jharbour/build.xml
===================================================================
--- applications/editors/josm/plugins/smed2/jharbour/build.xml	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jharbour/build.xml	(revision 30184)
@@ -0,0 +1,27 @@
+<project name="jharbour" default="dist" basedir=".">
+  <property name="src" location="src"/>
+  <property name="build" location="build"/>
+  <property name="jarfile" location="./jharbour.jar"/>
+
+  <target name="init">
+    <mkdir dir="${build}"/>
+  </target>
+
+  <target name="compile" depends="init" description="compile the source " >
+    <javac srcdir="${src}" destdir="${build}"/>
+  </target>
+
+  <target name="dist" depends="compile" description="generate the distribution" >
+    <jar jarfile="${jarfile}" basedir="${build}" >
+      <manifest>
+        <attribute name="Main-Class" value="jharbour.Jharbour"/>
+        <attribute name="Class-Path" value="$jarfile"/>
+      </manifest>
+    </jar>
+  </target>
+
+  <target name="clean" description="clean up" >
+    <delete dir="${build}"/>
+    <delete file="${jarfile}"/>
+  </target>
+</project>
Index: applications/editors/josm/plugins/smed2/jharbour/src/jharbour/Jharbour.java
===================================================================
--- applications/editors/josm/plugins/smed2/jharbour/src/jharbour/Jharbour.java	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jharbour/src/jharbour/Jharbour.java	(revision 30184)
@@ -0,0 +1,259 @@
+/* Copyright 2013 Malcolm Herring
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
+ */
+
+package jharbour;
+
+import java.io.*;
+import java.util.*;
+
+public class Jharbour {
+
+	static class Node {
+		public double lat;
+		public double lon;
+		
+		public Node() {
+			lat = 0.0;
+			lon = 0.0;
+		}
+		public Node(double iLat, double iLon) {
+			lat = iLat;
+			lon = iLon;
+		}
+	}
+
+	static HashMap<Long, Node> nodes = new HashMap<Long, Node>();
+	static HashMap<Long, ArrayList<Long>> ways = new HashMap<Long, ArrayList<Long>>();
+
+	public static void main(String[] args) throws IOException {
+
+//BufferedReader in = new BufferedReader(new FileReader("/Users/mherring/boatsw/oseam/openseamap/renderer/work/tst.osm"));
+		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+		PrintStream out = System.out;
+
+		ArrayList<String> tags = null;
+		ArrayList<Long> refs = null;
+		ArrayList<Long> outers = null;
+
+		boolean inOsm = false;
+		boolean inNode = false;
+		boolean inWay = false;
+		boolean inRel = false;
+		boolean isHarbour = false;
+		long id = 0;
+
+		String ln;
+		while ((ln = in.readLine()) != null) {
+			if (inOsm) {
+				if (ln.contains("</osm")) {
+					inOsm = false;
+					out.println("</harbours>");
+				} else if (inNode) {
+					if (ln.contains("</node")) {
+						inNode = false;
+						if (isHarbour) {
+							out.println(String.format("  <harbour node=\"%d\" lat=\"%f\" lon=\"%f\">", id, nodes.get(id).lat, nodes.get(id).lon));
+							for (String tag : tags) {
+								out.println(tag);
+							}
+							out.println("  </harbour>");
+						}
+					} else if (ln.contains("<tag")) {
+						tags.add(ln);
+						if (ln.contains("seamark:type") && (ln.contains("harbour") || ln.contains("anchorage"))) {
+							isHarbour = true;
+						}
+					}
+				} else if (inWay) {
+					if (ln.contains("</way")) {
+						inWay = false;
+						ways.put(id, refs);
+						if (isHarbour) {
+							Node node = findCentroid(refs);
+							out.println(String.format("  <harbour way=\"%d\" lat=\"%f\" lon=\"%f\">", id, node.lat, node.lon));
+							for (String tag : tags) {
+								out.println(tag);
+							}
+							out.println("  </harbour>");
+						}
+					} else if (ln.contains("<nd")) {
+						for (String token : ln.split("[ ]+")) {
+							if (token.matches("^ref=.+")) {
+								refs.add(Long.parseLong(token.split("[\"\']")[1]));
+							}
+						}
+					} else if (ln.contains("<tag")) {
+						tags.add(ln);
+						if (ln.contains("seamark:type") && (ln.contains("harbour") || ln.contains("anchorage"))) {
+							isHarbour = true;
+						}
+					}
+				} else if (inRel) {
+					if (ln.contains("</relation")) {
+						inRel = false;
+						if (isHarbour) {
+							refs = new ArrayList<Long>();
+							long first = 0;
+							long last = 0;
+							int sweep = outers.size();
+							while (!outers.isEmpty() && (sweep > 0)) {
+								long way = outers.remove(0);
+								if (refs.isEmpty()) {
+									refs.addAll(ways.get(way));
+									first = refs.get(0);
+									last = refs.get(refs.size()-1);
+								} else {
+									ArrayList<Long> nway = ways.get(way);
+									if (nway.get(0) == last) {
+										refs.addAll(nway);
+										last = refs.get(refs.size()-1);
+										sweep = outers.size();
+									} else if (nway.get(nway.size()-1) == last) {
+										Collections.reverse(nway);
+										refs.addAll(nway);
+										last = refs.get(refs.size()-1);
+										sweep = outers.size();
+									} else {
+										outers.add(way);
+										sweep--;
+									}
+								}
+								if (first == last) {
+									Node node = findCentroid(refs);
+									out.println(String.format("  <harbour rel=\"%d\" lat=\"%f\" lon=\"%f\">", id, node.lat, node.lon));
+									for (String tag : tags) {
+										out.println(tag);
+									}
+									out.println("  </harbour>");
+									refs = new ArrayList<Long>();
+									sweep = outers.size();
+								}
+							}
+						}
+					} else if (ln.contains("<member") && ln.contains("way") && ln.contains("outer")) {
+						for (String token : ln.split("[ ]+")) {
+							if (token.matches("^ref=.+")) {
+								outers.add(Long.parseLong(token.split("[\"\']")[1]));
+							}
+						}
+					} else if (ln.contains("<tag")) {
+						tags.add(ln);
+						if (ln.contains("seamark:type") && (ln.contains("harbour") || ln.contains("anchorage"))) {
+							isHarbour = true;
+						}
+					}
+				} else if (ln.contains("<node")) {
+					inNode = true;
+					isHarbour = false;
+					tags = new ArrayList<String>();
+					Node node = new Node();
+					for (String token : ln.split("[ ]+")) {
+						if (token.matches("^id=.+")) {
+							id = Long.parseLong(token.split("[\"\']")[1]);
+							nodes.put(id, node);
+						} else if (token.matches("^lat=.+")) {
+							node.lat = Double.parseDouble(token.split("[\"\']")[1]);
+						} else if (token.matches("^lon=.+")) {
+							node.lon = Double.parseDouble(token.split("[\"\']")[1]);
+						}
+					}
+					if (ln.contains("/>")) {
+						inNode = false;
+					}
+				} else if (ln.contains("<way")) {
+					inWay = true;
+					isHarbour = false;
+					tags = new ArrayList<String>();
+					refs = new ArrayList<Long>();
+					for (String token : ln.split("[ ]+")) {
+						if (token.matches("^id=.+")) {
+							id = Long.parseLong(token.split("[\"\']")[1]);
+						}
+					}
+					if (ln.contains("/>")) {
+						inWay = false;
+					}
+				} else if (ln.contains("<relation")) {
+					inRel = true;
+					isHarbour = false;
+					tags = new ArrayList<String>();
+					outers = new ArrayList<Long>();
+					for (String token : ln.split("[ ]+")) {
+						if (token.matches("^id=.+")) {
+							id = Long.parseLong(token.split("[\"\']")[1]);
+						}
+					}
+					if (ln.contains("/>")) {
+						inRel = false;
+					}
+				}
+			} else {
+				if (ln.contains("<osm")) {
+					inOsm = true;
+					out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+					out.println("<harbours>");
+				}
+			}
+		}
+	}
+
+	static Node findCentroid(ArrayList<Long> refs) {
+		double lat, lon, slat, slon, llat, llon, sarc;
+		boolean first = true;
+		slat = slon = sarc = lat = lon = llat = llon = 0.0;
+		if (refs.get(0).equals(refs.get(refs.size() - 1))) {
+			for (Long ref : refs) {
+				lat = nodes.get(ref).lat;
+				lon = nodes.get(ref).lon;
+				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 Node((sarc > 0.0 ? slat / sarc : 0.0), (sarc > 0.0 ? slon / sarc : 0.0));
+		} else {
+			for (Long ref : refs) {
+				lat = nodes.get(ref).lat;
+				lon = nodes.get(ref).lon;
+				if (first) {
+					first = false;
+				} else {
+					sarc += (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+				}
+				llat = lat;
+				llon = lon;
+			}
+			double harc = sarc / 2;
+			sarc = 0.0;
+			first = true;
+			for (Long ref : refs) {
+				lat = nodes.get(ref).lat;
+				lon = nodes.get(ref).lon;
+				if (first) {
+					first = false;
+				} else {
+					sarc = (Math.acos(Math.cos(lon - llon) * Math.cos(lat - llat)));
+					if (sarc > harc)
+						break;
+				}
+				harc -= sarc;
+				llat = lat;
+				llon = lon;
+			}
+			return new Node(llat + ((lat - llat) * harc / sarc), llon + ((lon - llon) * harc / sarc));
+		}
+	}
+
+}
Index: applications/editors/josm/plugins/smed2/jrender/build.xml
===================================================================
--- applications/editors/josm/plugins/smed2/jrender/build.xml	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jrender/build.xml	(revision 30184)
@@ -0,0 +1,27 @@
+<project name="jrender" default="dist" basedir=".">
+  <property name="src" location="src"/>
+  <property name="build" location="build"/>
+  <property name="dist"  location="dist"/>
+
+  <target name="init">
+    <mkdir dir="${build}"/>
+  </target>
+
+  <target name="compile" depends="init" description="compile the source " >
+    <javac srcdir="${src}" destdir="${build}"/>
+  </target>
+
+  <target name="dist" depends="compile" description="generate the distribution" >
+    <jar jarfile="./jrender.jar" basedir="${build}" >
+      <manifest>
+        <attribute name="Main-Class" value="Jrender"/>
+      </manifest>
+    </jar>
+  </target>
+
+  <target name="clean" description="clean up" >
+    <delete dir="${build}"/>
+    <delete dir="${dist}"/>
+    <delete file="./jrender.jar"/>
+  </target>
+</project>
Index: applications/editors/josm/plugins/smed2/jrender/src/jrender/Jrender.java
===================================================================
--- applications/editors/josm/plugins/smed2/jrender/src/jrender/Jrender.java	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jrender/src/jrender/Jrender.java	(revision 30184)
@@ -0,0 +1,80 @@
+/* Copyright 2012 Malcolm Herring
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
+ */
+
+package jrender;
+
+import java.io.File;
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Panel;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+
+import javax.imageio.ImageIO;
+import javax.swing.JFrame;
+
+import symbols.*;
+import symbols.Symbols.Scheme;
+import render.*;
+
+public class Jrender extends Panel {
+	private static final long serialVersionUID = 1L;
+
+	public static void main(String[] args) {
+		BufferedImage img;
+		Graphics2D g2;
+		
+		JFrame frame = new JFrame("Jrender");
+		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+    Panel panel = new Jrender();
+    frame.getContentPane().add("Center", panel);
+		frame.setSize(256, 256);
+		frame.setVisible(true);
+/*		
+		for (int x = 0; x < 4; x++) {
+			for (int y = 0; y < 4; y++) {
+				img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
+				g2 = img.createGraphics();
+				g2.translate(-(x*256), -(y*256));
+				drawRendering(g2);
+				try {
+					ImageIO.write(img, "png", new File("tst" + x + "_" + y + ".png"));
+				} catch (IOException e) {
+					System.out.println("IO Exception");
+				}
+			}
+		}*/
+		
+		img = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB);
+		g2 = img.createGraphics();
+		g2.translate(-32, -32);
+		drawRendering(g2);
+		try {
+			ImageIO.write(img, "png", new File("/Users/mherring/Desktop/export.png"));
+		} catch (Exception e) {
+			System.out.println("Exception");
+		}
+		
+	}
+	
+	public static void drawRendering(Graphics2D g2) {
+		double scale = Renderer.symbolScale[7];
+		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+		g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
+//		System.out.println("hello");
+   
+		Symbols.drawSymbol(g2, Areas.Seaplane, scale/2, 64.0, 64.0, new Scheme(Color.green), null);
+	}
+	
+	public void paint(Graphics g) {
+		Graphics2D g2 = (Graphics2D)g;
+		drawRendering(g2);
+	}
+}
Index: applications/editors/josm/plugins/smed2/jrender/src/render
===================================================================
--- applications/editors/josm/plugins/smed2/jrender/src/render	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jrender/src/render	(revision 30184)
@@ -0,0 +1,1 @@
+link ../../src/render
Index: applications/editors/josm/plugins/smed2/jrender/src/s57
===================================================================
--- applications/editors/josm/plugins/smed2/jrender/src/s57	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jrender/src/s57	(revision 30184)
@@ -0,0 +1,1 @@
+link ../../src/s57
Index: applications/editors/josm/plugins/smed2/jrender/src/symbols
===================================================================
--- applications/editors/josm/plugins/smed2/jrender/src/symbols	(revision 30184)
+++ applications/editors/josm/plugins/smed2/jrender/src/symbols	(revision 30184)
@@ -0,0 +1,1 @@
+link ../../src/symbols
Index: applications/editors/josm/plugins/smed2/js57toosm/build.xml
===================================================================
--- applications/editors/josm/plugins/smed2/js57toosm/build.xml	(revision 30184)
+++ applications/editors/josm/plugins/smed2/js57toosm/build.xml	(revision 30184)
@@ -0,0 +1,27 @@
+<project name="js57toosm" default="dist" basedir=".">
+  <property name="src" location="src"/>
+  <property name="build" location="build"/>
+  <property name="jarfile" location="./js57toosm.jar"/>
+
+  <target name="init">
+    <mkdir dir="${build}"/>
+  </target>
+
+  <target name="compile" depends="init" description="compile the source " >
+    <javac srcdir="${src}" destdir="${build}"/>
+  </target>
+
+  <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"/>
+      </manifest>
+    </jar>
+  </target>
+
+  <target name="clean" description="clean up" >
+    <delete dir="${build}"/>
+    <delete file="${jarfile}"/>
+  </target>
+</project>
Index: applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
===================================================================
--- applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30184)
+++ applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java	(revision 30184)
@@ -0,0 +1,132 @@
+/* Copyright 2013 Malcolm Herring
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
+ */
+
+package js57toosm;
+
+import java.io.*;
+
+import s57.S57map;
+import s57.S57map.*;
+import s57.S57dat;
+import s57.S57dat.*;
+
+public class Js57toosm {
+	
+	public static void main(String[] args) throws IOException {
+
+		FileInputStream in = new FileInputStream("/Users/mherring/boatsw/oseam/openseamap/renderer/js57toosm/tst.000");
+		PrintStream out = System.out;
+
+		byte[] leader = new byte[24];
+		boolean ddr = false;
+		int length;
+		int fields;
+		int mapfl, mapfp, mapts, entry;
+		String tag;
+		int len;
+		int pos;
+		
+		double comf = 1;
+		double somf = 1;
+		long name = 0;
+		S57map map = new S57map();;
+
+		while (in.read(leader) == 24) {
+			length = Integer.parseInt(new String(leader, 0, 5)) - 24;
+			ddr = (leader[6] == 'L');
+			fields = Integer.parseInt(new String(leader, 12, 5)) - 24;
+			mapfl = leader[20] - '0';
+			mapfp = leader[21] - '0';
+			mapts = leader[23] - '0';
+			entry = mapfl + mapfp + mapts;
+			byte[] record = new byte[length];
+			if (in.read(record) != length)
+				break;
+			for (int idx = 0; idx < fields-1; idx += entry) {
+				tag = new String(record, idx, mapts);
+				len = Integer.parseInt(new String(record, idx+mapts, mapfl));
+				pos = Integer.parseInt(new String(record, idx+mapts+mapfl, mapfp));
+				if (!ddr) switch (tag) {
+				case "0001":
+					out.println("Record: " + (long)S57dat.getSubf(record, fields+pos, S57field.I8RI, S57subf.I8RN));
+					break;
+				case "DSID":
+					break;
+				case "DSSI":
+					break;
+				case "DSPM":
+					comf = (double)(long)S57dat.getSubf(record, fields+pos, S57field.DSPM, S57subf.COMF);
+					somf = (double)(long)S57dat.getSubf(S57subf.SOMF);
+					break;
+				case "FRID":
+					break;
+				case "FOID":
+					break;
+				case "ATTF":
+					break;
+				case "NATF":
+					break;
+				case "FFPC":
+					break;
+				case "FFPT":
+					break;
+				case "FSPC":
+					break;
+				case "FSPT":
+					break;
+				case "VRID":
+					name = (long)S57dat.getSubf(record, fields+pos, S57field.VRID, S57subf.RCNM) << 32;
+					name += (long)S57dat.getSubf(record, fields+pos, S57field.VRID, S57subf.RCID);
+					name <<= 16;
+					break;
+				case "ATTV":
+					break;
+				case "VRPC":
+					break;
+				case "VRPT":
+					break;
+				case "SGCC":
+					break;
+				case "SG2D":
+					S57dat.setField(record, fields + pos, S57field.SG2D, len);
+					while (S57dat.more()) {
+						double lat = (double) ((long) S57dat.getSubf(S57subf.YCOO)) / comf;
+						double lon = (double) ((long) S57dat.getSubf(S57subf.XCOO)) / comf;
+						map.addNode(name++, lat, lon);
+					}
+					break;
+				case "SG3D":
+					S57dat.setField(record, fields + pos, S57field.SG3D, len);
+					while (S57dat.more()) {
+						double lat = (double) ((long) S57dat.getSubf(S57subf.YCOO)) / comf;
+						double lon = (double) ((long) S57dat.getSubf(S57subf.XCOO)) / comf;
+						double depth = (double) ((long) S57dat.getSubf(S57subf.VE3D)) / somf;
+						map.addNode(name++, lat, lon, depth);
+					}
+					break;
+				}
+			}
+		}
+		int a = 0; int i = 0; int c = 0; int d = 0;
+		for (Snode node : map.nodes.values()) {
+			switch (node.flg) {
+			case ANON: a++; break;
+			case ISOL: i++; break;
+			case CONN: c++; break;
+			case DPTH: d++; break;
+			}
+		}
+		out.println("Anon " + a);
+		out.println("Isol " + i);
+		out.println("Conn " + c);
+		out.println("Dpth " + d);
+		in.close();
+	}
+
+}
Index: applications/editors/josm/plugins/smed2/js57toosm/src/s57
===================================================================
--- applications/editors/josm/plugins/smed2/js57toosm/src/s57	(revision 30184)
+++ applications/editors/josm/plugins/smed2/js57toosm/src/s57	(revision 30184)
@@ -0,0 +1,1 @@
+link ../../src/s57
Index: applications/editors/josm/plugins/smed2/src/render/Renderer.java
===================================================================
--- applications/editors/josm/plugins/smed2/src/render/Renderer.java	(revision 30183)
+++ applications/editors/josm/plugins/smed2/src/render/Renderer.java	(revision 30184)
@@ -198,10 +198,10 @@
 		switch (feature.flag) {
 		case LINE:
-			Edge edge = map.edges.get(feature.refs);
+			Edge edge = map.edges.get(feature.id);
 			area = map.new Area();
 			area.add(map.new Bound(map.new Side(edge, true), true));
 			break;
 		case AREA:
-			area = map.areas.get(feature.refs);
+			area = map.areas.get(feature.id);
 			break;
 		default:
@@ -288,5 +288,5 @@
 		switch (feature.flag) {
 		case LINE:
-			EdgeIterator eit = map.new EdgeIterator(map.edges.get(feature.refs), true);
+			EdgeIterator eit = map.new EdgeIterator(map.edges.get(feature.id), true);
 			point = context.getPoint(eit.next());
 			p.moveTo(point.getX(), point.getY());
@@ -297,5 +297,5 @@
 			break;
 		case AREA:
-			for (Bound bound : map.areas.get(feature.refs)) {
+			for (Bound bound : map.areas.get(feature.id)) {
 				BoundIterator bit = map.new BoundIterator(bound);
 				point = context.getPoint(bit.next());
@@ -373,5 +373,5 @@
 			break;
 		case AREA:
-			for (Bound bound : map.areas.get(feature.refs)) {
+			for (Bound bound : map.areas.get(feature.id)) {
 				BoundIterator bit = map.new BoundIterator(bound);
 				point = context.getPoint(bit.next());
@@ -506,10 +506,10 @@
 		switch (feature.flag) {
 		case LINE:
-			Edge edge = map.edges.get(feature.refs);
+			Edge edge = map.edges.get(feature.id);
 			area = map.new Area();
 			area.add(map.new Bound(map.new Side(edge, true), true));
 			break;
 		case AREA:
-			area = map.areas.get(feature.refs);
+			area = map.areas.get(feature.id);
 			break;
 		default:
