source: osm/applications/editors/josm/plugins/smed2/src/seamap/Rules.java@ 29340

Last change on this file since 29340 was 29340, checked in by malcolmh, 12 years ago

save

File size: 34.8 KB
Line 
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
10package seamap;
11
12import java.awt.Color;
13import java.awt.Font;
14import java.awt.geom.AffineTransform;
15import java.util.ArrayList;
16
17import s57.S57val;
18import s57.S57val.*;
19import s57.S57att.*;
20import s57.S57obj.*;
21
22import seamap.SeaMap.*;
23import symbols.*;
24import symbols.Symbols.*;
25
26public class Rules {
27
28 static SeaMap map;
29 static int zoom;
30
31 public static void rules (SeaMap m, int z) {
32 map = m;
33 zoom = z;
34 ArrayList<Feature> objects;
35 if ((objects = map.features.get(Obj.SLCONS)) != null) for (Feature feature : objects) shoreline(feature);
36 if ((objects = map.features.get(Obj.SLCONS)) != null) for (Feature feature : objects) shoreline(feature);;
37 if ((objects = map.features.get(Obj.PIPSOL)) != null) for (Feature feature : objects) pipelines(feature);
38 if ((objects = map.features.get(Obj.CBLSUB)) != null) for (Feature feature : objects) cables(feature);
39 if ((objects = map.features.get(Obj.PIPOHD)) != null) for (Feature feature : objects) pipelines(feature);
40 if ((objects = map.features.get(Obj.CBLOHD)) != null) for (Feature feature : objects) cables(feature);
41 if ((objects = map.features.get(Obj.TSEZNE)) != null) for (Feature feature : objects) separation(feature);
42 if ((objects = map.features.get(Obj.TSSCRS)) != null) for (Feature feature : objects) separation(feature);
43 if ((objects = map.features.get(Obj.TSSRON)) != null) for (Feature feature : objects) separation(feature);
44 if ((objects = map.features.get(Obj.TSELNE)) != null) for (Feature feature : objects) separation(feature);
45 if ((objects = map.features.get(Obj.TSSLPT)) != null) for (Feature feature : objects) separation(feature);
46 if ((objects = map.features.get(Obj.TSSBND)) != null) for (Feature feature : objects) separation(feature);
47 if ((objects = map.features.get(Obj.SNDWAV)) != null) for (Feature feature : objects) areas(feature);
48 if ((objects = map.features.get(Obj.OSPARE)) != null) for (Feature feature : objects) areas(feature);
49 if ((objects = map.features.get(Obj.FAIRWY)) != null) for (Feature feature : objects) areas(feature);
50 if ((objects = map.features.get(Obj.DRGARE)) != null) for (Feature feature : objects) areas(feature);
51 if ((objects = map.features.get(Obj.RESARE)) != null) for (Feature feature : objects) areas(feature);
52 if ((objects = map.features.get(Obj.SPLARE)) != null) for (Feature feature : objects) areas(feature);
53 if ((objects = map.features.get(Obj.SEAARE)) != null) for (Feature feature : objects) areas(feature);
54 if ((objects = map.features.get(Obj.OBSTRN)) != null) for (Feature feature : objects) obstructions(feature);
55 if ((objects = map.features.get(Obj.UWTROC)) != null) for (Feature feature : objects) obstructions(feature);
56 if ((objects = map.features.get(Obj.MARCUL)) != null) for (Feature feature : objects) areas(feature);
57 if ((objects = map.features.get(Obj.WTWAXS)) != null) for (Feature feature : objects) waterways(feature);
58 if ((objects = map.features.get(Obj.RECTRC)) != null) for (Feature feature : objects) transits(feature);
59 if ((objects = map.features.get(Obj.NAVLNE)) != null) for (Feature feature : objects) transits(feature);
60 if ((objects = map.features.get(Obj.HRBFAC)) != null) for (Feature feature : objects) harbours(feature);
61 if ((objects = map.features.get(Obj.ACHARE)) != null) for (Feature feature : objects) harbours(feature);
62 if ((objects = map.features.get(Obj.ACHBRT)) != null) for (Feature feature : objects) harbours(feature);
63 if ((objects = map.features.get(Obj.LOKBSN)) != null) for (Feature feature : objects) locks(feature);
64 if ((objects = map.features.get(Obj.LKBSPT)) != null) for (Feature feature : objects) locks(feature);
65 if ((objects = map.features.get(Obj.GATCON)) != null) for (Feature feature : objects) locks(feature);
66 if ((objects = map.features.get(Obj.DISMAR)) != null) for (Feature feature : objects) distances(feature);
67 if ((objects = map.features.get(Obj.HULKES)) != null) for (Feature feature : objects) ports(feature);
68 if ((objects = map.features.get(Obj.CRANES)) != null) for (Feature feature : objects) ports(feature);
69 if ((objects = map.features.get(Obj.LNDMRK)) != null) for (Feature feature : objects) landmarks(feature);
70 if ((objects = map.features.get(Obj.MORFAC)) != null) for (Feature feature : objects) moorings(feature);
71 if ((objects = map.features.get(Obj.NOTMRK)) != null) for (Feature feature : objects) notices(feature);
72 if ((objects = map.features.get(Obj.SMCFAC)) != null) for (Feature feature : objects) marinas(feature);
73 if ((objects = map.features.get(Obj.BRIDGE)) != null) for (Feature feature : objects) bridges(feature);
74 if ((objects = map.features.get(Obj.LITMAJ)) != null) for (Feature feature : objects) lights(feature);
75 if ((objects = map.features.get(Obj.LITMIN)) != null) for (Feature feature : objects) lights(feature);
76 if ((objects = map.features.get(Obj.LIGHTS)) != null) for (Feature feature : objects) lights(feature);
77 if ((objects = map.features.get(Obj.SISTAT)) != null) for (Feature feature : objects) signals(feature);
78 if ((objects = map.features.get(Obj.SISTAW)) != null) for (Feature feature : objects) signals(feature);
79 if ((objects = map.features.get(Obj.CGUSTA)) != null) for (Feature feature : objects) signals(feature);
80 if ((objects = map.features.get(Obj.RDOSTA)) != null) for (Feature feature : objects) signals(feature);
81 if ((objects = map.features.get(Obj.RADSTA)) != null) for (Feature feature : objects) signals(feature);
82 if ((objects = map.features.get(Obj.RSCSTA)) != null) for (Feature feature : objects) signals(feature);
83 if ((objects = map.features.get(Obj.PILBOP)) != null) for (Feature feature : objects) signals(feature);
84 if ((objects = map.features.get(Obj.WTWGAG)) != null) for (Feature feature : objects) gauges(feature);
85 if ((objects = map.features.get(Obj.OFSPLF)) != null) for (Feature feature : objects) platforms(feature);
86 if ((objects = map.features.get(Obj.WRECKS)) != null) for (Feature feature : objects) wrecks(feature);
87 if ((objects = map.features.get(Obj.LITVES)) != null) for (Feature feature : objects) floats(feature);
88 if ((objects = map.features.get(Obj.LITFLT)) != null) for (Feature feature : objects) floats(feature);
89 if ((objects = map.features.get(Obj.BOYINB)) != null) for (Feature feature : objects) floats(feature);
90 if ((objects = map.features.get(Obj.BOYLAT)) != null) for (Feature feature : objects) buoys(feature);
91 if ((objects = map.features.get(Obj.BOYCAR)) != null) for (Feature feature : objects) buoys(feature);
92 if ((objects = map.features.get(Obj.BOYISD)) != null) for (Feature feature : objects) buoys(feature);
93 if ((objects = map.features.get(Obj.BOYSAW)) != null) for (Feature feature : objects) buoys(feature);
94 if ((objects = map.features.get(Obj.BOYSPP)) != null) for (Feature feature : objects) buoys(feature);
95 if ((objects = map.features.get(Obj.BOYWTW)) != null) for (Feature feature : objects) buoys(feature);
96 if ((objects = map.features.get(Obj.BCNLAT)) != null) for (Feature feature : objects) beacons(feature);
97 if ((objects = map.features.get(Obj.BCNCAR)) != null) for (Feature feature : objects) beacons(feature);
98 if ((objects = map.features.get(Obj.BCNISD)) != null) for (Feature feature : objects) beacons(feature);
99 if ((objects = map.features.get(Obj.BCNSAW)) != null) for (Feature feature : objects) beacons(feature);
100 if ((objects = map.features.get(Obj.BCNSPP)) != null) for (Feature feature : objects) beacons(feature);
101 if ((objects = map.features.get(Obj.BCNWTW)) != null) for (Feature feature : objects) beacons(feature);
102 }
103
104 private static void areas(Feature feature) {
105 AttItem name = feature.atts.get(Att.OBJNAM);
106 switch (feature.type) {
107 case SPLARE:
108 if (zoom >= 12) {
109 Renderer.symbol(feature, Areas.Plane, Obj.SPLARE, null);
110 Renderer.lineSymbols(feature, Areas.Restricted, 0.5, Areas.LinePlane, 10);
111 }
112 if ((zoom >= 15) && (name != null))
113 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 80), Color.black, new Delta(Handle.BC, AffineTransform.getTranslateInstance(0, -90)));
114 break;
115 case MARCUL:
116 if (zoom >= 14)
117 Renderer.symbol(feature, Areas.MarineFarm, Obj.MARCUL, null);
118 if (zoom >= 16)
119 Renderer.lineVector(feature, new LineStyle( Color.black, 4, new float[] { 10, 10 }, null));
120 break;
121 case FAIRWY:
122 if (feature.area > 2.0) {
123 if (zoom < 16)
124 Renderer.lineVector(feature, new LineStyle(new Color(0xc480ff), 8, new float[] { 50, 50 }, new Color(0x40ffffff, true)));
125 else
126 Renderer.lineVector(feature, new LineStyle(new Color(0xc480ff), 8, new float[] { 50, 50 }, null));
127 } else {
128 if (zoom >= 14)
129 Renderer.lineVector(feature, new LineStyle(new Color(0x40ffffff, true), 0, null, null));
130 }
131 break;
132 case DRGARE:
133 if (zoom < 16)
134 Renderer.lineVector(feature, new LineStyle(Color.black, 8, new float[] { 25, 25 }, new Color(0x40ffffff, true)));
135 else
136 Renderer.lineVector(feature, new LineStyle(Color.black, 8, new float[] { 25, 25 }, null));
137 if ((zoom >= 12) && (name != null))
138 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.PLAIN, 100), Color.black, null);
139 break;
140 case RESARE:
141 if (zoom >= 12) {
142 Renderer.lineSymbols(feature, Areas.Restricted, 1.0, null, 0);
143// if ((CatREA)Renderer.getAttVal(feature, feature.type, 0, Att.CATREA) == CatREA.REA_NWAK)
144// Renderer.symbol(feature, Areas.NoWake, Obj.RESARE, null);
145 }
146 break;
147 case OSPARE:
148 if ((CatPRA)Renderer.getAttVal(feature, feature.type, 0, Att.CATPRA) == CatPRA.PRA_WFRM) {
149 Renderer.symbol(feature, Areas.WindFarm, Obj.OSPARE, null);
150 Renderer.lineVector(feature, new LineStyle(Color.black, 20, new float[] { 40, 40 }, null));
151 if ((zoom >= 15) && (name != null))
152 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 80), Color.black, new Delta(Handle.TC, AffineTransform.getTranslateInstance(0, 10)));
153 }
154 break;
155 case SEAARE:
156 switch ((CatSEA) Renderer.getAttVal(feature, feature.type, 0, Att.CATSEA)) {
157 case SEA_RECH:
158 break;
159 case SEA_BAY:
160 break;
161 case SEA_SHOL:
162 break;
163 case SEA_GAT:
164 case SEA_NRRW:
165 break;
166 }
167 break;
168 case SNDWAV:
169// if (zoom>=12)) area("fill:url(#sandwaves)");
170 break;
171 }
172/*
173 if (is_type("sea_area")) {
174 if (has_attribute("category")) {
175 make_string("");
176 attribute_switch("category")
177 attribute_case("reach") { if (zoom >= 10) add_string("font-family:Arial;font-weight:normal;font-style:italic;font-size:150;text-anchor:middle") }
178 attribute_case("bay") { if (zoom >= 12) add_string("font-family:Arial;font-weight:normal;font-style:italic;font-size:150;text-anchor:middle") }
179 attribute_case("shoal") { if (zoom >= 14) {
180 if (is_area) {
181 area("stroke:#c480ff;stroke-width:4;stroke-dasharray:25,25;fill:none");
182 if (has_item_attribute("name")) text(item_attribute("name"), "font-family:Arial;font-weight:normal;font-style:italic;font-size:75;text-anchor:middle", 0, -40);
183 text("(Shoal)", "font-family:Arial;font-weight:normal;font-size:60;text-anchor:middle", 0, 0);
184 } else if (is_line) {
185 if (has_item_attribute("name")) way_text(item_attribute("name"), "font-family:Arial;font-weight:normal;font-style:italic;font-size:75;text-anchor:middle", 0.5, -40, line("stroke:none;fill:none"));
186 way_text("(Shoal)", "font-family:Arial;font-weight:normal;font-size:60;text-anchor:middle", 0.5, 0, line("stroke:none;fill:none"));
187 } else {
188 if (has_item_attribute("name")) text(item_attribute("name"), "font-family:Arial;font-weight:normal;font-style:italic;font-size:75;text-anchor:middle", 0, -40);
189 text("(Shoal)", "font-family:Arial;font-weight:normal;font-size:60;text-anchor:middle", 0, 0);
190 }
191 }
192 }
193 attribute_case("gat|narrows") { if (zoom >= 12) add_string("font-family:Arial;font-weight:normal;font-style:italic;font-size:100;text-anchor:middle") }
194 end_switch
195 if ((strlen(string) > 0) && !attribute_test("category", "shoal")) {
196 int ref = line("stroke:none;fill:none");
197 if (ref != 0) {
198 if (has_item_attribute("name")) way_text(item_attribute("name"), string, 0.5, 0, ref);
199 } else {
200 if (has_item_attribute("name")) text(item_attribute("name"), string, 0, 0);
201 }
202 }
203 free_string
204 }
205 }
206 */
207 }
208 private static void beacons(Feature feature) {
209 BcnSHP shape = (BcnSHP) Renderer.getAttVal(feature, feature.type, 0, Att.BCNSHP);
210 if (((shape == BcnSHP.BCN_PRCH) || (shape == BcnSHP.BCN_WTHY)) && (feature.type == Obj.BCNLAT)) {
211 CatLAM cat = (CatLAM) Renderer.getAttVal(feature, feature.type, 0, Att.CATLAM);
212 switch (cat) {
213 case LAM_PORT:
214 if (shape == BcnSHP.BCN_PRCH)
215 Renderer.symbol(feature, Beacons.PerchPort, null, null);
216 else
217 Renderer.symbol(feature, Beacons.WithyPort, null, null);
218 break;
219 case LAM_STBD:
220 if (shape == BcnSHP.BCN_PRCH)
221 Renderer.symbol(feature, Beacons.PerchStarboard, null, null);
222 else
223 Renderer.symbol(feature, Beacons.WithyStarboard, null, null);
224 break;
225 default:
226 Renderer.symbol(feature, Beacons.Stake, feature.type, null);
227 }
228 } else {
229 Renderer.symbol(feature, Beacons.Shapes.get(shape), feature.type, null);
230 if (feature.objs.get(Obj.TOPMAR) != null)
231 Renderer.symbol(feature, Topmarks.Shapes.get(feature.objs.get(Obj.TOPMAR).get(0).get(Att.TOPSHP).val), Obj.TOPMAR, Topmarks.Beacons);
232 }
233 }
234 private static void buoys(Feature feature) {
235 BoySHP shape = (BoySHP) Renderer.getAttVal(feature, feature.type, 0, Att.BOYSHP);
236 Renderer.symbol(feature, Buoys.Shapes.get(shape), feature.type, null);
237 if (feature.objs.get(Obj.TOPMAR) != null) {
238 Renderer.symbol(feature, Topmarks.Shapes.get(feature.objs.get(Obj.TOPMAR).get(0).get(Att.TOPSHP).val), Obj.TOPMAR, Topmarks.Buoys.get(shape));
239 }
240 }
241 private static void bridges(Feature feature) {
242 if (zoom >= 16) {
243
244 }
245/* Att_t *attv = getAtt(getObj(item, BRIDGE, 0), VERCLR);
246 if (attv == NULL) attv = getAtt(getObj(item, BRIDGE, 0), VERCSA);
247 Att_t *attc = getAtt(getObj(item, BRIDGE, 0), VERCCL);
248 Att_t *atto = getAtt(getObj(item, BRIDGE, 0), VERCOP);
249 if (attv != NULL) {
250 renderSymbol(item, obja, "clear_v", "", "", CC, 0, 0, 0);
251 drawText(item, stringValue(attv->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 0, 12);
252 }
253 else if ((attc != NULL) && (atto == NULL)) {
254 renderSymbol(item, obja, "clear_v", "", "", CC, 0, 0, 0);
255 drawText(item, stringValue(attc->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 0, 12);
256 }
257 else if ((attc != NULL) && (atto != NULL)) {
258 renderSymbol(item, obja, "clear_v", "", "", RC, 5, 0, 0);
259 drawText(item, stringValue(attc->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", -35, 12);
260 renderSymbol(item, obja, "clear_v", "", "", LC, -5, 0, 0);
261 drawText(item, stringValue(atto->val), "font-family:Arial; font-weight:normal; font-size:70; text-anchor:middle", 35, 12);
262 }
263 }
264*/
265 }
266 private static void cables(Feature feature) {
267 if (zoom >= 14) {
268 if (feature.type == Obj.CBLSUB) {
269 Renderer.lineSymbols(feature, Areas.Cable, 0.0, null, 0);
270 } else if (feature.type == Obj.CBLOHD) {
271
272 }
273 }
274 }
275 private static void distances(Feature feature) {
276/*object_rules(distances) {
277 if ((zoom>=16) && (has_attribute("category"))) {
278 attribute_switch("category")
279 attribute_case("installed") symbol("distance_i");
280 attribute_default symbol("distance_u");
281 end_switch
282 }
283}
284*/
285 }
286 private static void floats(Feature feature) {
287 switch (feature.type) {
288 case LITVES:
289 Renderer.symbol(feature, Buoys.Super, feature.type, null);
290 break;
291 case LITFLT:
292 Renderer.symbol(feature, Buoys.Float, feature.type, null);
293 break;
294 case BOYINB:
295 Renderer.symbol(feature, Buoys.Storage, feature.type, null);
296 break;
297 }
298 if (feature.objs.get(Obj.TOPMAR) != null)
299 Renderer.symbol(feature, Topmarks.Shapes.get(feature.objs.get(Obj.TOPMAR).get(0).get(Att.TOPSHP).val), Obj.TOPMAR, Topmarks.Floats);
300 }
301 private static void gauges(Feature feature) {
302/*object_rules(gauge) {
303 if (zoom >= 14) symbol("tide_gauge");
304}
305*/
306 }
307 private static void harbours(Feature feature) {
308 AttItem name = feature.atts.get(Att.OBJNAM);
309 switch (feature.type) {
310 case ACHARE:
311 if (zoom >= 12) {
312 if (feature.flag != Fflag.LINE)
313 Renderer.symbol(feature, Harbours.Anchorage, null, null);
314 Renderer.lineSymbols(feature, Areas.Restricted, 1.0, Areas.LineAnchor, 10);
315 if ((zoom >= 15) && ((name) != null)) {
316 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 80), new Color(0x80c480ff), null);
317 }
318 }
319 break;
320 }
321 }
322/*
323 * if ((zoom >= 12) && is_type("anchorage")) {
324 symbol("anchorage");
325 if ((zoom >= 15) && (has_item_attribute("name")))
326 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:80; text-anchor:middle", 0, -90);
327 if ((zoom >= 12) && (is_area)) line_symbols("restricted_line", 0.5, "line_anchor", 10);
328 }
329 if ((zoom >= 16) && is_type("anchor_berth")) symbol("anchor_berth");
330 if ((zoom >= 12) && is_type("harbour")) {
331 if (has_attribute("category")) {
332 attribute_switch("category")
333 attribute_case("marina|yacht") symbol("marina");
334 attribute_case("marina_no_facilities") symbol("marina_nf");
335 attribute_default symbol("harbour");
336 end_switch
337 } else symbol("harbour");
338 if ((zoom >= 15) && (has_item_attribute("name")))
339 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:80; text-anchor:middle", 0, -90);
340 }
341*/
342 private static void landmarks(Feature feature) {
343 ArrayList<CatLMK> cats = (ArrayList<CatLMK>) Renderer.getAttVal(feature, feature.type, 0, Att.CATLMK);
344 Symbol catSym = Landmarks.Shapes.get(cats.get(0));
345 ArrayList<FncFNC> fncs = (ArrayList<FncFNC>) Renderer.getAttVal(feature, feature.type, 0, Att.FUNCTN);
346 Symbol fncSym = Landmarks.Funcs.get(fncs.get(0));
347 if ((fncs.get(0) == FncFNC.FNC_CHCH) && (cats.get(0) == CatLMK.LMK_TOWR))
348 catSym = Landmarks.ChurchTower;
349 if ((cats.get(0) == CatLMK.LMK_UNKN) && (fncs.get(0) == FncFNC.FNC_UNKN) && (feature.objs.get(Obj.LIGHTS) != null))
350 catSym = Beacons.LightMajor;
351 if (cats.get(0) == CatLMK.LMK_RADR)
352 fncSym = Landmarks.RadioTV;
353 Renderer.symbol(feature, catSym, null, null);
354 Renderer.symbol(feature, fncSym, null, null);
355/* if (!has_attribute("function") && !has_attribute("category") && has_object("light")) {
356 symbol("lighthouse");
357 if ((zoom >= 15) && has_item_attribute("name"))
358 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:80; text-anchor:middle", 0, -70);
359 } else {
360 if ((zoom >= 15) && has_item_attribute("name"))
361 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:80; text-anchor:start", 60, -50);
362 }
363 if (has_object("fog_signal")) object(fogs);
364 if (has_object("radar_transponder")) object(rtbs);
365 if (has_object("radar_station") && (zoom >= 12)) symbol("radar_station");
366 if (has_object("light")) object(lights);
367}
368*/
369 }
370 private static void lights(Feature feature) {
371 switch (feature.type) {
372 case LITMAJ:
373 Renderer.symbol(feature, Beacons.LightMajor, null, null);
374 break;
375 case LITMIN:
376 case LIGHTS:
377 Renderer.symbol(feature, Beacons.LightMinor, null, null);
378 break;
379 }
380 }
381 private static void locks(Feature feature) {
382/*object_rules(locks) {
383 if ((zoom>=13) && is_type("lock_basin|lock_basin_part")) symbol("lock");
384 if ((zoom>=15) && is_type("gate")) symbol("lock_gate");
385}
386*/
387 }
388 private static void marinas(Feature feature) {
389 if (zoom >= 16) {
390
391 }
392/* int n = countObjects(item, type);
393 Atta_t atta = enumAttribute("category", obja);
394 char **map = cluster_map(obja);
395 if (map == NULL) return;
396 switch (n) {
397 case 0: {
398 Obj_t *obj = getObj(item, obja, 0);
399 int n = countValues(getAtt(obj, atta));
400 switch (n) {
401 case 1:
402 renderSymbol(item, obja, map[getAttEnum(obj, atta, 0)], "", "", CC, 0, 0, 0);
403 break;
404 case 2:
405 renderSymbol(item, obja, map[getAttEnum(obj, atta, 0)], "", "", RC, 0, 0, 0);
406 renderSymbol(item, obja, map[getAttEnum(obj, atta, 1)], "", "", LC, 0, 0, 0);
407 break;
408 case 3:
409 renderSymbol(item, obja, map[getAttEnum(obj, atta, 0)], "", "", BC, 0, 0, 0);
410 renderSymbol(item, obja, map[getAttEnum(obj, atta, 1)], "", "", TR, 0, 0, 0);
411 renderSymbol(item, obja, map[getAttEnum(obj, atta, 2)], "", "", TL, 0, 0, 0);
412 break;
413 case 4:
414 renderSymbol(item, obja, map[getAttEnum(obj, atta, 0)], "", "", BR, 0, 0, 0);
415 renderSymbol(item, obja, map[getAttEnum(obj, atta, 1)], "", "", BL, 0, 0, 0);
416 renderSymbol(item, obja, map[getAttEnum(obj, atta, 2)], "", "", TR, 0, 0, 0);
417 renderSymbol(item, obja, map[getAttEnum(obj, atta, 3)], "", "", TL, 0, 0, 0);
418 break;
419 }
420 }
421 break;
422 case 1:
423 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 1), atta, 0)], "", "", CC, 0, 0, 0);
424 break;
425 case 2:
426 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 1), atta, 0)], "", "", RC, 0, 0, 0);
427 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 2), atta, 0)], "", "", LC, 0, 0, 0);
428 break;
429 case 3:
430 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 1), atta, 0)], "", "", BC, 0, 0, 0);
431 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 2), atta, 0)], "", "", TR, 0, 0, 0);
432 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 3), atta, 0)], "", "", TL, 0, 0, 0);
433 break;
434 case 4:
435 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 1), atta, 0)], "", "", BR, 0, 0, 0);
436 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 2), atta, 0)], "", "", BL, 0, 0, 0);
437 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 3), atta, 0)], "", "", TR, 0, 0, 0);
438 renderSymbol(item, obja, map[getAttEnum(getObj(item, obja, 4), atta, 0)], "", "", TL, 0, 0, 0);
439 break;
440 }
441*/
442 }
443 private static void moorings(Feature feature) {
444 CatMOR cat = (CatMOR) Renderer.getAttVal(feature, feature.type, 0, Att.CATMOR);
445 switch (cat) {
446 case MOR_DLPN:
447 Renderer.symbol(feature, Harbours.Dolphin, null, null);
448 break;
449 case MOR_DDPN:
450 Renderer.symbol(feature, Harbours.DeviationDolphin, null, null);
451 break;
452 case MOR_BLRD:
453 case MOR_POST:
454 Renderer.symbol(feature, Harbours.Bollard, null, null);
455 break;
456 case MOR_BUOY:
457 BoySHP shape = (BoySHP) Renderer.getAttVal(feature, feature.type, 0, Att.BOYSHP);
458 if (shape == BoySHP.BOY_UNKN)
459 shape = BoySHP.BOY_SPHR;
460 Renderer.symbol(feature, Buoys.Shapes.get(shape), feature.type, null);
461 break;
462 }
463/* if (has_object("fog_signal")) object(fogs);
464 if (has_object("radar_transponder")) object(rtbs);
465 if (has_object("light")) object(lights);
466}
467*/
468 }
469
470 private static void notices(Feature feature) {
471 if (zoom >= 14) {
472 double dx = 0.0, dy = 0.0;
473 switch (feature.type) {
474 case BCNCAR:
475 case BCNISD:
476 case BCNLAT:
477 case BCNSAW:
478 case BCNSPP:
479 case BCNWTW:
480 dy = 45.0;
481 break;
482 case NOTMRK:
483 dy = 0.0;
484 break;
485 default:
486 return;
487 }
488 Symbol s1 = null, s2 = null;
489 MarSYS sys = MarSYS.SYS_CEVN;
490 AttItem att = feature.atts.get(Att.MARSYS);
491 if (att != null) sys = (MarSYS)att.val;
492 ObjTab objs = feature.objs.get(Obj.NOTMRK);
493 int n = objs.size();
494 if (n > 2) {
495 s1 = Notices.Notice;
496 n = 1;
497 } else {
498 for (AttMap atts : objs.values()) {
499 if (atts.get(Att.MARSYS) != null) sys = (MarSYS)atts.get(Att.MARSYS).val;
500 CatNMK cat = CatNMK.NMK_UNKN;
501 if (atts.get(Att.CATNMK) != null) cat = (CatNMK)atts.get(Att.CATNMK).val;
502 s2 = Notices.getNotice(cat, sys);
503 }
504 }
505/* Obj_t *obj = getObj(item, NOTMRK, i);
506 if (obj == NULL) continue;
507 Atta_t add;
508 int idx = 0;
509 while ((add = getAttEnum(obj, ADDMRK, idx++)) != MRK_UNKN) {
510 if ((add == MRK_LTRI) && (i == 2)) swap = true;
511 if ((add == MRK_RTRI) && (i != 2)) swap = true;
512 }
513 }
514 } else {
515
516 }
517 for (int i = 0; i <=2; i++) {
518 Obj_t *obj = getObj(item, NOTMRK, i);
519 if (obj == NULL) continue;
520 Atta_t category = getAttEnum(obj, CATNMK, i);
521 Atta_t add;
522 int idx = 0;
523 int top=0, bottom=0, left=0, right=0;
524 while ((add = getAttEnum(obj, ADDMRK, idx++)) != MRK_UNKN) {
525 switch (add) {
526 case MRK_TOPB:
527 top = add;
528 break;
529 case MRK_BOTB:
530 case MRK_BTRI:
531 bottom = add;
532 break;
533 case MRK_LTRI:
534 left = add;
535 break;
536 case MRK_RTRI:
537 right = add;
538 break;
539 default:
540 break;
541 }
542 }
543 double orient = getAtt(obj, ORIENT) != NULL ? getAtt(obj, ORIENT)->val.val.f : 0.0;
544 int system = getAtt(obj, MARSYS) != NULL ? getAtt(obj, MARSYS)->val.val.e : 0;
545 double flip = 0.0;
546 char *symb = "";
547 char *base = "";
548 char *colour = "black";
549 if ((system == SYS_BWR2) || (system == SYS_BNWR)) {
550 symb = bniwr_map[category];
551 switch (category) {
552 case NMK_NANK:
553 case NMK_LMHR:
554 case NMK_KTPM...NMK_RSPD:
555 {
556 int bank = getAtt(obj, BNKWTW) != NULL ? getAtt(obj, BNKWTW)->val.val.e : 0;
557 switch (bank) {
558 case BWW_LEFT:
559 base = "notice_blb";
560 colour = "red";
561 break;
562 case BWW_RGHT:
563 base = "notice_brb";
564 colour = "green";
565 break;
566 default:
567 base = "notice_bsi";
568 colour = "black";
569 break;
570 }
571 }
572 default:
573 break;
574 }
575 } else if (system == SYS_PPWB) {
576 int bank = getAtt(obj, BNKWTW) != NULL ? getAtt(obj, BNKWTW)->val.val.e : 0;
577 if (bank != 0) {
578 switch (category) {
579 case NMK_WLAR:
580 if (bank == BNK_LEFT)
581 base = "notice_pwlarl";
582 else
583 base = "notice_pwlarr";
584 break;
585 case NMK_WRAL:
586 if (bank == BNK_LEFT)
587 base = "notice_pwrall";
588 else
589 base = "notice_pwralr";
590 break;
591 case NMK_KTPM:
592 if (bank == BNK_LEFT)
593 base = "notice_ppml";
594 else
595 base = "notice_ppmr";
596 break;
597 case NMK_KTSM:
598 if (bank == BNK_LEFT)
599 base = "notice_psml";
600 else
601 base = "notice_psmr";
602 break;
603 case NMK_KTMR:
604 if (bank == BNK_LEFT)
605 base = "notice_pmrl";
606 else
607 base = "notice_pmrr";
608 break;
609 case NMK_CRTP:
610 if (bank == BNK_LEFT)
611 base = "notice_pcpl";
612 else
613 base = "notice_pcpr";
614 break;
615 case NMK_CRTS:
616 if (bank == BNK_LEFT)
617 base = "notice_pcsl";
618 else
619 base = "notice_pcsr";
620 break;
621 default:
622 break;
623 }
624 }
625 } else {
626 symb = notice_map[category];
627 switch (category) {
628 case NMK_NOVK...NMK_NWSH:
629 case NMK_NMTC...NMK_NLBG:
630 base = "notice_a";
631 break;
632 case NMK_MVTL...NMK_CHDR:
633 base = "notice_b";
634 break;
635 case NMK_PRTL...NMK_PRTR:
636 case NMK_OVHC...NMK_LBGP:
637 base = "notice_e";
638 colour = "white";
639 break;
640 default:
641 break;
642 }
643 switch (category) {
644 case NMK_MVTL:
645 case NMK_ANKP:
646 case NMK_PRTL:
647 case NMK_MWAL:
648 case NMK_MWAR:
649 flip = 180.0;
650 break;
651 case NMK_SWWR:
652 case NMK_WRSL:
653 case NMK_WARL:
654 flip = -90.0;
655 break;
656 case NMK_SWWC:
657 case NMK_SWWL:
658 case NMK_WLSR:
659 case NMK_WALR:
660 flip = 90.0;
661 break;
662 default:
663 break;
664 }
665 }
666 if (n == 2) {
667 dx = (((i != 2) && swap) || ((i == 2) && !swap)) ? -30.0 : 30.0;
668 }
669 if (top == MRK_TOPB)
670 renderSymbol(item, NOTMRK, "notice_board", "", "", BC, dx, dy, orient);
671 if (bottom == MRK_BOTB)
672 renderSymbol(item, NOTMRK, "notice_board", "", "", BC, dx, dy, orient+180);
673 if (bottom == MRK_BTRI)
674 renderSymbol(item, NOTMRK, "notice_triangle", "", "", BC, dx, dy, orient+180);
675 if (left == MRK_LTRI)
676 renderSymbol(item, NOTMRK, "notice_triangle", "", "", BC, dx, dy, orient-90);
677 if (right == MRK_RTRI)
678 renderSymbol(item, NOTMRK, "notice_triangle", "", "", BC, dx, dy, orient+90);
679 renderSymbol(item, NOTMRK, base, "", "", CC, dx, dy, orient);
680 renderSymbol(item, NOTMRK, symb, "", colour, CC, dx, dy, orient+flip);
681 }
682*/
683 }
684 }
685 private static void obstructions(Feature feature) {
686 if ((zoom >= 14) && (feature.type == Obj.UWTROC)) {
687 WatLEV lvl = (WatLEV) Renderer.getAttVal(feature, feature.type, 0, Att.WATLEV);
688 switch (lvl) {
689 case LEV_CVRS:
690 Renderer.symbol(feature, Areas.RockC, null, null);
691 break;
692 case LEV_AWSH:
693 Renderer.symbol(feature, Areas.RockA, null, null);
694 break;
695 default:
696 Renderer.symbol(feature, Areas.Rock, null, null);
697 }
698 } else {
699 Renderer.symbol(feature, Areas.Rock, null, null);
700 }
701 }
702 private static void pipelines(Feature feature) {
703 if (zoom >= 14) {
704 if (feature.type == Obj.PIPSOL) {
705 Renderer.lineSymbols(feature, Areas.Pipeline, 1.0, null, 0);
706 } else if (feature.type == Obj.PIPOHD) {
707
708 }
709 }
710 }
711 private static void platforms(Feature feature) {
712 Renderer.symbol(feature, Landmarks.Platform, null, null);
713/*object_rules(platforms) {
714 if (has_attribute("category")) {
715 attribute_switch("category")
716 attribute_case("fpso") symbol("storage");
717 attribute_default symbol("platform");
718 end_switch
719 } else {
720 symbol("platform");
721 }
722 if ((zoom >= 15) && has_item_attribute("name"))
723 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:80; text-anchor:start", 60, -50);
724 if (has_object("fog_signal")) object(fogs);
725 if (has_object("radar_transponder")) object(rtbs);
726 if (has_object("light")) object(lights);
727}
728*/
729 }
730 private static void ports(Feature feature) {
731/*object_rules(ports) {
732 if (zoom>=14) {
733 if (is_type("crane")) {
734 if (attribute_test("category", "container_crane")) symbol("container_crane");
735 else symbol("port_crane");
736 }
737 if (is_type("hulk")) {
738 area("fill:#ffe000;fill-opacity:1;stroke:#000000;stroke-width:2;stroke-opacity:1");
739 if ((zoom >= 15) && (has_item_attribute("name")))
740 text(item_attribute("name"), "font-family:Arial; font-weight:bold; font-size:70; text-anchor:middle", 0, 0);
741 }
742 }
743}
744*/
745 }
746 private static void separation(Feature feature) {
747 switch (feature.type) {
748 case TSEZNE:
749 case TSSCRS:
750 case TSSRON:
751 if (zoom <= 15)
752 Renderer.lineVector(feature, new LineStyle(null, 0, null, new Color(0x80c480ff, true)));
753 else
754 Renderer.lineVector(feature, new LineStyle(new Color(0x80c480ff, true), 20, null, null));
755 AttItem name = feature.atts.get(Att.OBJNAM);
756 if ((zoom >= 10) && (name != null))
757 Renderer.labelText(feature, (String) name.val, new Font("Arial", Font.BOLD, 150), new Color(0x80c480ff), null);
758 break;
759 case TSELNE:
760 Renderer.lineVector(feature, new LineStyle(new Color(0x80c480ff, true), 20, null, null));
761 break;
762 case TSSLPT:
763 Renderer.lineSymbols(feature, Areas.LaneArrow, 0.5, null, 0);
764 break;
765 case TSSBND:
766 Renderer.lineVector(feature, new LineStyle(new Color(0x80c480ff, true), 20, new float[] { 40, 40 }, null));
767 break;
768 }
769 }
770 private static void shoreline(Feature feature) {
771 if (zoom >= 12) {
772 switch ((CatSLC) Renderer.getAttVal(feature, feature.type, 0, Att.CATSLC)) {
773 case SLC_TWAL:
774 WatLEV lev = (WatLEV) Renderer.getAttVal(feature, feature.type, 0, Att.WATLEV);
775 if (lev == WatLEV.LEV_CVRS) {
776 Renderer.lineVector(feature, new LineStyle(Color.black, 10, new float[] { 40, 40 }, null));
777 if (zoom >= 15)
778 Renderer.lineText(feature, "(covers)", new Font("Arial", Font.PLAIN, 80), 0.5, 20);
779 } else {
780 Renderer.lineVector(feature, new LineStyle(Color.black, 10, null, null));
781 }
782 if (zoom >= 15)
783 Renderer.lineText(feature, "Training Wall", new Font("Arial", Font.PLAIN, 80), 0.5, -20);
784 }
785 }
786 }
787 private static void signals(Feature feature) {
788 switch (feature.type) {
789 case SISTAT:
790 case SISTAW:
791 Renderer.symbol(feature, Harbours.SignalStation, null, null);
792 break;
793 case RDOSTA:
794 Renderer.symbol(feature, Harbours.SignalStation, null, null);
795 break;
796 case RADSTA:
797 Renderer.symbol(feature, Harbours.SignalStation, null, null);
798 Renderer.symbol(feature, Beacons.RadarStation, null, null);
799 break;
800 case PILBOP:
801 Renderer.symbol(feature, Harbours.Pilot, null, null);
802 break;
803 case CGUSTA:
804 Renderer.symbol(feature, Harbours.SignalStation, null, null);
805 break;
806 case RSCSTA:
807 Renderer.symbol(feature, Harbours.Rescue, null, null);
808 break;
809 }
810/* if (has_object("fog_signal")) object(fogs);
811 if (has_object("radar_transponder")) object(rtbs);
812 if (has_object("light")) object(lights);
813}
814*/
815 }
816 private static void transits(Feature feature) {
817/*object_rules(transits) {
818 int ref;
819 if (zoom >= 12) {
820 if (is_type("recommended_track")) ref = line("stroke-width:8; stroke:#000000; stroke-linecap:butt; fill:none");
821 else if (is_type("navigation_line")) ref = line("stroke-width:8; stroke-dasharray:20,20; stroke:#000000; stroke-linecap:butt; fill:none");
822 }
823 if (zoom >= 15) {
824 make_string("");
825 if (has_object("name")) {
826 add_string(item_attribute("name"));
827 add_string(" ");
828 }
829 if (has_attribute("orientation")) {
830 add_string(attribute("orientation"));
831 add_string("\u00A1");
832 }
833 if (has_attribute("category")) {
834 add_string(" (");
835 add_string(attribute("category"));
836 add_string(")");
837 }
838 line_text(string, "font-family:Arial; font-weight:normal; font-size:80; text-anchor:middle", 0.5, -20, ref);
839 free_string
840 }
841}
842*/
843 }
844 private static void waterways(Feature feature) {
845 if ((zoom >= 14) && (feature.atts.get(Att.OBJNAM) != null)) {
846 // lineText(item_attribute("name"), "font-family:Arial;font-weight:bold;font-size:80;text-anchor:middle", 0.5, 15, line("stroke:none;fill:none"));
847 }
848 }
849 private static void wrecks(Feature feature) {
850 if (zoom >= 14) {
851 CatWRK cat = (CatWRK) Renderer.getAttVal(feature, feature.type, 0, Att.CATWRK);
852 switch (cat) {
853 case WRK_DNGR:
854 case WRK_MSTS:
855 Renderer.symbol(feature, Areas.WreckD, null, null);
856 break;
857 case WRK_HULS:
858 Renderer.symbol(feature, Areas.WreckS, null, null);
859 break;
860 default:
861 Renderer.symbol(feature, Areas.WreckND, null, null);
862 }
863 } else {
864 Renderer.symbol(feature, Areas.WreckND, null, null);
865 }
866 }
867}
Note: See TracBrowser for help on using the repository browser.