Changeset 35404 in osm
- Timestamp:
- 2020-03-29T23:03:21+02:00 (5 years ago)
- 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 103 103 if ((node.lat >= map.bounds.minlat) && (node.lat <= map.bounds.maxlat) 104 104 && (node.lon >= map.bounds.minlon) && (node.lon <= map.bounds.maxlon)) { 105 return Symbols. Bwater;105 return Symbols.Gdries; 106 106 } 107 107 } … … 114 114 return Symbols.Yland; 115 115 } else { 116 return Symbols. Bwater;116 return Symbols.Gdries; 117 117 } 118 118 } … … 127 127 public static void main(String[] args) throws Exception { 128 128 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)>]"); 130 130 System.exit(-1); 131 131 } … … 134 134 map = new S57map(false); 135 135 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 } 137 147 context = new Context(); 138 148 Point2D size = context.getPoint(new Snode(map.bounds.minlat, map.bounds.maxlon)); -
applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java
r35392 r35404 7 7 import java.awt.geom.Point2D; 8 8 import java.awt.image.BufferedImage; 9 import java.io.BufferedReader;10 9 import java.io.ByteArrayOutputStream; 11 10 import java.io.File; 12 11 import java.io.FileOutputStream; 13 import java.io.FileReader;14 12 import java.io.IOException; 15 13 import java.io.PrintWriter; -
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r35392 r35404 25 25 26 26 import s57.S57map; 27 import s57.S57map.Feature;28 27 import s57.S57map.GeomIterator; 29 28 import s57.S57map.Pflag; … … 330 329 331 330 public static void grid() { 332 if (context.grid() > 0) { 331 if ((context.grid() > 0) && (map != null)) { 333 332 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)); 335 336 double mult = 1.0; 336 337 if (nspan < 1.0) { … … 355 356 Path2D.Double p = new Path2D.Double(); 356 357 for (double lon = left; lon < map.bounds.maxlon; lon += Math.toRadians(nspan)) { 357 Point2Dpoint = context.getPoint(new Snode(map.bounds.maxlat, lon));358 point = context.getPoint(new Snode(map.bounds.maxlat, lon)); 358 359 p.moveTo(point.getX(), point.getY()); 359 360 point = context.getPoint(new Snode(map.bounds.minlat, lon)); 360 361 p.lineTo(point.getX(), point.getY()); 361 362 double deg = Math.toDegrees(lon); 362 String ew = (deg < 0) ? "W" :"E";363 String ew = (deg < -0.001) ? "W" : (deg > 0.001) ? "E" : ""; 363 364 deg = Math.abs(deg); 364 365 String dstr = String.format("%03d°", (int)Math.floor(deg)); … … 366 367 String mstr = String.format("%05.2f'%s", min, ew); 367 368 Symbol label = new Symbol(); 368 if (point.getX() > 500.0) {369 if (point.getX() > 600.0) { 369 370 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))))); 370 371 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 375 g2.setPaint(style.line); 375 376 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)); 377 378 mult = 1.0; 378 379 if (tspan < 1.0) { … … 397 398 p = new Path2D.Double(); 398 399 for (double lat = bottom; lat < map.bounds.maxlat; lat += Math.toRadians(tspan)) { 399 Point2Dpoint = context.getPoint(new Snode(lat, map.bounds.maxlon));400 point = context.getPoint(new Snode(lat, map.bounds.maxlon)); 400 401 p.moveTo(point.getX(), point.getY()); 401 402 point = context.getPoint(new Snode(lat, map.bounds.minlon)); 402 403 p.lineTo(point.getX(), point.getY()); 403 404 double deg = Math.toDegrees(lat); 404 String ns = (deg < 0) ? "S" :"N";405 String ns = (deg < -0.001) ? "S" : (deg > 0.001) ? "N" : ""; 405 406 deg = Math.abs(deg); 406 407 String dstr = String.format("%02d°%s", (int)Math.floor(deg), ns); … … 408 409 String mstr = String.format("%05.2f'", min); 409 410 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 } 413 416 } 414 417 g2.setPaint(style.line); 415 418 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(); 419 422 legend.add(new Instr(Form.FILL, Color.white)); 420 423 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)); 424 426 Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0))); 425 427 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))))); 428 430 point = context.getPoint(new Snode(map.bounds.minlat, map.bounds.minlon)); 429 431 Symbols.drawSymbol(g2, legend, sScale, point.getX(), point.getY(), null, new Delta(Handle.BL, AffineTransform.getTranslateInstance(0, 0))); 430 */}432 } 431 433 } 432 434 … … 761 763 } 762 764 } 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 } 763 782 } -
applications/editors/josm/plugins/seachart/src/render/Rules.java
r35391 r35404 56 56 import s57.S57val.MarSYS; 57 57 import s57.S57val.StsSTS; 58 import s57.S57val.TecSOU; 58 59 import s57.S57val.TopSHP; 59 60 import s57.S57val.TrfTRF; … … 259 260 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) { 260 261 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(); 261 265 if (testObject(Obj.BUAARE)) for (Feature f : objects) if (testFeature(f)) areas(); 262 266 if (testObject(Obj.HRBFAC)) for (Feature f : objects) if (testFeature(f)) areas(); … … 271 275 if (testObject(Obj.ROADWY)) for (Feature f : objects) if (testFeature(f)) highways(); 272 276 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();277 277 } 278 278 if (testObject(Obj.SLCONS)) for (Feature f : objects) if (testFeature(f)) shoreline(); … … 365 365 String name = getName(); 366 366 switch (feature.type) { 367 case TESARE: 368 Renderer.lineSymbols(Areas.LimitDash, 0.0, Areas.LimitCC, null, 30, Symbols.Mline); 369 break; 367 370 case BUAARE: 368 371 Renderer.lineVector(new LineStyle(new Color(0x20000000, true))); … … 696 699 switch (feature.type) { 697 700 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)) { 699 710 double depth = (double) getAttVal(Obj.SOUNDG, Att.VALSOU); 700 711 String dstr = df.format(depth); … … 718 729 break; 719 730 case DEPCNT: 731 Renderer.lineVector(new LineStyle(Color.blue, 2)); 720 732 break; 721 733 default: -
applications/editors/josm/plugins/seachart/src/s57/S57att.java
r34906 r35404 115 115 AttStr.put(Att.HORCLR, "clearance_width"); AttStr.put(Att.HORLEN, "length"); AttStr.put(Att.HORWID, "width"); AttStr.put(Att.ICEFAC, "factor"); 116 116 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, "nation ality");117 AttStr.put(Att.LITVIS, "visibility"); AttStr.put(Att.MARSYS, "system"); AttStr.put(Att.MLTYLT, "multiple"); AttStr.put(Att.NATION, "nation"); 118 118 AttStr.put(Att.NATCON, "construction"); AttStr.put(Att.NATSUR, "surface"); AttStr.put(Att.NATQUA, "surface_qualification"); AttStr.put(Att.NMDATE, "nm_date"); 119 119 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 59 59 OSMtags.put("landuse=industrial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=commercial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); 60 60 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)); 61 62 } 62 63 … … 98 99 99 100 public static void OSMmap(File in, S57map map, boolean bb) throws Exception { 100 String k = "";101 String v = "";102 103 101 double lat = 0; 104 102 double lon = 0; 105 103 long id = 0; 106 104 long ref = 0; 105 String k = ""; 106 String v = ""; 107 107 String type = ""; 108 108 String role = ""; … … 121 121 System.exit(-1); 122 122 } 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 } 137 140 138 141 nList = doc.getElementsByTagName("node"); … … 141 144 Node nNode = nList.item(i); 142 145 if (nNode.getNodeType() == Node.ELEMENT_NODE) { 143 146 nnmap = nNode.getAttributes(); 144 147 id = Long.parseLong(nnmap.getNamedItem("id").getNodeValue()); 145 148 lat = Double.parseDouble(nnmap.getNamedItem("lat").getNodeValue()); -
applications/editors/josm/plugins/seachart/src/symbols/Areas.java
r32907 r35404 33 33 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(); 34 34 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))); 35 52 } 36 53
Note:
See TracChangeset
for help on using the changeset viewer.