Index: applications/editors/josm/plugins/seachart/jchart/src/jchart/Jchart.java
===================================================================
--- applications/editors/josm/plugins/seachart/jchart/src/jchart/Jchart.java	(revision 35394)
+++ applications/editors/josm/plugins/seachart/jchart/src/jchart/Jchart.java	(revision 35404)
@@ -103,5 +103,5 @@
                             if ((node.lat >= map.bounds.minlat) && (node.lat <= map.bounds.maxlat)
                                     && (node.lon >= map.bounds.minlon) && (node.lon <= map.bounds.maxlon)) {
-                                return Symbols.Bwater;
+                                return Symbols.Gdries;
                             }
                         }
@@ -114,5 +114,5 @@
                     return Symbols.Yland;
                 } else {
-                    return Symbols.Bwater;
+                    return Symbols.Gdries;
                 }
             }
@@ -127,5 +127,5 @@
     public static void main(String[] args) throws Exception {
         if (args.length < 4) {
-            System.err.println("Usage: java -jar jrender.jar <osm data file> <zoom> <scale> <output image file>");
+            System.err.println("Usage: java -jar jrender.jar <osm data file> <zoom> <scale> <output image file> [<bounds (S W N E)>]");
             System.exit(-1);
         }
@@ -134,5 +134,15 @@
         map = new S57map(false);
         S57osm.OSMmap(in, map, false);
-//        in.close();
+        if (args.length >= 8) {
+            map.bounds.minlat = Math.toRadians(Double.parseDouble(args[4]));
+            map.bounds.minlon = Math.toRadians(Double.parseDouble(args[5]));
+            map.bounds.maxlat = Math.toRadians(Double.parseDouble(args[6]));
+            map.bounds.maxlon = Math.toRadians(Double.parseDouble(args[7]));
+        }
+        if ((map.bounds.minlat == Math.toRadians(90)) || (map.bounds.minlon == Math.toRadians(180)) ||
+            (map.bounds.maxlat == Math.toRadians(-90)) || (map.bounds.maxlon == Math.toRadians(-180))) {
+            System.err.println("Invalid map bounds");
+            System.exit(-1);
+        }
         context = new Context();
         Point2D size = context.getPoint(new Snode(map.bounds.minlat, map.bounds.maxlon));
Index: applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java
===================================================================
--- applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java	(revision 35394)
+++ applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java	(revision 35404)
@@ -7,9 +7,7 @@
 import java.awt.geom.Point2D;
 import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintWriter;
Index: applications/editors/josm/plugins/seachart/src/render/Renderer.java
===================================================================
--- applications/editors/josm/plugins/seachart/src/render/Renderer.java	(revision 35394)
+++ applications/editors/josm/plugins/seachart/src/render/Renderer.java	(revision 35404)
@@ -25,5 +25,4 @@
 
 import s57.S57map;
-import s57.S57map.Feature;
 import s57.S57map.GeomIterator;
 import s57.S57map.Pflag;
@@ -330,7 +329,9 @@
     
     public static void grid() {
-        if (context.grid() > 0) {
+        if ((context.grid() > 0) && (map != null)) {
             LineStyle style = new LineStyle(Color.black, (float)2.0);
-            double nspan = 60 * Math.toDegrees(map.bounds.maxlon - map.bounds.minlon) / context.grid();
+            Point2D point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.maxlon));
+            double ratio = point.getX() / point.getY();
+            double nspan = 60 * Math.toDegrees(map.bounds.maxlon - map.bounds.minlon) / (context.grid() * (ratio > 1.0 ? ratio : 1.0));
             double mult = 1.0;
             if (nspan < 1.0) {
@@ -355,10 +356,10 @@
             Path2D.Double p = new Path2D.Double();
             for (double lon = left; lon < map.bounds.maxlon; lon += Math.toRadians(nspan)) {
-                Point2D point = context.getPoint(new Snode(map.bounds.maxlat, lon));
+                point = context.getPoint(new Snode(map.bounds.maxlat, lon));
                 p.moveTo(point.getX(), point.getY());
                 point = context.getPoint(new Snode(map.bounds.minlat, lon));
                 p.lineTo(point.getX(), point.getY());
                 double deg = Math.toDegrees(lon);
-                String ew = (deg < 0) ? "W" : "E";
+                String ew = (deg < -0.001) ? "W" : (deg > 0.001) ? "E" : "";
                 deg = Math.abs(deg);
                 String dstr = String.format("%03d°", (int)Math.floor(deg));
@@ -366,5 +367,5 @@
                 String mstr = String.format("%05.2f'%s", min, ew);
                 Symbol label = new Symbol();
-                if (point.getX() > 500.0) {
+                if (point.getX() > 600.0) {
                     label.add(new Instr(Form.TEXT, new Caption(dstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-10, -20)))));
                     label.add(new Instr(Form.TEXT, new Caption(mstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(20, 0)))));
@@ -374,5 +375,5 @@
             g2.setPaint(style.line);
             g2.draw(p);
-            double tspan = 60 * Math.toDegrees(map.bounds.maxlat - map.bounds.minlat) / context.grid();
+            double tspan = 60 * Math.toDegrees(map.bounds.maxlat - map.bounds.minlat) / (context.grid() / (ratio < 1.0 ? ratio : 1.0));
             mult = 1.0;
             if (tspan < 1.0) {
@@ -397,10 +398,10 @@
             p = new Path2D.Double();
             for (double lat = bottom; lat < map.bounds.maxlat; lat += Math.toRadians(tspan)) {
-                Point2D point = context.getPoint(new Snode(lat, map.bounds.maxlon));
+                point = context.getPoint(new Snode(lat, map.bounds.maxlon));
                 p.moveTo(point.getX(), point.getY());
                 point = context.getPoint(new Snode(lat, map.bounds.minlon));
                 p.lineTo(point.getX(), point.getY());
                 double deg = Math.toDegrees(lat);
-                String ns = (deg < 0) ? "S" : "N";
+                String ns = (deg < -0.001) ? "S" : (deg > 0.001) ? "N" : "";
                 deg = Math.abs(deg);
                 String dstr = String.format("%02d°%s", (int)Math.floor(deg), ns);
@@ -408,25 +409,26 @@
                 String mstr = String.format("%05.2f'", min);
                 Symbol label = new Symbol();
-                label.add(new Instr(Form.TEXT, new Caption(dstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(10, -10)))));
-                label.add(new Instr(Form.TEXT, new Caption(mstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 50)))));
-                Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null);
+                if (point.getY() < (context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon)).getY() - 200.0)) {
+                	label.add(new Instr(Form.TEXT, new Caption(dstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(10, -10)))));
+                	label.add(new Instr(Form.TEXT, new Caption(mstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 50)))));
+                	Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null);
+                }
             }
             g2.setPaint(style.line);
             g2.draw(p);
