Changeset 35404 in osm


Ignore:
Timestamp:
2020-03-29T23:03:21+02:00 (5 years ago)
Author:
malcolmh
Message:

more map features

Location:
applications/editors/josm/plugins/seachart
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/seachart/jchart/src/jchart/Jchart.java

    r35392 r35404  
    103103                            if ((node.lat >= map.bounds.minlat) && (node.lat <= map.bounds.maxlat)
    104104                                    && (node.lon >= map.bounds.minlon) && (node.lon <= map.bounds.maxlon)) {
    105                                 return Symbols.Bwater;
     105                                return Symbols.Gdries;
    106106                            }
    107107                        }
     
    114114                    return Symbols.Yland;
    115115                } else {
    116                     return Symbols.Bwater;
     116                    return Symbols.Gdries;
    117117                }
    118118            }
     
    127127    public static void main(String[] args) throws Exception {
    128128        if (args.length < 4) {
    129             System.err.println("Usage: java -jar jrender.jar <osm data file> <zoom> <scale> <output image file>");
     129            System.err.println("Usage: java -jar jrender.jar <osm data file> <zoom> <scale> <output image file> [<bounds (S W N E)>]");
    130130            System.exit(-1);
    131131        }
     
    134134        map = new S57map(false);
    135135        S57osm.OSMmap(in, map, false);
    136 //        in.close();
     136        if (args.length >= 8) {
     137            map.bounds.minlat = Math.toRadians(Double.parseDouble(args[4]));
     138            map.bounds.minlon = Math.toRadians(Double.parseDouble(args[5]));
     139            map.bounds.maxlat = Math.toRadians(Double.parseDouble(args[6]));
     140            map.bounds.maxlon = Math.toRadians(Double.parseDouble(args[7]));
     141        }
     142        if ((map.bounds.minlat == Math.toRadians(90)) || (map.bounds.minlon == Math.toRadians(180)) ||
     143            (map.bounds.maxlat == Math.toRadians(-90)) || (map.bounds.maxlon == Math.toRadians(-180))) {
     144            System.err.println("Invalid map bounds");
     145            System.exit(-1);
     146        }
    137147        context = new Context();
    138148        Point2D size = context.getPoint(new Snode(map.bounds.minlat, map.bounds.maxlon));
  • applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java

    r35392 r35404  
    77import java.awt.geom.Point2D;
    88import java.awt.image.BufferedImage;
    9 import java.io.BufferedReader;
    109import java.io.ByteArrayOutputStream;
    1110import java.io.File;
    1211import java.io.FileOutputStream;
    13 import java.io.FileReader;
    1412import java.io.IOException;
    1513import java.io.PrintWriter;
  • applications/editors/josm/plugins/seachart/src/render/Renderer.java

    r35392 r35404  
    2525
    2626import s57.S57map;
    27 import s57.S57map.Feature;
    2827import s57.S57map.GeomIterator;
    2928import s57.S57map.Pflag;
     
    330329   
    331330    public static void grid() {
    332         if (context.grid() > 0) {
     331        if ((context.grid() > 0) && (map != null)) {
    333332            LineStyle style = new LineStyle(Color.black, (float)2.0);
    334             double nspan = 60 * Math.toDegrees(map.bounds.maxlon - map.bounds.minlon) / context.grid();
     333            Point2D point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.maxlon));
     334            double ratio = point.getX() / point.getY();
     335            double nspan = 60 * Math.toDegrees(map.bounds.maxlon - map.bounds.minlon) / (context.grid() * (ratio > 1.0 ? ratio : 1.0));
    335336            double mult = 1.0;
    336337            if (nspan < 1.0) {
     
    355356            Path2D.Double p = new Path2D.Double();
    356357            for (double lon = left; lon < map.bounds.maxlon; lon += Math.toRadians(nspan)) {
    357                 Point2D point = context.getPoint(new Snode(map.bounds.maxlat, lon));
     358                point = context.getPoint(new Snode(map.bounds.maxlat, lon));
    358359                p.moveTo(point.getX(), point.getY());
    359360                point = context.getPoint(new Snode(map.bounds.minlat, lon));
    360361                p.lineTo(point.getX(), point.getY());
    361362                double deg = Math.toDegrees(lon);
    362                 String ew = (deg < 0) ? "W" : "E";
     363                String ew = (deg < -0.001) ? "W" : (deg > 0.001) ? "E" : "";
    363364                deg = Math.abs(deg);
    364365                String dstr = String.format("%03d°", (int)Math.floor(deg));
     
    366367                String mstr = String.format("%05.2f'%s", min, ew);
    367368                Symbol label = new Symbol();
    368                 if (point.getX() > 500.0) {
     369                if (point.getX() > 600.0) {
    369370                    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)))));
    370371                    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)))));
     
    374375            g2.setPaint(style.line);
    375376            g2.draw(p);
    376             double tspan = 60 * Math.toDegrees(map.bounds.maxlat - map.bounds.minlat) / context.grid();
     377            double tspan = 60 * Math.toDegrees(map.bounds.maxlat - map.bounds.minlat) / (context.grid() / (ratio < 1.0 ? ratio : 1.0));
    377378            mult = 1.0;
    378379            if (tspan < 1.0) {
     
    397398            p = new Path2D.Double();
    398399            for (double lat = bottom; lat < map.bounds.maxlat; lat += Math.toRadians(tspan)) {
    399                 Point2D point = context.getPoint(new Snode(lat, map.bounds.maxlon));
     400                point = context.getPoint(new Snode(lat, map.bounds.maxlon));
    400401                p.moveTo(point.getX(), point.getY());
    401402                point = context.getPoint(new Snode(lat, map.bounds.minlon));
    402403                p.lineTo(point.getX(), point.getY());
    403404                double deg = Math.toDegrees(lat);
    404                 String ns = (deg < 0) ? "S" : "N";
     405                String ns = (deg < -0.001) ? "S" : (deg > 0.001) ? "N" : "";
    405406                deg = Math.abs(deg);
    406407                String dstr = String.format("%02d°%s", (int)Math.floor(deg), ns);
     
    408409                String mstr = String.format("%05.2f'", min);
    409410                Symbol label = new Symbol();
    410                 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)))));
    411                 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)))));
    412                 Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null);
     411                if (point.getY() < (context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon)).getY() - 200.0)) {
     412                        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)))));
     413                        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)))));
     414                        Symbols.drawSymbol(g2, label, sScale, point.getX(), point.getY(), null, null);
     415                }
    413416            }
    414417            g2.setPaint(style.line);
    415418            g2.draw(p);
    416 /*            Symbol legend = new Symbol();
    417             legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 900, 300)));
    418             Path2D.Double path = new Path2D.Double(); path.moveTo(0, 0); path.lineTo(900, 0); path.lineTo(900, 300); path.lineTo(0, 300); path.closePath();
     419            Symbol legend = new Symbol();
     420            legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 500, 100)));
     421            Path2D.Double path = new Path2D.Double(); path.moveTo(0, 0); path.lineTo(500, 0); path.lineTo(500, 100); path.lineTo(0, 100); path.closePath();
    419422            legend.add(new Instr(Form.FILL, Color.white));
    420423            legend.add(new Instr(Form.PGON, path));
    421             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)))));
    422             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)))));
    423             Point2D point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
     424            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)))));
     425            point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
    424426            Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0)));
    425427            legend = new Symbol();
    426             legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 900, 300)));
    427             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)))));
     428            legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 500, 100)));
     429            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)))));
    428430            point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
    429431            Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0)));
    430 */        }
     432        }
    431433    }
    432434
     
    761763        }
    762764    }
     765   
     766    public static void rasterPixel(double size, Color col) {
     767        double s = Rules.feature.geom.centre.lat - (size / 2.0);
     768        double w = Rules.feature.geom.centre.lon - (size / 2.0);
     769        double n = Rules.feature.geom.centre.lat + (size / 2.0);
     770        double e = Rules.feature.geom.centre.lon + (size / 2.0);
     771        Point2D sw = context.getPoint(new Snode(s, w));
     772        Point2D nw = context.getPoint(new Snode(n, w));
     773        Point2D ne = context.getPoint(new Snode(n, e));
     774        Point2D se = context.getPoint(new Snode(s, e));
     775        Symbol pixel = new Symbol();
     776        Path2D.Double path = new Path2D.Double(); path.moveTo(sw.getX(), sw.getY()); path.lineTo(nw.getX(), nw.getY());
     777        path.lineTo(ne.getX(), ne.getY()); path.lineTo(se.getX(), se.getY()); path.closePath();
     778        pixel.add(new Instr(Form.FILL, col));
     779        pixel.add(new Instr(Form.PGON, path));
     780        Symbols.drawSymbol(g2, pixel, 1.0, 0, 0, null, null);
     781    }
    763782}
  • applications/editors/josm/plugins/seachart/src/render/Rules.java

    r35391 r35404  
    5656import s57.S57val.MarSYS;
    5757import s57.S57val.StsSTS;
     58import s57.S57val.TecSOU;
    5859import s57.S57val.TopSHP;
    5960import s57.S57val.TrfTRF;
     
    259260                        if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) {
    260261                                if (testObject(Obj.LNDARE)) for (Feature f : objects) if (testFeature(f)) areas();
     262                                if (testObject(Obj.SOUNDG)) for (Feature f : objects) if (testFeature(f)) depths();
     263                                if (testObject(Obj.DEPCNT)) for (Feature f : objects) if (testFeature(f)) depths();
     264                                if (testObject(Obj.TESARE)) for (Feature f : objects) if (testFeature(f)) areas();
    261265                                if (testObject(Obj.BUAARE)) for (Feature f : objects) if (testFeature(f)) areas();
    262266                                if (testObject(Obj.HRBFAC)) for (Feature f : objects) if (testFeature(f)) areas();
     
    271275                                if (testObject(Obj.ROADWY)) for (Feature f : objects) if (testFeature(f)) highways();
    272276                                if (testObject(Obj.RAILWY)) for (Feature f : objects) if (testFeature(f)) highways();
    273                         }
    274                         if (Renderer.context.ruleset() == RuleSet.ALL) {
    275                                 if (testObject(Obj.SOUNDG)) for (Feature f : objects) if (testFeature(f)) depths();
    276                                 if (testObject(Obj.DEPCNT)) for (Feature f : objects) if (testFeature(f)) depths();
    277277                        }
    278278                        if (testObject(Obj.SLCONS)) for (Feature f : objects) if (testFeature(f)) shoreline();
     
    365365                String name = getName();
    366366                switch (feature.type) {
     367                case TESARE:
     368                        Renderer.lineSymbols(Areas.LimitDash, 0.0, Areas.LimitCC, null, 30, Symbols.Mline);
     369                        break;
    367370                case BUAARE:
    368371                        Renderer.lineVector(new LineStyle(new Color(0x20000000, true)));
     
    696699                switch (feature.type) {
    697700                case SOUNDG:
    698                         if ((Renderer.zoom >= 14) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
     701                        if (testAttribute(Obj.SOUNDG, Att.TECSOU, TecSOU.SOU_COMP) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
     702                                double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU);
     703                                Color col = new Color(0x00ffffff, true);
     704                                if (depth > 0.0) col = Symbols.Bwater;
     705                                if (depth > 5.0) col = new Color(0xcde2f1);
     706                                if (depth > 20.0) col = new Color(0xe6eff8);
     707                                if (depth > 50.0) col = new Color(0xf3f8fc);
     708                                Renderer.rasterPixel(Math.toRadians(1.0/60.0/16.0), col);
     709                        } else if ((Renderer.zoom >= 14) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
    699710                                double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU);
    700711                                String dstr = df.format(depth);
     
    718729                        break;
    719730                case DEPCNT:
     731                        Renderer.lineVector(new LineStyle(Color.blue, 2));
    720732                        break;
    721733                default:
  • applications/editors/josm/plugins/seachart/src/s57/S57att.java

    r34906 r35404  
    115115        AttStr.put(Att.HORCLR, "clearance_width"); AttStr.put(Att.HORLEN, "length"); AttStr.put(Att.HORWID, "width"); AttStr.put(Att.ICEFAC, "factor");
    116116        AttStr.put(Att.INFORM, "information"); AttStr.put(Att.JRSDTN, "jurisdiction"); AttStr.put(Att.LIFCAP, "maximum_load"); AttStr.put(Att.LITCHR, "character");
    117         AttStr.put(Att.LITVIS, "visibility"); AttStr.put(Att.MARSYS, "system"); AttStr.put(Att.MLTYLT, "multiple"); AttStr.put(Att.NATION, "nationality");
     117        AttStr.put(Att.LITVIS, "visibility"); AttStr.put(Att.MARSYS, "system"); AttStr.put(Att.MLTYLT, "multiple"); AttStr.put(Att.NATION, "nation");
    118118        AttStr.put(Att.NATCON, "construction"); AttStr.put(Att.NATSUR, "surface"); AttStr.put(Att.NATQUA, "surface_qualification"); AttStr.put(Att.NMDATE, "nm_date");
    119119        AttStr.put(Att.OBJNAM, "name"); AttStr.put(Att.ORIENT, "orientation"); AttStr.put(Att.PEREND, "period_end"); AttStr.put(Att.PERSTA, "period_start");
  • applications/editors/josm/plugins/seachart/src/s57/S57osm.java

    r35392 r35404  
    5959        OSMtags.put("landuse=industrial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=commercial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
    6060        OSMtags.put("landuse=retail", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=residential", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
     61        OSMtags.put("boundary_type=territorial_waters", new KeyVal<>(Obj.TESARE, Att.UNKATT, null, null));
    6162    }
    6263
     
    9899
    99100    public static void OSMmap(File in, S57map map, boolean bb) throws Exception {
    100         String k = "";
    101         String v = "";
    102 
    103101        double lat = 0;
    104102        double lon = 0;
    105103        long id = 0;
    106104        long ref = 0;
     105        String k = "";
     106        String v = "";
    107107        String type = "";
    108108        String role = "";
     
    121121            System.exit(-1);
    122122        }
    123         NodeList nList = doc.getElementsByTagName("bounds");
    124         NamedNodeMap nnmap = nList.item(0).getAttributes();
    125         map.bounds.minlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlat").getNodeValue()));
    126         map.nodes.get(2L).lat = map.bounds.minlat;
    127         map.nodes.get(3L).lat = map.bounds.minlat;
    128         map.bounds.minlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlon").getNodeValue()));
    129         map.nodes.get(1L).lon = map.bounds.minlon;
    130         map.nodes.get(2L).lon = map.bounds.minlon;
    131         map.bounds.maxlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlat").getNodeValue()));
    132         map.nodes.get(1L).lat = map.bounds.maxlat;
    133         map.nodes.get(4L).lat = map.bounds.maxlat;
    134         map.bounds.maxlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlon").getNodeValue()));
    135         map.nodes.get(3L).lon = map.bounds.maxlon;
    136         map.nodes.get(4L).lon = map.bounds.maxlon;
     123                NodeList nList = doc.getElementsByTagName("bounds");
     124                NamedNodeMap nnmap;
     125                if (nList.getLength() != 0) {
     126                        nnmap = nList.item(0).getAttributes();
     127                        map.bounds.minlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlat").getNodeValue()));
     128                        map.nodes.get(2L).lat = map.bounds.minlat;
     129                        map.nodes.get(3L).lat = map.bounds.minlat;
     130                        map.bounds.minlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("minlon").getNodeValue()));
     131                        map.nodes.get(1L).lon = map.bounds.minlon;
     132                        map.nodes.get(2L).lon = map.bounds.minlon;
     133                        map.bounds.maxlat = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlat").getNodeValue()));
     134                        map.nodes.get(1L).lat = map.bounds.maxlat;
     135                        map.nodes.get(4L).lat = map.bounds.maxlat;
     136                        map.bounds.maxlon = Math.toRadians(Double.parseDouble(nnmap.getNamedItem("maxlon").getNodeValue()));
     137                        map.nodes.get(3L).lon = map.bounds.maxlon;
     138                        map.nodes.get(4L).lon = map.bounds.maxlon;
     139                }
    137140
    138141        nList = doc.getElementsByTagName("node");
     
    141144            Node nNode = nList.item(i);
    142145            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
    143                 nnmap = nNode.getAttributes();
     146                nnmap = nNode.getAttributes();
    144147                id = Long.parseLong(nnmap.getNamedItem("id").getNodeValue());
    145148                lat = Double.parseDouble(nnmap.getNamedItem("lat").getNodeValue());
  • applications/editors/josm/plugins/seachart/src/symbols/Areas.java

    r32907 r35404  
    3333        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();
    3434        Plane.add(new Instr(Form.PGON, p));
     35    }
     36
     37    public static final Symbol LimitDash = new Symbol();
     38    static {
     39        LimitDash.add(new Instr(Form.BBOX, new Rectangle2D.Double(-30, -30, 60, 60)));
     40        LimitDash.add(new Instr(Form.STRK, new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)));
     41        LimitDash.add(new Instr(Form.LINE, new Line2D.Double(0, -30, 0, 30)));
     42    }
     43
     44    public static final Symbol LimitCC = new Symbol();
     45    static {
     46        LimitCC.add(new Instr(Form.BBOX, new Rectangle2D.Double(-30, -240, 60, 240)));
     47        LimitCC.add(new Instr(Form.STRK, new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)));
     48        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(0, -200, 0, -160)));
     49        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(-20, -180, 20, -180)));
     50        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(0, -80, 0, -120)));
     51        LimitCC.add(new Instr(Form.LINE, new Line2D.Double(-20, -100, 20, -100)));
    3552    }
    3653
Note: See TracChangeset for help on using the changeset viewer.