Changeset 35404 in osm for applications/editors/josm/plugins/seachart/src/render
- Timestamp:
- 2020-03-29T23:03:21+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/seachart/src/render
- Files:
-
- 2 edited
-
Renderer.java (modified) (8 diffs)
-
Rules.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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:
Note:
See TracChangeset
for help on using the changeset viewer.