-/*            Symbol legend = new Symbol();
-            legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 900, 300)));
-            Path2D.Double path = new Path2D.Double(); path.moveTo(0, 0); path.lineTo(900, 0); path.lineTo(900, 300); path.lineTo(0, 300); path.closePath();
+            Symbol legend = new Symbol();
+            legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 500, 100)));
+            Path2D.Double path = new Path2D.Double(); path.moveTo(0, 0); path.lineTo(500, 0); path.lineTo(500, 100); path.lineTo(0, 100); path.closePath();
             legend.add(new Instr(Form.FILL, Color.white));
             legend.add(new Instr(Form.PGON, path));
-            legend.add(new Instr(Form.TEXT, new Caption("© OpenStreetMap contributors", new Font("Arial", Font.PLAIN, 25), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(450, 300)))));
-            legend.add(new Instr(Form.TEXT, new Caption("Mercator projection", new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(450, 250)))));
-            Point2D point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
+            legend.add(new Instr(Form.TEXT, new Caption("Mercator Projection", new Font("Arial", Font.PLAIN, 50), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(250, 60)))));
+            point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
             Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0)));
             legend = new Symbol();
-            legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 900, 300)));
-            legend.add(new Instr(Form.TEXT, new Caption("Mercator projection", new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(450, 250)))));
+            legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 500, 100)));
+            legend.add(new Instr(Form.TEXT, new Caption("© OpenStreetMap contributors", new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(250, 100)))));
             point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
             Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0)));
-*/        }
+        }
     }
 
