| 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.util.ArrayList;
|
|---|
| 16 | import java.util.EnumMap;
|
|---|
| 17 |
|
|---|
| 18 | import s57.S57att.*;
|
|---|
| 19 | import s57.S57obj.*;
|
|---|
| 20 | import s57.S57val.*;
|
|---|
| 21 | import s57.S57map.*;
|
|---|
| 22 | import symbols.Beacons;
|
|---|
| 23 | import symbols.Topmarks;
|
|---|
| 24 | import symbols.Symbols.*;
|
|---|
| 25 |
|
|---|
| 26 | public class Signals {
|
|---|
| 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 |
|
|---|
| 82 | public static void addSignals(Feature feature) {
|
|---|
| 83 | if (feature.objs.containsKey(Obj.FOGSIG)) fogSignals(feature);
|
|---|
| 84 | if (feature.objs.containsKey(Obj.RTPBCN)) radarStations(feature);
|
|---|
| 85 | if (feature.objs.containsKey(Obj.RADSTA)) radarStations(feature);
|
|---|
| 86 | if (feature.objs.containsKey(Obj.RDOSTA)) radioStations(feature);
|
|---|
| 87 | if (feature.objs.containsKey(Obj.LIGHTS)) lights(feature);
|
|---|
| 88 | }
|
|---|
| 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 |
|
|---|
| 104 | public static void fogSignals(Feature feature) {
|
|---|
| 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 | }
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | public static void radarStations(Feature feature) {
|
|---|
| 128 | Renderer.symbol(feature, Beacons.RadarStation);
|
|---|
| 129 | String bstr = "";
|
|---|
| 130 | CatRTB cat = (CatRTB) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.CATRTB);
|
|---|
| 131 | switch (cat) {
|
|---|
| 132 | case RTB_RAMK:
|
|---|
| 133 | bstr += " Ramark";
|
|---|
| 134 | break;
|
|---|
| 135 | case RTB_RACN:
|
|---|
| 136 | bstr += " Racon";
|
|---|
| 137 | String astr = (String) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.SIGGRP);
|
|---|
| 138 | if (!astr.isEmpty()) {
|
|---|
| 139 | bstr += "(" + astr + ")";
|
|---|
| 140 | }
|
|---|
| 141 | Double per = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.SIGPER);
|
|---|
| 142 | Double mxr = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.VALMXR);
|
|---|
| 143 | if ((per != 0) || (mxr != 0)) {
|
|---|
| 144 | bstr += (astr.isEmpty() ? " " : "");
|
|---|
| 145 | bstr += (per != 0) ? per.toString() + "s" : "";
|
|---|
| 146 | bstr += (mxr != 0) ? mxr.toString() + "M" : "";
|
|---|
| 147 | }
|
|---|
| 148 | break;
|
|---|
| 149 | default:
|
|---|
| 150 | break;
|
|---|
| 151 | }
|
|---|
| 152 | if ((Renderer.zoom >= 15) && !bstr.isEmpty()) {
|
|---|
| 153 | Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40),Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
|
|---|
| 154 | }
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | public static void radioStations(Feature feature) {
|
|---|
| 158 | Renderer.symbol(feature, Beacons.RadarStation);
|
|---|
| 159 | ArrayList<CatROS> cats = (ArrayList<CatROS>)Rules.getAttVal(feature, Obj.RDOSTA, 0, Att.CATROS);
|
|---|
| 160 | boolean vais = false;
|
|---|
| 161 | String bstr = "";
|
|---|
| 162 | for (CatROS ros : cats) {
|
|---|
| 163 | switch (ros) {
|
|---|
| 164 | case ROS_OMNI:
|
|---|
| 165 | bstr += " RC";
|
|---|
| 166 | break;
|
|---|
| 167 | case ROS_DIRL:
|
|---|
| 168 | bstr += " RD";
|
|---|
| 169 | break;
|
|---|
| 170 | case ROS_ROTP:
|
|---|
| 171 | bstr += " RW";
|
|---|
| 172 | break;
|
|---|
| 173 | case ROS_CNSL:
|
|---|
| 174 | bstr += " Consol";
|
|---|
| 175 | break;
|
|---|
| 176 | case ROS_RDF:
|
|---|
| 177 | bstr += " RG";
|
|---|
| 178 | break;
|
|---|
| 179 | case ROS_QTA:
|
|---|
| 180 | bstr += " R";
|
|---|
| 181 | break;
|
|---|
| 182 | case ROS_AERO:
|
|---|
| 183 | bstr += " AeroRC";
|
|---|
| 184 | break;
|
|---|
| 185 | case ROS_DECA:
|
|---|
| 186 | bstr += " Decca";
|
|---|
| 187 | break;
|
|---|
| 188 | case ROS_LORN:
|
|---|
| 189 | bstr += " Loran";
|
|---|
| 190 | break;
|
|---|
| 191 | case ROS_DGPS:
|
|---|
| 192 | bstr += " DGPS";
|
|---|
| 193 | break;
|
|---|
| 194 | case ROS_TORN:
|
|---|
| 195 | bstr += " Toran";
|
|---|
| 196 | break;
|
|---|
| 197 | case ROS_OMGA:
|
|---|
| 198 | bstr += " Omega";
|
|---|
| 199 | break;
|
|---|
| 200 | case ROS_SYLD:
|
|---|
| 201 | bstr += " Syledis";
|
|---|
| 202 | break;
|
|---|
| 203 | case ROS_CHKA:
|
|---|
| 204 | bstr += " Chiaka";
|
|---|
| 205 | break;
|
|---|
| 206 | case ROS_PCOM:
|
|---|
| 207 | case ROS_COMB:
|
|---|
| 208 | case ROS_FACS:
|
|---|
| 209 | case ROS_TIME:
|
|---|
| 210 | break;
|
|---|
| 211 | case ROS_PAIS:
|
|---|
| 212 | case ROS_SAIS:
|
|---|
| 213 | bstr += " AIS";
|
|---|
| 214 | break;
|
|---|
| 215 | case ROS_VAIS:
|
|---|
| 216 | vais = true;
|
|---|
| 217 | break;
|
|---|
| 218 | case ROS_VANC:
|
|---|
| 219 | vais = true;
|
|---|
| 220 | Renderer.symbol(feature, Topmarks.TopNorth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 221 | break;
|
|---|
| 222 | case ROS_VASC:
|
|---|
| 223 | vais = true;
|
|---|
| 224 | Renderer.symbol(feature, Topmarks.TopSouth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 225 | break;
|
|---|
| 226 | case ROS_VAEC:
|
|---|
| 227 | vais = true;
|
|---|
| 228 | Renderer.symbol(feature, Topmarks.TopEast, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 229 | break;
|
|---|
| 230 | case ROS_VAWC:
|
|---|
| 231 | vais = true;
|
|---|
| 232 | Renderer.symbol(feature, Topmarks.TopWest, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 233 | break;
|
|---|
| 234 | case ROS_VAPL:
|
|---|
| 235 | vais = true;
|
|---|
| 236 | Renderer.symbol(feature, Topmarks.TopCan, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 237 | break;
|
|---|
| 238 | case ROS_VASL:
|
|---|
| 239 | vais = true;
|
|---|
| 240 | Renderer.symbol(feature, Topmarks.TopCone, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 241 | break;
|
|---|
| 242 | case ROS_VAID:
|
|---|
| 243 | vais = true;
|
|---|
| 244 | Renderer.symbol(feature, Topmarks.TopIsol, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 245 | break;
|
|---|
| 246 | case ROS_VASW:
|
|---|
| 247 | vais = true;
|
|---|
| 248 | Renderer.symbol(feature, Topmarks.TopSphere, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 249 | break;
|
|---|
| 250 | case ROS_VASP:
|
|---|
| 251 | vais = true;
|
|---|
| 252 | Renderer.symbol(feature, Topmarks.TopX, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 253 | break;
|
|---|
| 254 | case ROS_VAWK:
|
|---|
| 255 | vais = true;
|
|---|
| 256 | Renderer.symbol(feature, Topmarks.TopCross, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 257 | break;
|
|---|
| 258 | default:
|
|---|
| 259 | break;
|
|---|
| 260 | }
|
|---|
| 261 | }
|
|---|
| 262 | if (Renderer.zoom >= 15) {
|
|---|
| 263 | if (vais) {
|
|---|
| 264 | Renderer.labelText(feature, "V-AIS", new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 265 | }
|
|---|
| 266 | if (!bstr.isEmpty()) {
|
|---|
| 267 | Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -110)));
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | public static void lights(Feature feature) {
|
|---|
| 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 | /*
|
|---|
| 334 | void renderSector(Item_t *item, int s, char *text, char *style, double offset, int dy) {
|
|---|
| 335 | Obj_t *sector;
|
|---|
| 336 | double start, end;
|
|---|
| 337 | Att_t *att;
|
|---|
| 338 | XY_t p0, p1;
|
|---|
| 339 | double r0, r1;
|
|---|
| 340 | double b0, b1, span;
|
|---|
| 341 | char *col;
|
|---|
| 342 | XY_t pos = findCentroid(item);
|
|---|
| 343 | if ((sector = getObj(item, LIGHTS, s)) != NULL) {
|
|---|
| 344 | strcpy(string1, (att = getAtt(sector, LITRAD)) != NULL ? att->val.val.a : "0.2");
|
|---|
| 345 | if (((att = getAtt(sector, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(sector, ORIENT)) != NULL)) {
|
|---|
| 346 | b0 = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 347 | if ((att = getAtt(sector, COLOUR)) != NULL) {
|
|---|
| 348 | col = light_colours[att->val.val.l->val];
|
|---|
| 349 | r0 = atof(string1);
|
|---|
| 350 | p0 = radial(pos, r0, b0);
|
|---|
| 351 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
|---|
| 352 | pos.x, pos.y, p0.x, p0.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
|---|
| 353 | start = fmod(b0 + 2.0, 360.0);
|
|---|
| 354 | end = fmod(360.0 + b0 - 2.0, 360.0);
|
|---|
| 355 | Obj_t *adj;
|
|---|
| 356 | for (int i = s-1; i <= s+1; i++) {
|
|---|
| 357 | if (i == s) continue;
|
|---|
| 358 | if ((adj = getObj(item, LIGHTS, i)) == NULL) continue;
|
|---|
| 359 | Att_t *att;
|
|---|
| 360 | if (((att = getAtt(adj, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(adj, ORIENT)) != NULL)) {
|
|---|
| 361 | b1 = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 362 | if (fabs(b0 - b1) > 180.0) {
|
|---|
| 363 | if (b0 < b1) b0 += 360.0;
|
|---|
| 364 | else b1 += 360.0;
|
|---|
| 365 | }
|
|---|
| 366 | if (fabs(b0 - b1) < 4.0) {
|
|---|
| 367 | if (b1 > b0) start = fmod((720.0 + b0 + b1) / 2.0, 360.0);
|
|---|
| 368 | else end = fmod((720.0 + b0 + b1) / 2.0, 360.0);
|
|---|
| 369 | }
|
|---|
| 370 | }
|
|---|
| 371 | }
|
|---|
| 372 | p0 = radial(pos, r0, start);
|
|---|
| 373 | p1 = radial(pos, r0, end);
|
|---|
| 374 | printf("<path id=\"%d\" d=\"M %g,%g A %g,%g,0,0,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
|---|
| 375 | ++ref, p0.x, p0.y, r0*mile, r0*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
|---|
| 376 | if (att->val.val.l->next != NULL) {
|
|---|
| 377 | char *col = light_colours[att->val.val.l->next->val];
|
|---|
| 378 | r1 = r0 - (20 * symbolScale[zoom]/mile);
|
|---|
| 379 | p0 = radial(pos, r1, start);
|
|---|
| 380 | p1 = radial(pos, r1, end);
|
|---|
| 381 | printf("<path d=\"M %g,%g A %g,%g,0,0,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
|---|
| 382 | p0.x, p0.y, r1*mile, r1*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
|---|
| 383 | }
|
|---|
| 384 | }
|
|---|
| 385 | } else if ((att = getAtt(sector, SECTR1)) != NULL) {
|
|---|
| 386 | start = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 387 | if ((att = getAtt(sector, SECTR2)) != NULL) {
|
|---|
| 388 | end = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 389 | start += start < end ? 360.0 : 0.0;
|
|---|
| 390 | if ((att = getAtt(sector, COLOUR)) != NULL) {
|
|---|
| 391 | char *ttok, *etok;
|
|---|
| 392 | char *radstr = strdup(string1);
|
|---|
| 393 | int arc = 0;
|
|---|
| 394 | col = light_colours[att->val.val.l->val];
|
|---|
| 395 | r0 = 0.0;
|
|---|
| 396 | b0 = b1 = start;
|
|---|
| 397 | for (char *tpl = strtok_r(radstr, ";", &ttok); tpl != NULL; tpl = strtok_r(NULL, ";", &ttok)) {
|
|---|
| 398 | p0 = radial(pos, r0, b0);
|
|---|
| 399 | span = 0.0;
|
|---|
| 400 | char *ele = strtok_r(tpl, ":", &etok);
|
|---|
| 401 | if ((*tpl == ':') && (r0 == 0.0)) {
|
|---|
| 402 | r1 = 0.2;
|
|---|
| 403 | } else if (*tpl != ':') {
|
|---|
| 404 | r1 = atof(tpl);
|
|---|
| 405 | ele = strtok_r(NULL, ":", &etok);
|
|---|
| 406 | }
|
|---|
| 407 | while (ele != NULL) {
|
|---|
| 408 | if (isalpha(*ele)) {
|
|---|
| 409 | if (strcmp(ele, "suppress") == 0) arc = 2;
|
|---|
| 410 | else if (strcmp(ele, "dashed") == 0) arc = 1;
|
|---|
| 411 | else arc = 0;
|
|---|
| 412 | } else {
|
|---|
| 413 | span = atof(ele);
|
|---|
| 414 | }
|
|---|
| 415 | ele = strtok_r(NULL, ":", &etok);
|
|---|
| 416 | }
|
|---|
| 417 | if (span == 0.0) {
|
|---|
| 418 | char *back = (ttok != NULL) ? strstr(ttok, "-") : NULL;
|
|---|
| 419 | if (back != NULL) {
|
|---|
| 420 | span = b0 - end + atof(back);
|
|---|
| 421 | } else {
|
|---|
| 422 | span = b0 - end;
|
|---|
| 423 | }
|
|---|
| 424 | }
|
|---|
| 425 | if (r1 != r0) {
|
|---|
| 426 | p1 = radial(pos, r1, b0);
|
|---|
| 427 | if (!((start == 180.0) && (end == 180.0)))
|
|---|
| 428 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
|---|
| 429 | p0.x, p0.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
|---|
| 430 | r0 = r1;
|
|---|
| 431 | p0 = p1;
|
|---|
| 432 | }
|
|---|
| 433 | if (span < 0.0) {
|
|---|
| 434 | b1 = end - span;
|
|---|
| 435 | b1 = b1 > b0 ? b0 : b1;
|
|---|
| 436 | b0 = b1;
|
|---|
| 437 | b1 = end;
|
|---|
| 438 | p0 = radial(pos, r0, b0);
|
|---|
| 439 | } else {
|
|---|
| 440 | b1 = b0 - span;
|
|---|
| 441 | b1 = b1 < end ? end : b1;
|
|---|
| 442 | }
|
|---|
| 443 | p1 = radial(pos, r1, b1);
|
|---|
| 444 | if ((b0 == 180.0) && (b1 == 180.0)) {
|
|---|
| 445 | span = 360.0;
|
|---|
| 446 | p1 = radial(pos, r1, b1+0.01);
|
|---|
| 447 | }
|
|---|
| 448 | if (arc == 0) {
|
|---|
| 449 | if (p0.x < p1.x)
|
|---|
| 450 | printf("<path id=\"%d\" d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
|---|
| 451 | ++ref, p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
|---|
| 452 | else
|
|---|
| 453 | printf("<path id=\"%d\" d=\"M %g,%g A %g,%g,0,%d,0,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
|---|
| 454 | ++ref, p1.x, p1.y, r1*mile, r1*mile, span>180.0, p0.x, p0.y, col, (20 * symbolScale[zoom]));
|
|---|
| 455 | if (text != NULL) {
|
|---|
| 456 | double chord = sqrt(pow((p0.x - p1.x), 2) + pow((p0.y - p1.y), 2));
|
|---|
| 457 | if ((chord > (strlen(text) * textScale[zoom] * 50)) || ((b0 == 180.0) && (b1 == 180.0)))
|
|---|
| 458 | drawLineText(item, text, style, offset, dy, ref);
|
|---|
| 459 | }
|
|---|
| 460 | } else if (arc == 1) {
|
|---|
| 461 | printf("<path d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g;stroke-opacity:0.5;stroke-dasharray:%g\"/>\n",
|
|---|
| 462 | p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (10 * symbolScale[zoom]), (30 * symbolScale[zoom]));
|
|---|
| 463 | }
|
|---|
| 464 | if ((arc == 0) && (att->val.val.l->next != NULL)) {
|
|---|
| 465 | char *col = light_colours[att->val.val.l->next->val];
|
|---|
| 466 | double r2 = r1 - (20 * symbolScale[zoom]/mile);
|
|---|
| 467 | XY_t p2 = radial(pos, r2, b0);
|
|---|
| 468 | XY_t p3 = radial(pos, r2, b1);
|
|---|
| 469 | printf("<path d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
|---|
| 470 | p2.x, p2.y, r1*mile, r1*mile, span>180.0, p3.x, p3.y, col, (20 * symbolScale[zoom]));
|
|---|
| 471 | }
|
|---|
| 472 | b0 = b1;
|
|---|
| 473 | if (b0 == end) break;
|
|---|
| 474 | }
|
|---|
| 475 | if (!((start == 180.0) && (end == 180.0)))
|
|---|
| 476 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
|---|
| 477 | pos.x, pos.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
|---|
| 478 | free(radstr);
|
|---|
| 479 | }
|
|---|
| 480 | }
|
|---|
| 481 | }
|
|---|
| 482 | }
|
|---|
| 483 | }
|
|---|
| 484 | char *charString(Item_t *item, char *type, int idx) {
|
|---|
| 485 | strcpy(string1, "");
|
|---|
| 486 | Att_t *att = NULL;
|
|---|
| 487 | Obj_t *obj = getObj(item, enumType(type), idx);
|
|---|
| 488 | switch (enumType(type)) {
|
|---|
| 489 | case LIGHTS:
|
|---|
| 490 | {
|
|---|
| 491 | int secmax = countObjects(item, "light");
|
|---|
| 492 | if ((idx == 0) && (secmax > 0)) {
|
|---|
| 493 | struct SECT {
|
|---|
| 494 | struct SECT *next;
|
|---|
| 495 | int dir;
|
|---|
| 496 | LitCHR_t chr;
|
|---|
| 497 | ColCOL_t col;
|
|---|
| 498 | ColCOL_t alt;
|
|---|
| 499 | char *grp;
|
|---|
| 500 | double per;
|
|---|
| 501 | double rng;
|
|---|
| 502 | } *lights = NULL;
|
|---|
| 503 | for (int i = secmax; i > 0; i--) {
|
|---|
| 504 | struct SECT *tmp = calloc(1, sizeof(struct SECT));
|
|---|
| 505 | tmp->next = lights;
|
|---|
| 506 | lights = tmp;
|
|---|
| 507 | obj = getObj(item, LIGHTS, i);
|
|---|
| 508 | if ((att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 509 | lights->dir = testAtt(att, LIT_DIR);
|
|---|
| 510 | }
|
|---|
| 511 | if ((att = getAtt(obj, LITCHR)) != NULL) {
|
|---|
| 512 | lights->chr = att->val.val.e;
|
|---|
| 513 | switch (lights->chr) {
|
|---|
| 514 | case CHR_AL:
|
|---|
| 515 | lights->chr = CHR_F;
|
|---|
| 516 | break;
|
|---|
| 517 | case CHR_ALOC:
|
|---|
| 518 | lights->chr = CHR_OC;
|
|---|
| 519 | break;
|
|---|
| 520 | case CHR_ALLFL:
|
|---|
| 521 | lights->chr = CHR_LFL;
|
|---|
| 522 | break;
|
|---|
| 523 | case CHR_ALFL:
|
|---|
| 524 | lights->chr = CHR_FL;
|
|---|
| 525 | break;
|
|---|
| 526 | case CHR_ALFFL:
|
|---|
| 527 | lights->chr = CHR_FFL;
|
|---|
| 528 | break;
|
|---|
| 529 | default:
|
|---|
| 530 | break;
|
|---|
| 531 | }
|
|---|
| 532 | }
|
|---|
| 533 | if ((att = getAtt(obj, SIGGRP)) != NULL) {
|
|---|
| 534 | lights->grp = att->val.val.a;
|
|---|
| 535 | } else {
|
|---|
| 536 | lights->grp = "";
|
|---|
| 537 | }
|
|---|
| 538 | if ((att = getAtt(obj, SIGPER)) != NULL) {
|
|---|
| 539 | lights->per = att->val.val.f;
|
|---|
| 540 | }
|
|---|
| 541 | if ((att = getAtt(obj, VALNMR)) != NULL) {
|
|---|
| 542 | lights->rng = att->val.val.f;
|
|---|
| 543 | }
|
|---|
| 544 | if ((att = getAtt(obj, COLOUR)) != NULL) {
|
|---|
| 545 | lights->col = att->val.val.l->val;
|
|---|
| 546 | if (att->val.val.l->next != NULL)
|
|---|
| 547 | lights->alt = att->val.val.l->next->val;
|
|---|
| 548 | }
|
|---|
| 549 | }
|
|---|
| 550 | struct COLRNG {
|
|---|
| 551 | int col;
|
|---|
| 552 | double rng;
|
|---|
| 553 | } colrng[14];
|
|---|
| 554 | while (lights != NULL) {
|
|---|
| 555 | strcpy(string2, "");
|
|---|
| 556 | bzero(colrng, 14*sizeof(struct COLRNG));
|
|---|
| 557 | colrng[lights->col].col = 1;
|
|---|
| 558 | colrng[lights->col].rng = lights->rng;
|
|---|
| 559 | struct SECT *this = lights;
|
|---|
| 560 | struct SECT *next = lights->next;
|
|---|
| 561 | while (next != NULL) {
|
|---|
| 562 | if ((this->dir == next->dir) && (this->chr == next->chr) &&
|
|---|
| 563 | (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) {
|
|---|
| 564 | colrng[next->col].col = 1;
|
|---|
| 565 | if (next->rng > colrng[next->col].rng)
|
|---|
| 566 | colrng[next->col].rng = next->rng;
|
|---|
| 567 | struct SECT *tmp = lights;
|
|---|
| 568 | while (tmp->next != next) tmp = tmp->next;
|
|---|
| 569 | tmp->next = next->next;
|
|---|
| 570 | free(next);
|
|---|
| 571 | next = tmp->next;
|
|---|
| 572 | } else {
|
|---|
| 573 | next = next->next;
|
|---|
| 574 | }
|
|---|
| 575 | }
|
|---|
| 576 | if (this->chr != CHR_UNKN) {
|
|---|
| 577 | if (this->dir) strcpy(string2, "Dir.");
|
|---|
| 578 | strcat(string2, light_characters[this->chr]);
|
|---|
| 579 | if (strcmp(this->grp, "") != 0) {
|
|---|
| 580 | if (this->grp[0] == '(')
|
|---|
| 581 | sprintf(strchr(string2, 0), "%s", this->grp);
|
|---|
| 582 | else
|
|---|
| 583 | sprintf(strchr(string2, 0), "(%s)", this->grp);
|
|---|
| 584 | } else {
|
|---|
| 585 | if (strlen(string2) > 0) strcat(string2, ".");
|
|---|
| 586 | }
|
|---|
| 587 | int n = 0;
|
|---|
| 588 | for (int i = 0; i < 14; i++) if (colrng[i].col) n++;
|
|---|
| 589 | double max = 0.0;
|
|---|
| 590 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng;
|
|---|
| 591 | double min = max;
|
|---|
| 592 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng;
|
|---|
| 593 | if (min == max) {
|
|---|
| 594 | for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]);
|
|---|
| 595 | } else {
|
|---|
| 596 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]);
|
|---|
| 597 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]);
|
|---|
| 598 | for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]);
|
|---|
| 599 | }
|
|---|
| 600 | strcat(string2, ".");
|
|---|
| 601 | if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per);
|
|---|
| 602 | if (max > 0.0) {
|
|---|
| 603 | sprintf(strchr(string2, 0), "%g", max);
|
|---|
| 604 | if (min != max) {
|
|---|
| 605 | if (n == 2) strcat(string2, "/");
|
|---|
| 606 | else if (n > 2) strcat(string2, "-");
|
|---|
| 607 | if (min < max) sprintf(strchr(string2, 0), "%g", min);
|
|---|
| 608 | }
|
|---|
| 609 | strcat(string2, "M");
|
|---|
| 610 | }
|
|---|
| 611 | if (strlen(string1) > 0) strcat(string1, "\n");
|
|---|
| 612 | strcat(string1, string2);
|
|---|
| 613 | }
|
|---|
| 614 | lights = this->next;
|
|---|
| 615 | free(this);
|
|---|
| 616 | this = lights;
|
|---|
| 617 | }
|
|---|
| 618 | } else {
|
|---|
| 619 | if ((att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 620 | if (testAtt(att, LIT_DIR))
|
|---|
| 621 | strcat(string1, "Dir");
|
|---|
| 622 | }
|
|---|
| 623 | if ((att = getAtt(obj, MLTYLT)) != NULL)
|
|---|
| 624 | sprintf(strchr(string1, 0), "%s", stringValue(att->val));
|
|---|
| 625 | if ((att = getAtt(obj, LITCHR)) != NULL) {
|
|---|
| 626 | char *chrstr = strdup(stringValue(att->val));
|
|---|
| 627 | Att_t *grp = getAtt(obj, SIGGRP);
|
|---|
| 628 | if (grp != NULL) {
|
|---|
| 629 | char *strgrp = strdup(stringValue(grp->val));
|
|---|
| 630 | char *grpstr = strtok(strgrp, "()");
|
|---|
| 631 | switch (att->val.val.e) {
|
|---|
| 632 | case CHR_QLFL:
|
|---|
| 633 | sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr);
|
|---|
| 634 | break;
|
|---|
| 635 | case CHR_VQLFL:
|
|---|
| 636 | sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr);
|
|---|
| 637 | break;
|
|---|
| 638 | case CHR_UQLFL:
|
|---|
| 639 | sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr);
|
|---|
| 640 | break;
|
|---|
| 641 | default:
|
|---|
| 642 | sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr);
|
|---|
| 643 | break;
|
|---|
| 644 | }
|
|---|
| 645 | free(strgrp);
|
|---|
| 646 | } else {
|
|---|
| 647 | sprintf(strchr(string1, 0), "%s", chrstr);
|
|---|
| 648 | }
|
|---|
| 649 | free(chrstr);
|
|---|
| 650 | }
|
|---|
| 651 | if ((att = getAtt(obj, COLOUR)) != NULL) {
|
|---|
| 652 | int n = countValues(att);
|
|---|
| 653 | if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) {
|
|---|
| 654 | if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')')))
|
|---|
| 655 | strcat(string1, ".");
|
|---|
| 656 | Lst_t *lst = att->val.val.l;
|
|---|
| 657 | while (lst != NULL) {
|
|---|
| 658 | strcat(string1, light_letters[lst->val]);
|
|---|
| 659 | lst = lst->next;
|
|---|
| 660 | }
|
|---|
| 661 | }
|
|---|
| 662 | }
|
|---|
| 663 | if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 664 | if (testAtt(att, LIT_VERT))
|
|---|
| 665 | strcat(string1, "(vert)");
|
|---|
| 666 | if (testAtt(att, LIT_HORI))
|
|---|
| 667 | strcat(string1, "(hor)");
|
|---|
| 668 | }
|
|---|
| 669 | if ((strlen(string1) > 0) &&
|
|---|
| 670 | ((getAtt(obj, SIGPER) != NULL) ||
|
|---|
| 671 | (getAtt(obj, HEIGHT) != NULL) ||
|
|---|
| 672 | (getAtt(obj, VALMXR) != NULL)) &&
|
|---|
| 673 | (string1[strlen(string1)-1] != ')'))
|
|---|
| 674 | strcat(string1, ".");
|
|---|
| 675 | if ((att = getAtt(obj, SIGPER)) != NULL)
|
|---|
| 676 | sprintf(strchr(string1, 0), "%ss", stringValue(att->val));
|
|---|
| 677 | if ((idx == 0) && (item->objs.obj != LITMIN)) {
|
|---|
| 678 | if ((att = getAtt(obj, HEIGHT)) != NULL)
|
|---|
| 679 | sprintf(strchr(string1, 0), "%sm", stringValue(att->val));
|
|---|
| 680 | if ((att = getAtt(obj, VALNMR)) != NULL)
|
|---|
| 681 | sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
|
|---|
| 682 | }
|
|---|
| 683 | if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 684 | if (testAtt(att, LIT_FRNT))
|
|---|
| 685 | strcat(string1, "(Front)");
|
|---|
| 686 | if (testAtt(att, LIT_REAR))
|
|---|
| 687 | strcat(string1, "(Rear)");
|
|---|
| 688 | if (testAtt(att, LIT_UPPR))
|
|---|
| 689 | strcat(string1, "(Upper)");
|
|---|
| 690 | if (testAtt(att, LIT_LOWR))
|
|---|
| 691 | strcat(string1, "(Lower)");
|
|---|
| 692 | }
|
|---|
| 693 | }
|
|---|
| 694 | }
|
|---|
| 695 | break;
|
|---|
| 696 | default: break;
|
|---|
| 697 | }
|
|---|
| 698 | return string1;
|
|---|
| 699 | }
|
|---|
| 700 | */
|
|---|
| 701 |
|
|---|
| 702 | }
|
|---|