Changeset 35685 in osm for applications


Ignore:
Timestamp:
2021-01-13T10:42:07+01:00 (4 years ago)
Author:
malcolmh
Message:

null exception fix + misc updates

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

Legend:

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

    r35404 r35685  
    44import java.awt.Color;
    55import java.awt.Dimension;
     6import java.awt.Font;
    67import java.awt.Graphics2D;
    78import java.awt.Rectangle;
     
    127128    public static void main(String[] args) throws Exception {
    128129        if (args.length < 4) {
    129             System.err.println("Usage: java -jar jrender.jar <osm data file> <zoom> <scale> <output image file> [<bounds (S W N E)>]");
     130            System.err.println("Usage: java -jar jchart.jar <osm data file> <zoom> <scale> <output image file> [<bounds (S W N E)>]");
    130131            System.exit(-1);
    131132        }
     
    152153            Graphics2D g2 = img.createGraphics();
    153154            Renderer.reRender(g2, new Rectangle((int) size.getX(), (int) size.getY()), zoom, Double.parseDouble(args[2]), map, context);
     155           
     156            //Renderer.labelText("000", new Font("Arial", Font.PLAIN, 20), Color.red);
    154157            try {
    155158                ImageIO.write(img, "png", new File(args[3]));
  • applications/editors/josm/plugins/seachart/src/render/Renderer.java

    r35483 r35685  
    9797    }
    9898
     99    public static void symbol(Symbol symbol, double scale, Delta delta) {
     100        Point2D point = context.getPoint(Rules.feature.geom.centre);
     101        Symbols.drawSymbol(g2, symbol, (sScale * scale), point.getX(), point.getY(), null, delta);
     102    }
     103
    99104    public static void symbol(Symbol symbol, Scheme scheme, Delta delta) {
    100105        Point2D point = context.getPoint(Rules.feature.geom.centre);
    101106        Symbols.drawSymbol(g2, symbol, sScale, point.getX(), point.getY(), scheme, delta);
     107    }
     108
     109    public static void symbol(Symbol symbol, double scale, Scheme scheme) {
     110        Point2D point = context.getPoint(Rules.feature.geom.centre);
     111        Symbols.drawSymbol(g2, symbol, (sScale * scale), point.getX(), point.getY(), scheme, null);
    102112    }
    103113
     
    426436            g2.draw(p);
    427437            Symbol legend = new Symbol();
    428             legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 500, 100)));
    429             Path2D.Double path = new Path2D.Double(); path.moveTo(0, 0); path.lineTo(500, 0); path.lineTo(500, 100); path.lineTo(0, 100); path.closePath();
     438            legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 600, 250)));
     439            Path2D.Double path = new Path2D.Double(); path.moveTo(0, 0); path.lineTo(600, 0); path.lineTo(600, 250); path.lineTo(0, 250); path.closePath();
    430440            legend.add(new Instr(Form.FILL, Color.white));
    431441            legend.add(new Instr(Form.PGON, path));
    432             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)))));
     442            legend.add(new Instr(Form.TEXT, new Caption("Mercator Projection", new Font("Arial", Font.PLAIN, 50), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(300, 60)))));
     443            legend.add(new Instr(Form.TEXT, new Caption("© OpenStreetMap contributors", new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 40)))));
     444            legend.add(new Instr(Form.TEXT, new Caption("EMODnet Bathymetry Consortium (2018)", new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 40)))));
     445            legend.add(new Instr(Form.TEXT, new Caption("EMODnet Digital Bathymetry (DTM)", new Font("Arial", Font.PLAIN, 30), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 40)))));
     446            legend.add(new Instr(Form.TEXT, new Caption("http://doi.org/10.12770/18ff0d48-b203-4a65-94a9-5fd8b0ec35f6", new Font("Arial", Font.PLAIN, 20), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 35)))));
    433447            point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
    434448            Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0)));
    435             legend = new Symbol();
    436             legend.add(new Instr(Form.BBOX, new Rectangle2D.Double(0, 0, 500, 100)));
    437             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)))));
    438             point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon));
    439             Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0)));
    440         }
    441     }
    442 
     449        }
     450    }
     451   
    443452    public static void lineCircle(LineStyle style, double radius, UniHLU units) {
    444453        switch (units) {
  • applications/editors/josm/plugins/seachart/src/render/Rules.java

    r35483 r35685  
    317317                                if (testObject(Obj.SPLARE)) for (Feature f : objects) if (testFeature(f)) areas();
    318318                                if (testObject(Obj.SEAARE)) for (Feature f : objects) if (testFeature(f)) areas();
     319                                if (testObject(Obj.CBLARE)) for (Feature f : objects) if (testFeature(f)) areas();
     320                                if (testObject(Obj.PIPARE)) for (Feature f : objects) if (testFeature(f)) areas();
    319321                                if (testObject(Obj.DMPGRD)) for (Feature f : objects) if (testFeature(f)) areas();
    320322                                if (testObject(Obj.OBSTRN)) for (Feature f : objects) if (testFeature(f)) obstructions();
     
    395397                        break;
    396398                case DEPARE:
    397                         Double depmax = 0.0;
    398                         if (((depmax = (Double) getAttVal(Obj.DEPARE, Att.DRVAL2)) != null) && (depmax <= 0.0)) {
    399                                 Renderer.lineVector(new LineStyle(Symbols.Gdries));
     399                        Double depmax = (Double) getAttVal(Obj.DEPARE, Att.DRVAL2);
     400                        if (depmax != null) {
     401                                if (depmax <= 0.0) {
     402                                        Renderer.lineVector(new LineStyle(Symbols.Gdries));
     403                                } else if (depmax <= 2.0) {
     404                                        Renderer.lineVector(new LineStyle(Color.blue, 2, new Color(0x2090ff)));
     405                                } else if (depmax <= 5.0) {
     406                                        Renderer.lineVector(new LineStyle(Color.blue, 2, new Color(0x40a0ff)));
     407                                } else if (depmax <= 10.0) {
     408                                        Renderer.lineVector(new LineStyle(Color.blue, 2, new Color(0x60b0ff)));
     409                                } else if (depmax <= 15.0) {
     410                                        Renderer.lineVector(new LineStyle(Color.blue, 2, new Color(0x80c0ff)));
     411                                } else if (depmax <= 20.0) {
     412                                        Renderer.lineVector(new LineStyle(Color.blue, 2, new Color(0xa0d0ff)));
     413                                } else if (depmax <= 50.0) {
     414                                        Renderer.lineVector(new LineStyle(Color.blue, 2, new Color(0xc0e0ff)));
     415                                } else {
     416                                        Renderer.lineVector(new LineStyle(Color.blue, 2, new Color(0xe0f0ff)));
     417                                }
    400418                        }
    401419                        break;
     
    547565                                Renderer.symbol(Areas.Plane, new Scheme(Symbols.Msymb));
    548566                                Renderer.lineSymbols(Areas.Restricted, 0.5, Areas.LinePlane, null, 10, Symbols.Mline);
    549                         }
    550                         addName(15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));
    551                         break;
     567                                addName(15, new Font("Arial", Font.BOLD, 80), new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));
     568                        }
     569                        break;
     570                case CBLARE:
     571                        if (Renderer.zoom >= 12) {
     572                        Renderer.lineSymbols(Areas.Restricted, 1.0, Areas.Cable, null, 4, Symbols.Mline);
     573                        }
     574                        break;
     575                case PIPARE:
     576                        if (Renderer.zoom >= 12) {
     577                        Renderer.lineSymbols(Areas.Restricted, 1.0, Areas.Pipeline, null, 4, Symbols.Mline);
     578                        break;
     579                        }
    552580                default:
    553581                        break;
     
    721749                                double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU);
    722750                                Color col = new Color(0x00ffffff, true);
    723                                 if (depth > 0.0) col = Symbols.Bwater;
    724                                 if (depth > 5.0) col = new Color(0xcde2f1);
    725                                 if (depth > 20.0) col = new Color(0xe6eff8);
    726                                 if (depth > 50.0) col = new Color(0xf3f8fc);
     751                                if (depth > 0.0) col =  new Color(0x2090ff);
     752                                if (depth > 2.0) col =  new Color(0x40a0ff);
     753                                if (depth > 5.0) col =  new Color(0x60b0ff);
     754                                if (depth > 10.0) col = new Color(0x80c0ff);
     755                                if (depth > 15.0) col = new Color(0xa0d0ff);
     756                                if (depth > 20.0) col = new Color(0xc0e0ff);
     757                                if (depth > 50.0) col = new Color(0xe0f0ff);
    727758                                Renderer.rasterPixel(Math.toRadians(1.0/60.0/16.0), col);
    728759                        } else if ((Renderer.zoom >= 14) && hasAttribute(Obj.SOUNDG, Att.VALSOU)) {
     
    862893                case ACHARE:
    863894                        if (Renderer.zoom >= 12) {
     895                                ArrayList<CatACH> cats = (ArrayList<CatACH>) getAttList(Obj.ACHARE, Att.CATACH);
    864896                                if (feature.geom.prim != Pflag.AREA) {
    865897                                        Renderer.symbol(Harbours.Anchorage, new Scheme(Color.black));
    866898                                } else {
    867                                         Renderer.symbol(Harbours.Anchorage, new Scheme(Symbols.Mline));
     899                                        if (cats.contains(CatACH.ACH_SMCM)) {
     900                                                Renderer.symbol(Buoys.Shapes.get(BoySHP.BOY_SPHR), new Scheme(Symbols.Msymb));
     901                                        Renderer.symbol(Topmarks.TopMooring, Topmarks.BuoyDeltas.get(BoySHP.BOY_SPHR));
     902                                        } else {
     903                                                Renderer.symbol(Harbours.Anchorage, new Scheme(Symbols.Mline));
     904                                        }
    868905                                        Renderer.lineSymbols(Areas.Restricted, 1.0, Areas.LineAnchor, null, 10, Symbols.Mline);
    869906                                }
     
    873910                                        Renderer.labelText("Reserved", new Font("Arial", Font.PLAIN, 50), Symbols.Mline, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 60)));
    874911                                }
    875                                 ArrayList<CatACH> cats = (ArrayList<CatACH>) getAttList(Obj.ACHARE, Att.CATACH);
    876912                                int dy = (cats.size() - 1) * -30;
    877913                                for (CatACH cat : cats) {
     
    899935                                        case ACH_SEAP:
    900936                                                Renderer.symbol(Areas.Seaplane, new Scheme(Symbols.Msymb), new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
     937                                                dy += 60;
     938                                                break;
     939                                        case ACH_SMCF:
     940                                        case ACH_SMCM:
     941                                                Renderer.labelText("Small", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.RC, AffineTransform.getTranslateInstance(-60, dy)));
     942                                                Renderer.labelText("Craft", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.LC, AffineTransform.getTranslateInstance(60, dy)));
    901943                                                dy += 60;
    902944                                                break;
     
    11171159                                break;
    11181160                        case MOR_BUOY:
    1119                             if (Renderer.zoom >= 17) {
     1161                            if (Renderer.zoom >= 16) {
    11201162                                BoySHP shape = (BoySHP) getAttEnum(feature.type, Att.BOYSHP);
    11211163                                if (shape == BoySHP.BOY_UNKN) {
    11221164                                    shape = BoySHP.BOY_SPHR;
    11231165                                }
    1124                                 Renderer.symbol(Buoys.Shapes.get(shape), getScheme(feature.type));
    1125                                 Renderer.symbol(Topmarks.TopMooring, Topmarks.BuoyDeltas.get(shape));
     1166                                Renderer.symbol(Buoys.Shapes.get(shape), (1.0 / (1.0 + (0.25 * (18 - Renderer.zoom)))), getScheme(feature.type));
     1167                                Renderer.symbol(Topmarks.TopMooring, (1.0 / (1.0 + (0.25 * (18 - Renderer.zoom)))), Topmarks.BuoyDeltas.get(shape));
    11261168                            Signals.addSignals();
    11271169                            addName(15, new Font("Arial", Font.BOLD, 40), new Delta(Handle.BL, AffineTransform.getTranslateInstance(60, -50)));
     
    12351277                                }
    12361278                        }
     1279                        if (getAttEnum(feature.type, Att.CATOBS) == CatOBS.OBS_FLGD) {
     1280                                        Renderer.symbol(Areas.Foul, new Scheme(Color.black));
     1281                                        if (feature.geom.prim == Pflag.AREA) {
     1282                                        Renderer.lineSymbols(Areas.Dash, 1.0, Areas.LineFoul, null, 10, Color.black);
     1283                                }
     1284                        }
    12371285                }
    12381286                if ((Renderer.zoom >= 14) && (feature.type == Obj.UWTROC)) {
     
    12461294                        default:
    12471295                                Renderer.symbol(Areas.Rock);
     1296                                break;
    12481297                        }
    12491298                }
  • applications/editors/josm/plugins/seachart/src/render/Signals.java

    r35483 r35685  
    603603            }
    604604        } else {
    605             if (Renderer.zoom >= 15) {
     605            if ((Renderer.zoom >= 15) && (lights.get(0) != null)) {
    606606                AttMap atts = lights.get(0);
    607607                ArrayList<CatLIT> cats = new ArrayList<>();
  • applications/editors/josm/plugins/seachart/src/symbols/Areas.java

    r35460 r35685  
    8181    }
    8282
     83    public static final Symbol Dash = new Symbol();
     84    static {
     85        Dash.add(new Instr(Form.BBOX, new Rectangle2D.Double(-15, -30, 30, 30)));
     86        Dash.add(new Instr(Form.STRK, new BasicStroke(4, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)));
     87        Dash.add(new Instr(Form.LINE, new Line2D.Double(0, 0, 0, -30)));
     88    }
     89
     90    public static final Symbol Foul = new Symbol();
     91    static {
     92        Foul.add(new Instr(Form.BBOX, new Rectangle2D.Double(-30, -60, 60, 60)));
     93        Foul.add(new Instr(Form.STRK, new BasicStroke(8, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)));
     94        Foul.add(new Instr(Form.FILL, Color.black));
     95        Path2D.Double p = new Path2D.Double();
     96        p.moveTo(0, -30); p.lineTo(-20, 30);
     97        p.moveTo(20, -30); p.lineTo(0, 30);
     98        p.moveTo(-20, -15); p.lineTo(30, -15);
     99        p.moveTo(-30, 15); p.lineTo(20, 15);
     100        Foul.add(new Instr(Form.PLIN, p));
     101    }
     102
    83103    public static final Symbol LaneArrow = new Symbol();
    84104    static {
     
    95115        LineAnchor.add(new Instr(Form.BBOX, new Rectangle2D.Double(-30, -60, 60, 90)));
    96116        LineAnchor.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Harbours.Anchor, 0.5, 0, 0, null, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(-90.0))))));
     117    }
     118
     119    public static final Symbol LineFoul = new Symbol();
     120    static {
     121        LineFoul.add(new Instr(Form.BBOX, new Rectangle2D.Double(-30, -60, 60, 90)));
     122        LineFoul.add(new Instr(Form.SYMB, new Symbols.SubSymbol(Foul, 0.5, 0, 0, null, new Delta(Handle.CC, AffineTransform.getRotateInstance(Math.toRadians(-90.0))))));
    97123    }
    98124
Note: See TracChangeset for help on using the changeset viewer.