@@ -761,3 +763,20 @@
         }
     }
+    
+    public static void rasterPixel(double size, Color col) {
+    	double s = Rules.feature.geom.centre.lat - (size / 2.0);
+    	double w = Rules.feature.geom.centre.lon - (size / 2.0);
+    	double n = Rules.feature.geom.centre.lat + (size / 2.0);
+    	double e = Rules.feature.geom.centre.lon + (size / 2.0);
+    	Point2D sw = context.getPoint(new Snode(s, w)); 
+    	Point2D nw = context.getPoint(new Snode(n, w)); 
+    	Point2D ne = context.getPoint(new Snode(n, e)); 
+    	Point2D se = context.getPoint(new Snode(s, e)); 
+        Symbol pixel = new Symbol();
+        Path2D.Double path = new Path2D.Double(); path.moveTo(sw.getX(), sw.getY()); path.lineTo(nw.getX(), nw.getY());
+        path.lineTo(ne.getX(), ne.getY()); path.lineTo(se.getX(), se.getY()); path.closePath();
+        pixel.add(new Instr(Form.FILL, col));
+        pixel.add(new Instr(Form.PGON, path));
+        Symbols.drawSymbol(g2, pixel, 1.0, 0, 0, null, null);
+    }
 }
Index: applications/editors/josm/plugins/seachart/src/render/Rules.java
===================================================================
--- applications/editors/josm/plugins/seachart/src/render/Rules.java	(revision 35394)
+++ applications/editors/josm/plugins/seachart/src/render/Rules.java	(revision 35404)
@@ -56,4 +56,5 @@
 import s57.S57val.MarSYS;
 import s57.S57val.StsSTS;
+import s57.S57val.TecSOU;
 import s57.S57val.TopSHP;
 import s57.S57val.TrfTRF;
@@ -259,4 +260,7 @@
 			if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) {
 				if (testObject(Obj.LNDARE)) for (Feature f : objects) if (testFeature(f)) areas();
+				if (testObject(Obj.SOUNDG)) for (Feature f : objects) if (testFeature(f)) depths();
+				if (testObject(Obj.DEPCNT)) for (Feature f : objects) if (testFeature(f)) depths();
+				if (testObject(Obj.TESARE)) for (Feature f : objects) if (testFeature(f)) areas();
 				if (testObject(Obj.BUAARE)) for (Feature f : objects) if (testFeature(f)) areas();
 				if (testObject(Obj.HRBFAC)) for (Feature f : objects) if (testFeature(f)) areas();
@@ -271,8 +275,4 @@
 				if (testObject(Obj.ROADWY)) for (Feature f : objects) if (testFeature(f)) highways();
 				if (testObject(Obj.RAILWY)) for (Feature f : objects) if (testFeature(f)) highways();
-			}
-			if (Renderer.context.ruleset() == RuleSet.ALL) {
-				if (testObject(Obj.SOUNDG)) for (Feature f : objects) if (testFeature(f)) depths();
-				if (testObject(Obj.DEPCNT)) for (Feature f : objects) if (testFeature(f)) depths();
 			}
 			if (testObject(Obj.SLCONS)) for (Feature f : objects) if (testFeature(f)) shoreline();
