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

more map features

Location:
applications/editors/josm/plugins/seachart/src/render
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.