source: osm/applications/editors/josm/plugins/seachart/src/render/Signals.java@ 31044

Last change on this file since 31044 was 31044, checked in by malcolmh, 11 years ago

[seachart]update & tidy directories

File size: 26.5 KB
Line 
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
10package render;
11
12import java.awt.Color;
13import java.awt.Font;
14import java.awt.geom.*;
15import java.util.ArrayList;
16import java.util.EnumMap;
17
18import s57.S57att.*;
19import s57.S57obj.*;
20import s57.S57val.*;
21import s57.S57map.*;
22import symbols.Beacons;
23import symbols.Symbols;
24import symbols.Topmarks;
25import symbols.Symbols.*;
26
27public class Signals {
28
29 static final EnumMap<ColCOL, Color> lightColours = new EnumMap<ColCOL, Color>(ColCOL.class);
30 static {
31 lightColours.put(ColCOL.COL_WHT, new Color(0xffff00));
32 lightColours.put(ColCOL.COL_RED, new Color(0xff0000));
33 lightColours.put(ColCOL.COL_GRN, new Color(0x00ff00));
34 lightColours.put(ColCOL.COL_BLU, new Color(0x0000ff));
35 lightColours.put(ColCOL.COL_YEL, new Color(0xffff00));
36 lightColours.put(ColCOL.COL_AMB, new Color(0xffc200));
37 lightColours.put(ColCOL.COL_VIO, new Color(0xee82ee));
38 lightColours.put(ColCOL.COL_ORG, Color.orange);
39 lightColours.put(ColCOL.COL_MAG, Color.magenta);
40 }
41
42 static final EnumMap<ColCOL, String> lightLetters = new EnumMap<ColCOL, String>(ColCOL.class);
43 static {
44 lightLetters.put(ColCOL.COL_WHT, "W");
45 lightLetters.put(ColCOL.COL_RED, "R");
46 lightLetters.put(ColCOL.COL_GRN, "G");
47 lightLetters.put(ColCOL.COL_BLU, "Bu");
48 lightLetters.put(ColCOL.COL_YEL, "Y");
49 lightLetters.put(ColCOL.COL_AMB, "Am");
50 lightLetters.put(ColCOL.COL_VIO, "Vi");
51 lightLetters.put(ColCOL.COL_ORG, "Or");
52 }
53
54 static final EnumMap<LitCHR, String> lightCharacters = new EnumMap<LitCHR, String>(LitCHR.class);
55 static {
56 lightCharacters.put(LitCHR.CHR_F, "W");
57 lightCharacters.put(LitCHR.CHR_FL, "Fl");
58 lightCharacters.put(LitCHR.CHR_LFL, "LFl");
59 lightCharacters.put(LitCHR.CHR_Q, "Q");
60 lightCharacters.put(LitCHR.CHR_VQ, "VQ");
61 lightCharacters.put(LitCHR.CHR_UQ, "UQ");
62 lightCharacters.put(LitCHR.CHR_ISO, "Iso");
63 lightCharacters.put(LitCHR.CHR_OC, "Oc");
64 lightCharacters.put(LitCHR.CHR_IQ, "IQ");
65 lightCharacters.put(LitCHR.CHR_IVQ, "IVQ");
66 lightCharacters.put(LitCHR.CHR_IUQ, "IUQ");
67 lightCharacters.put(LitCHR.CHR_MO, "Mo");
68 lightCharacters.put(LitCHR.CHR_FFL, "FFl");
69 lightCharacters.put(LitCHR.CHR_FLLFL, "FlLFl");
70 lightCharacters.put(LitCHR.CHR_OCFL, "OcFl");
71 lightCharacters.put(LitCHR.CHR_FLFL, "FLFl");
72 lightCharacters.put(LitCHR.CHR_ALOC, "Al.Oc");
73 lightCharacters.put(LitCHR.CHR_ALLFL, "Al.LFl");
74 lightCharacters.put(LitCHR.CHR_ALFL, "Al.Fl");
75 lightCharacters.put(LitCHR.CHR_ALGR, "Al.Gr");
76 lightCharacters.put(LitCHR.CHR_QLFL, "Q+LFl");
77 lightCharacters.put(LitCHR.CHR_VQLFL, "VQ+LFl");
78 lightCharacters.put(LitCHR.CHR_UQLFL, "UQ+LFl");
79 lightCharacters.put(LitCHR.CHR_AL, "Al");
80 lightCharacters.put(LitCHR.CHR_ALFFL, "Al.FFl");
81 }
82
83 public static void addSignals(Feature feature) {
84 if (feature.objs.containsKey(Obj.FOGSIG)) fogSignals(feature);
85 if (feature.objs.containsKey(Obj.RTPBCN)) radarStations(feature);
86 if (feature.objs.containsKey(Obj.RADSTA)) radarStations(feature);
87 if (feature.objs.containsKey(Obj.RDOSTA)) radioStations(feature);
88 if (feature.objs.containsKey(Obj.LIGHTS)) lights(feature);
89 }
90
91 static final EnumMap<CatFOG, String> fogSignals = new EnumMap<CatFOG, String>(CatFOG.class);
92 static {
93 fogSignals.put(CatFOG.FOG_EXPL, "Explos");
94 fogSignals.put(CatFOG.FOG_DIA, "Dia");
95 fogSignals.put(CatFOG.FOG_SIRN, "Siren");
96 fogSignals.put(CatFOG.FOG_NAUT, "Horn");
97 fogSignals.put(CatFOG.FOG_REED, "Horn");
98 fogSignals.put(CatFOG.FOG_TYPH, "Horn");
99 fogSignals.put(CatFOG.FOG_BELL, "Bell");
100 fogSignals.put(CatFOG.FOG_WHIS, "Whis");
101 fogSignals.put(CatFOG.FOG_GONG, "Gong");
102 fogSignals.put(CatFOG.FOG_HORN, "Horn");
103 }
104
105 public static void fogSignals(Feature feature) {
106 Renderer.symbol(feature, Beacons.FogSignal);
107 AttMap atts = feature.objs.get(Obj.FOGSIG).get(0);
108 String str = "";
109 if (atts.containsKey(Att.CATFOG)) {
110 str += fogSignals.get(((ArrayList<?>)(atts.get(Att.CATFOG).val)).get(0));
111 }
112 if (atts.containsKey(Att.SIGGRP)) {
113 str += "(" + atts.get(Att.SIGGRP).val + ")";
114 } else {
115 str += " ";
116 }
117 if (atts.containsKey(Att.SIGPER)) {
118 str += atts.get(Att.SIGPER).val + "s";
119 }
120 if (atts.containsKey(Att.VALMXR)) {
121 str += atts.get(Att.VALMXR).val + "M";
122 }
123 if ((Renderer.zoom >= 15) && !str.isEmpty()) {
124 Renderer.labelText(feature, str, new Font("Arial", Font.PLAIN, 40),Color.black, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-60, -30)));
125 }
126 }
127
128 public static void radarStations(Feature feature) {
129 Renderer.symbol(feature, Beacons.RadarStation);
130 String bstr = "";
131 CatRTB cat = (CatRTB) Rules.getAttEnum(feature, Obj.RTPBCN, 0, Att.CATRTB);
132 String wal = Rules.getAttStr(feature, Obj.RTPBCN, 0, Att.RADWAL);
133 switch (cat) {
134 case RTB_RAMK:
135 bstr += " Ramark";
136 break;
137 case RTB_RACN:
138 bstr += " Racon";
139 String astr = Rules.getAttStr(feature, Obj.RTPBCN, 0, Att.SIGGRP);
140 if (!astr.isEmpty()) {
141 bstr += "(" + astr + ")";
142 }
143 Double per = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.SIGPER);
144 Double mxr = (Double) Rules.getAttVal(feature, Obj.RTPBCN, 0, Att.VALMXR);
145 if ((per != null) || (mxr != null)) {
146 bstr += (astr.isEmpty() ? " " : "");
147 if (per != null) bstr += (per != 0) ? per.toString() + "s" : "";
148 if (mxr != null) bstr += (mxr != 0) ? mxr.toString() + "M" : "";
149 }
150 break;
151 default:
152 break;
153 }
154 if (!wal.isEmpty()) {
155 switch (wal) {
156 case "0.03-X":
157 bstr += "(3cm)";
158 break;
159 case "0.10-S":
160 bstr += "(10cm)";
161 break;
162 }
163 }
164 if ((Renderer.zoom >= 15) && !bstr.isEmpty()) {
165 Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -70)));
166 }
167 }
168
169 public static void radioStations(Feature feature) {
170 Renderer.symbol(feature, Beacons.RadarStation);
171 ArrayList<CatROS> cats = (ArrayList<CatROS>)Rules.getAttList(feature, Obj.RDOSTA, 0, Att.CATROS);
172 boolean vais = false;
173 String bstr = "";
174 for (CatROS ros : cats) {
175 switch (ros) {
176 case ROS_OMNI:
177 bstr += " RC";
178 break;
179 case ROS_DIRL:
180 bstr += " RD";
181 break;
182 case ROS_ROTP:
183 bstr += " RW";
184 break;
185 case ROS_CNSL:
186 bstr += " Consol";
187 break;
188 case ROS_RDF:
189 bstr += " RG";
190 break;
191 case ROS_QTA:
192 bstr += " R";
193 break;
194 case ROS_AERO:
195 bstr += " AeroRC";
196 break;
197 case ROS_DECA:
198 bstr += " Decca";
199 break;
200 case ROS_LORN:
201 bstr += " Loran";
202 break;
203 case ROS_DGPS:
204 bstr += " DGPS";
205 break;
206 case ROS_TORN:
207 bstr += " Toran";
208 break;
209 case ROS_OMGA:
210 bstr += " Omega";
211 break;
212 case ROS_SYLD:
213 bstr += " Syledis";
214 break;
215 case ROS_CHKA:
216 bstr += " Chiaka";
217 break;
218 case ROS_PCOM:
219 case ROS_COMB:
220 case ROS_FACS:
221 case ROS_TIME:
222 break;
223 case ROS_PAIS:
224 case ROS_SAIS:
225 bstr += " AIS";
226 break;
227 case ROS_VAIS:
228 vais = true;
229 break;
230 case ROS_VANC:
231 vais = true;
232 Renderer.symbol(feature, Topmarks.TopNorth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
233 break;
234 case ROS_VASC:
235 vais = true;
236 Renderer.symbol(feature, Topmarks.TopSouth, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
237 break;
238 case ROS_VAEC:
239 vais = true;
240 Renderer.symbol(feature, Topmarks.TopEast, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
241 break;
242 case ROS_VAWC:
243 vais = true;
244 Renderer.symbol(feature, Topmarks.TopWest, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
245 break;
246 case ROS_VAPL:
247 vais = true;
248 Renderer.symbol(feature, Topmarks.TopCan, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
249 break;
250 case ROS_VASL:
251 vais = true;
252 Renderer.symbol(feature, Topmarks.TopCone, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
253 break;
254 case ROS_VAID:
255 vais = true;
256 Renderer.symbol(feature, Topmarks.TopIsol, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
257 break;
258 case ROS_VASW:
259 vais = true;
260 Renderer.symbol(feature, Topmarks.TopSphere, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
261 break;
262 case ROS_VASP:
263 vais = true;
264 Renderer.symbol(feature, Topmarks.TopX, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
265 break;
266 case ROS_VAWK:
267 vais = true;
268 Renderer.symbol(feature, Topmarks.TopCross, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -25)));
269 break;
270 default:
271 break;
272 }
273 }
274 if (Renderer.zoom >= 15) {
275 if (vais) {
276 Renderer.labelText(feature, "V-AIS", new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, 70)));
277 }
278 if (!bstr.isEmpty()) {
279 Renderer.labelText(feature, bstr, new Font("Arial", Font.PLAIN, 40), Symbols.Msymb, new Delta(Handle.TR, AffineTransform.getTranslateInstance(-30, -110)));
280 }
281 }
282 }
283
284 public static void lights(Feature feature) {
285 Enum<ColCOL> col = null;
286 Enum<ColCOL> tcol = null;
287 ObjTab objs = feature.objs.get(Obj.LIGHTS);
288 for (AttMap atts : objs.values()) {
289 if (atts.containsKey(Att.COLOUR)) {
290 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
291 if (cols.size() == 1) {
292 tcol = cols.get(0);
293 if (col == null) {
294 col = tcol;
295 } else if (tcol != col) {
296 col = ColCOL.COL_MAG;
297 break;
298 }
299 } else {
300 col = ColCOL.COL_MAG;
301 break;
302 }
303 }
304 }
305 Renderer.symbol(feature, Beacons.LightFlare, new Scheme(lightColours.get(col)), new Delta(Handle.BC, AffineTransform.getRotateInstance(Math.toRadians(120))));
306 if (objs.get(1) != null) {
307 for (AttMap atts : objs.values()) {
308 Enum<ColCOL> col1 = null;
309 Enum<ColCOL> col2 = null;
310 double radius = 0.2;
311 double s1 = 0;
312 double s2 = 0;
313 boolean dir = false;
314 if (atts.containsKey(Att.COLOUR)) {
315 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
316 col1 = cols.get(0);
317 if (cols.size() > 1) col2 = cols.get(1);
318 } else {
319 continue;
320 }
321 if (atts.containsKey(Att.RADIUS)) {
322 radius = (Double) atts.get(Att.RADIUS).val;
323 }
324 if (atts.containsKey(Att.SECTR1)) {
325 s1 = (Double) atts.get(Att.SECTR1).val;
326 } else {
327 continue;
328 }
329 if (atts.containsKey(Att.SECTR2)) {
330 s2 = (Double) atts.get(Att.SECTR2).val;
331 } else {
332 continue;
333 }
334 if (atts.containsKey(Att.CATLIT)) {
335 ArrayList<CatLIT> cats = (ArrayList<CatLIT>) atts.get(Att.CATLIT).val;
336 if (cats.contains(CatLIT.LIT_DIR)) {
337 dir = true;
338 }
339 }
340 String str = "";
341 if (atts.containsKey(Att.LITCHR)) {
342 str += lightCharacters.get(atts.get(Att.LITCHR).val);
343 }
344 if (atts.containsKey(Att.SIGGRP)) {
345 str += "(" + atts.get(Att.SIGGRP).val + ")";
346 } else if (!str.isEmpty()) {
347 str += ".";
348 }
349 if (atts.containsKey(Att.COLOUR)) {
350 ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
351 str += lightLetters.get(cols.get(0));
352 if (cols.size() > 1)
353 str += lightLetters.get(cols.get(1));
354 }
355 if (dir && atts.containsKey(Att.ORIENT)) {
356 double orient = (Double)atts.get(Att.ORIENT).val;
357 str += " " + orient + "°";
358 s1 = (orient - 4 + 360) % 360;
359 s2 = (orient + 4) % 360;
360 double n1 = 360;
361 double n2 = 360;
362 for (AttMap sect : objs.values()) {
363 if (sect != atts) {
364
365 }
366 }
367 }
368 Renderer.lightSector(feature, lightColours.get(col1), lightColours.get(col2), radius, s1, s2, dir, str);
369 }
370 }
371 }
372
373 /*
374void renderSector(Item_t *item, int s, char *text, char *style, double offset, int dy) {
375 Obj_t *sector;
376 double start, end;
377 Att_t *att;
378 XY_t p0, p1;
379 double r0, r1;
380 double b0, b1, span;
381 char *col;
382 XY_t pos = findCentroid(item);
383 if ((sector = getObj(item, LIGHTS, s)) != NULL) {
384 strcpy(string1, (att = getAtt(sector, LITRAD)) != NULL ? att->val.val.a : "0.2");
385 if (((att = getAtt(sector, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(sector, ORIENT)) != NULL)) {
386 b0 = fmod(540.0 - att->val.val.f, 360.0);
387 if ((att = getAtt(sector, COLOUR)) != NULL) {
388 col = light_colours[att->val.val.l->val];
389 r0 = atof(string1);
390 p0 = radial(pos, r0, b0);
391 printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
392 pos.x, pos.y, p0.x, p0.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
393 start = fmod(b0 + 2.0, 360.0);
394 end = fmod(360.0 + b0 - 2.0, 360.0);
395 Obj_t *adj;
396 for (int i = s-1; i <= s+1; i++) {
397 if (i == s) continue;
398 if ((adj = getObj(item, LIGHTS, i)) == NULL) continue;
399 Att_t *att;
400 if (((att = getAtt(adj, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(adj, ORIENT)) != NULL)) {
401 b1 = fmod(540.0 - att->val.val.f, 360.0);
402 if (fabs(b0 - b1) > 180.0) {
403 if (b0 < b1) b0 += 360.0;
404 else b1 += 360.0;
405 }
406 if (fabs(b0 - b1) < 4.0) {
407 if (b1 > b0) start = fmod((720.0 + b0 + b1) / 2.0, 360.0);
408 else end = fmod((720.0 + b0 + b1) / 2.0, 360.0);
409 }
410 }
411 }
412 p0 = radial(pos, r0, start);
413 p1 = radial(pos, r0, end);
414 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",
415 ++ref, p0.x, p0.y, r0*mile, r0*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
416 if (att->val.val.l->next != NULL) {
417 char *col = light_colours[att->val.val.l->next->val];
418 r1 = r0 - (20 * symbolScale[zoom]/mile);
419 p0 = radial(pos, r1, start);
420 p1 = radial(pos, r1, end);
421 printf("<path d=\"M %g,%g A %g,%g,0,0,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
422 p0.x, p0.y, r1*mile, r1*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
423 }
424 }
425 } else if ((att = getAtt(sector, SECTR1)) != NULL) {
426 start = fmod(540.0 - att->val.val.f, 360.0);
427 if ((att = getAtt(sector, SECTR2)) != NULL) {
428 end = fmod(540.0 - att->val.val.f, 360.0);
429 start += start < end ? 360.0 : 0.0;
430 if ((att = getAtt(sector, COLOUR)) != NULL) {
431 char *ttok, *etok;
432 char *radstr = strdup(string1);
433 int arc = 0;
434 col = light_colours[att->val.val.l->val];
435 r0 = 0.0;
436 b0 = b1 = start;
437 for (char *tpl = strtok_r(radstr, ";", &ttok); tpl != NULL; tpl = strtok_r(NULL, ";", &ttok)) {
438 p0 = radial(pos, r0, b0);
439 span = 0.0;
440 char *ele = strtok_r(tpl, ":", &etok);
441 if ((*tpl == ':') && (r0 == 0.0)) {
442 r1 = 0.2;
443 } else if (*tpl != ':') {
444 r1 = atof(tpl);
445 ele = strtok_r(NULL, ":", &etok);
446 }
447 while (ele != NULL) {
448 if (isalpha(*ele)) {
449 if (strcmp(ele, "suppress") == 0) arc = 2;
450 else if (strcmp(ele, "dashed") == 0) arc = 1;
451 else arc = 0;
452 } else {
453 span = atof(ele);
454 }
455 ele = strtok_r(NULL, ":", &etok);
456 }
457 if (span == 0.0) {
458 char *back = (ttok != NULL) ? strstr(ttok, "-") : NULL;
459 if (back != NULL) {
460 span = b0 - end + atof(back);
461 } else {
462 span = b0 - end;
463 }
464 }
465 if (r1 != r0) {
466 p1 = radial(pos, r1, b0);
467 if (!((start == 180.0) && (end == 180.0)))
468 printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
469 p0.x, p0.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
470 r0 = r1;
471 p0 = p1;
472 }
473 if (span < 0.0) {
474 b1 = end - span;
475 b1 = b1 > b0 ? b0 : b1;
476 b0 = b1;
477 b1 = end;
478 p0 = radial(pos, r0, b0);
479 } else {
480 b1 = b0 - span;
481 b1 = b1 < end ? end : b1;
482 }
483 p1 = radial(pos, r1, b1);
484 if ((b0 == 180.0) && (b1 == 180.0)) {
485 span = 360.0;
486 p1 = radial(pos, r1, b1+0.01);
487 }
488 if (arc == 0) {
489 if (p0.x < p1.x)
490 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",
491 ++ref, p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (20 * symbolScale[zoom]));
492 else
493 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",
494 ++ref, p1.x, p1.y, r1*mile, r1*mile, span>180.0, p0.x, p0.y, col, (20 * symbolScale[zoom]));
495 if (text != NULL) {
496 double chord = sqrt(pow((p0.x - p1.x), 2) + pow((p0.y - p1.y), 2));
497 if ((chord > (strlen(text) * textScale[zoom] * 50)) || ((b0 == 180.0) && (b1 == 180.0)))
498 drawLineText(item, text, style, offset, dy, ref);
499 }
500 } else if (arc == 1) {
501 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",
502 p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (10 * symbolScale[zoom]), (30 * symbolScale[zoom]));
503 }
504 if ((arc == 0) && (att->val.val.l->next != NULL)) {
505 char *col = light_colours[att->val.val.l->next->val];
506 double r2 = r1 - (20 * symbolScale[zoom]/mile);
507 XY_t p2 = radial(pos, r2, b0);
508 XY_t p3 = radial(pos, r2, b1);
509 printf("<path d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
510 p2.x, p2.y, r1*mile, r1*mile, span>180.0, p3.x, p3.y, col, (20 * symbolScale[zoom]));
511 }
512 b0 = b1;
513 if (b0 == end) break;
514 }
515 if (!((start == 180.0) && (end == 180.0)))
516 printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
517 pos.x, pos.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
518 free(radstr);
519 }
520 }
521 }
522 }
523}
524char *charString(Item_t *item, char *type, int idx) {
525 strcpy(string1, "");
526 Att_t *att = NULL;
527 Obj_t *obj = getObj(item, enumType(type), idx);
528 switch (enumType(type)) {
529 case LIGHTS:
530 {
531 int secmax = countObjects(item, "light");
532 if ((idx == 0) && (secmax > 0)) {
533 struct SECT {
534 struct SECT *next;
535 int dir;
536 LitCHR_t chr;
537 ColCOL_t col;
538 ColCOL_t alt;
539 char *grp;
540 double per;
541 double rng;
542 } *lights = NULL;
543 for (int i = secmax; i > 0; i--) {
544 struct SECT *tmp = calloc(1, sizeof(struct SECT));
545 tmp->next = lights;
546 lights = tmp;
547 obj = getObj(item, LIGHTS, i);
548 if ((att = getAtt(obj, CATLIT)) != NULL) {
549 lights->dir = testAtt(att, LIT_DIR);
550 }
551 if ((att = getAtt(obj, LITCHR)) != NULL) {
552 lights->chr = att->val.val.e;
553 switch (lights->chr) {
554 case CHR_AL:
555 lights->chr = CHR_F;
556 break;
557 case CHR_ALOC:
558 lights->chr = CHR_OC;
559 break;
560 case CHR_ALLFL:
561 lights->chr = CHR_LFL;
562 break;
563 case CHR_ALFL:
564 lights->chr = CHR_FL;
565 break;
566 case CHR_ALFFL:
567 lights->chr = CHR_FFL;
568 break;
569 default:
570 break;
571 }
572 }
573 if ((att = getAtt(obj, SIGGRP)) != NULL) {
574 lights->grp = att->val.val.a;
575 } else {
576 lights->grp = "";
577 }
578 if ((att = getAtt(obj, SIGPER)) != NULL) {
579 lights->per = att->val.val.f;
580 }
581 if ((att = getAtt(obj, VALNMR)) != NULL) {
582 lights->rng = att->val.val.f;
583 }
584 if ((att = getAtt(obj, COLOUR)) != NULL) {
585 lights->col = att->val.val.l->val;
586 if (att->val.val.l->next != NULL)
587 lights->alt = att->val.val.l->next->val;
588 }
589 }
590 struct COLRNG {
591 int col;
592 double rng;
593 } colrng[14];
594 while (lights != NULL) {
595 strcpy(string2, "");
596 bzero(colrng, 14*sizeof(struct COLRNG));
597 colrng[lights->col].col = 1;
598 colrng[lights->col].rng = lights->rng;
599 struct SECT *this = lights;
600 struct SECT *next = lights->next;
601 while (next != NULL) {
602 if ((this->dir == next->dir) && (this->chr == next->chr) &&
603 (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) {
604 colrng[next->col].col = 1;
605 if (next->rng > colrng[next->col].rng)
606 colrng[next->col].rng = next->rng;
607 struct SECT *tmp = lights;
608 while (tmp->next != next) tmp = tmp->next;
609 tmp->next = next->next;
610 free(next);
611 next = tmp->next;
612 } else {
613 next = next->next;
614 }
615 }
616 if (this->chr != CHR_UNKN) {
617 if (this->dir) strcpy(string2, "Dir.");
618 strcat(string2, light_characters[this->chr]);
619 if (strcmp(this->grp, "") != 0) {
620 if (this->grp[0] == '(')
621 sprintf(strchr(string2, 0), "%s", this->grp);
622 else
623 sprintf(strchr(string2, 0), "(%s)", this->grp);
624 } else {
625 if (strlen(string2) > 0) strcat(string2, ".");
626 }
627 int n = 0;
628 for (int i = 0; i < 14; i++) if (colrng[i].col) n++;
629 double max = 0.0;
630 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng;
631 double min = max;
632 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng;
633 if (min == max) {
634 for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]);
635 } else {
636 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]);
637 for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]);
638 for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]);
639 }
640 strcat(string2, ".");
641 if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per);
642 if (max > 0.0) {
643 sprintf(strchr(string2, 0), "%g", max);
644 if (min != max) {
645 if (n == 2) strcat(string2, "/");
646 else if (n > 2) strcat(string2, "-");
647 if (min < max) sprintf(strchr(string2, 0), "%g", min);
648 }
649 strcat(string2, "M");
650 }
651 if (strlen(string1) > 0) strcat(string1, "\n");
652 strcat(string1, string2);
653 }
654 lights = this->next;
655 free(this);
656 this = lights;
657 }
658 } else {
659 if ((att = getAtt(obj, CATLIT)) != NULL) {
660 if (testAtt(att, LIT_DIR))
661 strcat(string1, "Dir");
662 }
663 if ((att = getAtt(obj, MLTYLT)) != NULL)
664 sprintf(strchr(string1, 0), "%s", stringValue(att->val));
665 if ((att = getAtt(obj, LITCHR)) != NULL) {
666 char *chrstr = strdup(stringValue(att->val));
667 Att_t *grp = getAtt(obj, SIGGRP);
668 if (grp != NULL) {
669 char *strgrp = strdup(stringValue(grp->val));
670 char *grpstr = strtok(strgrp, "()");
671 switch (att->val.val.e) {
672 case CHR_QLFL:
673 sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr);
674 break;
675 case CHR_VQLFL:
676 sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr);
677 break;
678 case CHR_UQLFL:
679 sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr);
680 break;
681 default:
682 sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr);
683 break;
684 }
685 free(strgrp);
686 } else {
687 sprintf(strchr(string1, 0), "%s", chrstr);
688 }
689 free(chrstr);
690 }
691 if ((att = getAtt(obj, COLOUR)) != NULL) {
692 int n = countValues(att);
693 if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) {
694 if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')')))
695 strcat(string1, ".");
696 Lst_t *lst = att->val.val.l;
697 while (lst != NULL) {
698 strcat(string1, light_letters[lst->val]);
699 lst = lst->next;
700 }
701 }
702 }
703 if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
704 if (testAtt(att, LIT_VERT))
705 strcat(string1, "(vert)");
706 if (testAtt(att, LIT_HORI))
707 strcat(string1, "(hor)");
708 }
709 if ((strlen(string1) > 0) &&
710 ((getAtt(obj, SIGPER) != NULL) ||
711 (getAtt(obj, HEIGHT) != NULL) ||
712 (getAtt(obj, VALMXR) != NULL)) &&
713 (string1[strlen(string1)-1] != ')'))
714 strcat(string1, ".");
715 if ((att = getAtt(obj, SIGPER)) != NULL)
716 sprintf(strchr(string1, 0), "%ss", stringValue(att->val));
717 if ((idx == 0) && (item->objs.obj != LITMIN)) {
718 if ((att = getAtt(obj, HEIGHT)) != NULL)
719 sprintf(strchr(string1, 0), "%sm", stringValue(att->val));
720 if ((att = getAtt(obj, VALNMR)) != NULL)
721 sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
722 }
723 if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
724 if (testAtt(att, LIT_FRNT))
725 strcat(string1, "(Front)");
726 if (testAtt(att, LIT_REAR))
727 strcat(string1, "(Rear)");
728 if (testAtt(att, LIT_UPPR))
729 strcat(string1, "(Upper)");
730 if (testAtt(att, LIT_LOWR))
731 strcat(string1, "(Lower)");
732 }
733 }
734 }
735 break;
736 default: break;
737 }
738 return string1;
739}
740*/
741
742}
Note: See TracBrowser for help on using the repository browser.