@@ -365,4 +365,7 @@
 		String name = getName();
 		switch (feature.type) {
+		case TESARE:
+			Renderer.lineSymbols(Areas.LimitDash, 0.0, Areas.LimitCC, null, 30, Symbols.Mline);
+			break;
 		case BUAARE:
 			Renderer.lineVector(new LineStyle(new Color(0x20000000, true)));
@@ -696,5 +699,13 @@
 		switch (feature.type) {
 		case SOUNDG:
-			if ((Renderer.zoom >= 14) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
+			if (testAttribute(Obj.SOUNDG, Att.TECSOU, TecSOU.SOU_COMP) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
+				double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU);
+				Color col = new Color(0x00ffffff, true);
+				if (depth > 0.0) col = Symbols.Bwater;
+				if (depth > 5.0) col = new Color(0xcde2f1);
+				if (depth > 20.0) col = new Color(0xe6eff8);
+				if (depth > 50.0) col = new Color(0xf3f8fc);
+				Renderer.rasterPixel(Math.toRadians(1.0/60.0/16.0), col);
+			} else if ((Renderer.zoom >= 14) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
 				double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU);
 				String dstr = df.format(depth);
@@ -718,4 +729,5 @@
 			break;
 		case DEPCNT:
+			Renderer.lineVector(new LineStyle(Color.blue, 2));
 			break;
 		default:
Index: applications/editors/josm/plugins/seachart/src/s57/S57att.java
===================================================================
--- applications/editors/josm/plugins/seachart/src/s57/S57att.java	(revision 35394)
+++ applications/editors/josm/plugins/seachart/src/s57/S57att.java	(revision 35404)
@@ -115,5 +115,5 @@
         AttStr.put(Att.HORCLR, "clearance_width"); AttStr.put(Att.HORLEN, "length"); AttStr.put(Att.HORWID, "width"); AttStr.put(Att.ICEFAC, "factor");
         AttStr.put(Att.INFORM, "information"); AttStr.put(Att.JRSDTN, "jurisdiction"); AttStr.put(Att.LIFCAP, "maximum_load"); AttStr.put(Att.LITCHR, "character");
-        AttStr.put(Att.LITVIS, "visibility"); AttStr.put(Att.MARSYS, "system"); AttStr.put(Att.MLTYLT, "multiple"); AttStr.put(Att.NATION, "nationality");
+        AttStr.put(Att.LITVIS, "visibility"); AttStr.put(Att.MARSYS, "system"); AttStr.put(Att.MLTYLT, "multiple"); AttStr.put(Att.NATION, "nation");
         AttStr.put(Att.NATCON, "construction"); AttStr.put(Att.NATSUR, "surface"); AttStr.put(Att.NATQUA, "surface_qualification"); AttStr.put(Att.NMDATE, "nm_date");
         AttStr.put(Att.OBJNAM, "name"); AttStr.put(Att.ORIENT, "orientation"); AttStr.put(Att.PEREND, "period_end"); AttStr.put(Att.PERSTA, "period_start");
Index: applications/editors/josm/plugins/seachart/src/s57/S57osm.java
===================================================================
--- applications/editors/josm/plugins/seachart/src/s57/S57osm.java	(revision 35394)
+++ applications/editors/josm/plugins/seachart/src/s57/S57osm.java	(revision 35404)
@@ -59,4 +59,5 @@
         OSMtags.put("landuse=industrial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=commercial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
         OSMtags.put("landuse=retail", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=residential", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
+        OSMtags.put("boundary_type=territorial_waters", new KeyVal<>(Obj.TESARE, Att.UNKATT, null, null));
     }
 
@@ -98,11 +99,10 @@
 
     public static void OSMmap(File in, S57map map, boolean bb) throws Exception {
-        String k = "";
-        String v = "";
-
         double lat = 0;
         double lon = 0;
         long id = 0;
         long ref = 0;
+        String k = "";
+        String v = "";
         String type = "";
         String role = "";
@@ -121,18 +121,21 @@
             System.exit(-1);
         }
-        NodeList nList = doc.getElementsByTagName("bounds");
-        NamedNodeMap nnmap = nList.item(0).getAttributes();
-        map.bounds.minlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlat").getNodeValue()));
-        map.nodes.get(2L).lat = map.bounds.minlat;
-        map.nodes.get(3L).lat = map.bounds.minlat;
-        map.bounds.minlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlon").getNodeValue()));
-        map.nodes.get(1L).lon = map.bounds.minlon;
-        map.nodes.get(2L).lon = map.bounds.minlon;
-        map.bounds.maxlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlat").getNodeValue()));
-        map.nodes.get(1L).lat = map.bounds.maxlat;
-        map.nodes.get(4L).lat = map.bounds.maxlat;
-        map.bounds.maxlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlon").getNodeValue()));
-        map.nodes.get(3L).lon = map.bounds.maxlon;
-        map.nodes.get(4L).lon = map.bounds.maxlon;
+		NodeList nList = doc.getElementsByTagName("bounds");
+		NamedNodeMap nnmap;
+		if (nList.getLength() != 0) {
+			nnmap = nList.item(0).getAttributes();
+			map.bounds.minlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlat").getNodeValue()));
+			map.nodes.get(2L).lat = map.bounds.minlat;
+			map.nodes.get(3L).lat = map.bounds.minlat;
+			map.bounds.minlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlon").getNodeValue()));
+			map.nodes.get(1L).lon = map.bounds.minlon;
+			map.nodes.get(2L).lon = map.bounds.minlon;
+			map.bounds.maxlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlat").getNodeValue()));
+			map.nodes.get(1L).lat = map.bounds.maxlat;
+			map.nodes.get(4L).lat = map.bounds.maxlat;
+			map.bounds.maxlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlon").getNodeValue()));
+			map.nodes.get(3L).lon = map.bounds.maxlon;
+			map.nodes.get(4L).lon = map.bounds.maxlon;
+		}
 
         nList = doc.getElementsByTagName("node");
@@ -141,5 +144,5 @@
             Node nNode = nList.item(i);
             if (nNode.getNodeType() == Node.ELEMENT_NODE) {
-                nnmap = nNode.getAttributes();
+            	nnmap = nNode.getAttributes();
                 id = Long.parseLong(nnmap.getNamedItem("id").getNodeValue());
                 lat = Double.parseDouble(nnmap.getNamedItem("lat").getNodeValue());
Index: applications/editors/josm/plugins/seachart/src/symbols/Areas.java
===================================================================
--- applications/editors/josm/plugins/seachart/src/symbols/Areas.java	(revision 35394)
+++ applications/editors/josm/plugins/seachart/src/symbols/Areas.java	(revision 35404)
@@ -33,4 +33,21 @@
         p.quadTo(31, -11, 30, -15); p.lineTo(-30, 2); p.quadTo(-35, -12, -45, -15); p.quadTo(-56, -3, -50, 15); p.lineTo(18.4, 7.3); p.lineTo(21.7, 14); p.lineTo(-20, 20); p.closePath();
         Plane.add(new Instr(Form.PGON, p));
+    }
+
+    public static final Symbol LimitDash = new Symbol();
+    static {
+        LimitDash.add(new Instr(Form.BBOX, new Rectangle2D.Double(-30, -30, 60, 60)));
+        LimitDash.add(new Instr(Form.STRK, new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)));
+        LimitDash.add(new Instr(Form.LINE, new Line2D.Double(0, -30, 0, 30)));
+    }
+
+    public static final Symbol LimitCC = new Symbol();
+    static {
+        LimitCC.add(new Instr(Form.BBOX, new Rectangle2D.Double(-30, -240, 60, 240)));
+        LimitCC.add(new Instr(Form.STRK, new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)));
+        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(0, -200, 0, -160)));
+        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(-20, -180, 20, -180)));
+        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(0, -80, 0, -120)));
+        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(-20, -100, 20, -100)));
     }
 
