Changeset 30323 in osm
- Timestamp:
- 2014-03-14T12:32:18+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/smed2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/js57toosm/src/js57toosm/Js57toosm.java
r30315 r30323 33 33 ArrayList<Long> done = new ArrayList<Long>(); 34 34 35 if (args.length < 1) {36 System.err.println("Usage: java -jar js57toosm.jar S57_filename [types_filename]");35 if (args.length < 3) { 36 System.err.println("Usage: java -jar js57toosm.jar S57_filename types_filename OSM_filename"); 37 37 System.exit(-1); 38 38 } 39 39 in = new FileInputStream(args[0]); 40 out = System.out;40 out = new PrintStream(args[2]); 41 41 ArrayList<Obj> types = new ArrayList<Obj>(); 42 if (args.length == 2) {43 42 Scanner tin = new Scanner(new FileInputStream(args[1])); 44 43 while (tin.hasNext()) { … … 48 47 } 49 48 tin.close(); 50 }51 49 52 50 map = new S57map(); 53 MapBounds bounds = S57dec.decodeFile(in, types,map);51 MapBounds bounds = S57dec.decodeFile(in, map); 54 52 55 53 out.format("<?xml version='1.0' encoding='UTF-8'?>%n"); … … 168 166 } 169 167 out.println("</osm>\n"); 168 out.close(); 169 System.out.println("Finished"); 170 170 } 171 171 -
applications/editors/josm/plugins/smed2/src/panels/PanelS57.java
r30315 r30323 65 65 } 66 66 map = new S57map(); 67 MapBounds bounds = S57dec.decodeFile(in, types,map);67 MapBounds bounds = S57dec.decodeFile(in, map); 68 68 69 69 in.close(); -
applications/editors/josm/plugins/smed2/src/render/Renderer.java
r30317 r30323 27 27 public static final double symbolScale[] = { 256.0, 128.0, 64.0, 32.0, 16.0, 8.0, 4.0, 2.0, 1.0, 0.61, 0.372, 0.227, 0.138, 0.0843, 0.0514, 0.0313, 0.0191, 0.0117, 0.007, 0.138 }; 28 28 29 static final EnumMap<ColCOL, Color> bodyColours = new EnumMap<ColCOL, Color>(ColCOL.class);30 static {31 bodyColours.put(ColCOL.COL_UNK, new Color(0, true));32 bodyColours.put(ColCOL.COL_WHT, new Color(0xffffff));33 bodyColours.put(ColCOL.COL_BLK, new Color(0x000000));34 bodyColours.put(ColCOL.COL_RED, new Color(0xd40000));35 bodyColours.put(ColCOL.COL_GRN, new Color(0x00d400));36 bodyColours.put(ColCOL.COL_BLU, Color.blue);37 bodyColours.put(ColCOL.COL_YEL, new Color(0xffd400));38 bodyColours.put(ColCOL.COL_GRY, Color.gray);39 bodyColours.put(ColCOL.COL_BRN, new Color(0x8b4513));40 bodyColours.put(ColCOL.COL_AMB, new Color(0xfbf00f));41 bodyColours.put(ColCOL.COL_VIO, new Color(0xee82ee));42 bodyColours.put(ColCOL.COL_ORG, Color.orange);43 bodyColours.put(ColCOL.COL_MAG, new Color(0xf000f0));44 bodyColours.put(ColCOL.COL_PNK, Color.pink);45 }46 47 static final EnumMap<ColPAT, Patt> pattMap = new EnumMap<ColPAT, Patt>(ColPAT.class);48 static {49 pattMap.put(ColPAT.PAT_UNKN, Patt.Z);50 pattMap.put(ColPAT.PAT_HORI, Patt.H);51 pattMap.put(ColPAT.PAT_VERT, Patt.V);52 pattMap.put(ColPAT.PAT_DIAG, Patt.D);53 pattMap.put(ColPAT.PAT_BRDR, Patt.B);54 pattMap.put(ColPAT.PAT_SQUR, Patt.S);55 pattMap.put(ColPAT.PAT_CROS, Patt.C);56 pattMap.put(ColPAT.PAT_SALT, Patt.X);57 pattMap.put(ColPAT.PAT_STRP, Patt.H);58 }59 60 29 public enum LabelStyle { NONE, RRCT, RECT, ELPS, CIRC, VCLR, PCLR, HCLR } 61 30 … … 558 527 } 559 528 } 529 530 public static void lightSector(Feature feature, Color col1, Color col2, double radius, double s1, double s2, boolean dir, String str) { 531 // private static Point2D.Double radial(Feature feature, Snode centre, double radius, double angle) { 532 // Point2D origin = Renderer.context.getPoint(centre); 533 // return new Point2D.Double(origin.getX() - (radius * Renderer.context.mile(feature) * Math.sin(angle)), origin.getY() - (radius * Renderer.context.mile(feature) * Math.cos(angle))); 534 //} 535 536 } 560 537 } -
applications/editors/josm/plugins/smed2/src/render/Rules.java
r30317 r30323 14 14 import java.awt.geom.AffineTransform; 15 15 import java.util.ArrayList; 16 import java.util.EnumMap; 16 17 import java.util.HashMap; 17 18 … … 30 31 public static final Color Mline = new Color(0xc480ff); 31 32 public static final Color Msymb = new Color(0xa30075); 33 34 static final EnumMap<ColCOL, Color> bodyColours = new EnumMap<ColCOL, Color>(ColCOL.class); 35 static { 36 bodyColours.put(ColCOL.COL_UNK, new Color(0, true)); 37 bodyColours.put(ColCOL.COL_WHT, new Color(0xffffff)); 38 bodyColours.put(ColCOL.COL_BLK, new Color(0x000000)); 39 bodyColours.put(ColCOL.COL_RED, new Color(0xd40000)); 40 bodyColours.put(ColCOL.COL_GRN, new Color(0x00d400)); 41 bodyColours.put(ColCOL.COL_BLU, Color.blue); 42 bodyColours.put(ColCOL.COL_YEL, new Color(0xffd400)); 43 bodyColours.put(ColCOL.COL_GRY, Color.gray); 44 bodyColours.put(ColCOL.COL_BRN, new Color(0x8b4513)); 45 bodyColours.put(ColCOL.COL_AMB, new Color(0xfbf00f)); 46 bodyColours.put(ColCOL.COL_VIO, new Color(0xee82ee)); 47 bodyColours.put(ColCOL.COL_ORG, Color.orange); 48 bodyColours.put(ColCOL.COL_MAG, new Color(0xf000f0)); 49 bodyColours.put(ColCOL.COL_PNK, Color.pink); 50 } 51 52 static final EnumMap<ColPAT, Patt> pattMap = new EnumMap<ColPAT, Patt>(ColPAT.class); 53 static { 54 pattMap.put(ColPAT.PAT_UNKN, Patt.Z); 55 pattMap.put(ColPAT.PAT_HORI, Patt.H); 56 pattMap.put(ColPAT.PAT_VERT, Patt.V); 57 pattMap.put(ColPAT.PAT_DIAG, Patt.D); 58 pattMap.put(ColPAT.PAT_BRDR, Patt.B); 59 pattMap.put(ColPAT.PAT_SQUR, Patt.S); 60 pattMap.put(ColPAT.PAT_CROS, Patt.C); 61 pattMap.put(ColPAT.PAT_SALT, Patt.X); 62 pattMap.put(ColPAT.PAT_STRP, Patt.H); 63 } 32 64 33 65 static String getName(Feature feature) { … … 68 100 ArrayList<Color> colours = new ArrayList<Color>(); 69 101 for (ColCOL col : (ArrayList<ColCOL>)getAttVal(feature, obj, 0, Att.COLOUR)) { 70 colours.add( Renderer.bodyColours.get(col));102 colours.add(bodyColours.get(col)); 71 103 } 72 104 ArrayList<Patt> patterns = new ArrayList<Patt>(); 73 105 for(ColPAT pat: (ArrayList<ColPAT>) getAttVal(feature, obj, 0, Att.COLPAT)) { 74 patterns.add( Renderer.pattMap.get(pat));106 patterns.add(pattMap.get(pat)); 75 107 } 76 108 return new Scheme(patterns, colours); … … 1029 1061 Signals.addSignals(feature); 1030 1062 } 1063 /* case CGUSTA: 1064 strcpy(string1, "CG"); 1065 if ((obj != NULL) && (att = getAtt(obj, COMCHA)) != NULL) 1066 sprintf(strchr(string1, 0), " Ch.%s", stringValue(att->val)); 1067 break; 1068 case SISTAT: 1069 strcpy(string1, "SS"); 1070 if (obj != NULL) { 1071 if ((att = getAtt(obj, CATSIT)) != NULL) 1072 strcat(string1, sit_map[att->val.val.l->val]); 1073 if ((att = getAtt(obj, COMCHA)) != NULL) 1074 sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val)); 1075 } 1076 break; 1077 case SISTAW: 1078 strcpy(string1, "SS"); 1079 if (obj != NULL) { 1080 if ((att = getAtt(obj, CATSIW)) != NULL) 1081 strcat(string1, siw_map[att->val.val.l->val]); 1082 if ((att = getAtt(obj, COMCHA)) != NULL) 1083 sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val)); 1084 } 1085 break;*/ 1031 1086 } 1032 1087 -
applications/editors/josm/plugins/smed2/src/render/Signals.java
r30317 r30323 14 14 import java.awt.geom.*; 15 15 import java.util.ArrayList; 16 import java.util.EnumMap; 16 17 17 18 import s57.S57att.*; … … 25 26 public class Signals { 26 27 28 static final EnumMap<ColCOL, Color> lightColours = new EnumMap<ColCOL, Color>(ColCOL.class); 29 static { 30 lightColours.put(ColCOL.COL_WHT, new Color(0xffff00)); 31 lightColours.put(ColCOL.COL_RED, new Color(0xff0000)); 32 lightColours.put(ColCOL.COL_GRN, new Color(0x00ff00)); 33 lightColours.put(ColCOL.COL_BLU, new Color(0x0000ff)); 34 lightColours.put(ColCOL.COL_YEL, new Color(0xffff00)); 35 lightColours.put(ColCOL.COL_AMB, new Color(0xfbf00f)); 36 lightColours.put(ColCOL.COL_VIO, new Color(0xee82ee)); 37 lightColours.put(ColCOL.COL_ORG, Color.orange); 38 lightColours.put(ColCOL.COL_MAG, Color.magenta); 39 } 40 41 static final EnumMap<ColCOL, String> lightLetters = new EnumMap<ColCOL, String>(ColCOL.class); 42 static { 43 lightLetters.put(ColCOL.COL_WHT, "W"); 44 lightLetters.put(ColCOL.COL_RED, "R"); 45 lightLetters.put(ColCOL.COL_GRN, "G"); 46 lightLetters.put(ColCOL.COL_BLU, "Bu"); 47 lightLetters.put(ColCOL.COL_YEL, "Y"); 48 lightLetters.put(ColCOL.COL_AMB, "Am"); 49 lightLetters.put(ColCOL.COL_VIO, "Vi"); 50 lightLetters.put(ColCOL.COL_ORG, "Or"); 51 } 52 53 static final EnumMap<LitCHR, String> lightCharacters = new EnumMap<LitCHR, String>(LitCHR.class); 54 static { 55 lightCharacters.put(LitCHR.CHR_F, "W"); 56 lightCharacters.put(LitCHR.CHR_FL, "Fl"); 57 lightCharacters.put(LitCHR.CHR_LFL, "LFl"); 58 lightCharacters.put(LitCHR.CHR_Q, "Q"); 59 lightCharacters.put(LitCHR.CHR_VQ, "VQ"); 60 lightCharacters.put(LitCHR.CHR_UQ, "UQ"); 61 lightCharacters.put(LitCHR.CHR_ISO, "Iso"); 62 lightCharacters.put(LitCHR.CHR_OC, "Oc"); 63 lightCharacters.put(LitCHR.CHR_IQ, "IQ"); 64 lightCharacters.put(LitCHR.CHR_IVQ, "IVQ"); 65 lightCharacters.put(LitCHR.CHR_IUQ, "IUQ"); 66 lightCharacters.put(LitCHR.CHR_MO, "Mo"); 67 lightCharacters.put(LitCHR.CHR_FFL, "FFl"); 68 lightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl"); 69 lightCharacters.put(LitCHR.CHR_OCFL, "OcFl"); 70 lightCharacters.put(LitCHR.CHR_FLFL, "FLFl"); 71 lightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc"); 72 lightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl"); 73 lightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl"); 74 lightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr"); 75 lightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl"); 76 lightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl"); 77 lightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl"); 78 lightCharacters.put(LitCHR.CHR_AL, "Al"); 79 lightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl"); 80 } 81 27 82 public static void addSignals(Feature feature) { 28 83 if (feature.objs.containsKey(Obj.FOGSIG)) fogSignals(feature); … … 33 88 } 34 89 90 static final EnumMap<CatFOG, String> fogSignals = new EnumMap<CatFOG, String>(CatFOG.class); 91 static { 92 fogSignals.put(CatFOG.FOG_EXPL, "Explos"); 93 fogSignals.put(CatFOG.FOG_DIA, "Dia"); 94 fogSignals.put(CatFOG.FOG_SIRN, "Siren"); 95 fogSignals.put(CatFOG.FOG_NAUT, "Horn"); 96 fogSignals.put(CatFOG.FOG_REED, "Horn"); 97 fogSignals.put(CatFOG.FOG_TYPH, "Horn"); 98 fogSignals.put(CatFOG.FOG_BELL, "Bell"); 99 fogSignals.put(CatFOG.FOG_WHIS, "Whis"); 100 fogSignals.put(CatFOG.FOG_GONG, "Gong"); 101 fogSignals.put(CatFOG.FOG_HORN, "Horn"); 102 } 103 35 104 public static void fogSignals(Feature feature) { 36 105 Renderer.symbol(feature, Beacons.FogSignal); 106 AttMap atts = feature.objs.get(Obj.FOGSIG).get(0); 107 String str = ""; 108 if (atts.containsKey(Att.CATFOG)) { 109 str += fogSignals.get(atts.get(Att.CATFOG).val); 110 } 111 if (atts.containsKey(Att.SIGGRP)) { 112 str += "(" + atts.get(Att.SIGGRP).val + ")"; 113 } else { 114 str += " "; 115 } 116 if (atts.containsKey(Att.SIGPER)) { 117 str += atts.get(Att.SIGPER).val + "s"; 118 } 119 if (atts.containsKey(Att.VALMXR)) { 120 str += atts.get(Att.VALMXR).val + "M"; 121 } 122 if ((Renderer.zoom >= 15) && !str.isEmpty()) { 123 Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40),Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-60, -30))); 124 } 37 125 } 38 126 … … 63 151 } 64 152 if ((Renderer.zoom >= 15) && !bstr.isEmpty()) { 65 Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40),Color.black, new Delta(Handle. BR, AffineTransform.getTranslateInstance(-30, -30)));153 Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40),Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70))); 66 154 } 67 155 } … … 177 265 } 178 266 if (!bstr.isEmpty()) { 179 Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle. BR, AffineTransform.getTranslateInstance(-30, -70)));267 Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -110))); 180 268 } 181 269 } … … 183 271 184 272 public static void lights(Feature feature) { 185 186 } 187 188 // private static Point2D.Double radial(Feature feature, Snode centre, double radius, double angle) { 189 // Point2D origin = Renderer.context.getPoint(centre); 190 // return new Point2D.Double(origin.getX() - (radius * Renderer.context.mile(feature) * Math.sin(angle)), origin.getY() - (radius * Renderer.context.mile(feature) * Math.cos(angle))); 191 // } 192 /* 193 void renderFlare(Item_t *item) { 194 char *col = light_colours[COL_MAG]; 195 Obj_t *obj = getObj(item, LIGHTS, 0); 196 Att_t *att; 197 if (((att = getAtt(obj, COLOUR)) != NULL) && (att->val.val.l->next == NULL)) { 198 col = light_colours[att->val.val.l->val]; 199 } 200 renderSymbol(item, LIGHTS, "light", "", col, CC, 0, 0, 120); 201 } 202 273 Enum<ColCOL> col = null; 274 Enum<ColCOL> tcol = null; 275 ObjTab objs = feature.objs.get(Obj.LIGHTS); 276 for (AttMap atts : objs.values()) { 277 if (atts.containsKey(Att.COLOUR)) { 278 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; 279 if (cols.size() == 1) { 280 tcol = cols.get(0); 281 if (col == null) { 282 col = tcol; 283 } else if (tcol != col) { 284 col = ColCOL.COL_MAG; 285 break; 286 } 287 } else { 288 col = ColCOL.COL_MAG; 289 break; 290 } 291 } 292 } 293 Renderer.symbol(feature, Beacons.LightFlare, new Scheme(lightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120)))); 294 if (objs.get(1) != null) { 295 for (AttMap atts : objs.values()) { 296 Enum<ColCOL> col1 = null; 297 Enum<ColCOL> col2 = null; 298 double radius = 0.2; 299 double s1 = 0; 300 double s2 = 0; 301 boolean dir = false; 302 if (atts.containsKey(Att.COLOUR)) { 303 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val; 304 col1 = cols.get(0); 305 if (cols.size() > 1) col2 = cols.get(1); 306 } else { 307 continue; 308 } 309 if (atts.containsKey(Att.RADIUS)) { 310 radius = (Double) atts.get(Att.RADIUS).val; 311 } 312 if (atts.containsKey(Att.SECTR1)) { 313 s1 = (Double) atts.get(Att.SECTR1).val; 314 } else { 315 continue; 316 } 317 if (atts.containsKey(Att.SECTR2)) { 318 s1 = (Double) atts.get(Att.SECTR2).val; 319 } else { 320 continue; 321 } 322 if (atts.containsKey(Att.CATLIT)) { 323 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val; 324 if (cats.contains(CatLIT.LIT_DIR)) { 325 dir = true; 326 } 327 } 328 Renderer.lightSector(feature, lightColours.get(col1), lightColours.get(col2), radius, s1, s2, dir, ""); 329 } 330 } 331 } 332 333 /* 203 334 void renderSector(Item_t *item, int s, char *text, char *style, double offset, int dy) { 204 335 Obj_t *sector; … … 356 487 Obj_t *obj = getObj(item, enumType(type), idx); 357 488 switch (enumType(type)) { 358 case CGUSTA:359 strcpy(string1, "CG");360 if ((obj != NULL) && (att = getAtt(obj, COMCHA)) != NULL)361 sprintf(strchr(string1, 0), " Ch.%s", stringValue(att->val));362 break;363 case FOGSIG:364 if (obj != NULL) {365 if ((att = getAtt(obj, CATFOG)) != NULL)366 strcat(string1, fog_signals[att->val.val.e]);367 if ((att = getAtt(obj, SIGGRP)) != NULL)368 sprintf(strchr(string1, 0), "(%s)", stringValue(att->val));369 else370 strcat(string1, " ");371 if ((att = getAtt(obj, SIGPER)) != NULL)372 sprintf(strchr(string1, 0), "%ss ", stringValue(att->val));373 if ((att = getAtt(obj, VALMXR)) != NULL)374 sprintf(strchr(string1, 0), "%sM", stringValue(att->val));375 }376 break;377 case SISTAT:378 strcpy(string1, "SS");379 if (obj != NULL) {380 if ((att = getAtt(obj, CATSIT)) != NULL)381 strcat(string1, sit_map[att->val.val.l->val]);382 if ((att = getAtt(obj, COMCHA)) != NULL)383 sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val));384 }385 break;386 case SISTAW:387 strcpy(string1, "SS");388 if (obj != NULL) {389 if ((att = getAtt(obj, CATSIW)) != NULL)390 strcat(string1, siw_map[att->val.val.l->val]);391 if ((att = getAtt(obj, COMCHA)) != NULL)392 sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val));393 }394 break;395 489 case LIGHTS: 396 490 { -
applications/editors/josm/plugins/smed2/src/s57/S57dec.java
r30285 r30323 12 12 import java.io.FileInputStream; 13 13 import java.io.IOException; 14 import java.util.ArrayList;15 14 16 15 import s57.S57dat.*; 17 16 import s57.S57map.*; 18 import s57.S57obj.*;19 17 20 18 public class S57dec { 21 19 22 public static MapBounds decodeFile(FileInputStream in, ArrayList<Obj> types,S57map map) throws IOException {20 public static MapBounds decodeFile(FileInputStream in, S57map map) throws IOException { 23 21 S57dat.rnum = 0; 24 22 byte[] leader = new byte[24]; -
applications/editors/josm/plugins/smed2/src/symbols/Beacons.java
r30285 r30323 16 16 17 17 import symbols.Symbols.*; 18 19 18 import s57.S57val.*; 20 19 … … 69 68 public static final Symbol LightFlare = new Symbol(); 70 69 static { 70 LightFlare.add(new Instr(Form.BBOX, new Rectangle2D.Double(-20,-100,40,100))); 71 71 LightFlare.add(new Instr(Form.RSHP, new Ellipse2D.Double(-3,-3,6,6))); 72 72 Path2D.Double p = new Path2D.Double();
Note:
See TracChangeset
for help on using the changeset viewer.