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 | s2 = (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 | String str = "";
|
---|
329 | if (atts.containsKey(Att.LITCHR)) {
|
---|
330 | str += lightCharacters.get(atts.get(Att.LITCHR).val);
|
---|
331 | }
|
---|
332 | if (atts.containsKey(Att.SIGGRP)) {
|
---|
333 | str += "(" + atts.get(Att.SIGGRP).val + ")";
|
---|
334 | } else if (!str.isEmpty()) {
|
---|
335 | str += ".";
|
---|
336 | }
|
---|
337 | if (atts.containsKey(Att.COLOUR)) {
|
---|
338 | ArrayList<Enum<ColCOL>> cols = (ArrayList<Enum<ColCOL>>) atts.get(Att.COLOUR).val;
|
---|
339 | str += lightLetters.get(cols.get(0));
|
---|
340 | if (cols.size() > 1)
|
---|
341 | str += lightLetters.get(cols.get(1));
|
---|
342 | }
|
---|
343 | if (dir && atts.containsKey(Att.ORIENT)) {
|
---|
344 | double orient = (Double)atts.get(Att.ORIENT).val;
|
---|
345 | str += " " + orient + "°";
|
---|
346 | s1 = (orient - 4 + 360) % 360;
|
---|
347 | s2 = (orient + 4) % 360;
|
---|
348 | double n1 = 360;
|
---|
349 | double n2 = 360;
|
---|
350 | for (AttMap sect : objs.values()) {
|
---|
351 | if (sect != atts) {
|
---|
352 |
|
---|
353 | }
|
---|
354 | }
|
---|
355 | }
|
---|
356 | Renderer.lightSector(feature, lightColours.get(col1), lightColours.get(col2), radius, s1, s2, dir, str);
|
---|
357 | }
|
---|
358 | }
|
---|
359 | }
|
---|
360 |
|
---|
361 | /*
|
---|
362 | void renderSector(Item_t *item, int s, char *text, char *style, double offset, int dy) {
|
---|
363 | Obj_t *sector;
|
---|
364 | double start, end;
|
---|
365 | Att_t *att;
|
---|
366 | XY_t p0, p1;
|
---|
367 | double r0, r1;
|
---|
368 | double b0, b1, span;
|
---|
369 | char *col;
|
---|
370 | XY_t pos = findCentroid(item);
|
---|
371 | if ((sector = getObj(item, LIGHTS, s)) != NULL) {
|
---|
372 | strcpy(string1, (att = getAtt(sector, LITRAD)) != NULL ? att->val.val.a : "0.2");
|
---|
373 | if (((att = getAtt(sector, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(sector, ORIENT)) != NULL)) {
|
---|
374 | b0 = fmod(540.0 - att->val.val.f, 360.0);
|
---|
375 | if ((att = getAtt(sector, COLOUR)) != NULL) {
|
---|
376 | col = light_colours[att->val.val.l->val];
|
---|
377 | r0 = atof(string1);
|
---|
378 | p0 = radial(pos, r0, b0);
|
---|
379 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
---|
380 | pos.x, pos.y, p0.x, p0.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
---|
381 | start = fmod(b0 + 2.0, 360.0);
|
---|
382 | end = fmod(360.0 + b0 - 2.0, 360.0);
|
---|
383 | Obj_t *adj;
|
---|
384 | for (int i = s-1; i <= s+1; i++) {
|
---|
385 | if (i == s) continue;
|
---|
386 | if ((adj = getObj(item, LIGHTS, i)) == NULL) continue;
|
---|
387 | Att_t *att;
|
---|
388 | if (((att = getAtt(adj, CATLIT)) != NULL) && (testAtt(att, LIT_DIR)) && ((att = getAtt(adj, ORIENT)) != NULL)) {
|
---|
389 | b1 = fmod(540.0 - att->val.val.f, 360.0);
|
---|
390 | if (fabs(b0 - b1) > 180.0) {
|
---|
391 | if (b0 < b1) b0 += 360.0;
|
---|
392 | else b1 += 360.0;
|
---|
393 | }
|
---|
394 | if (fabs(b0 - b1) < 4.0) {
|
---|
395 | if (b1 > b0) start = fmod((720.0 + b0 + b1) / 2.0, 360.0);
|
---|
396 | else end = fmod((720.0 + b0 + b1) / 2.0, 360.0);
|
---|
397 | }
|
---|
398 | }
|
---|
399 | }
|
---|
400 | p0 = radial(pos, r0, start);
|
---|
401 | p1 = radial(pos, r0, end);
|
---|
402 | 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",
|
---|
403 | ++ref, p0.x, p0.y, r0*mile, r0*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
---|
404 | if (att->val.val.l->next != NULL) {
|
---|
405 | char *col = light_colours[att->val.val.l->next->val];
|
---|
406 | r1 = r0 - (20 * symbolScale[zoom]/mile);
|
---|
407 | p0 = radial(pos, r1, start);
|
---|
408 | p1 = radial(pos, r1, end);
|
---|
409 | printf("<path d=\"M %g,%g A %g,%g,0,0,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
---|
410 | p0.x, p0.y, r1*mile, r1*mile, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
---|
411 | }
|
---|
412 | }
|
---|
413 | } else if ((att = getAtt(sector, SECTR1)) != NULL) {
|
---|
414 | start = fmod(540.0 - att->val.val.f, 360.0);
|
---|
415 | if ((att = getAtt(sector, SECTR2)) != NULL) {
|
---|
416 | end = fmod(540.0 - att->val.val.f, 360.0);
|
---|
417 | start += start < end ? 360.0 : 0.0;
|
---|
418 | if ((att = getAtt(sector, COLOUR)) != NULL) {
|
---|
419 | char *ttok, *etok;
|
---|
420 | char *radstr = strdup(string1);
|
---|
421 | int arc = 0;
|
---|
422 | col = light_colours[att->val.val.l->val];
|
---|
423 | r0 = 0.0;
|
---|
424 | b0 = b1 = start;
|
---|
425 | for (char *tpl = strtok_r(radstr, ";", &ttok); tpl != NULL; tpl = strtok_r(NULL, ";", &ttok)) {
|
---|
426 | p0 = radial(pos, r0, b0);
|
---|
427 | span = 0.0;
|
---|
428 | char *ele = strtok_r(tpl, ":", &etok);
|
---|
429 | if ((*tpl == ':') && (r0 == 0.0)) {
|
---|
430 | r1 = 0.2;
|
---|
431 | } else if (*tpl != ':') {
|
---|
432 | r1 = atof(tpl);
|
---|
433 | ele = strtok_r(NULL, ":", &etok);
|
---|
434 | }
|
---|
435 | while (ele != NULL) {
|
---|
436 | if (isalpha(*ele)) {
|
---|
437 | if (strcmp(ele, "suppress") == 0) arc = 2;
|
---|
438 | else if (strcmp(ele, "dashed") == 0) arc = 1;
|
---|
439 | else arc = 0;
|
---|
440 | } else {
|
---|
441 | span = atof(ele);
|
---|
442 | }
|
---|
443 | ele = strtok_r(NULL, ":", &etok);
|
---|
444 | }
|
---|
445 | if (span == 0.0) {
|
---|
446 | char *back = (ttok != NULL) ? strstr(ttok, "-") : NULL;
|
---|
447 | if (back != NULL) {
|
---|
448 | span = b0 - end + atof(back);
|
---|
449 | } else {
|
---|
450 | span = b0 - end;
|
---|
451 | }
|
---|
452 | }
|
---|
453 | if (r1 != r0) {
|
---|
454 | p1 = radial(pos, r1, b0);
|
---|
455 | if (!((start == 180.0) && (end == 180.0)))
|
---|
456 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
---|
457 | p0.x, p0.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
---|
458 | r0 = r1;
|
---|
459 | p0 = p1;
|
---|
460 | }
|
---|
461 | if (span < 0.0) {
|
---|
462 | b1 = end - span;
|
---|
463 | b1 = b1 > b0 ? b0 : b1;
|
---|
464 | b0 = b1;
|
---|
465 | b1 = end;
|
---|
466 | p0 = radial(pos, r0, b0);
|
---|
467 | } else {
|
---|
468 | b1 = b0 - span;
|
---|
469 | b1 = b1 < end ? end : b1;
|
---|
470 | }
|
---|
471 | p1 = radial(pos, r1, b1);
|
---|
472 | if ((b0 == 180.0) && (b1 == 180.0)) {
|
---|
473 | span = 360.0;
|
---|
474 | p1 = radial(pos, r1, b1+0.01);
|
---|
475 | }
|
---|
476 | if (arc == 0) {
|
---|
477 | if (p0.x < p1.x)
|
---|
478 | 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",
|
---|
479 | ++ref, p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (20 * symbolScale[zoom]));
|
---|
480 | else
|
---|
481 | 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",
|
---|
482 | ++ref, p1.x, p1.y, r1*mile, r1*mile, span>180.0, p0.x, p0.y, col, (20 * symbolScale[zoom]));
|
---|
483 | if (text != NULL) {
|
---|
484 | double chord = sqrt(pow((p0.x - p1.x), 2) + pow((p0.y - p1.y), 2));
|
---|
485 | if ((chord > (strlen(text) * textScale[zoom] * 50)) || ((b0 == 180.0) && (b1 == 180.0)))
|
---|
486 | drawLineText(item, text, style, offset, dy, ref);
|
---|
487 | }
|
---|
488 | } else if (arc == 1) {
|
---|
489 | 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",
|
---|
490 | p0.x, p0.y, r1*mile, r1*mile, span>180.0, p1.x, p1.y, col, (10 * symbolScale[zoom]), (30 * symbolScale[zoom]));
|
---|
491 | }
|
---|
492 | if ((arc == 0) && (att->val.val.l->next != NULL)) {
|
---|
493 | char *col = light_colours[att->val.val.l->next->val];
|
---|
494 | double r2 = r1 - (20 * symbolScale[zoom]/mile);
|
---|
495 | XY_t p2 = radial(pos, r2, b0);
|
---|
496 | XY_t p3 = radial(pos, r2, b1);
|
---|
497 | printf("<path d=\"M %g,%g A %g,%g,0,%d,1,%g,%g\" style=\"fill:none;stroke:%s;stroke-width:%g\"/>\n",
|
---|
498 | p2.x, p2.y, r1*mile, r1*mile, span>180.0, p3.x, p3.y, col, (20 * symbolScale[zoom]));
|
---|
499 | }
|
---|
500 | b0 = b1;
|
---|
501 | if (b0 == end) break;
|
---|
502 | }
|
---|
503 | if (!((start == 180.0) && (end == 180.0)))
|
---|
504 | printf("<path d=\"M %g,%g L %g,%g\" style=\"fill:none;stroke:#808080;stroke-width:%g;stroke-dasharray:%g\"/>\n",
|
---|
505 | pos.x, pos.y, p1.x, p1.y, (4 * symbolScale[zoom]), (20 * symbolScale[zoom]));
|
---|
506 | free(radstr);
|
---|
507 | }
|
---|
508 | }
|
---|
509 | }
|
---|
510 | }
|
---|
511 | }
|
---|
512 | char *charString(Item_t *item, char *type, int idx) {
|
---|
513 | strcpy(string1, "");
|
---|
514 | Att_t *att = NULL;
|
---|
515 | Obj_t *obj = getObj(item, enumType(type), idx);
|
---|
516 | switch (enumType(type)) {
|
---|
517 | case LIGHTS:
|
---|
518 | {
|
---|
519 | int secmax = countObjects(item, "light");
|
---|
520 | if ((idx == 0) && (secmax > 0)) {
|
---|
521 | struct SECT {
|
---|
522 | struct SECT *next;
|
---|
523 | int dir;
|
---|
524 | LitCHR_t chr;
|
---|
525 | ColCOL_t col;
|
---|
526 | ColCOL_t alt;
|
---|
527 | char *grp;
|
---|
528 | double per;
|
---|
529 | double rng;
|
---|
530 | } *lights = NULL;
|
---|
531 | for (int i = secmax; i > 0; i--) {
|
---|
532 | struct SECT *tmp = calloc(1, sizeof(struct SECT));
|
---|
533 | tmp->next = lights;
|
---|
534 | lights = tmp;
|
---|
535 | obj = getObj(item, LIGHTS, i);
|
---|
536 | if ((att = getAtt(obj, CATLIT)) != NULL) {
|
---|
537 | lights->dir = testAtt(att, LIT_DIR);
|
---|
538 | }
|
---|
539 | if ((att = getAtt(obj, LITCHR)) != NULL) {
|
---|
540 | lights->chr = att->val.val.e;
|
---|
541 | switch (lights->chr) {
|
---|
542 | case CHR_AL:
|
---|
543 | lights->chr = CHR_F;
|
---|
544 | break;
|
---|
545 | case CHR_ALOC:
|
---|
546 | lights->chr = CHR_OC;
|
---|
547 | break;
|
---|
548 | case CHR_ALLFL:
|
---|
549 | lights->chr = CHR_LFL;
|
---|
550 | break;
|
---|
551 | case CHR_ALFL:
|
---|
552 | lights->chr = CHR_FL;
|
---|
553 | break;
|
---|
554 | case CHR_ALFFL:
|
---|
555 | lights->chr = CHR_FFL;
|
---|
556 | break;
|
---|
557 | default:
|
---|
558 | break;
|
---|
559 | }
|
---|
560 | }
|
---|
561 | if ((att = getAtt(obj, SIGGRP)) != NULL) {
|
---|
562 | lights->grp = att->val.val.a;
|
---|
563 | } else {
|
---|
564 | lights->grp = "";
|
---|
565 | }
|
---|
566 | if ((att = getAtt(obj, SIGPER)) != NULL) {
|
---|
567 | lights->per = att->val.val.f;
|
---|
568 | }
|
---|
569 | if ((att = getAtt(obj, VALNMR)) != NULL) {
|
---|
570 | lights->rng = att->val.val.f;
|
---|
571 | }
|
---|
572 | if ((att = getAtt(obj, COLOUR)) != NULL) {
|
---|
573 | lights->col = att->val.val.l->val;
|
---|
574 | if (att->val.val.l->next != NULL)
|
---|
575 | lights->alt = att->val.val.l->next->val;
|
---|
576 | }
|
---|
577 | }
|
---|
578 | struct COLRNG {
|
---|
579 | int col;
|
---|
580 | double rng;
|
---|
581 | } colrng[14];
|
---|
582 | while (lights != NULL) {
|
---|
583 | strcpy(string2, "");
|
---|
584 | bzero(colrng, 14*sizeof(struct COLRNG));
|
---|
585 | colrng[lights->col].col = 1;
|
---|
586 | colrng[lights->col].rng = lights->rng;
|
---|
587 | struct SECT *this = lights;
|
---|
588 | struct SECT *next = lights->next;
|
---|
589 | while (next != NULL) {
|
---|
590 | if ((this->dir == next->dir) && (this->chr == next->chr) &&
|
---|
591 | (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) {
|
---|
592 | colrng[next->col].col = 1;
|
---|
593 | if (next->rng > colrng[next->col].rng)
|
---|
594 | colrng[next->col].rng = next->rng;
|
---|
595 | struct SECT *tmp = lights;
|
---|
596 | while (tmp->next != next) tmp = tmp->next;
|
---|
597 | tmp->next = next->next;
|
---|
598 | free(next);
|
---|
599 | next = tmp->next;
|
---|
600 | } else {
|
---|
601 | next = next->next;
|
---|
602 | }
|
---|
603 | }
|
---|
604 | if (this->chr != CHR_UNKN) {
|
---|
605 | if (this->dir) strcpy(string2, "Dir.");
|
---|
606 | strcat(string2, light_characters[this->chr]);
|
---|
607 | if (strcmp(this->grp, "") != 0) {
|
---|
608 | if (this->grp[0] == '(')
|
---|
609 | sprintf(strchr(string2, 0), "%s", this->grp);
|
---|
610 | else
|
---|
611 | sprintf(strchr(string2, 0), "(%s)", this->grp);
|
---|
612 | } else {
|
---|
613 | if (strlen(string2) > 0) strcat(string2, ".");
|
---|
614 | }
|
---|
615 | int n = 0;
|
---|
616 | for (int i = 0; i < 14; i++) if (colrng[i].col) n++;
|
---|
617 | double max = 0.0;
|
---|
618 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng;
|
---|
619 | double min = max;
|
---|
620 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng;
|
---|
621 | if (min == max) {
|
---|
622 | for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]);
|
---|
623 | } else {
|
---|
624 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]);
|
---|
625 | for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]);
|
---|
626 | for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]);
|
---|
627 | }
|
---|
628 | strcat(string2, ".");
|
---|
629 | if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per);
|
---|
630 | if (max > 0.0) {
|
---|
631 | sprintf(strchr(string2, 0), "%g", max);
|
---|
632 | if (min != max) {
|
---|
633 | if (n == 2) strcat(string2, "/");
|
---|
634 | else if (n > 2) strcat(string2, "-");
|
---|
635 | if (min < max) sprintf(strchr(string2, 0), "%g", min);
|
---|
636 | }
|
---|
637 | strcat(string2, "M");
|
---|
638 | }
|
---|
639 | if (strlen(string1) > 0) strcat(string1, "\n");
|
---|
640 | strcat(string1, string2);
|
---|
641 | }
|
---|
642 | lights = this->next;
|
---|
643 | free(this);
|
---|
644 | this = lights;
|
---|
645 | }
|
---|
646 | } else {
|
---|
647 | if ((att = getAtt(obj, CATLIT)) != NULL) {
|
---|
648 | if (testAtt(att, LIT_DIR))
|
---|
649 | strcat(string1, "Dir");
|
---|
650 | }
|
---|
651 | if ((att = getAtt(obj, MLTYLT)) != NULL)
|
---|
652 | sprintf(strchr(string1, 0), "%s", stringValue(att->val));
|
---|
653 | if ((att = getAtt(obj, LITCHR)) != NULL) {
|
---|
654 | char *chrstr = strdup(stringValue(att->val));
|
---|
655 | Att_t *grp = getAtt(obj, SIGGRP);
|
---|
656 | if (grp != NULL) {
|
---|
657 | char *strgrp = strdup(stringValue(grp->val));
|
---|
658 | char *grpstr = strtok(strgrp, "()");
|
---|
659 | switch (att->val.val.e) {
|
---|
660 | case CHR_QLFL:
|
---|
661 | sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr);
|
---|
662 | break;
|
---|
663 | case CHR_VQLFL:
|
---|
664 | sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr);
|
---|
665 | break;
|
---|
666 | case CHR_UQLFL:
|
---|
667 | sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr);
|
---|
668 | break;
|
---|
669 | default:
|
---|
670 | sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr);
|
---|
671 | break;
|
---|
672 | }
|
---|
673 | free(strgrp);
|
---|
674 | } else {
|
---|
675 | sprintf(strchr(string1, 0), "%s", chrstr);
|
---|
676 | }
|
---|
677 | free(chrstr);
|
---|
678 | }
|
---|
679 | if ((att = getAtt(obj, COLOUR)) != NULL) {
|
---|
680 | int n = countValues(att);
|
---|
681 | if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) {
|
---|
682 | if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')')))
|
---|
683 | strcat(string1, ".");
|
---|
684 | Lst_t *lst = att->val.val.l;
|
---|
685 | while (lst != NULL) {
|
---|
686 | strcat(string1, light_letters[lst->val]);
|
---|
687 | lst = lst->next;
|
---|
688 | }
|
---|
689 | }
|
---|
690 | }
|
---|
691 | if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
|
---|
692 | if (testAtt(att, LIT_VERT))
|
---|
693 | strcat(string1, "(vert)");
|
---|
694 | if (testAtt(att, LIT_HORI))
|
---|
695 | strcat(string1, "(hor)");
|
---|
696 | }
|
---|
697 | if ((strlen(string1) > 0) &&
|
---|
698 | ((getAtt(obj, SIGPER) != NULL) ||
|
---|
699 | (getAtt(obj, HEIGHT) != NULL) ||
|
---|
700 | (getAtt(obj, VALMXR) != NULL)) &&
|
---|
701 | (string1[strlen(string1)-1] != ')'))
|
---|
702 | strcat(string1, ".");
|
---|
703 | if ((att = getAtt(obj, SIGPER)) != NULL)
|
---|
704 | sprintf(strchr(string1, 0), "%ss", stringValue(att->val));
|
---|
705 | if ((idx == 0) && (item->objs.obj != LITMIN)) {
|
---|
706 | if ((att = getAtt(obj, HEIGHT)) != NULL)
|
---|
707 | sprintf(strchr(string1, 0), "%sm", stringValue(att->val));
|
---|
708 | if ((att = getAtt(obj, VALNMR)) != NULL)
|
---|
709 | sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
|
---|
710 | }
|
---|
711 | if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
|
---|
712 | if (testAtt(att, LIT_FRNT))
|
---|
713 | strcat(string1, "(Front)");
|
---|
714 | if (testAtt(att, LIT_REAR))
|
---|
715 | strcat(string1, "(Rear)");
|
---|
716 | if (testAtt(att, LIT_UPPR))
|
---|
717 | strcat(string1, "(Upper)");
|
---|
718 | if (testAtt(att, LIT_LOWR))
|
---|
719 | strcat(string1, "(Lower)");
|
---|
720 | }
|
---|
721 | }
|
---|
722 | }
|
---|
723 | break;
|
---|
724 | default: break;
|
---|
725 | }
|
---|
726 | return string1;
|
---|
727 | }
|
---|
728 | */
|
---|
729 |
|
---|
730 | }
|
---|