| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package render;
|
|---|
| 3 |
|
|---|
| 4 | import java.awt.Color;
|
|---|
| 5 | import java.awt.Font;
|
|---|
| 6 | import java.awt.geom.AffineTransform;
|
|---|
| 7 | import java.text.DecimalFormat;
|
|---|
| 8 | import java.util.ArrayList;
|
|---|
| 9 | import java.util.EnumMap;
|
|---|
| 10 |
|
|---|
| 11 | import s57.S57att.Att;
|
|---|
| 12 | import s57.S57map.AttMap;
|
|---|
| 13 | import s57.S57map.ObjTab;
|
|---|
| 14 | import s57.S57obj.Obj;
|
|---|
| 15 | import s57.S57val.BoySHP;
|
|---|
| 16 | import s57.S57val.CatFOG;
|
|---|
| 17 | import s57.S57val.CatLIT;
|
|---|
| 18 | import s57.S57val.CatROS;
|
|---|
| 19 | import s57.S57val.CatRTB;
|
|---|
| 20 | import s57.S57val.ColCOL;
|
|---|
| 21 | import s57.S57val.LitCHR;
|
|---|
| 22 | import symbols.Beacons;
|
|---|
| 23 | import symbols.Symbols;
|
|---|
| 24 | import symbols.Symbols.Delta;
|
|---|
| 25 | import symbols.Symbols.Handle;
|
|---|
| 26 | import symbols.Symbols.Scheme;
|
|---|
| 27 | import symbols.Topmarks;
|
|---|
| 28 |
|
|---|
| 29 | /**
|
|---|
| 30 | * @author Malcolm Herring
|
|---|
| 31 | */
|
|---|
| 32 | public class Signals extends Rules {
|
|---|
| 33 |
|
|---|
| 34 | static final EnumMap<ColCOL, Color> LightColours = new EnumMap<>(ColCOL.class);
|
|---|
| 35 | static {
|
|---|
| 36 | LightColours.put(ColCOL.COL_WHT, new Color(0xffff00));
|
|---|
| 37 | LightColours.put(ColCOL.COL_RED, new Color(0xff0000));
|
|---|
| 38 | LightColours.put(ColCOL.COL_GRN, new Color(0x00ff00));
|
|---|
| 39 | LightColours.put(ColCOL.COL_BLU, new Color(0x0000ff));
|
|---|
| 40 | LightColours.put(ColCOL.COL_YEL, new Color(0xffff00));
|
|---|
| 41 | LightColours.put(ColCOL.COL_AMB, new Color(0xffc200));
|
|---|
| 42 | LightColours.put(ColCOL.COL_VIO, new Color(0xee82ee));
|
|---|
| 43 | LightColours.put(ColCOL.COL_ORG, Color.orange);
|
|---|
| 44 | LightColours.put(ColCOL.COL_MAG, Color.magenta);
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | static final EnumMap<ColCOL, String> LightLetters = new EnumMap<>(ColCOL.class);
|
|---|
| 48 | static {
|
|---|
| 49 | LightLetters.put(ColCOL.COL_WHT, "W");
|
|---|
| 50 | LightLetters.put(ColCOL.COL_RED, "R");
|
|---|
| 51 | LightLetters.put(ColCOL.COL_GRN, "G");
|
|---|
| 52 | LightLetters.put(ColCOL.COL_BLU, "Bu");
|
|---|
| 53 | LightLetters.put(ColCOL.COL_YEL, "Y");
|
|---|
| 54 | LightLetters.put(ColCOL.COL_AMB, "Am");
|
|---|
| 55 | LightLetters.put(ColCOL.COL_VIO, "Vi");
|
|---|
| 56 | LightLetters.put(ColCOL.COL_ORG, "Or");
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | static final EnumMap<LitCHR, String> LightCharacters = new EnumMap<>(LitCHR.class);
|
|---|
| 60 | static {
|
|---|
| 61 | LightCharacters.put(LitCHR.CHR_F, "F");
|
|---|
| 62 | LightCharacters.put(LitCHR.CHR_FL, "Fl");
|
|---|
| 63 | LightCharacters.put(LitCHR.CHR_LFL, "LFl");
|
|---|
| 64 | LightCharacters.put(LitCHR.CHR_Q, "Q");
|
|---|
| 65 | LightCharacters.put(LitCHR.CHR_VQ, "VQ");
|
|---|
| 66 | LightCharacters.put(LitCHR.CHR_UQ, "UQ");
|
|---|
| 67 | LightCharacters.put(LitCHR.CHR_ISO, "Iso");
|
|---|
| 68 | LightCharacters.put(LitCHR.CHR_OC, "Oc");
|
|---|
| 69 | LightCharacters.put(LitCHR.CHR_IQ, "IQ");
|
|---|
| 70 | LightCharacters.put(LitCHR.CHR_IVQ, "IVQ");
|
|---|
| 71 | LightCharacters.put(LitCHR.CHR_IUQ, "IUQ");
|
|---|
| 72 | LightCharacters.put(LitCHR.CHR_MO, "Mo");
|
|---|
| 73 | LightCharacters.put(LitCHR.CHR_FFL, "FFl");
|
|---|
| 74 | LightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl");
|
|---|
| 75 | LightCharacters.put(LitCHR.CHR_OCFL, "OcFl");
|
|---|
| 76 | LightCharacters.put(LitCHR.CHR_FLFL, "FLFl");
|
|---|
| 77 | LightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc");
|
|---|
| 78 | LightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl");
|
|---|
| 79 | LightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl");
|
|---|
| 80 | LightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr");
|
|---|
| 81 | LightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl");
|
|---|
| 82 | LightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl");
|
|---|
| 83 | LightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl");
|
|---|
| 84 | LightCharacters.put(LitCHR.CHR_AL, "Al");
|
|---|
| 85 | LightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl");
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | static final EnumMap<CatFOG, String> fogSignals = new EnumMap<>(CatFOG.class);
|
|---|
| 89 | static {
|
|---|
| 90 | fogSignals.put(CatFOG.FOG_EXPL, "Explos");
|
|---|
| 91 | fogSignals.put(CatFOG.FOG_DIA, "Dia");
|
|---|
| 92 | fogSignals.put(CatFOG.FOG_SIRN, "Siren");
|
|---|
| 93 | fogSignals.put(CatFOG.FOG_NAUT, "Horn");
|
|---|
| 94 | fogSignals.put(CatFOG.FOG_REED, "Horn");
|
|---|
| 95 | fogSignals.put(CatFOG.FOG_TYPH, "Horn");
|
|---|
| 96 | fogSignals.put(CatFOG.FOG_BELL, "Bell");
|
|---|
| 97 | fogSignals.put(CatFOG.FOG_WHIS, "Whis");
|
|---|
| 98 | fogSignals.put(CatFOG.FOG_GONG, "Gong");
|
|---|
| 99 | fogSignals.put(CatFOG.FOG_HORN, "Horn");
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | static final DecimalFormat df = new DecimalFormat("#.#");
|
|---|
| 103 |
|
|---|
| 104 | public static void addSignals() {
|
|---|
| 105 | if (feature.objs.containsKey(Obj.RADRFL)) reflectors();
|
|---|
| 106 | if (feature.objs.containsKey(Obj.FOGSIG)) fogSignals();
|
|---|
| 107 | if (feature.objs.containsKey(Obj.RTPBCN)) radarStations();
|
|---|
| 108 | if (feature.objs.containsKey(Obj.RADSTA)) radarStations();
|
|---|
| 109 | if (feature.objs.containsKey(Obj.RDOSTA)) radioStations();
|
|---|
| 110 | if (feature.objs.containsKey(Obj.LIGHTS)) lights();
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | public static void reflectors() {
|
|---|
| 114 | if (Renderer.zoom >= 14) {
|
|---|
| 115 | switch (feature.type) {
|
|---|
| 116 | case BCNLAT:
|
|---|
| 117 | case BCNCAR:
|
|---|
| 118 | case BCNISD:
|
|---|
| 119 | case BCNSAW:
|
|---|
| 120 | case BCNSPP:
|
|---|
| 121 | if ((feature.objs.containsKey(Obj.TOPMAR)) || (feature.objs.containsKey(Obj.DAYMAR))) {
|
|---|
| 122 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -140)));
|
|---|
| 123 | } else {
|
|---|
| 124 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -80)));
|
|---|
| 125 | }
|
|---|
| 126 | break;
|
|---|
| 127 | case LITFLT:
|
|---|
| 128 | case LITVES:
|
|---|
| 129 | case BOYINB:
|
|---|
| 130 | if ((feature.objs.containsKey(Obj.TOPMAR)) || (feature.objs.containsKey(Obj.DAYMAR))) {
|
|---|
| 131 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -110)));
|
|---|
| 132 | } else {
|
|---|
| 133 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -60)));
|
|---|
| 134 | }
|
|---|
| 135 | break;
|
|---|
| 136 | case LITMAJ:
|
|---|
| 137 | case LITMIN:
|
|---|
| 138 | if ((feature.objs.containsKey(Obj.TOPMAR)) || (feature.objs.containsKey(Obj.DAYMAR))) {
|
|---|
| 139 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));
|
|---|
| 140 | } else {
|
|---|
| 141 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -30)));
|
|---|
| 142 | }
|
|---|
| 143 | break;
|
|---|
| 144 | case BOYLAT:
|
|---|
| 145 | case BOYCAR:
|
|---|
| 146 | case BOYISD:
|
|---|
| 147 | case BOYSAW:
|
|---|
| 148 | case BOYSPP:
|
|---|
| 149 | if ((feature.objs.containsKey(Obj.TOPMAR)) || (feature.objs.containsKey(Obj.DAYMAR))) {
|
|---|
| 150 | if (testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_PILR) || testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_SPAR)) {
|
|---|
| 151 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(50, -160)));
|
|---|
| 152 | } else {
|
|---|
| 153 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(25, -80)));
|
|---|
| 154 | }
|
|---|
| 155 | } else {
|
|---|
| 156 | if (testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_PILR) || testAttribute(feature.type, Att.BOYSHP, BoySHP.BOY_SPAR)) {
|
|---|
| 157 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(30, -100)));
|
|---|
| 158 | } else {
|
|---|
| 159 | Renderer.symbol(Topmarks.RadarReflector, new Delta(Handle.BC, AffineTransform.getTranslateInstance(10, -50)));
|
|---|
| 160 | }
|
|---|
| 161 | }
|
|---|
| 162 | break;
|
|---|
| 163 | default:
|
|---|
| 164 | break;
|
|---|
| 165 | }
|
|---|
| 166 | }
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | public static void fogSignals() {
|
|---|
| 170 | if (Renderer.zoom >= 11)
|
|---|
| 171 | Renderer.symbol(Beacons.FogSignal);
|
|---|
| 172 | if (Renderer.zoom >= 15) {
|
|---|
| 173 | AttMap atts = feature.objs.get(Obj.FOGSIG).get(0);
|
|---|
| 174 | if (atts != null) {
|
|---|
| 175 | String str = "";
|
|---|
| 176 | if (atts.containsKey(Att.CATFOG)) {
|
|---|
| 177 | str += fogSignals.get(((ArrayList<?>) (atts.get(Att.CATFOG).val)).get(0));
|
|---|
| 178 | }
|
|---|
| 179 | if (atts.containsKey(Att.SIGGRP)) {
|
|---|
| 180 | str += "(" + atts.get(Att.SIGGRP).val + ")";
|
|---|
| 181 | } else {
|
|---|
| 182 | str += " ";
|
|---|
| 183 | }
|
|---|
| 184 | if (atts.containsKey(Att.SIGPER)) {
|
|---|
| 185 | str += df.format(atts.get(Att.SIGPER).val) + "s";
|
|---|
| 186 | }
|
|---|
| 187 | if (atts.containsKey(Att.VALMXR)) {
|
|---|
| 188 | str += df.format(atts.get(Att.VALMXR).val) + "M";
|
|---|
| 189 | }
|
|---|
| 190 | if (!str.isEmpty()) {
|
|---|
| 191 | Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black,
|
|---|
| 192 | new Delta(Handle.TR, AffineTransform.getTranslateInstance(-60, -30)));
|
|---|
| 193 | }
|
|---|
| 194 | }
|
|---|
| 195 | }
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | public static void radarStations() {
|
|---|
| 199 | if (Renderer.zoom >= 11)
|
|---|
| 200 | Renderer.symbol(Beacons.RadarStation);
|
|---|
| 201 | if (Renderer.zoom >= 15) {
|
|---|
| 202 | String bstr = "";
|
|---|
| 203 | CatRTB cat = (CatRTB) getAttEnum(Obj.RTPBCN, Att.CATRTB);
|
|---|
| 204 | String wal = getAttStr(Obj.RTPBCN, Att.RADWAL);
|
|---|
| 205 | switch (cat) {
|
|---|
| 206 | case RTB_RAMK:
|
|---|
| 207 | bstr += " Ramark";
|
|---|
| 208 | break;
|
|---|
| 209 | case RTB_RACN:
|
|---|
| 210 | bstr += " Racon";
|
|---|
| 211 | String astr = getAttStr(Obj.RTPBCN, Att.SIGGRP);
|
|---|
| 212 | if (!astr.isEmpty()) {
|
|---|
| 213 | bstr += "(" + astr + ")";
|
|---|
| 214 | }
|
|---|
| 215 | Double per = (Double) getAttVal(Obj.RTPBCN, Att.SIGPER);
|
|---|
| 216 | Double mxr = (Double) getAttVal(Obj.RTPBCN, Att.VALMXR);
|
|---|
| 217 | if ((per != null) || (mxr != null)) {
|
|---|
| 218 | bstr += (astr.isEmpty() ? " " : "");
|
|---|
| 219 | if (per != null)
|
|---|
| 220 | bstr += (per != 0) ? per.toString() + "s" : "";
|
|---|
| 221 | if (mxr != null)
|
|---|
| 222 | bstr += (mxr != 0) ? mxr.toString() + "M" : "";
|
|---|
| 223 | }
|
|---|
| 224 | break;
|
|---|
| 225 | default:
|
|---|
| 226 | break;
|
|---|
| 227 | }
|
|---|
| 228 | if (!wal.isEmpty()) {
|
|---|
| 229 | switch (wal) {
|
|---|
| 230 | case "0.03-X":
|
|---|
| 231 | bstr += "(3cm)";
|
|---|
| 232 | break;
|
|---|
| 233 | case "0.10-S":
|
|---|
| 234 | bstr += "(10cm)";
|
|---|
| 235 | break;
|
|---|
| 236 | }
|
|---|
| 237 | }
|
|---|
| 238 | if (!bstr.isEmpty()) {
|
|---|
| 239 | Renderer.labelText(bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb,
|
|---|
| 240 | new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
|
|---|
| 241 | }
|
|---|
| 242 | }
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | @SuppressWarnings("unchecked")
|
|---|
| 246 | public static void radioStations() {
|
|---|
| 247 | boolean vais = false;
|
|---|
| 248 | String bstr = "";
|
|---|
| 249 | if (Renderer.zoom >= 11) {
|
|---|
| 250 | ArrayList<CatROS> cats = (ArrayList<CatROS>) getAttList(Obj.RDOSTA, Att.CATROS);
|
|---|
| 251 | for (CatROS ros : cats) {
|
|---|
| 252 | switch (ros) {
|
|---|
| 253 | case ROS_OMNI:
|
|---|
| 254 | bstr += " RC";
|
|---|
| 255 | break;
|
|---|
| 256 | case ROS_DIRL:
|
|---|
| 257 | bstr += " RD";
|
|---|
| 258 | break;
|
|---|
| 259 | case ROS_ROTP:
|
|---|
| 260 | bstr += " RW";
|
|---|
| 261 | break;
|
|---|
| 262 | case ROS_CNSL:
|
|---|
| 263 | bstr += " Consol";
|
|---|
| 264 | break;
|
|---|
| 265 | case ROS_RDF:
|
|---|
| 266 | bstr += " RG";
|
|---|
| 267 | break;
|
|---|
| 268 | case ROS_QTA:
|
|---|
| 269 | bstr += " R";
|
|---|
| 270 | break;
|
|---|
| 271 | case ROS_AERO:
|
|---|
| 272 | bstr += " AeroRC";
|
|---|
| 273 | break;
|
|---|
| 274 | case ROS_DECA:
|
|---|
| 275 | bstr += " Decca";
|
|---|
| 276 | break;
|
|---|
| 277 | case ROS_LORN:
|
|---|
| 278 | bstr += " Loran";
|
|---|
| 279 | break;
|
|---|
| 280 | case ROS_DGPS:
|
|---|
| 281 | bstr += " DGPS";
|
|---|
| 282 | break;
|
|---|
| 283 | case ROS_TORN:
|
|---|
| 284 | bstr += " Toran";
|
|---|
| 285 | break;
|
|---|
| 286 | case ROS_OMGA:
|
|---|
| 287 | bstr += " Omega";
|
|---|
| 288 | break;
|
|---|
| 289 | case ROS_SYLD:
|
|---|
| 290 | bstr += " Syledis";
|
|---|
| 291 | break;
|
|---|
| 292 | case ROS_CHKA:
|
|---|
| 293 | bstr += " Chiaka";
|
|---|
| 294 | break;
|
|---|
| 295 | case ROS_PCOM:
|
|---|
| 296 | case ROS_COMB:
|
|---|
| 297 | case ROS_FACS:
|
|---|
| 298 | case ROS_TIME:
|
|---|
| 299 | break;
|
|---|
| 300 | case ROS_PAIS:
|
|---|
| 301 | case ROS_SAIS:
|
|---|
| 302 | bstr += " AIS";
|
|---|
| 303 | break;
|
|---|
| 304 | case ROS_VAIS:
|
|---|
| 305 | vais = true;
|
|---|
| 306 | break;
|
|---|
| 307 | case ROS_VANC:
|
|---|
| 308 | vais = true;
|
|---|
| 309 | Renderer.symbol(Topmarks.TopNorth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 310 | break;
|
|---|
| 311 | case ROS_VASC:
|
|---|
| 312 | vais = true;
|
|---|
| 313 | Renderer.symbol(Topmarks.TopSouth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 314 | break;
|
|---|
| 315 | case ROS_VAEC:
|
|---|
| 316 | vais = true;
|
|---|
| 317 | Renderer.symbol(Topmarks.TopEast, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 318 | break;
|
|---|
| 319 | case ROS_VAWC:
|
|---|
| 320 | vais = true;
|
|---|
| 321 | Renderer.symbol(Topmarks.TopWest, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 322 | break;
|
|---|
| 323 | case ROS_VAPL:
|
|---|
| 324 | vais = true;
|
|---|
| 325 | Renderer.symbol(Topmarks.TopCan, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 326 | break;
|
|---|
| 327 | case ROS_VASL:
|
|---|
| 328 | vais = true;
|
|---|
| 329 | Renderer.symbol(Topmarks.TopCone, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 330 | break;
|
|---|
| 331 | case ROS_VAID:
|
|---|
| 332 | vais = true;
|
|---|
| 333 | Renderer.symbol(Topmarks.TopIsol, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 334 | break;
|
|---|
| 335 | case ROS_VASW:
|
|---|
| 336 | vais = true;
|
|---|
| 337 | Renderer.symbol(Topmarks.TopSphere, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 338 | break;
|
|---|
| 339 | case ROS_VASP:
|
|---|
| 340 | vais = true;
|
|---|
| 341 | Renderer.symbol(Topmarks.TopX, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 342 | break;
|
|---|
| 343 | case ROS_VAWK:
|
|---|
| 344 | vais = true;
|
|---|
| 345 | Renderer.symbol(Topmarks.TopCross, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 346 | break;
|
|---|
| 347 | default:
|
|---|
| 348 | break;
|
|---|
| 349 | }
|
|---|
| 350 | }
|
|---|
| 351 | if (!vais) {
|
|---|
| 352 | Renderer.symbol(Beacons.RadarStation);
|
|---|
| 353 | }
|
|---|
| 354 | }
|
|---|
| 355 | if (Renderer.zoom >= 15) {
|
|---|
| 356 | if (vais) {
|
|---|
| 357 | Renderer.labelText("V-AIS", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb,
|
|---|
| 358 | new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 359 | }
|
|---|
| 360 | if (!bstr.isEmpty()) {
|
|---|
| 361 | Renderer.labelText(bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb,
|
|---|
| 362 | new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -110)));
|
|---|
| 363 | }
|
|---|
| 364 | }
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | static class Sect {
|
|---|
| 368 | int dir;
|
|---|
| 369 | LitCHR chr;
|
|---|
| 370 | ColCOL col;
|
|---|
| 371 | ColCOL alt;
|
|---|
| 372 | String grp;
|
|---|
| 373 | double per;
|
|---|
| 374 | double rng;
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | @SuppressWarnings("unchecked")
|
|---|
| 378 | public static void lights() {
|
|---|
| 379 | Enum<ColCOL> col = null;
|
|---|
| 380 | Enum<ColCOL> tcol = null;
|
|---|
| 381 | ObjTab lights = feature.objs.get(Obj.LIGHTS);
|
|---|
| 382 | for (AttMap atts : lights.values()) {
|
|---|
| 383 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 384 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
|---|
| 385 | if (cols.size() == 1) {
|
|---|
| 386 | tcol = cols.get(0);
|
|---|
| 387 | if (col == null) {
|
|---|
| 388 | col = tcol;
|
|---|
| 389 | } else if (tcol != col) {
|
|---|
| 390 | col = ColCOL.COL_MAG;
|
|---|
| 391 | break;
|
|---|
| 392 | }
|
|---|
| 393 | } else {
|
|---|
| 394 | col = ColCOL.COL_MAG;
|
|---|
| 395 | break;
|
|---|
| 396 | }
|
|---|
| 397 | }
|
|---|
| 398 | }
|
|---|
| 399 | Renderer.symbol(Beacons.LightFlare, new Scheme(LightColours.get(col)),
|
|---|
| 400 | new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
|
|---|
| 401 | if (Renderer.zoom >= 12) {
|
|---|
| 402 | String str = "";
|
|---|
| 403 | if (lights.get(1) != null) {
|
|---|
| 404 | for (AttMap atts : lights.values()) {
|
|---|
| 405 | Enum<ColCOL> col1 = null;
|
|---|
| 406 | Enum<ColCOL> col2 = null;
|
|---|
| 407 | double radius = 0.2;
|
|---|
| 408 | double s1 = 361;
|
|---|
| 409 | double s2 = 361;
|
|---|
| 410 | Double dir = null;
|
|---|
| 411 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 412 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
|---|
| 413 | col1 = cols.get(0);
|
|---|
| 414 | if (cols.size() > 1)
|
|---|
| 415 | col2 = cols.get(1);
|
|---|
| 416 | } else {
|
|---|
| 417 | continue;
|
|---|
| 418 | }
|
|---|
| 419 | if (atts.containsKey(Att.LITRAD)) {
|
|---|
| 420 | radius = (Double) atts.get(Att.LITRAD).val;
|
|---|
| 421 | }
|
|---|
| 422 | if (atts.containsKey(Att.CATLIT)) {
|
|---|
| 423 | ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
|
|---|
| 424 | if (cats.contains(CatLIT.LIT_DIR)) {
|
|---|
| 425 | if (atts.containsKey(Att.ORIENT)) {
|
|---|
| 426 | dir = (Double) atts.get(Att.ORIENT).val;
|
|---|
| 427 | s1 = ((dir - 4) + 360) % 360;
|
|---|
| 428 | s2 = (dir + 4) % 360;
|
|---|
| 429 | for (AttMap satts : lights.values()) {
|
|---|
| 430 | double srad = 0.2;
|
|---|
| 431 | double ss1 = 361;
|
|---|
| 432 | double ss2 = 361;
|
|---|
| 433 | Double sdir = null;
|
|---|
| 434 | if (satts == atts)
|
|---|
| 435 | continue;
|
|---|
| 436 | if (satts.containsKey(Att.LITRAD)) {
|
|---|
| 437 | srad = (Double) satts.get(Att.LITRAD).val;
|
|---|
| 438 | }
|
|---|
| 439 | if (srad == radius) {
|
|---|
| 440 | ArrayList<CatLIT> scats = (satts.containsKey(Att.CATLIT)) ?
|
|---|
| 441 | (ArrayList<CatLIT>) satts.get(Att.CATLIT).val : new ArrayList<>();
|
|---|
| 442 | if (scats.contains(CatLIT.LIT_DIR)) {
|
|---|
| 443 | if (satts.containsKey(Att.ORIENT)) {
|
|---|
| 444 | sdir = (Double) satts.get(Att.ORIENT).val;
|
|---|
| 445 | ss1 = sdir;
|
|---|
| 446 | ss2 = sdir;
|
|---|
| 447 | }
|
|---|
| 448 | } else {
|
|---|
| 449 | if (satts.containsKey(Att.SECTR1)) {
|
|---|
| 450 | ss1 = (Double) satts.get(Att.SECTR1).val;
|
|---|
| 451 | }
|
|---|
| 452 | if (satts.containsKey(Att.SECTR2)) {
|
|---|
| 453 | ss2 = (Double) satts.get(Att.SECTR2).val;
|
|---|
| 454 | }
|
|---|
| 455 | }
|
|---|
| 456 | if ((ss1 > 360) || (ss2 > 360))
|
|---|
| 457 | continue;
|
|---|
| 458 | if (sdir != null) {
|
|---|
| 459 | if (((dir - sdir + 360) % 360) < 8) {
|
|---|
| 460 | s1 = ((((sdir > dir) ? 360 : 0) + sdir + dir) / 2) % 360;
|
|---|
| 461 | }
|
|---|
| 462 | if (((sdir - dir + 360) % 360) < 8) {
|
|---|
| 463 | s2 = ((((dir > sdir) ? 360 : 0) + sdir + dir) / 2) % 360;
|
|---|
| 464 | }
|
|---|
| 465 | } else {
|
|---|
| 466 | if (((dir - ss2 + 360) % 360) < 4) {
|
|---|
| 467 | s1 = ss2;
|
|---|
| 468 | }
|
|---|
| 469 | if (((ss1 - dir + 360) % 360) < 4) {
|
|---|
| 470 | s2 = ss1;
|
|---|
| 471 | }
|
|---|
| 472 | }
|
|---|
| 473 | }
|
|---|
| 474 | }
|
|---|
| 475 | }
|
|---|
| 476 | }
|
|---|
| 477 | }
|
|---|
| 478 | if ((s1 > 360) && atts.containsKey(Att.SECTR1)) {
|
|---|
| 479 | s1 = (Double) atts.get(Att.SECTR1).val;
|
|---|
| 480 | } else if (dir == null) {
|
|---|
| 481 | continue;
|
|---|
| 482 | }
|
|---|
| 483 | if ((s2 > 360) && atts.containsKey(Att.SECTR2)) {
|
|---|
| 484 | s2 = (Double) atts.get(Att.SECTR2).val;
|
|---|
| 485 | } else if (dir == null) {
|
|---|
| 486 | continue;
|
|---|
| 487 | }
|
|---|
| 488 | str = "";
|
|---|
| 489 | if (atts.containsKey(Att.LITCHR)) {
|
|---|
| 490 | str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
|
|---|
| 491 | }
|
|---|
| 492 | if (atts.containsKey(Att.SIGGRP)) {
|
|---|
| 493 | str += "(" + atts.get(Att.SIGGRP).val + ")";
|
|---|
| 494 | } else if (!str.isEmpty()) {
|
|---|
| 495 | str += ".";
|
|---|
| 496 | }
|
|---|
| 497 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 498 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
|---|
| 499 | str += LightLetters.get(cols.get(0));
|
|---|
| 500 | if (cols.size() > 1)
|
|---|
| 501 | str += LightLetters.get(cols.get(1));
|
|---|
| 502 | }
|
|---|
| 503 | if (atts.containsKey(Att.SIGPER)) {
|
|---|
| 504 | str += "." + df.format(atts.get(Att.SIGPER).val) + "s";
|
|---|
| 505 | }
|
|---|
| 506 | if ((s1 <= 360) && (s2 <= 360) && (s1 != s2))
|
|---|
| 507 | Renderer.lightSector(LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir,
|
|---|
| 508 | (Renderer.zoom >= 15) ? str : "");
|
|---|
| 509 | }
|
|---|
| 510 | if (Renderer.zoom >= 15) {
|
|---|
| 511 | class LitSect {
|
|---|
| 512 | boolean dir;
|
|---|
| 513 | LitCHR chr;
|
|---|
| 514 | ColCOL col;
|
|---|
| 515 | String grp;
|
|---|
| 516 | double per;
|
|---|
| 517 | double rng;
|
|---|
| 518 | double hgt;
|
|---|
| 519 | }
|
|---|
| 520 |
|
|---|
| 521 | ArrayList<LitSect> litatts = new ArrayList<>();
|
|---|
| 522 | for (AttMap atts : lights.values()) {
|
|---|
| 523 | LitSect sect = new LitSect();
|
|---|
| 524 | sect.dir = (atts.containsKey(Att.CATLIT) && ((ArrayList<CatLIT>) atts.get(Att.CATLIT).val).contains(CatLIT.LIT_DIR));
|
|---|
| 525 | sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN;
|
|---|
| 526 | switch (sect.chr) {
|
|---|
| 527 | case CHR_AL:
|
|---|
| 528 | sect.chr = LitCHR.CHR_F;
|
|---|
| 529 | break;
|
|---|
| 530 | case CHR_ALOC:
|
|---|
| 531 | sect.chr = LitCHR.CHR_OC;
|
|---|
| 532 | break;
|
|---|
| 533 | case CHR_ALLFL:
|
|---|
| 534 | sect.chr = LitCHR.CHR_LFL;
|
|---|
| 535 | break;
|
|---|
| 536 | case CHR_ALFL:
|
|---|
| 537 | sect.chr = LitCHR.CHR_FL;
|
|---|
| 538 | break;
|
|---|
| 539 | case CHR_ALFFL:
|
|---|
| 540 | sect.chr = LitCHR.CHR_FFL;
|
|---|
| 541 | break;
|
|---|
| 542 | default:
|
|---|
| 543 | break;
|
|---|
| 544 | }
|
|---|
| 545 | sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
|
|---|
| 546 | sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
|
|---|
| 547 | sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
|
|---|
| 548 | sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
|
|---|
| 549 | ArrayList<ColCOL> cols = (ArrayList<ColCOL>)
|
|---|
| 550 | (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>());
|
|---|
| 551 | sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
|
|---|
| 552 | if ((sect.chr != LitCHR.CHR_UNKN) && (sect.col != null))
|
|---|
| 553 | litatts.add(sect);
|
|---|
| 554 | }
|
|---|
| 555 | ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
|
|---|
| 556 | for (LitSect lit : litatts) {
|
|---|
| 557 | boolean found = false;
|
|---|
| 558 | for (ArrayList<LitSect> group : groupings) {
|
|---|
| 559 | LitSect mem = group.get(0);
|
|---|
| 560 | if ((lit.dir == mem.dir) && (lit.chr == mem.chr) && (lit.grp.equals(mem.grp)) &&
|
|---|
| 561 | (lit.per == mem.per) && (lit.hgt == mem.hgt)) {
|
|---|
| 562 | group.add(lit);
|
|---|
| 563 | found = true;
|
|---|
| 564 | }
|
|---|
| 565 | }
|
|---|
| 566 | if (!found) {
|
|---|
| 567 | ArrayList<LitSect> tmp = new ArrayList<>();
|
|---|
| 568 | tmp.add(lit);
|
|---|
| 569 | groupings.add(tmp);
|
|---|
| 570 | }
|
|---|
| 571 | }
|
|---|
| 572 | for (boolean moved = true; moved;) {
|
|---|
| 573 | moved = false;
|
|---|
| 574 | for (int i = 0; i < groupings.size() - 1; i++) {
|
|---|
| 575 | if (groupings.get(i).size() < groupings.get(i + 1).size()) {
|
|---|
| 576 | ArrayList<LitSect> tmp = groupings.remove(i);
|
|---|
| 577 | groupings.add(i + 1, tmp);
|
|---|
| 578 | moved = true;
|
|---|
| 579 | }
|
|---|
| 580 | }
|
|---|
| 581 | }
|
|---|
| 582 | class ColRng {
|
|---|
| 583 | ColCOL col;
|
|---|
| 584 | double rng;
|
|---|
| 585 |
|
|---|
| 586 | ColRng(ColCOL c, double r) {
|
|---|
| 587 | col = c;
|
|---|
| 588 | rng = r;
|
|---|
| 589 | }
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | int y = -30;
|
|---|
| 593 | for (ArrayList<LitSect> group : groupings) {
|
|---|
| 594 | ArrayList<ColRng> colrng = new ArrayList<>();
|
|---|
| 595 | for (LitSect lit : group) {
|
|---|
| 596 | boolean found = false;
|
|---|
| 597 | for (ColRng cr : colrng) {
|
|---|
| 598 | if (cr.col == lit.col) {
|
|---|
| 599 | if (lit.rng > cr.rng) {
|
|---|
| 600 | cr.rng = lit.rng;
|
|---|
| 601 | }
|
|---|
| 602 | found = true;
|
|---|
| 603 | }
|
|---|
| 604 | }
|
|---|
| 605 | if (!found) {
|
|---|
| 606 | colrng.add(new ColRng(lit.col, lit.rng));
|
|---|
| 607 | }
|
|---|
| 608 | }
|
|---|
| 609 | for (boolean moved = true; moved;) {
|
|---|
| 610 | moved = false;
|
|---|
| 611 | for (int i = 0; i < colrng.size() - 1; i++) {
|
|---|
| 612 | if (colrng.get(i).rng < colrng.get(i + 1).rng) {
|
|---|
| 613 | ColRng tmp = colrng.remove(i);
|
|---|
| 614 | colrng.add(i + 1, tmp);
|
|---|
| 615 | moved = true;
|
|---|
| 616 | }
|
|---|
| 617 | }
|
|---|
| 618 | }
|
|---|
| 619 | LitSect tmp = group.get(0);
|
|---|
| 620 | str = (tmp.dir) ? "Dir" : "";
|
|---|
| 621 | str += LightCharacters.get(tmp.chr);
|
|---|
| 622 | if (!tmp.grp.isEmpty())
|
|---|
| 623 | str += "(" + tmp.grp + ")";
|
|---|
| 624 | else
|
|---|
| 625 | str += ".";
|
|---|
| 626 | for (ColRng cr : colrng) {
|
|---|
| 627 | str += LightLetters.get(cr.col);
|
|---|
| 628 | }
|
|---|
| 629 | if ((tmp.per > 0) || (tmp.hgt > 0) || (colrng.get(0).rng > 0))
|
|---|
| 630 | str += ".";
|
|---|
| 631 | if (tmp.per > 0)
|
|---|
| 632 | str += df.format(tmp.per) + "s";
|
|---|
| 633 | if (tmp.hgt > 0)
|
|---|
| 634 | str += df.format(tmp.hgt) + "m";
|
|---|
| 635 | if (colrng.get(0).rng > 0)
|
|---|
| 636 | str += df.format(colrng.get(0).rng) + ((colrng.size() > 1) ? ((colrng.size() > 2) ?
|
|---|
| 637 | ("-" + df.format(colrng.get(colrng.size() - 1).rng)) : ("/" + df.format(colrng.get(1).rng))) : "") + "M";
|
|---|
| 638 | Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black,
|
|---|
| 639 | new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
|
|---|
| 640 | y += 40;
|
|---|
| 641 | str = "";
|
|---|
| 642 | }
|
|---|
| 643 | }
|
|---|
| 644 | } else {
|
|---|
| 645 | if (Renderer.zoom >= 15) {
|
|---|
| 646 | AttMap atts = lights.get(0);
|
|---|
| 647 | ArrayList<CatLIT> cats = new ArrayList<>();
|
|---|
| 648 | if (atts.containsKey(Att.CATLIT)) {
|
|---|
| 649 | cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
|
|---|
| 650 | }
|
|---|
| 651 | str = (cats.contains(CatLIT.LIT_DIR)) ? "Dir" : "";
|
|---|
| 652 | str += (atts.containsKey(Att.MLTYLT)) ? atts.get(Att.MLTYLT).val : "";
|
|---|
| 653 | if (atts.containsKey(Att.LITCHR)) {
|
|---|
| 654 | LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
|
|---|
| 655 | if (atts.containsKey(Att.SIGGRP)) {
|
|---|
| 656 | String grp = (String) atts.get(Att.SIGGRP).val;
|
|---|
| 657 | switch (chr) {
|
|---|
| 658 | case CHR_QLFL:
|
|---|
| 659 | str += String.format("Q(%s)+LFl", grp);
|
|---|
| 660 | break;
|
|---|
| 661 | case CHR_VQLFL:
|
|---|
| 662 | str += String.format("VQ(%s)+LFl", grp);
|
|---|
| 663 | break;
|
|---|
| 664 | case CHR_UQLFL:
|
|---|
| 665 | str += String.format("UQ(%s)+LFl", grp);
|
|---|
| 666 | break;
|
|---|
| 667 | default:
|
|---|
| 668 | str += String.format("%s(%s)", LightCharacters.get(chr), grp);
|
|---|
| 669 | break;
|
|---|
| 670 | }
|
|---|
| 671 | } else {
|
|---|
| 672 | str += LightCharacters.get(chr);
|
|---|
| 673 | }
|
|---|
| 674 | }
|
|---|
| 675 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 676 | ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
|
|---|
| 677 | if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
|
|---|
| 678 | if (!str.isEmpty() && !str.endsWith(")")) {
|
|---|
| 679 | str += ".";
|
|---|
| 680 | }
|
|---|
| 681 | for (ColCOL acol : cols) {
|
|---|
| 682 | str += LightLetters.get(acol);
|
|---|
| 683 | }
|
|---|
| 684 | }
|
|---|
| 685 | }
|
|---|
| 686 | str += (cats.contains(CatLIT.LIT_VERT)) ? "(vert)" : "";
|
|---|
| 687 | str += (cats.contains(CatLIT.LIT_HORI)) ? "(hor)" : "";
|
|---|
| 688 | str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR))
|
|---|
| 689 | && !str.endsWith(")")) ? "." : "";
|
|---|
| 690 | str += (atts.containsKey(Att.SIGPER)) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
|
|---|
| 691 | str += (atts.containsKey(Att.HEIGHT)) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
|
|---|
| 692 | str += (atts.containsKey(Att.VALNMR)) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
|
|---|
| 693 | str += (cats.contains(CatLIT.LIT_FRNT)) ? "(Front)" : "";
|
|---|
| 694 | str += (cats.contains(CatLIT.LIT_REAR)) ? "(Rear)" : "";
|
|---|
| 695 | str += (cats.contains(CatLIT.LIT_UPPR)) ? "(Upper)" : "";
|
|---|
| 696 | str += (cats.contains(CatLIT.LIT_LOWR)) ? "(Lower)" : "";
|
|---|
| 697 | Renderer.labelText(str, new Font("Arial", Font.PLAIN, 40), Color.black,
|
|---|
| 698 | new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
|
|---|
| 699 | }
|
|---|
| 700 | }
|
|---|
| 701 | }
|
|---|
| 702 | }
|
|---|
| 703 | }
|
|---|