| 1 | /* Copyright 2014 Malcolm Herring
|
|---|
| 2 | *
|
|---|
| 3 | * This is free software: you can redistribute it and/or modify
|
|---|
| 4 | * it under the terms of the GNU General Public License as published by
|
|---|
| 5 | * the Free Software Foundation, version 3 of the License.
|
|---|
| 6 | *
|
|---|
| 7 | * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | package render;
|
|---|
| 11 |
|
|---|
| 12 | import java.awt.Color;
|
|---|
| 13 | import java.awt.Font;
|
|---|
| 14 | import java.awt.geom.*;
|
|---|
| 15 | import java.text.DecimalFormat;
|
|---|
| 16 | import java.util.ArrayList;
|
|---|
| 17 | import java.util.EnumMap;
|
|---|
| 18 |
|
|---|
| 19 | import s57.S57val.CatLIT;
|
|---|
| 20 | import s57.S57val.ColCOL;
|
|---|
| 21 | import s57.S57att.*;
|
|---|
| 22 | import s57.S57obj.*;
|
|---|
| 23 | import s57.S57val.*;
|
|---|
| 24 | import s57.S57map.*;
|
|---|
| 25 | import symbols.Beacons;
|
|---|
| 26 | import symbols.Symbols;
|
|---|
| 27 | import symbols.Topmarks;
|
|---|
| 28 | import symbols.Symbols.*;
|
|---|
| 29 |
|
|---|
| 30 | public class Signals {
|
|---|
| 31 |
|
|---|
| 32 | static final EnumMap<ColCOL, Color> LightColours = new EnumMap<ColCOL, Color>(ColCOL.class);
|
|---|
| 33 | static {
|
|---|
| 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);
|
|---|
| 46 | static {
|
|---|
| 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);
|
|---|
| 58 | static {
|
|---|
| 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");
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | public static void addSignals(Feature feature) {
|
|---|
| 87 | if (feature.objs.containsKey(Obj.FOGSIG)) fogSignals(feature);
|
|---|
| 88 | if (feature.objs.containsKey(Obj.RTPBCN)) radarStations(feature);
|
|---|
| 89 | if (feature.objs.containsKey(Obj.RADSTA)) radarStations(feature);
|
|---|
| 90 | if (feature.objs.containsKey(Obj.RDOSTA)) radioStations(feature);
|
|---|
| 91 | if (feature.objs.containsKey(Obj.LIGHTS)) lights(feature);
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | static final EnumMap<CatFOG, String> fogSignals = new EnumMap<CatFOG, String>(CatFOG.class);
|
|---|
| 95 | static {
|
|---|
| 96 | fogSignals.put(CatFOG.FOG_EXPL, "Explos");
|
|---|
| 97 | fogSignals.put(CatFOG.FOG_DIA, "Dia");
|
|---|
| 98 | fogSignals.put(CatFOG.FOG_SIRN, "Siren");
|
|---|
| 99 | fogSignals.put(CatFOG.FOG_NAUT, "Horn");
|
|---|
| 100 | fogSignals.put(CatFOG.FOG_REED, "Horn");
|
|---|
| 101 | fogSignals.put(CatFOG.FOG_TYPH, "Horn");
|
|---|
| 102 | fogSignals.put(CatFOG.FOG_BELL, "Bell");
|
|---|
| 103 | fogSignals.put(CatFOG.FOG_WHIS, "Whis");
|
|---|
| 104 | fogSignals.put(CatFOG.FOG_GONG, "Gong");
|
|---|
| 105 | fogSignals.put(CatFOG.FOG_HORN, "Horn");
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | static final DecimalFormat df = new DecimalFormat("#.#");
|
|---|
| 109 |
|
|---|
| 110 | public static void fogSignals(Feature feature) {
|
|---|
| 111 | Renderer.symbol(feature, Beacons.FogSignal);
|
|---|
| 112 | AttMap atts = feature.objs.get(Obj.FOGSIG).get(0);
|
|---|
| 113 | String str = "";
|
|---|
| 114 | if (atts.containsKey(Att.CATFOG)) {
|
|---|
| 115 | str += fogSignals.get(((ArrayList<?>)(atts.get(Att.CATFOG).val)).get(0));
|
|---|
| 116 | }
|
|---|
| 117 | if (atts.containsKey(Att.SIGGRP)) {
|
|---|
| 118 | str += "(" + atts.get(Att.SIGGRP).val + ")";
|
|---|
| 119 | } else {
|
|---|
| 120 | str += " ";
|
|---|
| 121 | }
|
|---|
| 122 | if (atts.containsKey(Att.SIGPER)) {
|
|---|
| 123 | str += df.format(atts.get(Att.SIGPER).val) + "s";
|
|---|
| 124 | }
|
|---|
| 125 | if (atts.containsKey(Att.VALMXR)) {
|
|---|
| 126 | str += df.format(atts.get(Att.VALMXR).val) + "M";
|
|---|
| 127 | }
|
|---|
| 128 | if ((Renderer.zoom >= 15) && !str.isEmpty()) {
|
|---|
| 129 | Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40),Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-60, -30)));
|
|---|
| 130 | }
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | public static void radarStations(Feature feature) {
|
|---|
| 134 | Renderer.symbol(feature, Beacons.RadarStation);
|
|---|
| 135 | String bstr = "";
|
|---|
| 136 | CatRTB cat = (CatRTB) Rules.getAttEnum(feature, Obj.RTPBCN, 0, Att.CATRTB);
|
|---|
| 137 | String wal = Rules.getAttStr(feature, Obj.RTPBCN, 0, Att.RADWAL);
|
|---|
| 138 | switch (cat) {
|
|---|
| 139 | case RTB_RAMK:
|
|---|
| 140 | bstr += " Ramark";
|
|---|
| 141 | break;
|
|---|
| 142 | case RTB_RACN:
|
|---|
| 143 | bstr += " Racon";
|
|---|
| 144 | String astr = Rules.getAttStr(feature, Obj.RTPBCN, 0, Att.SIGGRP);
|
|---|
| 145 | if (!astr.isEmpty()) {
|
|---|
| 146 | bstr += "(" + astr + ")";
|
|---|
| 147 | }
|
|---|
| 148 | Double per = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.SIGPER);
|
|---|
| 149 | Double mxr = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.VALMXR);
|
|---|
| 150 | if ((per != null) || (mxr != null)) {
|
|---|
| 151 | bstr += (astr.isEmpty() ? " " : "");
|
|---|
| 152 | if (per != null) bstr += (per != 0) ? per.toString() + "s" : "";
|
|---|
| 153 | if (mxr != null) bstr += (mxr != 0) ? mxr.toString() + "M" : "";
|
|---|
| 154 | }
|
|---|
| 155 | break;
|
|---|
| 156 | default:
|
|---|
| 157 | break;
|
|---|
| 158 | }
|
|---|
| 159 | if (!wal.isEmpty()) {
|
|---|
| 160 | switch (wal) {
|
|---|
| 161 | case "0.03-X":
|
|---|
| 162 | bstr += "(3cm)";
|
|---|
| 163 | break;
|
|---|
| 164 | case "0.10-S":
|
|---|
| 165 | bstr += "(10cm)";
|
|---|
| 166 | break;
|
|---|
| 167 | }
|
|---|
| 168 | }
|
|---|
| 169 | if ((Renderer.zoom >= 15) && !bstr.isEmpty()) {
|
|---|
| 170 | Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
|
|---|
| 171 | }
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | @SuppressWarnings("unchecked")
|
|---|
| 175 | public static void radioStations(Feature feature) {
|
|---|
| 176 | ArrayList<CatROS> cats = (ArrayList<CatROS>)Rules.getAttList(feature, Obj.RDOSTA, 0, Att.CATROS);
|
|---|
| 177 | boolean vais = false;
|
|---|
| 178 | String bstr = "";
|
|---|
| 179 | for (CatROS ros : cats) {
|
|---|
| 180 | switch (ros) {
|
|---|
| 181 | case ROS_OMNI:
|
|---|
| 182 | bstr += " RC";
|
|---|
| 183 | break;
|
|---|
| 184 | case ROS_DIRL:
|
|---|
| 185 | bstr += " RD";
|
|---|
| 186 | break;
|
|---|
| 187 | case ROS_ROTP:
|
|---|
| 188 | bstr += " RW";
|
|---|
| 189 | break;
|
|---|
| 190 | case ROS_CNSL:
|
|---|
| 191 | bstr += " Consol";
|
|---|
| 192 | break;
|
|---|
| 193 | case ROS_RDF:
|
|---|
| 194 | bstr += " RG";
|
|---|
| 195 | break;
|
|---|
| 196 | case ROS_QTA:
|
|---|
| 197 | bstr += " R";
|
|---|
| 198 | break;
|
|---|
| 199 | case ROS_AERO:
|
|---|
| 200 | bstr += " AeroRC";
|
|---|
| 201 | break;
|
|---|
| 202 | case ROS_DECA:
|
|---|
| 203 | bstr += " Decca";
|
|---|
| 204 | break;
|
|---|
| 205 | case ROS_LORN:
|
|---|
| 206 | bstr += " Loran";
|
|---|
| 207 | break;
|
|---|
| 208 | case ROS_DGPS:
|
|---|
| 209 | bstr += " DGPS";
|
|---|
| 210 | break;
|
|---|
| 211 | case ROS_TORN:
|
|---|
| 212 | bstr += " Toran";
|
|---|
| 213 | break;
|
|---|
| 214 | case ROS_OMGA:
|
|---|
| 215 | bstr += " Omega";
|
|---|
| 216 | break;
|
|---|
| 217 | case ROS_SYLD:
|
|---|
| 218 | bstr += " Syledis";
|
|---|
| 219 | break;
|
|---|
| 220 | case ROS_CHKA:
|
|---|
| 221 | bstr += " Chiaka";
|
|---|
| 222 | break;
|
|---|
| 223 | case ROS_PCOM:
|
|---|
| 224 | case ROS_COMB:
|
|---|
| 225 | case ROS_FACS:
|
|---|
| 226 | case ROS_TIME:
|
|---|
| 227 | break;
|
|---|
| 228 | case ROS_PAIS:
|
|---|
| 229 | case ROS_SAIS:
|
|---|
| 230 | bstr += " AIS";
|
|---|
| 231 | break;
|
|---|
| 232 | case ROS_VAIS:
|
|---|
| 233 | vais = true;
|
|---|
| 234 | break;
|
|---|
| 235 | case ROS_VANC:
|
|---|
| 236 | vais = true;
|
|---|
| 237 | Renderer.symbol(feature, Topmarks.TopNorth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 238 | break;
|
|---|
| 239 | case ROS_VASC:
|
|---|
| 240 | vais = true;
|
|---|
| 241 | Renderer.symbol(feature, Topmarks.TopSouth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 242 | break;
|
|---|
| 243 | case ROS_VAEC:
|
|---|
| 244 | vais = true;
|
|---|
| 245 | Renderer.symbol(feature, Topmarks.TopEast, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 246 | break;
|
|---|
| 247 | case ROS_VAWC:
|
|---|
| 248 | vais = true;
|
|---|
| 249 | Renderer.symbol(feature, Topmarks.TopWest, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 250 | break;
|
|---|
| 251 | case ROS_VAPL:
|
|---|
| 252 | vais = true;
|
|---|
| 253 | Renderer.symbol(feature, Topmarks.TopCan, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 254 | break;
|
|---|
| 255 | case ROS_VASL:
|
|---|
| 256 | vais = true;
|
|---|
| 257 | Renderer.symbol(feature, Topmarks.TopCone, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 258 | break;
|
|---|
| 259 | case ROS_VAID:
|
|---|
| 260 | vais = true;
|
|---|
| 261 | Renderer.symbol(feature, Topmarks.TopIsol, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 262 | break;
|
|---|
| 263 | case ROS_VASW:
|
|---|
| 264 | vais = true;
|
|---|
| 265 | Renderer.symbol(feature, Topmarks.TopSphere, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 266 | break;
|
|---|
| 267 | case ROS_VASP:
|
|---|
| 268 | vais = true;
|
|---|
| 269 | Renderer.symbol(feature, Topmarks.TopX, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 270 | break;
|
|---|
| 271 | case ROS_VAWK:
|
|---|
| 272 | vais = true;
|
|---|
| 273 | Renderer.symbol(feature, Topmarks.TopCross, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 274 | break;
|
|---|
| 275 | default:
|
|---|
| 276 | break;
|
|---|
| 277 | }
|
|---|
| 278 | }
|
|---|
| 279 | if (!vais) {
|
|---|
| 280 | Renderer.symbol(feature, Beacons.RadarStation);
|
|---|
| 281 | }
|
|---|
| 282 | if (Renderer.zoom >= 15) {
|
|---|
| 283 | if (vais) {
|
|---|
| 284 | Renderer.labelText(feature, "V-AIS", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 285 | }
|
|---|
| 286 | if (!bstr.isEmpty()) {
|
|---|
| 287 | Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -110)));
|
|---|
| 288 | }
|
|---|
| 289 | }
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | class Sect {
|
|---|
| 293 | int dir;
|
|---|
| 294 | LitCHR chr;
|
|---|
| 295 | ColCOL col;
|
|---|
| 296 | ColCOL alt;
|
|---|
| 297 | String grp;
|
|---|
| 298 | double per;
|
|---|
| 299 | double rng;
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | @SuppressWarnings("unchecked")
|
|---|
| 303 | public static void lights(Feature feature) {
|
|---|
| 304 | Enum<ColCOL> col = null;
|
|---|
| 305 | Enum<ColCOL> tcol = null;
|
|---|
| 306 | ObjTab lights = feature.objs.get(Obj.LIGHTS);
|
|---|
| 307 | for (AttMap atts : lights.values()) {
|
|---|
| 308 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 309 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
|---|
| 310 | if (cols.size() == 1) {
|
|---|
| 311 | tcol = cols.get(0);
|
|---|
| 312 | if (col == null) {
|
|---|
| 313 | col = tcol;
|
|---|
| 314 | } else if (tcol != col) {
|
|---|
| 315 | col = ColCOL.COL_MAG;
|
|---|
| 316 | break;
|
|---|
| 317 | }
|
|---|
| 318 | } else {
|
|---|
| 319 | col = ColCOL.COL_MAG;
|
|---|
| 320 | break;
|
|---|
| 321 | }
|
|---|
| 322 | }
|
|---|
| 323 | }
|
|---|
| 324 | Renderer.symbol(feature, Beacons.LightFlare, new Scheme(LightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
|
|---|
| 325 | String str = "";
|
|---|
| 326 | if (lights.get(1) != null) {
|
|---|
| 327 | for (AttMap atts : lights.values()) {
|
|---|
| 328 | Enum<ColCOL> col1 = null;
|
|---|
| 329 | Enum<ColCOL> col2 = null;
|
|---|
| 330 | double radius = 0.2;
|
|---|
| 331 | double s1 = 0;
|
|---|
| 332 | double s2 = 0;
|
|---|
| 333 | boolean dir = false;
|
|---|
| 334 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 335 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
|---|
| 336 | col1 = cols.get(0);
|
|---|
| 337 | if (cols.size() > 1)
|
|---|
| 338 | col2 = cols.get(1);
|
|---|
| 339 | } else {
|
|---|
| 340 | continue;
|
|---|
| 341 | }
|
|---|
| 342 | if (atts.containsKey(Att.LITRAD)) {
|
|---|
| 343 | radius = (Double) atts.get(Att.LITRAD).val;
|
|---|
| 344 | }
|
|---|
| 345 | if (atts.containsKey(Att.SECTR1)) {
|
|---|
| 346 | s1 = (Double) atts.get(Att.SECTR1).val;
|
|---|
| 347 | } else {
|
|---|
| 348 | continue;
|
|---|
| 349 | }
|
|---|
| 350 | if (atts.containsKey(Att.SECTR2)) {
|
|---|
| 351 | s2 = (Double) atts.get(Att.SECTR2).val;
|
|---|
| 352 | } else {
|
|---|
| 353 | continue;
|
|---|
| 354 | }
|
|---|
| 355 | if (atts.containsKey(Att.CATLIT)) {
|
|---|
| 356 | ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
|
|---|
| 357 | if (cats.contains(CatLIT.LIT_DIR)) {
|
|---|
| 358 | dir = true;
|
|---|
| 359 | }
|
|---|
| 360 | }
|
|---|
| 361 | str = "";
|
|---|
| 362 | if (atts.containsKey(Att.LITCHR)) {
|
|---|
| 363 | str += LightCharacters.get(((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0));
|
|---|
| 364 | }
|
|---|
| 365 | if (atts.containsKey(Att.SIGGRP)) {
|
|---|
| 366 | str += "(" + atts.get(Att.SIGGRP).val + ")";
|
|---|
| 367 | } else if (!str.isEmpty()) {
|
|---|
| 368 | str += ".";
|
|---|
| 369 | }
|
|---|
| 370 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 371 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
|---|
| 372 | str += LightLetters.get(cols.get(0));
|
|---|
| 373 | if (cols.size() > 1)
|
|---|
| 374 | str += LightLetters.get(cols.get(1));
|
|---|
| 375 | }
|
|---|
| 376 | if (atts.containsKey(Att.SIGPER)) {
|
|---|
| 377 | str += "." + df.format(atts.get(Att.SIGPER).val) + "s";
|
|---|
| 378 | }
|
|---|
| 379 | if (dir && atts.containsKey(Att.ORIENT)) {
|
|---|
| 380 | double orient = (Double) atts.get(Att.ORIENT).val;
|
|---|
| 381 | str += " " + orient + "°";
|
|---|
| 382 | s1 = (orient - 4 + 360) % 360;
|
|---|
| 383 | s2 = (orient + 4) % 360;
|
|---|
| 384 | double n1 = 360;
|
|---|
| 385 | double n2 = 360;
|
|---|
| 386 | for (AttMap sect : lights.values()) {
|
|---|
| 387 | if (sect != atts) {
|
|---|
| 388 |
|
|---|
| 389 | }
|
|---|
| 390 | }
|
|---|
| 391 | }
|
|---|
| 392 | Renderer.lightSector(feature, LightColours.get(col1), LightColours.get(col2), radius, s1, s2, dir, (Renderer.zoom >= 15) ? str : "");
|
|---|
| 393 | }
|
|---|
| 394 | if (Renderer.zoom >= 15) {
|
|---|
| 395 | class LitSect {
|
|---|
| 396 | boolean dir;
|
|---|
| 397 | LitCHR chr;
|
|---|
| 398 | ColCOL col;
|
|---|
| 399 | ColCOL alt;
|
|---|
| 400 | String grp;
|
|---|
| 401 | double per;
|
|---|
| 402 | double rng;
|
|---|
| 403 | double hgt;
|
|---|
| 404 | }
|
|---|
| 405 | str = "";
|
|---|
| 406 | ArrayList<LitSect> litatts = new ArrayList<>();
|
|---|
| 407 | for (AttMap atts : lights.values()) {
|
|---|
| 408 | LitSect sect = new LitSect();
|
|---|
| 409 | sect.dir = (atts.containsKey(Att.CATLIT)) && (atts.get(Att.CATLIT).val == CatLIT.LIT_DIR);
|
|---|
| 410 | sect.chr = atts.containsKey(Att.LITCHR) ? ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0) : LitCHR.CHR_UNKN;
|
|---|
| 411 | switch (sect.chr) {
|
|---|
| 412 | case CHR_AL:
|
|---|
| 413 | sect.chr = LitCHR.CHR_F;
|
|---|
| 414 | break;
|
|---|
| 415 | case CHR_ALOC:
|
|---|
| 416 | sect.chr = LitCHR.CHR_OC;
|
|---|
| 417 | break;
|
|---|
| 418 | case CHR_ALLFL:
|
|---|
| 419 | sect.chr = LitCHR.CHR_LFL;
|
|---|
| 420 | break;
|
|---|
| 421 | case CHR_ALFL:
|
|---|
| 422 | sect.chr = LitCHR.CHR_FL;
|
|---|
| 423 | break;
|
|---|
| 424 | case CHR_ALFFL:
|
|---|
| 425 | sect.chr = LitCHR.CHR_FFL;
|
|---|
| 426 | break;
|
|---|
| 427 | default:
|
|---|
| 428 | break;
|
|---|
| 429 | }
|
|---|
| 430 | sect.grp = atts.containsKey(Att.SIGGRP) ? (String) atts.get(Att.SIGGRP).val : "";
|
|---|
| 431 | sect.per = atts.containsKey(Att.SIGPER) ? (Double) atts.get(Att.SIGPER).val : 0.0;
|
|---|
| 432 | sect.rng = atts.containsKey(Att.VALNMR) ? (Double) atts.get(Att.VALNMR).val : 0.0;
|
|---|
| 433 | sect.hgt = atts.containsKey(Att.HEIGHT) ? (Double) atts.get(Att.HEIGHT).val : 0.0;
|
|---|
| 434 | ArrayList<ColCOL> cols = (ArrayList<ColCOL>) (atts.containsKey(Att.COLOUR) ? atts.get(Att.COLOUR).val : new ArrayList<>());
|
|---|
| 435 | sect.col = cols.size() > 0 ? cols.get(0) : ColCOL.COL_UNK;
|
|---|
| 436 | sect.alt = cols.size() > 1 ? cols.get(1) : ColCOL.COL_UNK;
|
|---|
| 437 | if ((sect.chr != LitCHR.CHR_UNKN) && (sect.col != null))
|
|---|
| 438 | litatts.add(sect);
|
|---|
| 439 | }
|
|---|
| 440 | ArrayList<ArrayList<LitSect>> groupings = new ArrayList<>();
|
|---|
| 441 | for (LitSect lit : litatts) {
|
|---|
| 442 | boolean found = false;
|
|---|
| 443 | for (ArrayList<LitSect> group : groupings) {
|
|---|
| 444 | LitSect mem = group.get(0);
|
|---|
| 445 | if ((lit.dir == mem.dir) && (lit.chr == mem.chr) && (lit.grp.equals(mem.grp)) && (lit.per == mem.per) && (lit.hgt == mem.hgt)) {
|
|---|
| 446 | group.add(lit);
|
|---|
| 447 | found = true;
|
|---|
| 448 | }
|
|---|
| 449 | }
|
|---|
| 450 | if (!found) {
|
|---|
| 451 | ArrayList<LitSect> tmp = new ArrayList<LitSect>();
|
|---|
| 452 | tmp.add(lit);
|
|---|
| 453 | groupings.add(tmp);
|
|---|
| 454 | }
|
|---|
| 455 | }
|
|---|
| 456 | for (boolean moved = true; moved;) {
|
|---|
| 457 | moved = false;
|
|---|
| 458 | for (int i = 0; i < groupings.size() - 1; i++) {
|
|---|
| 459 | if (groupings.get(i).size() < groupings.get(i + 1).size()) {
|
|---|
| 460 | ArrayList<LitSect> tmp = groupings.remove(i);
|
|---|
| 461 | groupings.add(i + 1, tmp);
|
|---|
| 462 | moved = true;
|
|---|
| 463 | }
|
|---|
| 464 | }
|
|---|
| 465 | }
|
|---|
| 466 | class ColRng {
|
|---|
| 467 | ColCOL col;
|
|---|
| 468 | double rng;
|
|---|
| 469 |
|
|---|
| 470 | public ColRng(ColCOL c, double r) {
|
|---|
| 471 | col = c;
|
|---|
| 472 | rng = r;
|
|---|
| 473 | }
|
|---|
| 474 | }
|
|---|
| 475 | int y = -30;
|
|---|
| 476 | for (ArrayList<LitSect> group : groupings) {
|
|---|
| 477 | ArrayList<ColRng> colrng = new ArrayList<>();
|
|---|
| 478 | for (LitSect lit : group) {
|
|---|
| 479 | boolean found = false;
|
|---|
| 480 | for (ColRng cr : colrng) {
|
|---|
| 481 | if (cr.col == lit.col) {
|
|---|
| 482 | if (lit.rng > cr.rng) {
|
|---|
| 483 | cr.rng = lit.rng;
|
|---|
| 484 | }
|
|---|
| 485 | found = true;
|
|---|
| 486 | }
|
|---|
| 487 | }
|
|---|
| 488 | if (!found) {
|
|---|
| 489 | colrng.add(new ColRng(lit.col, lit.rng));
|
|---|
| 490 | }
|
|---|
| 491 | }
|
|---|
| 492 | for (boolean moved = true; moved;) {
|
|---|
| 493 | moved = false;
|
|---|
| 494 | for (int i = 0; i < colrng.size() - 1; i++) {
|
|---|
| 495 | if (colrng.get(i).rng < colrng.get(i + 1).rng) {
|
|---|
| 496 | ColRng tmp = colrng.remove(i);
|
|---|
| 497 | colrng.add(i + 1, tmp);
|
|---|
| 498 | moved = true;
|
|---|
| 499 | }
|
|---|
| 500 | }
|
|---|
| 501 | }
|
|---|
| 502 | LitSect tmp = group.get(0);
|
|---|
| 503 | if (tmp.dir)
|
|---|
| 504 | str += "Dir";
|
|---|
| 505 | str += LightCharacters.get(tmp.chr);
|
|---|
| 506 | if (!tmp.grp.isEmpty())
|
|---|
| 507 | str += "(" + tmp.grp + ")";
|
|---|
| 508 | else
|
|---|
| 509 | str += ".";
|
|---|
| 510 | for (ColRng cr : colrng) {
|
|---|
| 511 | str += LightLetters.get(cr.col);
|
|---|
| 512 | }
|
|---|
| 513 | if ((tmp.per > 0) || (tmp.hgt > 0) || (colrng.get(0).rng > 0))
|
|---|
| 514 | str += ".";
|
|---|
| 515 | if (tmp.per > 0)
|
|---|
| 516 | str += df.format(tmp.per) + "s";
|
|---|
| 517 | if (tmp.hgt > 0)
|
|---|
| 518 | str += df.format(tmp.hgt) + "m";
|
|---|
| 519 | if (colrng.get(0).rng > 0)
|
|---|
| 520 | 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";
|
|---|
| 521 | Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, y)));
|
|---|
| 522 | y += 40;
|
|---|
| 523 | str = "";
|
|---|
| 524 | }
|
|---|
| 525 | }
|
|---|
| 526 | } else {
|
|---|
| 527 | if (Renderer.zoom >= 15) {
|
|---|
| 528 | AttMap atts = lights.get(0);
|
|---|
| 529 | ArrayList<CatLIT> cats = new ArrayList<>();
|
|---|
| 530 | if (atts.containsKey(Att.CATLIT)) {
|
|---|
| 531 | cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
|
|---|
| 532 | }
|
|---|
| 533 | str += (cats.contains(CatLIT.LIT_DIR)) ? "Dir" : "";
|
|---|
| 534 | str += (atts.containsKey(Att.MLTYLT)) ? atts.get(Att.MLTYLT).val : "";
|
|---|
| 535 | if (atts.containsKey(Att.LITCHR)) {
|
|---|
| 536 | LitCHR chr = ((ArrayList<LitCHR>) atts.get(Att.LITCHR).val).get(0);
|
|---|
| 537 | if (atts.containsKey(Att.SIGGRP)) {
|
|---|
| 538 | String grp = (String) atts.get(Att.SIGGRP).val;
|
|---|
| 539 | switch (chr) {
|
|---|
| 540 | case CHR_QLFL:
|
|---|
| 541 | str += String.format("Q(%s)+LFl", grp);
|
|---|
| 542 | break;
|
|---|
| 543 | case CHR_VQLFL:
|
|---|
| 544 | str += String.format("VQ(%s)+LFl", grp);
|
|---|
| 545 | break;
|
|---|
| 546 | case CHR_UQLFL:
|
|---|
| 547 | str += String.format("UQ(%s)+LFl", grp);
|
|---|
| 548 | break;
|
|---|
| 549 | default:
|
|---|
| 550 | str += String.format("%s(%s)", LightCharacters.get(chr), grp);
|
|---|
| 551 | break;
|
|---|
| 552 | }
|
|---|
| 553 | } else {
|
|---|
| 554 | str += LightCharacters.get(chr);
|
|---|
| 555 | }
|
|---|
| 556 | }
|
|---|
| 557 | if (atts.containsKey(Att.COLOUR)) {
|
|---|
| 558 | ArrayList<ColCOL> cols = (ArrayList<ColCOL>) atts.get(Att.COLOUR).val;
|
|---|
| 559 | if (!((cols.size() == 1) && (cols.get(0) == ColCOL.COL_WHT))) {
|
|---|
| 560 | if (!str.isEmpty() && !str.endsWith(")")) {
|
|---|
| 561 | str += ".";
|
|---|
| 562 | }
|
|---|
| 563 | for (ColCOL acol : cols) {
|
|---|
| 564 | str += LightLetters.get(acol);
|
|---|
| 565 | }
|
|---|
| 566 | }
|
|---|
| 567 | }
|
|---|
| 568 | str += (cats.contains(CatLIT.LIT_VERT)) ? "(vert)" : "";
|
|---|
| 569 | str += (cats.contains(CatLIT.LIT_HORI)) ? "(hor)" : "";
|
|---|
| 570 | str += (!str.isEmpty() && (atts.containsKey(Att.SIGPER) || atts.containsKey(Att.HEIGHT) || atts.containsKey(Att.VALMXR)) && !str.endsWith(")")) ? "." : "";
|
|---|
| 571 | str += (atts.containsKey(Att.SIGPER)) ? df.format(atts.get(Att.SIGPER).val) + "s" : "";
|
|---|
| 572 | str += (atts.containsKey(Att.HEIGHT)) ? df.format(atts.get(Att.HEIGHT).val) + "m" : "";
|
|---|
| 573 | str += (atts.containsKey(Att.VALNMR)) ? df.format(atts.get(Att.VALNMR).val) + "M" : "";
|
|---|
| 574 | str += (cats.contains(CatLIT.LIT_FRNT)) ? "(Front)" : "";
|
|---|
| 575 | str += (cats.contains(CatLIT.LIT_REAR)) ? "(Rear)" : "";
|
|---|
| 576 | str += (cats.contains(CatLIT.LIT_UPPR)) ? "(Upper)" : "";
|
|---|
| 577 | str += (cats.contains(CatLIT.LIT_LOWR)) ? "(Lower)" : "";
|
|---|
| 578 | Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TL, AffineTransform.getTranslateInstance(60, -30)));
|
|---|
| 579 | }
|
|---|
| 580 | }
|
|---|
| 581 | }
|
|---|
| 582 | }
|
|---|