| 1 | /* Copyright 2013 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 seamap;
|
|---|
| 11 |
|
|---|
| 12 | import java.awt.Color;
|
|---|
| 13 | import java.awt.Font;
|
|---|
| 14 | import java.awt.geom.*;
|
|---|
| 15 | import java.util.ArrayList;
|
|---|
| 16 |
|
|---|
| 17 | import s57.S57att.Att;
|
|---|
| 18 | import s57.S57obj.Obj;
|
|---|
| 19 | import s57.S57val.CatROS;
|
|---|
| 20 | import seamap.Renderer.LabelStyle;
|
|---|
| 21 | import seamap.SeaMap.*;
|
|---|
| 22 | import symbols.Beacons;
|
|---|
| 23 | import symbols.Topmarks;
|
|---|
| 24 | import symbols.Symbols.Delta;
|
|---|
| 25 | import symbols.Symbols.Handle;
|
|---|
| 26 |
|
|---|
| 27 | public class Signals {
|
|---|
| 28 |
|
|---|
| 29 | public static void addSignals(Feature feature) {
|
|---|
| 30 | if (feature.objs.containsKey(Obj.FOGSIG)) Signals.fogSignals(feature);
|
|---|
| 31 | if (feature.objs.containsKey(Obj.RTPBCN)) Signals.radarStations(feature);
|
|---|
| 32 | if (feature.objs.containsKey(Obj.RADSTA)) Signals.radarStations(feature);
|
|---|
| 33 | if (feature.objs.containsKey(Obj.RDOSTA)) Signals.radioStations(feature);
|
|---|
| 34 | if (feature.objs.containsKey(Obj.LIGHTS)) Signals.lights(feature);
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | public static void fogSignals(Feature feature) {
|
|---|
| 38 |
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | public static void radarStations(Feature feature) {
|
|---|
| 42 | Renderer.symbol(feature, Beacons.RadarStation);
|
|---|
| 43 | ArrayList<CatROS> cats = (ArrayList<CatROS>)Util.getAttVal(feature, Obj.RDOSTA, 0, Att.CATROS);
|
|---|
| 44 | String str = "";
|
|---|
| 45 | for (CatROS ros : cats) {
|
|---|
| 46 | switch (ros) {
|
|---|
| 47 | case ROS_OMNI:
|
|---|
| 48 | str += " RC";
|
|---|
| 49 | break;
|
|---|
| 50 | case ROS_DIRL:
|
|---|
| 51 | str += " RD";
|
|---|
| 52 | break;
|
|---|
| 53 | case ROS_ROTP:
|
|---|
| 54 | str += " RW";
|
|---|
| 55 | break;
|
|---|
| 56 | case ROS_CNSL:
|
|---|
| 57 | str += " Consol";
|
|---|
| 58 | break;
|
|---|
| 59 | case ROS_RDF:
|
|---|
| 60 | str += " RG";
|
|---|
| 61 | break;
|
|---|
| 62 | case ROS_QTA:
|
|---|
| 63 | str += " R";
|
|---|
| 64 | break;
|
|---|
| 65 | case ROS_AERO:
|
|---|
| 66 | str += " AeroRC";
|
|---|
| 67 | break;
|
|---|
| 68 | case ROS_DECA:
|
|---|
| 69 | str += " Decca";
|
|---|
| 70 | break;
|
|---|
| 71 | case ROS_LORN:
|
|---|
| 72 | str += " Loran";
|
|---|
| 73 | break;
|
|---|
| 74 | case ROS_DGPS:
|
|---|
| 75 | str += " DGPS";
|
|---|
| 76 | break;
|
|---|
| 77 | case ROS_TORN:
|
|---|
| 78 | str += " Toran";
|
|---|
| 79 | break;
|
|---|
| 80 | case ROS_OMGA:
|
|---|
| 81 | str += " Omega";
|
|---|
| 82 | break;
|
|---|
| 83 | case ROS_SYLD:
|
|---|
| 84 | str += " Syledis";
|
|---|
| 85 | break;
|
|---|
| 86 | case ROS_CHKA:
|
|---|
| 87 | str += " Chiaka";
|
|---|
| 88 | break;
|
|---|
| 89 | case ROS_PCOM:
|
|---|
| 90 | case ROS_COMB:
|
|---|
| 91 | case ROS_FACS:
|
|---|
| 92 | case ROS_TIME:
|
|---|
| 93 | break;
|
|---|
| 94 | case ROS_PAIS:
|
|---|
| 95 | case ROS_SAIS:
|
|---|
| 96 | str += " AIS";
|
|---|
| 97 | break;
|
|---|
| 98 | case ROS_VAIS:
|
|---|
| 99 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 100 | break;
|
|---|
| 101 | case ROS_VANC:
|
|---|
| 102 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 103 | Renderer.symbol(feature, Topmarks.TopNorth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 104 | break;
|
|---|
| 105 | case ROS_VASC:
|
|---|
| 106 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 107 | Renderer.symbol(feature, Topmarks.TopSouth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 108 | break;
|
|---|
| 109 | case ROS_VAEC:
|
|---|
| 110 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 111 | Renderer.symbol(feature, Topmarks.TopEast, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 112 | break;
|
|---|
| 113 | case ROS_VAWC:
|
|---|
| 114 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 115 | Renderer.symbol(feature, Topmarks.TopWest, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 116 | break;
|
|---|
| 117 | case ROS_VAPL:
|
|---|
| 118 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 119 | Renderer.symbol(feature, Topmarks.TopCan, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 120 | break;
|
|---|
| 121 | case ROS_VASL:
|
|---|
| 122 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 123 | Renderer.symbol(feature, Topmarks.TopCone, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 124 | break;
|
|---|
| 125 | case ROS_VAID:
|
|---|
| 126 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 127 | Renderer.symbol(feature, Topmarks.TopIsol, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 128 | break;
|
|---|
| 129 | case ROS_VASW:
|
|---|
| 130 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 131 | Renderer.symbol(feature, Topmarks.TopSphere, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 132 | break;
|
|---|
| 133 | case ROS_VASP:
|
|---|
| 134 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 135 | Renderer.symbol(feature, Topmarks.TopX, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 136 | break;
|
|---|
| 137 | case ROS_VAWK:
|
|---|
| 138 | Renderer.labelText(feature, " V-AIS", new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
|
|---|
| 139 | Renderer.symbol(feature, Topmarks.TopCross, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
|
|---|
| 140 | break;
|
|---|
| 141 | default:
|
|---|
| 142 | break;
|
|---|
| 143 | }
|
|---|
| 144 | }
|
|---|
| 145 | if (!str.isEmpty()) Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40), LabelStyle.NONE, Color.black, null, new Delta(Handle.BR, AffineTransform.getTranslateInstance(-30, -70)));
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | public static void radioStations(Feature feature) {
|
|---|
| 149 |
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | public static void lights(Feature feature) {
|
|---|
| 153 |
|
|---|
| 154 | }
|
|---|
| 155 |
|
|---|
| 156 | private static Point2D.Double radial(Snode centre, double radius, double angle) {
|
|---|
| 157 | Point2D origin = Renderer.context.getPoint(centre);
|
|---|
| 158 | double mile = Renderer.context.getPoint(Renderer.map.new Snode((centre.lat + Math.toRadians(1/60)), centre.lon)).getY() - origin.getY();
|
|---|
| 159 | return new Point2D.Double(origin.getX() - (radius * mile * Math.sin(angle)), origin.getY() - (radius * mile * Math.cos(angle)));
|
|---|
| 160 | }
|
|---|
| 161 | /*
|
|---|
| 162 | void renderFlare(Item_t *item) {
|
|---|
| 163 | char *col = light_colours[COL_MAG];
|
|---|
| 164 | Obj_t *obj = getObj(item, LIGHTS, 0);
|
|---|
| 165 | Att_t *att;
|
|---|
| 166 | if (((att = getAtt(obj, COLOUR)) != NULL) && (att->val.val.l->next == NULL)) {
|
|---|
| 167 | col = light_colours[att->val.val.l->val];
|
|---|
| 168 | }
|
|---|
| 169 | renderSymbol(item, LIGHTS, "light", "", col, CC, 0, 0, 120);
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | void renderSector(Item_t *item, int s, char *text, char *style, double offset, int dy) {
|
|---|
| 173 | Obj_t *sector;
|
|---|
| 174 | double start, end;
|
|---|
| 175 | Att_t *att;
|
|---|
| 176 | XY_t p0, p1;
|
|---|
| 177 | double r0, r1;
|
|---|
| 178 | double b0, b1, span;
|
|---|
| 179 | char *col;
|
|---|
| 180 | XY_t pos = findCentroid(item);
|
|---|
| 181 | if ((sector = getObj(item, LIGHTS, s)) != NULL) {
|
|---|
| 182 | strcpy(string1, (att = getAtt(sector, LITRAD)) != NULL ? att->val.val.a : "0.2");
|
|---|
| 183 | if (((att = getAtt(sector, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(sector, ORIENT)) != NULL)) {
|
|---|
| 184 | b0 = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 185 | if ((att = getAtt(sector, COLOUR)) != NULL) {
|
|---|
| 186 | col = light_colours[att->val.val.l->val];
|
|---|
| 187 | r0 = atof(string1);
|
|---|
| 188 | p0 = radial(pos, r0, b0);
|
|---|
| 189 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
|---|
| 190 | pos.x, pos.y, p0.x, p0.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
|---|
| 191 | start = fmod(b0 + 2.0, 360.0);
|
|---|
| 192 | end = fmod(360.0 + b0 - 2.0, 360.0);
|
|---|
| 193 | Obj_t *adj;
|
|---|
| 194 | for (int i = s-1; i <= s+1; i++) {
|
|---|
| 195 | if (i == s) continue;
|
|---|
| 196 | if ((adj = getObj(item, LIGHTS, i)) == NULL) continue;
|
|---|
| 197 | Att_t *att;
|
|---|
| 198 | if (((att = getAtt(adj, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(adj, ORIENT)) != NULL)) {
|
|---|
| 199 | b1 = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 200 | if (fabs(b0 - b1) > 180.0) {
|
|---|
| 201 | if (b0 < b1) b0 += 360.0;
|
|---|
| 202 | else b1 += 360.0;
|
|---|
| 203 | }
|
|---|
| 204 | if (fabs(b0 - b1) < 4.0) {
|
|---|
| 205 | if (b1 > b0) start = fmod((720.0 + b0 + b1) / 2.0, 360.0);
|
|---|
| 206 | else end = fmod((720.0 + b0 + b1) / 2.0, 360.0);
|
|---|
| 207 | }
|
|---|
| 208 | }
|
|---|
| 209 | }
|
|---|
| 210 | p0 = radial(pos, r0, start);
|
|---|
| 211 | p1 = radial(pos, r0, end);
|
|---|
| 212 | 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",
|
|---|
| 213 | ++ref, p0.x, p0.y, r0*mile, r0*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
|---|
| 214 | if (att->val.val.l->next != NULL) {
|
|---|
| 215 | char *col = light_colours[att->val.val.l->next->val];
|
|---|
| 216 | r1 = r0 - (20 * symbolScale[zoom]/mile);
|
|---|
| 217 | p0 = radial(pos, r1, start);
|
|---|
| 218 | p1 = radial(pos, r1, end);
|
|---|
| 219 | printf("<path d=\"M %g,%g A %g,%g,0,0,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
|---|
| 220 | p0.x, p0.y, r1*mile, r1*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
|---|
| 221 | }
|
|---|
| 222 | }
|
|---|
| 223 | } else if ((att = getAtt(sector, SECTR1)) != NULL) {
|
|---|
| 224 | start = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 225 | if ((att = getAtt(sector, SECTR2)) != NULL) {
|
|---|
| 226 | end = fmod(540.0 - att->val.val.f, 360.0);
|
|---|
| 227 | start += start < end ? 360.0 : 0.0;
|
|---|
| 228 | if ((att = getAtt(sector, COLOUR)) != NULL) {
|
|---|
| 229 | char *ttok, *etok;
|
|---|
| 230 | char *radstr = strdup(string1);
|
|---|
| 231 | int arc = 0;
|
|---|
| 232 | col = light_colours[att->val.val.l->val];
|
|---|
| 233 | r0 = 0.0;
|
|---|
| 234 | b0 = b1 = start;
|
|---|
| 235 | for (char *tpl = strtok_r(radstr, ";", &ttok); tpl != NULL; tpl = strtok_r(NULL, ";", &ttok)) {
|
|---|
| 236 | p0 = radial(pos, r0, b0);
|
|---|
| 237 | span = 0.0;
|
|---|
| 238 | char *ele = strtok_r(tpl, ":", &etok);
|
|---|
| 239 | if ((*tpl == ':') && (r0 == 0.0)) {
|
|---|
| 240 | r1 = 0.2;
|
|---|
| 241 | } else if (*tpl != ':') {
|
|---|
| 242 | r1 = atof(tpl);
|
|---|
| 243 | ele = strtok_r(NULL, ":", &etok);
|
|---|
| 244 | }
|
|---|
| 245 | while (ele != NULL) {
|
|---|
| 246 | if (isalpha(*ele)) {
|
|---|
| 247 | if (strcmp(ele, "suppress") == 0) arc = 2;
|
|---|
| 248 | else if (strcmp(ele, "dashed") == 0) arc = 1;
|
|---|
| 249 | else arc = 0;
|
|---|
| 250 | } else {
|
|---|
| 251 | span = atof(ele);
|
|---|
| 252 | }
|
|---|
| 253 | ele = strtok_r(NULL, ":", &etok);
|
|---|
| 254 | }
|
|---|
| 255 | if (span == 0.0) {
|
|---|
| 256 | char *back = (ttok != NULL) ? strstr(ttok, "-") : NULL;
|
|---|
| 257 | if (back != NULL) {
|
|---|
| 258 | span = b0 - end + atof(back);
|
|---|
| 259 | } else {
|
|---|
| 260 | span = b0 - end;
|
|---|
| 261 | }
|
|---|
| 262 | }
|
|---|
| 263 | if (r1 != r0) {
|
|---|
| 264 | p1 = radial(pos, r1, b0);
|
|---|
| 265 | if (!((start == 180.0) && (end == 180.0)))
|
|---|
| 266 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
|---|
| 267 | p0.x, p0.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
|---|
| 268 | r0 = r1;
|
|---|
| 269 | p0 = p1;
|
|---|
| 270 | }
|
|---|
| 271 | if (span < 0.0) {
|
|---|
| 272 | b1 = end - span;
|
|---|
| 273 | b1 = b1 > b0 ? b0 : b1;
|
|---|
| 274 | b0 = b1;
|
|---|
| 275 | b1 = end;
|
|---|
| 276 | p0 = radial(pos, r0, b0);
|
|---|
| 277 | } else {
|
|---|
| 278 | b1 = b0 - span;
|
|---|
| 279 | b1 = b1 < end ? end : b1;
|
|---|
| 280 | }
|
|---|
| 281 | p1 = radial(pos, r1, b1);
|
|---|
| 282 | if ((b0 == 180.0) && (b1 == 180.0)) {
|
|---|
| 283 | span = 360.0;
|
|---|
| 284 | p1 = radial(pos, r1, b1+0.01);
|
|---|
| 285 | }
|
|---|
| 286 | if (arc == 0) {
|
|---|
| 287 | if (p0.x < p1.x)
|
|---|
| 288 | 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",
|
|---|
| 289 | ++ref, p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
|---|
| 290 | else
|
|---|
| 291 | 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",
|
|---|
| 292 | ++ref, p1.x, p1.y, r1*mile, r1*mile, span>180.0, p0.x, p0.y, col, (20 * symbolScale[zoom]));
|
|---|
| 293 | if (text != NULL) {
|
|---|
| 294 | double chord = sqrt(pow((p0.x - p1.x), 2) + pow((p0.y - p1.y), 2));
|
|---|
| 295 | if ((chord > (strlen(text) * textScale[zoom] * 50)) || ((b0 == 180.0) && (b1 == 180.0)))
|
|---|
| 296 | drawLineText(item, text, style, offset, dy, ref);
|
|---|
| 297 | }
|
|---|
| 298 | } else if (arc == 1) {
|
|---|
| 299 | 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",
|
|---|
| 300 | p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (10 * symbolScale[zoom]), (30 * symbolScale[zoom]));
|
|---|
| 301 | }
|
|---|
| 302 | if ((arc == 0) && (att->val.val.l->next != NULL)) {
|
|---|
| 303 | char *col = light_colours[att->val.val.l->next->val];
|
|---|
| 304 | double r2 = r1 - (20 * symbolScale[zoom]/mile);
|
|---|
| 305 | XY_t p2 = radial(pos, r2, b0);
|
|---|
| 306 | XY_t p3 = radial(pos, r2, b1);
|
|---|
| 307 | printf("<path d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
|---|
| 308 | p2.x, p2.y, r1*mile, r1*mile, span>180.0, p3.x, p3.y, col, (20 * symbolScale[zoom]));
|
|---|
| 309 | }
|
|---|
| 310 | b0 = b1;
|
|---|
| 311 | if (b0 == end) break;
|
|---|
| 312 | }
|
|---|
| 313 | if (!((start == 180.0) && (end == 180.0)))
|
|---|
| 314 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
|---|
| 315 | pos.x, pos.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
|---|
| 316 | free(radstr);
|
|---|
| 317 | }
|
|---|
| 318 | }
|
|---|
| 319 | }
|
|---|
| 320 | }
|
|---|
| 321 | }
|
|---|
| 322 | char *charString(Item_t *item, char *type, int idx) {
|
|---|
| 323 | strcpy(string1, "");
|
|---|
| 324 | Att_t *att = NULL;
|
|---|
| 325 | Obj_t *obj = getObj(item, enumType(type), idx);
|
|---|
| 326 | switch (enumType(type)) {
|
|---|
| 327 | case CGUSTA:
|
|---|
| 328 | strcpy(string1, "CG");
|
|---|
| 329 | if ((obj != NULL) && (att = getAtt(obj, COMCHA)) != NULL)
|
|---|
| 330 | sprintf(strchr(string1, 0), " Ch.%s", stringValue(att->val));
|
|---|
| 331 | break;
|
|---|
| 332 | case FOGSIG:
|
|---|
| 333 | if (obj != NULL) {
|
|---|
| 334 | if ((att = getAtt(obj, CATFOG)) != NULL)
|
|---|
| 335 | strcat(string1, fog_signals[att->val.val.e]);
|
|---|
| 336 | if ((att = getAtt(obj, SIGGRP)) != NULL)
|
|---|
| 337 | sprintf(strchr(string1, 0), "(%s)", stringValue(att->val));
|
|---|
| 338 | else
|
|---|
| 339 | strcat(string1, " ");
|
|---|
| 340 | if ((att = getAtt(obj, SIGPER)) != NULL)
|
|---|
| 341 | sprintf(strchr(string1, 0), "%ss ", stringValue(att->val));
|
|---|
| 342 | if ((att = getAtt(obj, VALMXR)) != NULL)
|
|---|
| 343 | sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
|
|---|
| 344 | }
|
|---|
| 345 | break;
|
|---|
| 346 | case RTPBCN:
|
|---|
| 347 | if (obj != NULL) {
|
|---|
| 348 | if ((att = getAtt(obj, CATRTB)) != NULL)
|
|---|
| 349 | strcat(string1, rtb_map[att->val.val.e]);
|
|---|
| 350 | if ((att = getAtt(obj, SIGGRP)) != NULL)
|
|---|
| 351 | sprintf(strchr(string1, 0), "(%s)", stringValue(att->val));
|
|---|
| 352 | else
|
|---|
| 353 | strcat(string1, " ");
|
|---|
| 354 | if ((att = getAtt(obj, SIGPER)) != NULL)
|
|---|
| 355 | sprintf(strchr(string1, 0), "%ss ", stringValue(att->val));
|
|---|
| 356 | if ((att = getAtt(obj, VALMXR)) != NULL)
|
|---|
| 357 | sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
|
|---|
| 358 | }
|
|---|
| 359 | break;
|
|---|
| 360 | case SISTAT:
|
|---|
| 361 | strcpy(string1, "SS");
|
|---|
| 362 | if (obj != NULL) {
|
|---|
| 363 | if ((att = getAtt(obj, CATSIT)) != NULL)
|
|---|
| 364 | strcat(string1, sit_map[att->val.val.l->val]);
|
|---|
| 365 | if ((att = getAtt(obj, COMCHA)) != NULL)
|
|---|
| 366 | sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val));
|
|---|
| 367 | }
|
|---|
| 368 | break;
|
|---|
| 369 | case SISTAW:
|
|---|
| 370 | strcpy(string1, "SS");
|
|---|
| 371 | if (obj != NULL) {
|
|---|
| 372 | if ((att = getAtt(obj, CATSIW)) != NULL)
|
|---|
| 373 | strcat(string1, siw_map[att->val.val.l->val]);
|
|---|
| 374 | if ((att = getAtt(obj, COMCHA)) != NULL)
|
|---|
| 375 | sprintf(strchr(string1, 0), "\nCh.%s", stringValue(att->val));
|
|---|
| 376 | }
|
|---|
| 377 | break;
|
|---|
| 378 | case LIGHTS:
|
|---|
| 379 | {
|
|---|
| 380 | int secmax = countObjects(item, "light");
|
|---|
| 381 | if ((idx == 0) && (secmax > 0)) {
|
|---|
| 382 | struct SECT {
|
|---|
| 383 | struct SECT *next;
|
|---|
| 384 | int dir;
|
|---|
| 385 | LitCHR_t chr;
|
|---|
| 386 | ColCOL_t col;
|
|---|
| 387 | ColCOL_t alt;
|
|---|
| 388 | char *grp;
|
|---|
| 389 | double per;
|
|---|
| 390 | double rng;
|
|---|
| 391 | } *lights = NULL;
|
|---|
| 392 | for (int i = secmax; i > 0; i--) {
|
|---|
| 393 | struct SECT *tmp = calloc(1, sizeof(struct SECT));
|
|---|
| 394 | tmp->next = lights;
|
|---|
| 395 | lights = tmp;
|
|---|
| 396 | obj = getObj(item, LIGHTS, i);
|
|---|
| 397 | if ((att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 398 | lights->dir = testAtt(att, LIT_DIR);
|
|---|
| 399 | }
|
|---|
| 400 | if ((att = getAtt(obj, LITCHR)) != NULL) {
|
|---|
| 401 | lights->chr = att->val.val.e;
|
|---|
| 402 | switch (lights->chr) {
|
|---|
| 403 | case CHR_AL:
|
|---|
| 404 | lights->chr = CHR_F;
|
|---|
| 405 | break;
|
|---|
| 406 | case CHR_ALOC:
|
|---|
| 407 | lights->chr = CHR_OC;
|
|---|
| 408 | break;
|
|---|
| 409 | case CHR_ALLFL:
|
|---|
| 410 | lights->chr = CHR_LFL;
|
|---|
| 411 | break;
|
|---|
| 412 | case CHR_ALFL:
|
|---|
| 413 | lights->chr = CHR_FL;
|
|---|
| 414 | break;
|
|---|
| 415 | case CHR_ALFFL:
|
|---|
| 416 | lights->chr = CHR_FFL;
|
|---|
| 417 | break;
|
|---|
| 418 | default:
|
|---|
| 419 | break;
|
|---|
| 420 | }
|
|---|
| 421 | }
|
|---|
| 422 | if ((att = getAtt(obj, SIGGRP)) != NULL) {
|
|---|
| 423 | lights->grp = att->val.val.a;
|
|---|
| 424 | } else {
|
|---|
| 425 | lights->grp = "";
|
|---|
| 426 | }
|
|---|
| 427 | if ((att = getAtt(obj, SIGPER)) != NULL) {
|
|---|
| 428 | lights->per = att->val.val.f;
|
|---|
| 429 | }
|
|---|
| 430 | if ((att = getAtt(obj, VALNMR)) != NULL) {
|
|---|
| 431 | lights->rng = att->val.val.f;
|
|---|
| 432 | }
|
|---|
| 433 | if ((att = getAtt(obj, COLOUR)) != NULL) {
|
|---|
| 434 | lights->col = att->val.val.l->val;
|
|---|
| 435 | if (att->val.val.l->next != NULL)
|
|---|
| 436 | lights->alt = att->val.val.l->next->val;
|
|---|
| 437 | }
|
|---|
| 438 | }
|
|---|
| 439 | struct COLRNG {
|
|---|
| 440 | int col;
|
|---|
| 441 | double rng;
|
|---|
| 442 | } colrng[14];
|
|---|
| 443 | while (lights != NULL) {
|
|---|
| 444 | strcpy(string2, "");
|
|---|
| 445 | bzero(colrng, 14*sizeof(struct COLRNG));
|
|---|
| 446 | colrng[lights->col].col = 1;
|
|---|
| 447 | colrng[lights->col].rng = lights->rng;
|
|---|
| 448 | struct SECT *this = lights;
|
|---|
| 449 | struct SECT *next = lights->next;
|
|---|
| 450 | while (next != NULL) {
|
|---|
| 451 | if ((this->dir == next->dir) && (this->chr == next->chr) &&
|
|---|
| 452 | (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) {
|
|---|
| 453 | colrng[next->col].col = 1;
|
|---|
| 454 | if (next->rng > colrng[next->col].rng)
|
|---|
| 455 | colrng[next->col].rng = next->rng;
|
|---|
| 456 | struct SECT *tmp = lights;
|
|---|
| 457 | while (tmp->next != next) tmp = tmp->next;
|
|---|
| 458 | tmp->next = next->next;
|
|---|
| 459 | free(next);
|
|---|
| 460 | next = tmp->next;
|
|---|
| 461 | } else {
|
|---|
| 462 | next = next->next;
|
|---|
| 463 | }
|
|---|
| 464 | }
|
|---|
| 465 | if (this->chr != CHR_UNKN) {
|
|---|
| 466 | if (this->dir) strcpy(string2, "Dir.");
|
|---|
| 467 | strcat(string2, light_characters[this->chr]);
|
|---|
| 468 | if (strcmp(this->grp, "") != 0) {
|
|---|
| 469 | if (this->grp[0] == '(')
|
|---|
| 470 | sprintf(strchr(string2, 0), "%s", this->grp);
|
|---|
| 471 | else
|
|---|
| 472 | sprintf(strchr(string2, 0), "(%s)", this->grp);
|
|---|
| 473 | } else {
|
|---|
| 474 | if (strlen(string2) > 0) strcat(string2, ".");
|
|---|
| 475 | }
|
|---|
| 476 | int n = 0;
|
|---|
| 477 | for (int i = 0; i < 14; i++) if (colrng[i].col) n++;
|
|---|
| 478 | double max = 0.0;
|
|---|
| 479 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng;
|
|---|
| 480 | double min = max;
|
|---|
| 481 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng;
|
|---|
| 482 | if (min == max) {
|
|---|
| 483 | for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]);
|
|---|
| 484 | } else {
|
|---|
| 485 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]);
|
|---|
| 486 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]);
|
|---|
| 487 | for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]);
|
|---|
| 488 | }
|
|---|
| 489 | strcat(string2, ".");
|
|---|
| 490 | if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per);
|
|---|
| 491 | if (max > 0.0) {
|
|---|
| 492 | sprintf(strchr(string2, 0), "%g", max);
|
|---|
| 493 | if (min != max) {
|
|---|
| 494 | if (n == 2) strcat(string2, "/");
|
|---|
| 495 | else if (n > 2) strcat(string2, "-");
|
|---|
| 496 | if (min < max) sprintf(strchr(string2, 0), "%g", min);
|
|---|
| 497 | }
|
|---|
| 498 | strcat(string2, "M");
|
|---|
| 499 | }
|
|---|
| 500 | if (strlen(string1) > 0) strcat(string1, "\n");
|
|---|
| 501 | strcat(string1, string2);
|
|---|
| 502 | }
|
|---|
| 503 | lights = this->next;
|
|---|
| 504 | free(this);
|
|---|
| 505 | this = lights;
|
|---|
| 506 | }
|
|---|
| 507 | } else {
|
|---|
| 508 | if ((att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 509 | if (testAtt(att, LIT_DIR))
|
|---|
| 510 | strcat(string1, "Dir");
|
|---|
| 511 | }
|
|---|
| 512 | if ((att = getAtt(obj, MLTYLT)) != NULL)
|
|---|
| 513 | sprintf(strchr(string1, 0), "%s", stringValue(att->val));
|
|---|
| 514 | if ((att = getAtt(obj, LITCHR)) != NULL) {
|
|---|
| 515 | char *chrstr = strdup(stringValue(att->val));
|
|---|
| 516 | Att_t *grp = getAtt(obj, SIGGRP);
|
|---|
| 517 | if (grp != NULL) {
|
|---|
| 518 | char *strgrp = strdup(stringValue(grp->val));
|
|---|
| 519 | char *grpstr = strtok(strgrp, "()");
|
|---|
| 520 | switch (att->val.val.e) {
|
|---|
| 521 | case CHR_QLFL:
|
|---|
| 522 | sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr);
|
|---|
| 523 | break;
|
|---|
| 524 | case CHR_VQLFL:
|
|---|
| 525 | sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr);
|
|---|
| 526 | break;
|
|---|
| 527 | case CHR_UQLFL:
|
|---|
| 528 | sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr);
|
|---|
| 529 | break;
|
|---|
| 530 | default:
|
|---|
| 531 | sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr);
|
|---|
| 532 | break;
|
|---|
| 533 | }
|
|---|
| 534 | free(strgrp);
|
|---|
| 535 | } else {
|
|---|
| 536 | sprintf(strchr(string1, 0), "%s", chrstr);
|
|---|
| 537 | }
|
|---|
| 538 | free(chrstr);
|
|---|
| 539 | }
|
|---|
| 540 | if ((att = getAtt(obj, COLOUR)) != NULL) {
|
|---|
| 541 | int n = countValues(att);
|
|---|
| 542 | if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) {
|
|---|
| 543 | if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')')))
|
|---|
| 544 | strcat(string1, ".");
|
|---|
| 545 | Lst_t *lst = att->val.val.l;
|
|---|
| 546 | while (lst != NULL) {
|
|---|
| 547 | strcat(string1, light_letters[lst->val]);
|
|---|
| 548 | lst = lst->next;
|
|---|
| 549 | }
|
|---|
| 550 | }
|
|---|
| 551 | }
|
|---|
| 552 | if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 553 | if (testAtt(att, LIT_VERT))
|
|---|
| 554 | strcat(string1, "(vert)");
|
|---|
| 555 | if (testAtt(att, LIT_HORI))
|
|---|
| 556 | strcat(string1, "(hor)");
|
|---|
| 557 | }
|
|---|
| 558 | if ((strlen(string1) > 0) &&
|
|---|
| 559 | ((getAtt(obj, SIGPER) != NULL) ||
|
|---|
| 560 | (getAtt(obj, HEIGHT) != NULL) ||
|
|---|
| 561 | (getAtt(obj, VALMXR) != NULL)) &&
|
|---|
| 562 | (string1[strlen(string1)-1] != ')'))
|
|---|
| 563 | strcat(string1, ".");
|
|---|
| 564 | if ((att = getAtt(obj, SIGPER)) != NULL)
|
|---|
| 565 | sprintf(strchr(string1, 0), "%ss", stringValue(att->val));
|
|---|
| 566 | if ((idx == 0) && (item->objs.obj != LITMIN)) {
|
|---|
| 567 | if ((att = getAtt(obj, HEIGHT)) != NULL)
|
|---|
| 568 | sprintf(strchr(string1, 0), "%sm", stringValue(att->val));
|
|---|
| 569 | if ((att = getAtt(obj, VALNMR)) != NULL)
|
|---|
| 570 | sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
|
|---|
| 571 | }
|
|---|
| 572 | if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
|
|---|
| 573 | if (testAtt(att, LIT_FRNT))
|
|---|
| 574 | strcat(string1, "(Front)");
|
|---|
| 575 | if (testAtt(att, LIT_REAR))
|
|---|
| 576 | strcat(string1, "(Rear)");
|
|---|
| 577 | if (testAtt(att, LIT_UPPR))
|
|---|
| 578 | strcat(string1, "(Upper)");
|
|---|
| 579 | if (testAtt(att, LIT_LOWR))
|
|---|
| 580 | strcat(string1, "(Lower)");
|
|---|
| 581 | }
|
|---|
| 582 | }
|
|---|
| 583 | }
|
|---|
| 584 | break;
|
|---|
| 585 | default: break;
|
|---|
| 586 | }
|
|---|
| 587 | return string1;
|
|---|
| 588 | }
|
|---|
| 589 | */
|
|---|
| 590 |
|
|---|
| 591 | }
|
|---|