Changeset 31028 in osm for applications


Ignore:
Timestamp:
2015-02-20T01:43:42+01:00 (10 years ago)
Author:
malcolmh
Message:

add base map rendering

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java

    r31027 r31028  
    1212import java.awt.Dimension;
    1313import java.awt.Graphics2D;
     14import java.awt.Rectangle;
    1415import java.awt.geom.Point2D;
    1516import java.awt.image.BufferedImage;
     
    209210                }
    210211               
    211 /*              img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
    212                 Renderer.reRender(img.createGraphics(), 12, 1, map, context);
     212//              img = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
     213                Rectangle rect = new Rectangle(2048, 2048);
     214                img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_ARGB);
     215                Renderer.reRender(img.createGraphics(), rect, zoom, 0.05, map, context);
    213216                ByteArrayOutputStream bos = new ByteArrayOutputStream();
    214217                ImageIO.write(img, "png", bos);
    215                 empty = bos.size();
    216                 tile(zoom, 1, 0, 0);
    217 */
     218//              empty = bos.size();
     219//              tile(zoom, 1, 0, 0);
     220                FileOutputStream fos = new FileOutputStream(dstdir + "tst_" + zoom + ".png");
     221                bos.writeTo(fos);
     222                fos.close();
     223
    218224//              for (int z = 12; z <= 18; z++) {
    219 int z = 9;
    220225                        DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
    221226                        Document document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
    222227                        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
    223228                        svgGenerator.setBackground(Rules.Bwater);
    224                         svgGenerator.clearRect(0, 0, 2048, 2048);
    225                         svgGenerator.setSVGCanvasSize(new Dimension(2048, 2048));
    226                         svgGenerator.setClip(0, 0, 2048, 2048);
    227 //                      svgGenerator.translate(-2048, -2048);
    228                         Renderer.reRender(svgGenerator, z, 0.05, map, context);
    229                         svgGenerator.stream(dstdir + "tst_" + z + ".svg");
     229                        svgGenerator.clearRect(rect.x, rect.y, rect.width, rect.height);
     230                        svgGenerator.setSVGCanvasSize(rect.getSize());
     231                        svgGenerator.setClip(rect.x, rect.y, rect.width, rect.height);
     232//                      svgGenerator.translate(-256, -256);
     233                        Renderer.reRender(svgGenerator, rect, zoom, 0.05, map, context);
     234                        svgGenerator.stream(dstdir + "tst_" + zoom + ".svg");
    230235//              }
    231236        }
     
    239244                g2.scale(s, s);
    240245                g2.translate(-(256 + (xn * 256 / s)), -(256 + (yn * 256 / s)));
    241                 Renderer.reRender(g2, zoom, 1, map, context);
     246                Renderer.reRender(g2, new Rectangle(256, 256), zoom, 1, map, context);
    242247                ByteArrayOutputStream bos = new ByteArrayOutputStream();
    243248                ImageIO.write(img, "png", bos);
  • applications/editors/josm/plugins/seachart/src/render/Renderer.java

    r31027 r31028  
    1919import s57.S57val.*;
    2020import s57.S57map;
    21 import s57.S57obj.Obj;
    2221import s57.S57map.*;
    2322import symbols.Areas;
     
    3736        static int zoom;
    3837
    39         public static void reRender(Graphics2D g, int z, double factor, S57map m, ChartContext c) {
     38        public static void reRender(Graphics2D g, Rectangle rect, int z, double factor, S57map m, ChartContext c) {
    4039                g2 = g;
    4140                zoom = z;
     
    4443                sScale = symbolScale[zoom] * factor;
    4544                if (map != null) {
     45                        g2.setBackground(Rules.Bwater);
     46                        g2.clearRect(rect.x, rect.y, rect.width, rect.height);
    4647                        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    4748                        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
  • applications/editors/josm/plugins/seachart/src/render/Rules.java

    r31027 r31028  
    282282                switch (feature.type) {
    283283                case BUAARE:
    284                         Renderer.lineVector(feature, new LineStyle(new Color(0x40000000, true)));
     284                        Renderer.lineVector(feature, new LineStyle(new Color(0x20000000, true)));
    285285                        break;
    286286                case COALNE:
     
    289289                case DEPARE:
    290290                        Double depmax = 0.0;
    291                         if (((depmax = (Double) getAttVal(feature, feature.type, 0, Att.DRVAL2)) != null) && (depmax <= 0.0)) {
     291                        if (((depmax = (Double) getAttVal(feature, Obj.DEPARE, 0, Att.DRVAL2)) != null) && (depmax <= 0.0)) {
    292292                                Renderer.lineVector(feature, new LineStyle(Gdries));
    293293                        }
  • applications/editors/josm/plugins/seachart/src/s57/S57map.java

    r31027 r31028  
    233233        }
    234234       
    235         ArrayList<OSMtag> osmtags;
    236 
    237235        public NodeTab nodes;
    238236        public EdgeTab edges;
     
    389387                feature.geom.prim = Pflag.POINT;
    390388                feature.geom.elems.add(new Prim(id));
    391                 osmtags = new ArrayList<OSMtag>();
    392389                edge = null;
    393390        }
     
    398395                feature.geom.prim = Pflag.LINE;
    399396                feature.geom.elems.add(new Prim(id));
    400                 osmtags = new ArrayList<OSMtag>();
    401397                edge = new Edge();
    402398        }
     
    418414                feature.reln = Rflag.UNKN;
    419415                feature.geom.prim = Pflag.AREA;
    420                 osmtags = new ArrayList<OSMtag>();
    421416                edge = null;
    422417        }
     
    479474                        }
    480475                } else {
    481                         osmtags.add(new OSMtag(key, val));
    482                 }
    483         }
    484 
    485         public void tagsDone(long id) {
    486                 for (OSMtag tag : osmtags) {
    487                         KeyVal kv = S57osm.OSMtag(tag.key, tag.val);
     476                        KeyVal kv = S57osm.OSMtag(key, val);
    488477                        if (kv.obj != Obj.UNKOBJ) {
    489478                                if (feature.type == Obj.UNKOBJ) {
     
    503492                                        atts.put(kv.att, new AttVal(kv.att, kv.conv, kv.val));
    504493                                }
    505                                 break;
    506                         }
    507                 }
     494                        }
     495                }
     496        }
     497
     498        public void tagsDone(long id) {
    508499                switch (feature.geom.prim) {
    509500                case POINT:
  • applications/editors/josm/plugins/seachart/src/s57/S57osm.java

    r31027 r31028  
    3838                OSMtags.put("waterway=canal", new KeyVal<>(Obj.CANALS, Att.UNKATT, null, null)); OSMtags.put("waterway=dock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null));
    3939                OSMtags.put("waterway=lock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null));
    40                 OSMtags.put("wetland=tidalflat", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (double)0)); OSMtags.put("tidal=yes", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (double)0));
     40                OSMtags.put("wetland=tidalflat", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (double)0)); OSMtags.put("tidal=yes", new KeyVal<Double>(Obj.DEPARE, Att.DRVAL2, Conv.F, (Double)0.0));
    4141                OSMtags.put("natural=mud", new KeyVal<>(Obj.DEPARE, Att.UNKATT, null, null)); OSMtags.put("natural=sand", new KeyVal<>(Obj.DEPARE, Att.UNKATT, null, null));
    4242                OSMtags.put("highway=motorway", new KeyVal<>(Obj.ROADWY, Att.CATROD, Conv.E, CatROD.ROD_MWAY)); OSMtags.put("highway=trunk", new KeyVal<>(Obj.ROADWY, Att.CATROD, Conv.E, CatROD.ROD_MAJR));
  • applications/editors/josm/plugins/seachart/src/seachart/ChartImage.java

    r31027 r31028  
    6666        public void paint(Graphics2D g2, MapView mv, Bounds bb) {
    6767                Rectangle rect = Main.map.mapView.getBounds();
    68                 g2.setBackground(Rules.Bwater);
    69                 g2.clearRect(rect.x, rect.y, rect.width, rect.height);
    70                 Renderer.reRender(g2, zoom, Math.pow(2, (zoom-12)), SeachartAction.map, this);
     68                Renderer.reRender(g2, rect, zoom, Math.pow(2, (zoom-12)), SeachartAction.map, this);
    7169                g2.setPaint(Color.black);
    7270                g2.setFont(new Font("Arial", Font.BOLD, 20));
Note: See TracChangeset for help on using the changeset viewer.