Changeset 32082 in osm for applications/editors/josm/plugins
- Timestamp:
- 2016-02-27T09:09:45+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/seachart
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/jbasemap/src/jbasemap/Jbasemap.java
r31846 r32082 35 35 static Context context; 36 36 static S57map map; 37 static int zoom; 38 static double z2; 37 39 38 40 static class Context implements ChartContext { … … 42 44 43 45 public Context () { 44 top = (1.0 - Math.log(Math.tan(map.bounds.maxlat) + 1.0 / Math.cos(map.bounds.maxlat)) / Math.PI) / 2.0 * 256.0 * 512.0;46 top = (1.0 - Math.log(Math.tan(map.bounds.maxlat) + 1.0 / Math.cos(map.bounds.maxlat)) / Math.PI) / 2.0 * 256.0 * z2; 45 47 mile = 256 / ((Math.toDegrees(map.bounds.maxlat) - Math.toDegrees(map.bounds.minlat)) * 60); 46 48 } 47 49 48 50 public Point2D getPoint(Snode coord) { 49 double x = (Math.toDegrees(coord.lon) - Math.toDegrees(map.bounds.minlon)) * 256.0 * 256.0/ 180.0;50 double y = ((1.0 - Math.log(Math.tan(coord.lat) + 1.0 / Math.cos(coord.lat)) / Math.PI) / 2.0 * 256.0 * 512.0) - top;51 double x = (Math.toDegrees(coord.lon) - Math.toDegrees(map.bounds.minlon)) * 256.0 * (z2 / 2) / 180.0; 52 double y = ((1.0 - Math.log(Math.tan(coord.lat) + 1.0 / Math.cos(coord.lat)) / Math.PI) / 2.0 * 256.0 * z2) - top; 51 53 return new Point2D.Double(x, y); 52 54 } … … 60 62 } 61 63 62 public Color background( ) {64 public Color background(S57map map) { 63 65 if (map.features.containsKey(Obj.COALNE)) { 64 return Symbols.Bwater; 66 for (Feature feature : map.features.get(Obj.COALNE)) { 67 if (feature.geom.prim == Pflag.POINT) { 68 break; 69 } 70 GeomIterator git = map.new GeomIterator(feature.geom); 71 git.nextComp(); 72 while (git.hasEdge()) { 73 git.nextEdge(); 74 while (git.hasNode()) { 75 Snode node = git.next(); 76 if (node == null) 77 continue; 78 if ((node.lat >= map.bounds.minlat) && (node.lat <= map.bounds.maxlat) && (node.lon >= map.bounds.minlon) && (node.lon <= map.bounds.maxlon)) { 79 return Symbols.Bwater; 80 } 81 } 82 } 83 } 84 return Symbols.Yland; 65 85 } else { 66 return Symbols.Yland; 86 if (map.features.containsKey(Obj.ROADWY) || map.features.containsKey(Obj.RAILWY) || map.features.containsKey(Obj.LAKARE) || map.features.containsKey(Obj.RIVERS) || map.features.containsKey(Obj.CANALS)) { 87 return Symbols.Yland; 88 } else { 89 return Symbols.Bwater; 90 } 67 91 } 68 92 } … … 74 98 75 99 public static void main(String[] args) throws IOException { 100 if (args.length < 5) { 101 System.err.println("Usage: java -jar jbasemap.jar OSM_file SVG_file zoom xtile ytile"); 102 System.exit(-1); 103 } 76 104 src = args[0]; 77 105 dst = args[1]; 106 zoom = Integer.parseInt(args[2]); 107 z2 = Math.pow(2, zoom); 108 double scale = 0.1; 78 109 try { 79 110 BufferedReader in = new BufferedReader(new FileReader(src)); 80 111 map = new S57map(false); 81 if (args.length == 4) {82 map.bounds.maxlat = Math.atan(Math.sinh(Math.PI * (1 - 2 * Double.parseDouble(args[3]) / 512))) * 180.0 / Math.PI;83 map.bounds.minlat = Math.atan(Math.sinh(Math.PI * (1 - 2 * (Double.parseDouble(args[3]) + 1) / 512))) * 180.0 / Math.PI;84 map.bounds.minlon = Double.parseDouble(args[2]) / 512 * 360.0 - 180.0;85 map.bounds.maxlon = (Double.parseDouble(args[2]) + 1) / 512 * 360.0 - 180.0;86 }87 112 try { 88 S57osm.OSMmap(in, map );113 S57osm.OSMmap(in, map, true); 89 114 } catch (Exception e) { 90 115 System.err.println("Input data error"); … … 96 121 System.exit(-1); 97 122 } 123 map.bounds.maxlat = Math.atan(Math.sinh(Math.PI * (1 - 2 * Double.parseDouble(args[4]) / z2))); 124 map.bounds.minlat = Math.atan(Math.sinh(Math.PI * (1 - 2 * (Double.parseDouble(args[4]) + 1) / z2))); 125 map.bounds.minlon = Math.toRadians(Double.parseDouble(args[3]) / z2 * 360.0 - 180.0); 126 map.bounds.maxlon = Math.toRadians((Double.parseDouble(args[3]) + 1) / z2 * 360.0 - 180.0); 98 127 context = new Context(); 99 128 Rectangle rect = new Rectangle(256, 256); … … 104 133 svgGenerator.setSVGCanvasSize(rect.getSize()); 105 134 svgGenerator.setClip(rect.x, rect.y, rect.width, rect.height); 106 Renderer.reRender(svgGenerator, rect, 9, 0.002, map, context);135 Renderer.reRender(svgGenerator, rect, zoom, scale, map, context); 107 136 svgGenerator.stream(dst); 108 137 System.exit(0); -
applications/editors/josm/plugins/seachart/jicons/src/jicons/Jicons.java
r31532 r32082 203 203 } 204 204 205 public Color background( ) {205 public Color background(S57map map) { 206 206 return new Color(0, true); 207 207 } -
applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java
r31846 r32082 35 35 import s57.S57osm; 36 36 import s57.S57map.*; 37 import symbols.*;38 37 import render.*; 39 38 … … 53 52 static class Context implements ChartContext { 54 53 55 static double top = 0;56 static double mile = 0;54 static double top; 55 static double mile; 57 56 58 57 public Context () { … … 75 74 } 76 75 77 public Color background( ) {76 public Color background(S57map map) { 78 77 return new Color(0, true); 79 78 } … … 88 87 context = new Context(); 89 88 90 int size = 256;91 for (int i = 0; i < (12 - zoom); i++) size *= 2;89 int size = 768; 90 // for (int i = 0; i < (12 - zoom); i++) size *= 2; 92 91 Rectangle rect = new Rectangle(size, size); 93 img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_ARGB);94 Renderer.reRender(img.createGraphics(), rect, zoom, 0.05, map, context);95 ByteArrayOutputStream bos = new ByteArrayOutputStream();96 ImageIO.write(img, "png", bos);92 // img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_ARGB); 93 // Renderer.reRender(img.createGraphics(), rect, zoom, 0.05, map, context); 94 // ByteArrayOutputStream bos = new ByteArrayOutputStream(); 95 // ImageIO.write(img, "png", bos); 97 96 // empty = bos.size(); 98 97 // tile(zoom, 1, 0, 0); 99 FileOutputStream fos = new FileOutputStream(dstdir + "tst_" + zoom + "-" + xtile + "-" + ytile + ".png");100 bos.writeTo(fos);101 fos.close();98 // FileOutputStream fos = new FileOutputStream(dstdir + "tst_" + zoom + "-" + xtile + "-" + ytile + ".png"); 99 // bos.writeTo(fos); 100 // fos.close(); 102 101 103 102 // for (int z = 12; z <= 18; z++) { … … 110 109 svgGenerator.setClip(rect.x, rect.y, rect.width, rect.height); 111 110 // svgGenerator.translate(-256, -256); 112 Renderer.reRender(svgGenerator, rect, zoom, 0.05, map, context); 113 svgGenerator.stream(dstdir + "tst_" + zoom + "-" + xtile + "-" + ytile + ".svg"); 111 Renderer.reRender(svgGenerator, rect, zoom, 1.0, map, context); 112 // svgGenerator.stream(dstdir + "tst_" + zoom + "-" + xtile + "-" + ytile + ".svg"); 113 svgGenerator.stream(dstdir); 114 114 // } 115 115 } … … 180 180 send = new ArrayList<String>(); 181 181 deletes = new HashMap<String, Boolean>(); 182 BufferedReader in = new BufferedReader(new FileReader(srcdir + zoom + "-" + xtile + "-" + ytile + ".osm")); 182 // BufferedReader in = new BufferedReader(new FileReader(srcdir + zoom + "-" + xtile + "-" + ytile + ".osm")); 183 BufferedReader in = new BufferedReader(new FileReader(srcdir)); 183 184 map = new S57map(true); 184 S57osm.OSMmap(in, map );185 S57osm.OSMmap(in, map, false); 185 186 in.close(); 186 if (zoom == 12) {187 clean(12, 0, 0);188 }187 // if (zoom == 12) { 188 // clean(12, 0, 0); 189 // } 189 190 tileMap(dstdir, zoom); 190 if ((send.size() + deletes.size()) > 0) {191 PrintWriter writer = new PrintWriter(srcdir + zoom + "-" + xtile + "-" + ytile + ".send", "UTF-8");192 for (String str : send) {193 writer.println(str);194 }195 for (String del : deletes.keySet()) {196 writer.println("rm " + del);197 }198 writer.close();199 }191 // if ((send.size() + deletes.size()) > 0) { 192 // PrintWriter writer = new PrintWriter(srcdir + zoom + "-" + xtile + "-" + ytile + ".send", "UTF-8"); 193 // for (String str : send) { 194 // writer.println(str); 195 // } 196 // for (String del : deletes.keySet()) { 197 // writer.println("rm " + del); 198 // } 199 // writer.close(); 200 // } 200 201 System.exit(0); 201 202 } -
applications/editors/josm/plugins/seachart/src/render/ChartContext.java
r31532 r32082 13 13 import java.awt.geom.Point2D; 14 14 15 import s57.S57map; 15 16 import s57.S57map.*; 16 17 … … 21 22 double mile(Feature feature); 22 23 boolean clip(); 23 Color background( );24 Color background(S57map map); 24 25 RuleSet ruleset(); 25 26 } -
applications/editors/josm/plugins/seachart/src/render/Renderer.java
r31532 r32082 47 47 g2.clip(new Rectangle2D.Double(tl.getX(), tl.getY(), (br.getX() - tl.getX()), (br.getY() - tl.getY()))); 48 48 } 49 g2.setBackground(context.background( ));49 g2.setBackground(context.background(map)); 50 50 g2.clearRect(rect.x, rect.y, rect.width, rect.height); 51 51 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); … … 484 484 g2.setPaint(colour); 485 485 FontRenderContext frc = g2.getFontRenderContext(); 486 GlyphVector gv = font.deriveFont( (float)(font.getSize()*sScale)).createGlyphVector(frc, (" " + str));486 GlyphVector gv = font.deriveFont(font.getSize2D() * (float)sScale).createGlyphVector(frc, (" " + str)); 487 487 GeneralPath path = new GeneralPath(); 488 488 Point2D prev = new Point2D.Double(); … … 560 560 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(mid)), centre.y + radial * Math.cos(Math.toRadians(mid)))); 561 561 } else { 562 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s1)), centre.y + radial * Math.cos(Math.toRadians(s1)))); 563 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s2)), centre.y + radial * Math.cos(Math.toRadians(s2)))); 562 if ((s1 != 0.0) || (s2 != 360.0)) { 563 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s1)), centre.y + radial * Math.cos(Math.toRadians(s1)))); 564 g2.draw(new Line2D.Double(centre.x, centre.y, centre.x - radial * Math.sin(Math.toRadians(s2)), centre.y + radial * Math.cos(Math.toRadians(s2)))); 565 } 564 566 } 565 567 double arcWidth = 10.0 * sScale; 566 568 g2.setStroke(new BasicStroke((float)arcWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1)); 567 569 g2.setPaint(col1); 568 g2.draw(new Arc2D.Double(centre.x - radial, centre.y - radial, 2 * radial, 2 * radial, -(s1 + 90), (s1 - s2 - 360) % 360, Arc2D.OPEN));570 g2.draw(new Arc2D.Double(centre.x - radial, centre.y - radial, 2 * radial, 2 * radial, -(s1 + 90), (s1 - s2), Arc2D.OPEN)); 569 571 if (col2 != null) { 570 572 g2.setPaint(col2); 571 g2.draw(new Arc2D.Double(centre.x - radial + arcWidth, centre.y - radial + arcWidth, 2 * (radial - arcWidth), 2 * (radial - arcWidth), -(s1 + 90), (s1 - s2 - 360) % 360, Arc2D.OPEN));573 g2.draw(new Arc2D.Double(centre.x - radial + arcWidth, centre.y - radial + arcWidth, 2 * (radial - arcWidth), 2 * (radial - arcWidth), -(s1 + 90), (s1 - s2), Arc2D.OPEN)); 572 574 } 573 575 if ((str != null) && (!str.isEmpty())) { … … 577 579 Font font = new Font("Arial", Font.PLAIN, 40); 578 580 GeneralPath path = new GeneralPath(); 579 GlyphVector gv = font.deriveFont( (float)(font.getSize()*sScale)).createGlyphVector(frc, (" " + str));581 GlyphVector gv = font.deriveFont(font.getSize2D() * (float)sScale).createGlyphVector(frc, (" " + str)); 580 582 double gwidth = gv.getLogicalBounds().getWidth(); 581 583 boolean hand = false; 582 584 double offset = 0; 583 585 Point2D origin; 584 double arc = (s2 - s1 + 360) % 360;586 double arc = (s2 - s1); 585 587 if (dir) { 586 588 radial += 10 * sScale; -
applications/editors/josm/plugins/seachart/src/render/Rules.java
r31846 r32082 278 278 break; 279 279 case COALNE: 280 Renderer.lineVector(feature, new LineStyle(Color.black, 10)); 280 if (Renderer.zoom >= 12) 281 Renderer.lineVector(feature, new LineStyle(Color.black, 10)); 281 282 break; 282 283 case DEPARE: … … 287 288 break; 288 289 case LAKARE: 289 Renderer.lineVector(feature, new LineStyle(Symbols.Bwater, 10, Symbols.Bwater)); 290 if ((Renderer.zoom >= 12) || (feature.geom.area > 10.0)) 291 Renderer.lineVector(feature, new LineStyle(Symbols.Bwater)); 290 292 break; 291 293 case DRGARE: … … 310 312 case LOKBSN: 311 313 case HRBBSN: 312 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater)); 314 if (Renderer.zoom >= 12) { 315 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater)); 316 } else { 317 Renderer.lineVector(feature, new LineStyle(Symbols.Bwater)); 318 } 313 319 break; 314 320 case HRBFAC: 315 321 if (feature.objs.get(Obj.HRBBSN) != null) { 316 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater)); 322 if (Renderer.zoom >= 12) { 323 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Bwater)); 324 } else { 325 Renderer.lineVector(feature, new LineStyle(Symbols.Bwater)); 326 } 317 327 } 318 328 break; … … 1038 1048 if ((Renderer.context.ruleset() == RuleSet.ALL) || (Renderer.context.ruleset() == RuleSet.BASE)) { 1039 1049 if ((cat != CatSLC.SLC_SWAY) && (cat != CatSLC.SLC_TWAL)) { 1040 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Yland)); 1050 if (Renderer.zoom >= 12) { 1051 Renderer.lineVector(feature, new LineStyle(Color.black, 10, Symbols.Yland)); 1052 } else { 1053 Renderer.lineVector(feature, new LineStyle(Symbols.Yland)); 1054 } 1041 1055 } 1042 1056 } … … 1049 1063 Renderer.lineVector(feature, new LineStyle(Color.black, 10, new float[] { 40, 40 }, null)); 1050 1064 if (Renderer.zoom >= 15) 1051 Renderer.lineText(feature, "(covers)", new Font("Arial", Font.PLAIN, 80), Color.black, 0.5, 80);1065 Renderer.lineText(feature, "(covers)", new Font("Arial", Font.PLAIN, 60), Color.black, 0.5, 80); 1052 1066 } else { 1053 1067 Renderer.lineVector(feature, new LineStyle(Color.black, 10, null, null)); 1054 1068 } 1055 1069 if (Renderer.zoom >= 15) 1056 Renderer.lineText(feature, "Training Wall", new Font("Arial", Font.PLAIN, 80), Color.black, 0.5, -30);1070 Renderer.lineText(feature, "Training Wall", new Font("Arial", Font.PLAIN, 60), Color.black, 0.5, -30); 1057 1071 break; 1058 1072 case SLC_SWAY: … … 1199 1213 1200 1214 private static void waterways() { 1201 Renderer.lineVector(feature, new LineStyle(Symbols.Bwater, 20, Symbols.Bwater));1215 Renderer.lineVector(feature, new LineStyle(Symbols.Bwater, 20, (feature.geom.prim == Pflag.AREA) ? Symbols.Bwater : null)); 1202 1216 } 1203 1217 -
applications/editors/josm/plugins/seachart/src/render/Signals.java
r31955 r32082 13 13 import java.awt.Font; 14 14 import java.awt.geom.*; 15 import java.text.DecimalFormat; 15 16 import java.util.ArrayList; 16 17 import java.util.EnumMap; 17 18 19 import s57.S57val.CatLIT; 20 import s57.S57val.ColCOL; 18 21 import s57.S57att.*; 19 22 import s57.S57obj.*; … … 27 30 public class Signals { 28 31 29 static final EnumMap<ColCOL, Color> lightColours = new EnumMap<ColCOL, Color>(ColCOL.class);32 static final EnumMap<ColCOL, Color> LightColours = new EnumMap<ColCOL, Color>(ColCOL.class); 30 33 static { 31 lightColours.put(ColCOL.COL_WHT, new Color(0xffff00));32 lightColours.put(ColCOL.COL_RED, new Color(0xff0000));33 lightColours.put(ColCOL.COL_GRN, new Color(0x00ff00));34 lightColours.put(ColCOL.COL_BLU, new Color(0x0000ff));35 lightColours.put(ColCOL.COL_YEL, new Color(0xffff00));36 lightColours.put(ColCOL.COL_AMB, new Color(0xffc200));37 lightColours.put(ColCOL.COL_VIO, new Color(0xee82ee));38 lightColours.put(ColCOL.COL_ORG, Color.orange);39 lightColours.put(ColCOL.COL_MAG, Color.magenta);40 } 41 42 static final EnumMap<ColCOL, String> lightLetters = new EnumMap<ColCOL, String>(ColCOL.class);34 LightColours.put(ColCOL.COL_WHT, new Color(0xffff00)); 35 LightColours.put(ColCOL.COL_RED, new Color(0xff0000)); 36 LightColours.put(ColCOL.COL_GRN, new Color(0x00ff00)); 37 LightColours.put(ColCOL.COL_BLU, new Color(0x0000ff)); 38 LightColours.put(ColCOL.COL_YEL, new Color(0xffff00)); 39 LightColours.put(ColCOL.COL_AMB, new Color(0xffc200)); 40 LightColours.put(ColCOL.COL_VIO, new Color(0xee82ee)); 41 LightColours.put(ColCOL.COL_ORG, Color.orange); 42 LightColours.put(ColCOL.COL_MAG, Color.magenta); 43 } 44 45 static final EnumMap<ColCOL, String> LightLetters = new EnumMap<ColCOL, String>(ColCOL.class); 43 46 static { 44 lightLetters.put(ColCOL.COL_WHT, "W");45 lightLetters.put(ColCOL.COL_RED, "R");46 lightLetters.put(ColCOL.COL_GRN, "G");47 lightLetters.put(ColCOL.COL_BLU, "Bu");48 lightLetters.put(ColCOL.COL_YEL, "Y");49 lightLetters.put(ColCOL.COL_AMB, "Am");50 lightLetters.put(ColCOL.COL_VIO, "Vi");51 lightLetters.put(ColCOL.COL_ORG, "Or");52 } 53 54 static final EnumMap<LitCHR, String> lightCharacters = new EnumMap<LitCHR, String>(LitCHR.class);47 LightLetters.put(ColCOL.COL_WHT, "W"); 48 LightLetters.put(ColCOL.COL_RED, "R"); 49 LightLetters.put(ColCOL.COL_GRN, "G"); 50 LightLetters.put(ColCOL.COL_BLU, "Bu"); 51 LightLetters.put(ColCOL.COL_YEL, "Y"); 52 LightLetters.put(ColCOL.COL_AMB, "Am"); 53 LightLetters.put(ColCOL.COL_VIO, "Vi"); 54 LightLetters.put(ColCOL.COL_ORG, "Or"); 55 } 56 57 static final EnumMap<LitCHR, String> LightCharacters = new EnumMap<LitCHR, String>(LitCHR.class); 55 58 static { 56 lightCharacters.put(LitCHR.CHR_F, "F");57 lightCharacters.put(LitCHR.CHR_FL, "Fl");58 lightCharacters.put(LitCHR.CHR_LFL, "LFl");59 lightCharacters.put(LitCHR.CHR_Q, "Q");60 lightCharacters.put(LitCHR.CHR_VQ, "VQ");61 lightCharacters.put(LitCHR.CHR_UQ, "UQ");62 lightCharacters.put(LitCHR.CHR_ISO, "Iso");63 lightCharacters.put(LitCHR.CHR_OC, "Oc");64 lightCharacters.put(LitCHR.CHR_IQ, "IQ");65 lightCharacters.put(LitCHR.CHR_IVQ, "IVQ");66 lightCharacters.put(LitCHR.CHR_IUQ, "IUQ");67 lightCharacters.put(LitCHR.CHR_MO, "Mo");68 lightCharacters.put(LitCHR.CHR_FFL, "FFl");69 lightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl");70 lightCharacters.put(LitCHR.CHR_OCFL, "OcFl");71 lightCharacters.put(LitCHR.CHR_FLFL, "FLFl");72 lightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc");73 lightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl");74 lightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl");75 lightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr");76 lightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl");77 lightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl");78 lightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl");79 lightCharacters.put(LitCHR.CHR_AL, "Al");80 lightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl");59 LightCharacters.put(LitCHR.CHR_F, "F"); 60 LightCharacters.put(LitCHR.CHR_FL, "Fl"); 61 LightCharacters.put(LitCHR.CHR_LFL, "LFl"); 62 LightCharacters.put(LitCHR.CHR_Q, "Q"); 63 LightCharacters.put(LitCHR.CHR_VQ, "VQ"); 64 LightCharacters.put(LitCHR.CHR_UQ, "UQ"); 65 LightCharacters.put(LitCHR.CHR_ISO, "Iso"); 66 LightCharacters.put(LitCHR.CHR_OC, "Oc"); 67 LightCharacters.put(LitCHR.CHR_IQ, "IQ"); 68 LightCharacters.put(LitCHR.CHR_IVQ, "IVQ"); 69 LightCharacters.put(LitCHR.CHR_IUQ, "IUQ"); 70 LightCharacters.put(LitCHR.CHR_MO, "Mo"); 71 LightCharacters.put(LitCHR.CHR_FFL, "FFl"); 72 LightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl"); 73 LightCharacters.put(LitCHR.CHR_OCFL, "OcFl"); 74 LightCharacters.put(LitCHR.CHR_FLFL, "FLFl"); 75 LightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc"); 76 LightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl"); 77 LightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl"); 78 LightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr"); 79 LightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl"); 80 LightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl"); 81 LightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl"); 82 LightCharacters.put(LitCHR.CHR_AL, "Al"); 83 LightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl"); 81 84 } 82 85 … … 103 106 } 104 107 108 static final DecimalFormat df = new DecimalFormat("#.#"); 109 105 110 public static void fogSignals(Feature feature) { 106 111 Renderer.symbol(feature, Beacons.FogSignal); … … 116 121 } 117 122 if (atts.containsKey(Att.SIGPER)) { 118 str += atts.get(Att.SIGPER).val+ "s";123 str += df.format(atts.get(Att.SIGPER).val) + "s"; 119 124 } 120 125 if (atts.containsKey(Att.VALMXR)) { 121 str += atts.get(Att.VALMXR).val+ "M";126 str += df.format(atts.get(Att.VALMXR).val) + "M"; 122 127 } 123 128 if ((Renderer.zoom >= 15) && !str.isEmpty()) { … … 169 174 @SuppressWarnings("unchecked") 170 175 public static void radioStations(Feature feature) { 171 Renderer.symbol(feature, Beacons.RadarStation);172 176 ArrayList<CatROS> cats = (ArrayList<CatROS>)Rules.getAttList(feature, Obj.RDOSTA, 0, Att.CATROS); 173 177 boolean vais = false; … … 272 276 break; 273 277 } 278 } 279 if (!vais) { 280 Renderer.symbol(feature, Beacons.RadarStation); 274 281 } 275 282 if (Renderer.zoom >= 15) { … … 315 322 } 316 323 } 317 Renderer.symbol(feature, Beacons.LightFlare, new Scheme(lightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120)))); 318 if (lights.get(1) != null) { 319 for (AttMap atts : lights.values()) { 320 Enum<ColCOL> col1 = null; 321 Enum<ColCOL> col2 = null; 322 double radius = 0.2; 323 double s1 = 0; 324 double s2 = 0; 325 boolean dir = false; 324 Renderer.symbol(feature, Beacons.LightFlare, new Scheme(LightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120)))); 325 if (Renderer.zoom >= 15) { 326 String str = ""; 327 if (lights.get(1) != null) { 328 for (AttMap atts : lights.values()) { 329 Enum<ColCOL> col1 = null; 330 Enum<ColCOL> col2 = null; 331 double radius = 0.2; 332 double s1 = 0; 333 double s2 = 0; 334 boolean dir = false; 335 if (atts.containsKey(Att.COLOUR)) { 336 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; 337 col1 = cols.get(0); 338 if (cols.size() > 1) 339 col2 = cols.get(1); 340 } else { 341 continue; 342 } 343 if (atts.containsKey(Att.LITRAD)) { 344 radius = (Double) atts.get(Att.LITRAD).val; 345 } 346 if (atts.containsKey(Att.SECTR1)) { 347 s1 = (Double) atts.get(Att.SECTR1).val; 348 } else { 349 continue; 350 } 351 if (atts.containsKey(Att.SECTR2)) { 352 s2 = (Double) atts.get(Att.SECTR2).val; 353 } else { 354 continue; 355 } 356 if (atts.containsKey(Att.CATLIT)) { 357 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val; 358 if (cats.contains(CatLIT.LIT_DIR)) { 359 dir = true; 360 } 361 } 362 str = ""; 363 if (atts.containsKey(Att.LITCHR)) { 364 str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0)); 365 } 366 if (atts.containsKey(Att.SIGGRP)) { 367 str += "(" + atts.get(Att.SIGGRP).val + ")"; 368 } else if (!str.isEmpty()) { 369 str += "."; 370 } 371 if (atts.containsKey(Att.COLOUR)) { 372 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; 373 str += LightLetters.get(cols.get(0)); 374 if (cols.size() > 1) 375 str += LightLetters.get(cols.get(1)); 376 } 377 if (dir && atts.containsKey(Att.ORIENT)) { 378 double orient = (Double) atts.get(Att.ORIENT).val; 379 str += " " + orient + "°"; 380 s1 = (orient - 4 + 360) % 360; 381 s2 = (orient + 4) % 360; 382 double n1 = 360; 383 double n2 = 360; 384 for (AttMap sect : lights.values()) { 385 if (sect != atts) { 386 387 } 388 } 389 } 390 Renderer.lightSector(feature, LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : ""); 391 } 392 class LitSect { 393 boolean dir; 394 LitCHR chr; 395 ColCOL col; 396 ColCOL alt; 397 String grp; 398 double per; 399 double rng; 400 double hgt; 401 } 402 str = ""; 403 ArrayList<LitSect> litatts = new ArrayList<>(); 404 for (AttMap atts : lights.values()) { 405 LitSect sect = new LitSect(); 406 litatts.add(sect); 407 sect.dir = (atts.containsKey(Att.CATLIT)) && (atts.get(Att.CATLIT).val == CatLIT.LIT_DIR); 408 sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN; 409 switch (sect.chr) { 410 case CHR_AL: 411 sect.chr = LitCHR.CHR_F; 412 break; 413 case CHR_ALOC: 414 sect.chr = LitCHR.CHR_OC; 415 break; 416 case CHR_ALLFL: 417 sect.chr = LitCHR.CHR_LFL; 418 break; 419 case CHR_ALFL: 420 sect.chr = LitCHR.CHR_FL; 421 break; 422 case CHR_ALFFL: 423 sect.chr = LitCHR.CHR_FFL; 424 break; 425 default: 426 break; 427 } 428 sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : ""; 429 sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0; 430 sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0; 431 sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0; 432 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>()); 433 sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK; 434 sect.alt = cols.size() > 1 ? cols.get(1) : ColCOL.COL_UNK; 435 } 436 ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>(); 437 for (LitSect lit : litatts) { 438 boolean found = false; 439 for (ArrayList<LitSect> group : groupings) { 440 LitSect mem = group.get(0); 441 if ((lit.dir == mem.dir) && (lit.chr == mem.chr) && (lit.grp.equals(mem.grp)) && (lit.per == mem.per) && (lit.hgt == mem.hgt)) { 442 group.add(lit); 443 found = true; 444 } 445 } 446 if (!found) { 447 ArrayList<LitSect> tmp = new ArrayList<LitSect>(); 448 tmp.add(lit); 449 groupings.add(tmp); 450 } 451 } 452 for (boolean moved = true; moved;) { 453 moved = false; 454 for (int i = 0; i < groupings.size() - 1; i++) { 455 if (groupings.get(i).size() < groupings.get(i + 1).size()) { 456 ArrayList<LitSect> tmp = groupings.remove(i); 457 groupings.add(i + 1, tmp); 458 moved = true; 459 } 460 } 461 } 462 class ColRng { 463 ColCOL col; 464 double rng; 465 466 public ColRng(ColCOL c, double r) { 467 col = c; 468 rng = r; 469 } 470 } 471 int y = -30; 472 for (ArrayList<LitSect> group : groupings) { 473 ArrayList<ColRng> colrng = new ArrayList<>(); 474 for (LitSect lit : group) { 475 boolean found = false; 476 for (ColRng cr : colrng) { 477 if (cr.col == lit.col) { 478 if (lit.rng > cr.rng) { 479 cr.rng = lit.rng; 480 } 481 found = true; 482 } 483 } 484 if (!found) { 485 colrng.add(new ColRng(lit.col, lit.rng)); 486 } 487 } 488 for (boolean moved = true; moved;) { 489 moved = false; 490 for (int i = 0; i < colrng.size() - 1; i++) { 491 if (colrng.get(i).rng < colrng.get(i + 1).rng) { 492 ColRng tmp = colrng.remove(i); 493 colrng.add(i + 1, tmp); 494 moved = true; 495 } 496 } 497 } 498 LitSect tmp = group.get(0); 499 if (tmp.dir) 500 str += "Dir"; 501 str += LightCharacters.get(tmp.chr); 502 if (!tmp.grp.isEmpty()) 503 str += "(" + tmp.grp + ")"; 504 else 505 str += "."; 506 for (ColRng cr : colrng) { 507 str += LightLetters.get(cr.col); 508 } 509 if (tmp.per > 0) 510 str += df.format(tmp.per) + "s"; 511 if (tmp.hgt > 0) 512 str += df.format(tmp.hgt) + "m"; 513 if (colrng.get(0).rng > 0) 514 str += df.format(colrng.get(0).rng) + ((colrng.size() > 1) ? ((colrng.size() > 2) ? ("-" + df.format(colrng.get(colrng.size() - 1).rng)) : ("/" + df.format(colrng.get(1).rng))) : "") + "M"; 515 Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y))); 516 y += 40; 517 str = ""; 518 } 519 } else { 520 AttMap atts = lights.get(0); 521 ArrayList<CatLIT> cats = new ArrayList<>(); 522 if (atts.containsKey(Att.CATLIT)) { 523 cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val; 524 } 525 str += (cats.contains(CatLIT.LIT_DIR)) ? "Dir" : ""; 526 str += (atts.containsKey(Att.MLTYLT)) ? atts.get(Att.MLTYLT).val : ""; 527 if (atts.containsKey(Att.LITCHR)) { 528 LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0); 529 if (atts.containsKey(Att.SIGGRP)) { 530 String grp = (String) atts.get(Att.SIGGRP).val; 531 switch (chr) { 532 case CHR_QLFL: 533 str += String.format("Q(%s)+LFl", grp); 534 break; 535 case CHR_VQLFL: 536 str += String.format("VQ(%s)+LFl", grp); 537 break; 538 case CHR_UQLFL: 539 str += String.format("UQ(%s)+LFl", grp); 540 break; 541 default: 542 str += String.format("%s(%s)", LightCharacters.get(chr), grp); 543 break; 544 } 545 } else { 546 str += LightCharacters.get(chr); 547 } 548 } 326 549 if (atts.containsKey(Att.COLOUR)) { 327 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; 328 col1 = cols.get(0); 329 if (cols.size() > 1) col2 = cols.get(1); 330 } else { 331 continue; 332 } 333 if (atts.containsKey(Att.RADIUS)) { 334 radius = (Double) atts.get(Att.RADIUS).val; 335 } 336 if (atts.containsKey(Att.SECTR1)) { 337 s1 = (Double) atts.get(Att.SECTR1).val; 338 } else { 339 continue; 340 } 341 if (atts.containsKey(Att.SECTR2)) { 342 s2 = (Double) atts.get(Att.SECTR2).val; 343 } else { 344 continue; 345 } 346 if (atts.containsKey(Att.CATLIT)) { 347 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val; 348 if (cats.contains(CatLIT.LIT_DIR)) { 349 dir = true; 350 } 351 } 352 String str = ""; 353 if (atts.containsKey(Att.LITCHR)) { 354 str += lightCharacters.get(atts.get(Att.LITCHR).val); 355 } 356 if (atts.containsKey(Att.SIGGRP)) { 357 str += "(" + atts.get(Att.SIGGRP).val + ")"; 358 } else if (!str.isEmpty()) { 359 str += "."; 360 } 361 if (atts.containsKey(Att.COLOUR)) { 362 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; 363 str += lightLetters.get(cols.get(0)); 364 if (cols.size() > 1) 365 str += lightLetters.get(cols.get(1)); 366 } 367 if (dir && atts.containsKey(Att.ORIENT)) { 368 double orient = (Double)atts.get(Att.ORIENT).val; 369 str += " " + orient + "°"; 370 s1 = (orient - 4 + 360) % 360; 371 s2 = (orient + 4) % 360; 372 double n1 = 360; 373 double n2 = 360; 374 for (AttMap sect : lights.values()) { 375 if (sect != atts) { 376 377 } 378 } 379 } 380 Renderer.lightSector(feature, lightColours.get(col1), lightColours.get(col2), radius, s1, s2, dir, str); 381 } 382 } 383 /* int secmax = countObjects(item, "light"); 384 if ((idx == 0) && (secmax > 0)) { 385 struct SECT { 386 struct SECT *next; 387 int dir; 388 LitCHR_t chr; 389 ColCOL_t col; 390 ColCOL_t alt; 391 char *grp; 392 double per; 393 double rng; 394 } *lights = NULL; 395 for (int i = secmax; i > 0; i--) { 396 struct SECT *tmp = calloc(1, sizeof(struct SECT)); 397 tmp->next = lights; 398 lights = tmp; 399 obj = getObj(item, LIGHTS, i); 400 if ((att = getAtt(obj, CATLIT)) != NULL) { 401 lights->dir = testAtt(att, LIT_DIR); 402 } 403 if ((att = getAtt(obj, LITCHR)) != NULL) { 404 lights->chr = att->val.val.e; 405 switch (lights->chr) { 406 case CHR_AL: 407 lights->chr = CHR_F; 408 break; 409 case CHR_ALOC: 410 lights->chr = CHR_OC; 411 break; 412 case CHR_ALLFL: 413 lights->chr = CHR_LFL; 414 break; 415 case CHR_ALFL: 416 lights->chr = CHR_FL; 417 break; 418 case CHR_ALFFL: 419 lights->chr = CHR_FFL; 420 break; 421 default: 422 break; 423 } 424 } 425 if ((att = getAtt(obj, SIGGRP)) != NULL) { 426 lights->grp = att->val.val.a; 427 } else { 428 lights->grp = ""; 429 } 430 if ((att = getAtt(obj, SIGPER)) != NULL) { 431 lights->per = att->val.val.f; 432 } 433 if ((att = getAtt(obj, VALNMR)) != NULL) { 434 lights->rng = att->val.val.f; 435 } 436 if ((att = getAtt(obj, COLOUR)) != NULL) { 437 lights->col = att->val.val.l->val; 438 if (att->val.val.l->next != NULL) 439 lights->alt = att->val.val.l->next->val; 440 } 441 } 442 struct COLRNG { 443 int col; 444 double rng; 445 } colrng[14]; 446 while (lights != NULL) { 447 strcpy(string2, ""); 448 bzero(colrng, 14*sizeof(struct COLRNG)); 449 colrng[lights->col].col = 1; 450 colrng[lights->col].rng = lights->rng; 451 struct SECT *this = lights; 452 struct SECT *next = lights->next; 453 while (next != NULL) { 454 if ((this->dir == next->dir) && (this->chr == next->chr) && 455 (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) { 456 colrng[next->col].col = 1; 457 if (next->rng > colrng[next->col].rng) 458 colrng[next->col].rng = next->rng; 459 struct SECT *tmp = lights; 460 while (tmp->next != next) tmp = tmp->next; 461 tmp->next = next->next; 462 free(next); 463 next = tmp->next; 464 } else { 465 next = next->next; 466 } 467 } 468 if (this->chr != CHR_UNKN) { 469 if (this->dir) strcpy(string2, "Dir."); 470 strcat(string2, light_characters[this->chr]); 471 if (strcmp(this->grp, "") != 0) { 472 if (this->grp[0] == '(') 473 sprintf(strchr(string2, 0), "%s", this->grp); 474 else 475 sprintf(strchr(string2, 0), "(%s)", this->grp); 476 } else { 477 if (strlen(string2) > 0) strcat(string2, "."); 478 } 479 int n = 0; 480 for (int i = 0; i < 14; i++) if (colrng[i].col) n++; 481 double max = 0.0; 482 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng; 483 double min = max; 484 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng; 485 if (min == max) { 486 for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]); 487 } else { 488 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]); 489 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]); 490 for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]); 491 } 492 strcat(string2, "."); 493 if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per); 494 if (max > 0.0) { 495 sprintf(strchr(string2, 0), "%g", max); 496 if (min != max) { 497 if (n == 2) strcat(string2, "/"); 498 else if (n > 2) strcat(string2, "-"); 499 if (min < max) sprintf(strchr(string2, 0), "%g", min); 500 } 501 strcat(string2, "M"); 502 } 503 if (strlen(string1) > 0) strcat(string1, "\n"); 504 strcat(string1, string2); 505 } 506 lights = this->next; 507 free(this); 508 this = lights; 509 } 510 } else { 511 if ((att = getAtt(obj, CATLIT)) != NULL) { 512 if (testAtt(att, LIT_DIR)) 513 strcat(string1, "Dir"); 514 } 515 if ((att = getAtt(obj, MLTYLT)) != NULL) 516 sprintf(strchr(string1, 0), "%s", stringValue(att->val)); 517 if ((att = getAtt(obj, LITCHR)) != NULL) { 518 char *chrstr = strdup(stringValue(att->val)); 519 Att_t *grp = getAtt(obj, SIGGRP); 520 if (grp != NULL) { 521 char *strgrp = strdup(stringValue(grp->val)); 522 char *grpstr = strtok(strgrp, "()"); 523 switch (att->val.val.e) { 524 case CHR_QLFL: 525 sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr); 526 break; 527 case CHR_VQLFL: 528 sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr); 529 break; 530 case CHR_UQLFL: 531 sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr); 532 break; 533 default: 534 sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr); 535 break; 536 } 537 free(strgrp); 538 } else { 539 sprintf(strchr(string1, 0), "%s", chrstr); 540 } 541 free(chrstr); 542 } 543 if ((att = getAtt(obj, COLOUR)) != NULL) { 544 int n = countValues(att); 545 if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) { 546 if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')'))) 547 strcat(string1, "."); 548 Lst_t *lst = att->val.val.l; 549 while (lst != NULL) { 550 strcat(string1, light_letters[lst->val]); 551 lst = lst->next; 552 } 553 } 554 } 555 if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) { 556 if (testAtt(att, LIT_VERT)) 557 strcat(string1, "(vert)"); 558 if (testAtt(att, LIT_HORI)) 559 strcat(string1, "(hor)"); 560 } 561 if ((strlen(string1) > 0) && 562 ((getAtt(obj, SIGPER) != NULL) || 563 (getAtt(obj, HEIGHT) != NULL) || 564 (getAtt(obj, VALMXR) != NULL)) && 565 (string1[strlen(string1)-1] != ')')) 566 strcat(string1, "."); 567 if ((att = getAtt(obj, SIGPER)) != NULL) 568 sprintf(strchr(string1, 0), "%ss", stringValue(att->val)); 569 if ((idx == 0) && (item->objs.obj != LITMIN)) { 570 if ((att = getAtt(obj, HEIGHT)) != NULL) 571 sprintf(strchr(string1, 0), "%sm", stringValue(att->val)); 572 if ((att = getAtt(obj, VALNMR)) != NULL) 573 sprintf(strchr(string1, 0), "%sM", stringValue(att->val)); 574 } 575 if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) { 576 if (testAtt(att, LIT_FRNT)) 577 strcat(string1, "(Front)"); 578 if (testAtt(att, LIT_REAR)) 579 strcat(string1, "(Rear)"); 580 if (testAtt(att, LIT_UPPR)) 581 strcat(string1, "(Upper)"); 582 if (testAtt(att, LIT_LOWR)) 583 strcat(string1, "(Lower)"); 584 } 585 } 586 } 587 */ } 588 550 ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val; 551 if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) { 552 if (!str.isEmpty() && !str.endsWith(")")) { 553 str += "."; 554 } 555 for (ColCOL acol : cols) { 556 str += LightLetters.get(acol); 557 } 558 } 559 } 560 str += (cats.contains(CatLIT.LIT_VERT)) ? "(vert)" : ""; 561 str += (cats.contains(CatLIT.LIT_HORI)) ? "(hor)" : ""; 562 str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : ""; 563 str += (atts.containsKey(Att.SIGPER)) ? df.format(atts.get(Att.SIGPER).val) + "s" : ""; 564 str += (atts.containsKey(Att.HEIGHT)) ? df.format(atts.get(Att.HEIGHT).val) + "m" : ""; 565 str += (atts.containsKey(Att.VALNMR)) ? df.format(atts.get(Att.VALNMR).val) + "M" : ""; 566 str += (cats.contains(CatLIT.LIT_FRNT)) ? "(Front)" : ""; 567 str += (cats.contains(CatLIT.LIT_REAR)) ? "(Rear)" : ""; 568 str += (cats.contains(CatLIT.LIT_UPPR)) ? "(Upper)" : ""; 569 str += (cats.contains(CatLIT.LIT_LOWR)) ? "(Lower)" : ""; 570 Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30))); 571 } 572 } 573 } 589 574 } -
applications/editors/josm/plugins/seachart/src/s57/S57att.java
r31955 r32082 122 122 AttStr.put(Att.SHIPAM, "shift"); AttStr.put(Att.SIGFRQ, "frequency"); AttStr.put(Att.SIGGEN, "generation"); AttStr.put(Att.SIGGRP, "group"); 123 123 AttStr.put(Att.SIGPER, "period"); AttStr.put(Att.SIGSEQ, "sequence"); AttStr.put(Att.SOUACC, "sounding_accuracy"); AttStr.put(Att.SDISMX, "maximum_sounding"); 124 AttStr.put(Att.SDISMN, "minimum_sounding"); AttStr.put(Att.SORDAT, " "); AttStr.put(Att.SORIND, ""); AttStr.put(Att.STATUS, "status");124 AttStr.put(Att.SDISMN, "minimum_sounding"); AttStr.put(Att.SORDAT, "source_date"); AttStr.put(Att.SORIND, "source"); AttStr.put(Att.STATUS, "status"); 125 125 AttStr.put(Att.SURATH, "authority"); AttStr.put(Att.SUREND, "survey_end"); AttStr.put(Att.SURSTA, "survey_start"); AttStr.put(Att.SURTYP, "survey"); 126 126 AttStr.put(Att.TECSOU, "technique"); AttStr.put(Att.TXTDSC, "document"); AttStr.put(Att.TIMEND, "end_time"); AttStr.put(Att.TIMSTA, "start_time"); -
applications/editors/josm/plugins/seachart/src/s57/S57box.java
r31846 r32082 18 18 19 19 enum Ext {I, N, W, S, E } 20 21 static Ext getExt(S57map map, double lat, double lon) { 22 if ((lat >= map.bounds.maxlat) && (lon < map.bounds.maxlon)) { 23 return Ext.N; 24 } else if (lon <= map.bounds.minlon) { 25 return Ext.W; 26 } else if (lat <= map.bounds.minlat) { 27 return Ext.S; 28 } else if (lon >= map.bounds.maxlon) { 29 return Ext.E; 30 } return Ext.I; 31 } 20 32 21 33 public static void bBox(S57map map) { … … 105 117 } 106 118 for (Land land : lands) { 107 GeomIterator git = map.new GeomIterator(land.land.geom); 108 Snode prev = null; 109 Ext bprev = Ext.I; 110 Ext ext; 111 land.ebound = land.sbound = Ext.I; 112 while (git.hasComp()) { 113 git.nextComp(); 114 while (git.hasEdge()) { 115 git.nextEdge(); 116 while (git.hasNode()) { 117 long ref = git.nextRef(false); 118 Snode node = map.nodes.get(ref); 119 if (node == null) 120 continue; 121 if (land.first == 0) { 122 land.first = ref; 123 } 124 if (prev == null) { 125 prev = node; 126 } 127 if ((node.lat >= map.bounds.maxlat) && (node.lon < map.bounds.maxlon)) { 128 ext = Ext.N; 129 } else if (node.lon <= map.bounds.minlon) { 130 ext = Ext.W; 131 } else if (node.lat <= map.bounds.minlat) { 132 ext = Ext.S; 133 } else if (node.lon >= map.bounds.maxlon) { 134 ext = Ext.E; 135 } else { 136 ext = Ext.I; 137 } 138 if (ext == Ext.I) { 139 if (land.start == null) { 140 land.start = prev; 141 land.sbound = bprev; 142 } 143 land.end = null; 144 land.ebound = Ext.I; 145 } else { 146 if ((land.start != null) && (land.end == null)) { 147 land.end = node; 148 land.ebound = ext; 149 } 150 } 151 prev = node; 152 bprev = ext; 153 land.last = ref; 154 } 155 } 156 } 119 land.first = map.edges.get(land.land.geom.elems.get(0).id).first; 120 land.start = map.nodes.get(land.first); 121 land.sbound = getExt(map, land.start.lat, land.start.lon); 122 land.last = map.edges.get(land.land.geom.elems.get(land.land.geom.comps.get(0).size - 1).id).last; 123 land.end = map.nodes.get(land.last); 124 land.ebound = getExt(map, land.end.lat, land.end.lon); 157 125 } 158 126 islands = new ArrayList<>(); … … 165 133 lands.remove(island); 166 134 } 167 while (lands.size() > 0) { 168 Land land = lands.get(0); 135 for (Land land : lands) { 169 136 Edge nedge = map.new Edge(); 170 137 nedge.first = land.last; 138 nedge.last = land.first; 171 139 Ext bound = land.ebound; 172 Snode last = land.end; 173 double delta = Math.PI; 174 int idx = -1; 175 Land next = null; 176 while (idx < 0) { 177 for (int i = 0; i < lands.size(); i++) { 178 next = lands.get(i); 179 if (next.sbound == bound) { 180 double diff = -Math.PI; 181 switch (bound) { 182 case N: 183 diff = last.lon - next.start.lon; 184 break; 185 case W: 186 diff = last.lat - next.start.lat; 187 break; 188 case S: 189 diff = next.start.lon - last.lon; 190 break; 191 case E: 192 diff = next.start.lat - last.lat; 193 break; 194 default: 195 continue; 196 } 197 if ((diff >= 0.0) && (diff < delta)) { 198 delta = diff; 199 idx = i; 200 } 201 } 202 } 203 if (idx < 0) { 204 long ref = (long) bound.ordinal(); 205 last = map.nodes.get(ref); 206 nedge.nodes.add(ref); 207 ref = ref < 4 ? ++ref : 1; 208 for (Ext e : Ext.values()) { 209 if (ref == e.ordinal()) { 210 bound = e; 211 break; 212 } 213 } 140 while (bound != land.sbound) { 141 switch (bound) { 142 case N: 143 nedge.nodes.add(1l); 144 bound = Ext.W; 145 break; 146 case W: 147 nedge.nodes.add(2l); 148 bound = Ext.S; 149 break; 150 case S: 151 nedge.nodes.add(3l); 152 bound = Ext.E; 153 break; 154 case E: 155 nedge.nodes.add(4l); 156 bound = Ext.N; 157 break; 158 default: 159 continue; 214 160 } 215 161 } 216 next = lands.get(idx);217 nedge.last = next.first;218 162 map.edges.put(++map.xref, nedge); 219 163 land.land.geom.elems.add(map.new Prim(map.xref)); 220 if (next != land) { 221 land.land.geom.elems.addAll(next.land.geom.elems); 222 land.ebound = next.ebound; 223 land.end = next.end; 224 land.last = next.last; 225 lands.remove(idx); 226 } 227 map.sortGeom(land.land); 228 if (land.land.geom.prim == Pflag.AREA) { 229 map.features.get(Obj.LNDARE).add(land.land); 230 lands.remove(land); 231 } 164 land.land.geom.comps.get(0).size++; 165 land.land.geom.prim = Pflag.AREA; 166 map.features.get(Obj.LNDARE).add(land.land); 232 167 } 233 168 } -
applications/editors/josm/plugins/seachart/src/s57/S57map.java
r31955 r32082 234 234 private Feature feature; 235 235 private Edge edge; 236 private KeyVal<?> osm = S57osm.OSMtag("", "");236 private ArrayList<KeyVal<?>> osm; 237 237 private boolean sea; 238 238 … … 375 375 feature.geom.elems.add(new Prim(id)); 376 376 edge = null; 377 osm = S57osm.OSMtag("", "");377 osm = new ArrayList<>(); 378 378 } 379 379 … … 385 385 feature.geom.elems.add(new Prim(id)); 386 386 edge = new Edge(); 387 osm = S57osm.OSMtag("", "");387 osm = new ArrayList<>(); 388 388 } 389 389 … … 406 406 feature.geom.prim = Pflag.AREA; 407 407 edge = null; 408 osm = S57osm.OSMtag("", "");408 osm = new ArrayList<>(); 409 409 } 410 410 … … 475 475 } 476 476 } else if (!sea) { 477 KeyVal<?> kv = S57osm.OSMtag(key, val); 478 if (kv.obj != Obj.UNKOBJ) { 479 osm.obj = kv.obj; 480 if (kv.att != Att.UNKATT) { 481 osm = kv; 482 } 483 } 477 S57osm.OSMtag(osm, key, val); 484 478 } 485 479 } … … 489 483 case POINT: 490 484 Snode node = nodes.get(id); 491 if ((node.flg != Nflag.CONN) && (node.flg != Nflag.DPTH) && (!feature.objs.isEmpty() || (osm.obj != Obj.UNKOBJ))) {485 if ((node.flg != Nflag.CONN) && (node.flg != Nflag.DPTH) && (!feature.objs.isEmpty() || !osm.isEmpty())) { 492 486 node.flg = Nflag.ISOL; 493 487 } … … 507 501 } 508 502 if (sortGeom(feature) && !((edge != null) && (edge.last == 0))) { 509 if (osm.obj != Obj.UNKOBJ) { 503 if (feature.type != Obj.UNKOBJ) { 504 index.put(id, feature); 505 if (features.get(feature.type) == null) { 506 features.put(feature.type, new ArrayList<Feature>()); 507 } 508 features.get(feature.type).add(feature); 509 } 510 for (KeyVal<?> kvx : osm) { 511 Feature base = new Feature(); 512 base.reln = Rflag.MASTER; 513 base.geom = feature.geom; 514 base.type = kvx.obj; 515 ObjTab objs = new ObjTab(); 516 base.objs.put(kvx.obj, objs); 517 AttMap atts = new AttMap(); 518 objs.put(0, atts); 519 if (kvx.att != Att.UNKATT) { 520 atts.put(kvx.att, new AttVal<>(kvx.conv, kvx.val)); 521 } 522 index.put(++xref, base); 523 if (features.get(kvx.obj) == null) { 524 features.put(kvx.obj, new ArrayList<Feature>()); 525 } 526 features.get(kvx.obj).add(base); 527 } 528 /* if (!osm.isEmpty()) { 510 529 if (feature.type == Obj.UNKOBJ) { 511 530 feature.type = osm.obj; … … 541 560 features.get(osm.obj).add(base); 542 561 } 543 } 544 if (feature.type != Obj.UNKOBJ) { 545 index.put(id, feature); 546 if (features.get(feature.type) == null) { 547 features.put(feature.type, new ArrayList<Feature>()); 548 } 549 features.get(feature.type).add(feature); 550 } 562 }*/ 551 563 } 552 564 } … … 575 587 feature.geom.centre = nodes.get(feature.geom.elems.get(0).id); 576 588 return true; 577 } else { 578 int sweep = feature.geom.elems.size(); 579 while (!feature.geom.elems.isEmpty()) { 580 Prim prim = feature.geom.elems.remove(0); 581 Edge edge = edges.get(prim.id); 582 if (edge == null) { 583 return false; 584 } 585 if (next == true) { 586 next = false; 587 first = edge.first; 589 } 590 Geom outer = new Geom(feature.geom.prim); 591 Geom inner = new Geom(feature.geom.prim); 592 for (Prim prim : feature.geom.elems) { 593 if (prim.outer) { 594 outer.elems.add(prim); 595 } else { 596 inner.elems.add(prim); 597 } 598 } 599 boolean outin = true; 600 int sweep = outer.elems.size(); 601 if (sweep == 0) { 602 return false; 603 } 604 int prev = sweep; 605 int top = 0; 606 while (!outer.elems.isEmpty()) { 607 Prim prim = outer.elems.remove(0); 608 Edge edge = edges.get(prim.id); 609 if (edge == null) { 610 return false; 611 } 612 if (next == true) { 613 next = false; 614 first = edge.first; 615 last = edge.last; 616 prim.forward = true; 617 sort.elems.add(prim); 618 if (prim.outer) { 619 sort.outers++; 620 } else { 621 sort.inners++; 622 } 623 comp = new Comp(cref++, 1); 624 sort.comps.add(comp); 625 } else { 626 if (edge.first == last) { 627 sort.elems.add(prim); 588 628 last = edge.last; 589 629 prim.forward = true; 630 comp.size++; 631 } else if (edge.last == first) { 632 sort.elems.add(top, prim); 633 first = edge.first; 634 prim.forward = true; 635 comp.size++; 636 } else if (edge.last == last) { 590 637 sort.elems.add(prim); 591 if (prim.outer) { 592 sort.outers++; 593 } else { 594 sort.inners++; 638 last = edge.first; 639 prim.forward = false; 640 comp.size++; 641 } else if (edge.first == first) { 642 sort.elems.add(top, prim); 643 first = edge.last; 644 prim.forward = false; 645 comp.size++; 646 } else { 647 outer.elems.add(prim); 648 } 649 } 650 if (--sweep == 0) { 651 sweep = outer.elems.size(); 652 if ((sweep == 0) || (sweep == prev)) { 653 if ((sort.prim == Pflag.AREA) && (first != last)) { 654 return false; 595 655 } 596 comp = new Comp(cref++, 1); 597 sort.comps.add(comp); 598 } else { 599 if (edge.first == last) { 600 sort.elems.add(prim); 601 last = edge.last; 602 prim.forward = true; 603 comp.size++; 604 } else if (edge.last == first) { 605 sort.elems.add(0, prim); 606 first = edge.first; 607 prim.forward = true; 608 comp.size++; 609 } else if (edge.last == last) { 610 sort.elems.add(prim); 611 last = edge.first; 612 prim.forward = false; 613 comp.size++; 614 } else if (edge.first == first) { 615 sort.elems.add(0, prim); 616 first = edge.last; 617 prim.forward = false; 618 comp.size++; 619 } else { 620 feature.geom.elems.add(prim); 656 if (outin) { 657 if (sweep != 0) { 658 return false; 659 } 660 outer = inner; 661 outin = false; 662 sweep = outer.elems.size(); 621 663 } 622 }623 if (--sweep == 0) {624 664 next = true; 625 sweep = feature.geom.elems.size(); 626 } 627 } 628 if ((sort.prim == Pflag.LINE) && (sort.outers == 1) && (sort.inners == 0) && (first == last)) { 629 sort.prim = Pflag.AREA; 630 } 631 feature.geom = sort; 632 } 665 top = sort.elems.size(); 666 } 667 prev = sweep; 668 } 669 } 670 if ((sort.prim == Pflag.LINE) && (sort.outers == 1) && (sort.inners == 0) && (first == last)) { 671 sort.prim = Pflag.AREA; 672 } 673 feature.geom = sort; 633 674 if (feature.geom.prim == Pflag.AREA) { 634 675 int ie = 0; -
applications/editors/josm/plugins/seachart/src/s57/S57osm.java
r31955 r32082 35 35 static { 36 36 OSMtags.put("natural=coastline", new KeyVal<>(Obj.COALNE, Att.UNKATT, null, null)); OSMtags.put("natural=water", new KeyVal<>(Obj.LAKARE, Att.UNKATT, null, null)); 37 OSMtags.put("water=river", new KeyVal<>(Obj.RIVERS, Att.UNKATT, null, null)); OSMtags.put("water=canal", new KeyVal<>(Obj.CANALS, Att.UNKATT, null, null)); 37 38 OSMtags.put("waterway=riverbank", new KeyVal<>(Obj.RIVERS, Att.UNKATT, null, null)); OSMtags.put("waterway=dock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null)); 38 39 OSMtags.put("waterway=lock", new KeyVal<>(Obj.HRBBSN, Att.UNKATT, null, null)); OSMtags.put("landuse=basin", new KeyVal<>(Obj.LAKARE, Att.UNKATT, null, null)); … … 51 52 } 52 53 53 public static KeyVal<?> OSMtag(String key, String val) {54 public static void OSMtag(ArrayList<KeyVal<?>> osm, String key, String val) { 54 55 KeyVal<?> kv = OSMtags.get(key + "=" + val); 55 56 if (kv != null) { … … 57 58 ArrayList<Enum<?>> list = new ArrayList<Enum<?>>(); 58 59 list.add((Enum<?>)kv.val); 59 return new KeyVal<>(kv.obj, kv.att, kv.conv, list); 60 } 61 return kv; 62 } 63 return new KeyVal<>(Obj.UNKOBJ, Att.UNKATT, null, null); 64 } 65 66 public static void OSMmap(BufferedReader in, S57map map) throws Exception { 60 osm.add(new KeyVal<>(kv.obj, kv.att, kv.conv, list)); 61 } else { 62 osm.add(kv); 63 } 64 } 65 KeyVal<?> kvl = null; 66 KeyVal<?> kvd = null; 67 boolean rc = false; 68 boolean rcl = false; 69 for (KeyVal<?> kvx : osm) { 70 if (kvx.obj == Obj.LAKARE) { 71 kvl = kvx; 72 } else if ((kvx.obj == Obj.RIVERS) || (kvx.obj == Obj.CANALS)) { 73 rc = true; 74 } 75 if (kvx.obj == Obj.DEPARE) { 76 kvd = kvx; 77 } else if ((kvx.obj == Obj.RIVERS) || (kvx.obj == Obj.CANALS) || (kvx.obj == Obj.LAKARE)) { 78 rcl = true; 79 } 80 } 81 if (rc && (kvl != null)) { 82 osm.remove(kvl); 83 } 84 if (rcl && (kvd != null)) { 85 osm.remove(kvd); 86 } 87 return; 88 } 89 90 public static void OSMmap(BufferedReader in, S57map map, boolean bb) throws Exception { 67 91 String k = ""; 68 92 String v = ""; … … 84 108 while ((ln = in.readLine()) != null) { 85 109 if (inOsm) { 86 if (ln.contains("<bounds") ) {110 if (ln.contains("<bounds") && !bb) { 87 111 for (String token : ln.split("[ ]+")) { 88 112 if (token.matches("^minlat=.+")) { -
applications/editors/josm/plugins/seachart/src/s57/S57val.java
r31846 r32082 616 616 private static final EnumMap<NatSUR, S57enum> Natsur = new EnumMap<>(NatSUR.class); static { Natsur.put(NatSUR.SUR_UNKN, new S57enum(0, "")); 617 617 Natsur.put(NatSUR.SUR_MUD, new S57enum(1, "mud")); Natsur.put(NatSUR.SUR_CLAY, new S57enum(2, "clay")); Natsur.put(NatSUR.SUR_SILT, new S57enum(3, "silt")); 618 Natsur.put(NatSUR.SUR_SAND, new S57enum(4, "sand")); Natsur.put(NatSUR.SUR_STON, new S57enum(5, "stone ")); Natsur.put(NatSUR.SUR_GRVL, new S57enum(6, "gravel"));619 Natsur.put(NatSUR.SUR_PBBL, new S57enum(7, "pebbles")); Natsur.put(NatSUR.SUR_CBBL, new S57enum(8, "cobbles")); Natsur.put(NatSUR.SUR_ROCK, new S57enum(9, "rock "));618 Natsur.put(NatSUR.SUR_SAND, new S57enum(4, "sand")); Natsur.put(NatSUR.SUR_STON, new S57enum(5, "stones")); Natsur.put(NatSUR.SUR_GRVL, new S57enum(6, "gravel")); 619 Natsur.put(NatSUR.SUR_PBBL, new S57enum(7, "pebbles")); Natsur.put(NatSUR.SUR_CBBL, new S57enum(8, "cobbles")); Natsur.put(NatSUR.SUR_ROCK, new S57enum(9, "rocky")); 620 620 Natsur.put(NatSUR.SUR_LAVA, new S57enum(11, "lava")); Natsur.put(NatSUR.SUR_CORL, new S57enum(14, "coral")); Natsur.put(NatSUR.SUR_SHEL, new S57enum(17, "shells")); 621 Natsur.put(NatSUR.SUR_BLDR, new S57enum(18, "boulder "));621 Natsur.put(NatSUR.SUR_BLDR, new S57enum(18, "boulders")); 622 622 } 623 623 public enum NatQUA { QUA_UNKN, QUA_FINE, QUA_MEDM, QUA_CORS, QUA_BRKN, QUA_STKY, QUA_SOFT, QUA_STIF, QUA_VCNC, QUA_CALC, QUA_HARD } … … 1094 1094 keys.put(Att.LC_DR1, new S57key(Conv.F, null)); keys.put(Att.LC_DR2, new S57key(Conv.F, null)); keys.put(Att.LC_SP1, new S57key(Conv.F, null)); 1095 1095 keys.put(Att.LC_SP2, new S57key(Conv.F, null)); keys.put(Att.LC_WD1, new S57key(Conv.F, null)); keys.put(Att.LC_WD2, new S57key(Conv.F, null)); 1096 keys.put(Att.LITRAD, new S57key(Conv. A, null)); keys.put(Att.CATCVR, new S57key(Conv.E, Catcvr));1096 keys.put(Att.LITRAD, new S57key(Conv.F, null)); keys.put(Att.CATCVR, new S57key(Conv.E, Catcvr)); 1097 1097 } 1098 1098 -
applications/editors/josm/plugins/seachart/src/seachart/ChartImage.java
r31532 r32082 30 30 import render.ChartContext; 31 31 import render.Renderer; 32 import s57.S57map; 32 33 import s57.S57map.*; 34 import s57.S57obj.Obj; 33 35 import symbols.Symbols; 34 36 … … 98 100 } 99 101 100 public Color background() { 101 return (Symbols.Bwater); 102 public Color background(S57map map) { 103 if (map.features.containsKey(Obj.COALNE)) { 104 for (Feature feature : map.features.get(Obj.COALNE)) { 105 if (feature.geom.prim == Pflag.POINT) { 106 break; 107 } 108 GeomIterator git = map.new GeomIterator(feature.geom); 109 git.nextComp(); 110 while (git.hasEdge()) { 111 git.nextEdge(); 112 while (git.hasNode()) { 113 Snode node = git.next(); 114 if (node == null) 115 continue; 116 if ((node.lat >= map.bounds.minlat) && (node.lat <= map.bounds.maxlat) && (node.lon >= map.bounds.minlon) && (node.lon <= map.bounds.maxlon)) { 117 return Symbols.Bwater; 118 } 119 } 120 } 121 } 122 return Symbols.Yland; 123 } else { 124 if (map.features.containsKey(Obj.ROADWY) || map.features.containsKey(Obj.RAILWY) || map.features.containsKey(Obj.LAKARE) || map.features.containsKey(Obj.RIVERS) || map.features.containsKey(Obj.CANALS)) { 125 return Symbols.Yland; 126 } else { 127 return Symbols.Bwater; 128 } 129 } 102 130 } 103 131
Note:
See TracChangeset
for help on using the changeset viewer.