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

Last change on this file since 29185 was 29185, checked in by malcolmh, 14 years ago

save

File size: 11.0 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.util.ArrayList;
13
14import s57.S57val.*;
15import s57.S57att.*;
16import s57.S57obj.*;
17
18import seamap.SeaMap.*;
19import symbols.Beacons;
20import symbols.Buoys;
21import symbols.Harbours;
22import symbols.Landmarks;
23import symbols.Symbols.Instr;
24
25public class Rules {
26
27 static SeaMap map;
28 static int zoom;
29
30 public static void rules (SeaMap m, int z) {
31 map = m;
32 zoom = z;
33 ArrayList<Feature> feature;
34 if ((feature = map.features.get(Obj.SLCONS)) != null) shoreline(feature);
35 if ((feature = map.features.get(Obj.SLCONS)) != null) shoreline(feature);
36 if ((feature = map.features.get(Obj.PIPSOL)) != null) pipelines(feature);
37 if ((feature = map.features.get(Obj.CBLSUB)) != null) cables(feature);
38 if ((feature = map.features.get(Obj.PIPOHD)) != null) pipelines(feature);
39 if ((feature = map.features.get(Obj.CBLOHD)) != null) cables(feature);
40 if ((feature = map.features.get(Obj.TSEZNE)) != null) separation(feature);
41 if ((feature = map.features.get(Obj.TSSCRS)) != null) separation(feature);
42 if ((feature = map.features.get(Obj.TSSRON)) != null) separation(feature);
43 if ((feature = map.features.get(Obj.TSELNE)) != null) separation(feature);
44 if ((feature = map.features.get(Obj.TSSLPT)) != null) separation(feature);
45 if ((feature = map.features.get(Obj.TSSBND)) != null) separation(feature);
46 if ((feature = map.features.get(Obj.SNDWAV)) != null) areas(feature);
47 if ((feature = map.features.get(Obj.OSPARE)) != null) areas(feature);
48 if ((feature = map.features.get(Obj.FAIRWY)) != null) areas(feature);
49 if ((feature = map.features.get(Obj.DRGARE)) != null) areas(feature);
50 if ((feature = map.features.get(Obj.RESARE)) != null) areas(feature);
51 if ((feature = map.features.get(Obj.SPLARE)) != null) areas(feature);
52 if ((feature = map.features.get(Obj.SEAARE)) != null) areas(feature);
53 if ((feature = map.features.get(Obj.OBSTRN)) != null) obstructions(feature);
54 if ((feature = map.features.get(Obj.UWTROC)) != null) obstructions(feature);
55 if ((feature = map.features.get(Obj.MARCUL)) != null) areas(feature);
56 if ((feature = map.features.get(Obj.WTWAXS)) != null) waterways(feature);
57 if ((feature = map.features.get(Obj.RECTRC)) != null) transits(feature);
58 if ((feature = map.features.get(Obj.NAVLNE)) != null) transits(feature);
59 if ((feature = map.features.get(Obj.HRBFAC)) != null) harbours(feature);
60 if ((feature = map.features.get(Obj.ACHARE)) != null) harbours(feature);
61 if ((feature = map.features.get(Obj.ACHBRT)) != null) harbours(feature);
62 if ((feature = map.features.get(Obj.LOKBSN)) != null) locks(feature);
63 if ((feature = map.features.get(Obj.LKBSPT)) != null) locks(feature);
64 if ((feature = map.features.get(Obj.GATCON)) != null) locks(feature);
65 if ((feature = map.features.get(Obj.DISMAR)) != null) distances(feature);
66 if ((feature = map.features.get(Obj.HULKES)) != null) ports(feature);
67 if ((feature = map.features.get(Obj.CRANES)) != null) ports(feature);
68 if ((feature = map.features.get(Obj.LNDMRK)) != null) landmarks(feature);
69 if ((feature = map.features.get(Obj.MORFAC)) != null) moorings(feature);
70 if ((feature = map.features.get(Obj.NOTMRK)) != null) notices(feature);
71 if ((feature = map.features.get(Obj.SMCFAC)) != null) marinas(feature);
72 if ((feature = map.features.get(Obj.BRIDGE)) != null) bridges(feature);
73 if ((feature = map.features.get(Obj.LITMAJ)) != null) lights(feature);
74 if ((feature = map.features.get(Obj.LITMIN)) != null) lights(feature);
75 if ((feature = map.features.get(Obj.LIGHTS)) != null) lights(feature);
76 if ((feature = map.features.get(Obj.SISTAT)) != null) signals(feature);
77 if ((feature = map.features.get(Obj.SISTAW)) != null) signals(feature);
78 if ((feature = map.features.get(Obj.CGUSTA)) != null) signals(feature);
79 if ((feature = map.features.get(Obj.RDOSTA)) != null) signals(feature);
80 if ((feature = map.features.get(Obj.RADSTA)) != null) signals(feature);
81 if ((feature = map.features.get(Obj.RSCSTA)) != null) signals(feature);
82 if ((feature = map.features.get(Obj.PILBOP)) != null) signals(feature);
83 if ((feature = map.features.get(Obj.WTWGAG)) != null) gauges(feature);
84 if ((feature = map.features.get(Obj.OFSPLF)) != null) platforms(feature);
85 if ((feature = map.features.get(Obj.WRECKS)) != null) wrecks(feature);
86 if ((feature = map.features.get(Obj.LITVES)) != null) floats(feature);
87 if ((feature = map.features.get(Obj.LITFLT)) != null) floats(feature);
88 if ((feature = map.features.get(Obj.BOYINB)) != null) floats(feature);
89 if ((feature = map.features.get(Obj.BOYLAT)) != null) buoys(feature);
90 if ((feature = map.features.get(Obj.BOYCAR)) != null) buoys(feature);
91 if ((feature = map.features.get(Obj.BOYISD)) != null) buoys(feature);
92 if ((feature = map.features.get(Obj.BOYSAW)) != null) buoys(feature);
93 if ((feature = map.features.get(Obj.BOYSPP)) != null) buoys(feature);
94 if ((feature = map.features.get(Obj.BOYWTW)) != null) buoys(feature);
95 if ((feature = map.features.get(Obj.BCNLAT)) != null) beacons(feature);
96 if ((feature = map.features.get(Obj.BCNCAR)) != null) beacons(feature);
97 if ((feature = map.features.get(Obj.BCNISD)) != null) beacons(feature);
98 if ((feature = map.features.get(Obj.BCNSAW)) != null) beacons(feature);
99 if ((feature = map.features.get(Obj.BCNSPP)) != null) beacons(feature);
100 if ((feature = map.features.get(Obj.BCNWTW)) != null) beacons(feature);
101 }
102
103 private static void shoreline(ArrayList<Feature> features) {
104// for (Feature feature : features) {
105// }
106 }
107 private static void pipelines(ArrayList<Feature> features) {}
108 private static void cables(ArrayList<Feature> features) {}
109 private static void separation(ArrayList<Feature> features) {}
110 private static void areas(ArrayList<Feature> features) {}
111 private static void obstructions(ArrayList<Feature> features) {}
112 private static void waterways(ArrayList<Feature> features) {}
113 private static void transits(ArrayList<Feature> features) {}
114 private static void harbours(ArrayList<Feature> features) {}
115 private static void locks(ArrayList<Feature> features) {}
116 private static void distances(ArrayList<Feature> features) {}
117 private static void ports(ArrayList<Feature> features) {}
118 private static void landmarks(ArrayList<Feature> features) {
119 for (Feature feature : features) {
120 ArrayList<CatLMK> cats = (ArrayList<CatLMK>) Renderer.getAttVal(feature, feature.type, 0, Att.CATLMK);
121 ArrayList<Instr> catSym = Landmarks.Shapes.get(cats.get(0));
122 ArrayList<FncFNC> fncs = (ArrayList<FncFNC>) Renderer.getAttVal(feature, feature.type, 0, Att.FUNCTN);
123 ArrayList<Instr> fncSym = Landmarks.Funcs.get(fncs.get(0));
124 if ((fncs.get(0) == FncFNC.FNC_CHCH) && (cats.get(0) == CatLMK.LMK_TOWR)) catSym = Landmarks.ChurchTower;
125 if ((cats.get(0) == CatLMK.LMK_UNKN) && (fncs.get(0) == FncFNC.FNC_UNKN) && (feature.objs.get(Obj.LIGHTS) != null)) catSym = Beacons.LightMajor;
126 if (cats.get(0) == CatLMK.LMK_RADR) fncSym = Landmarks.RadioTV;
127 Renderer.symbol(feature, catSym, feature.type);
128 Renderer.symbol(feature, fncSym, feature.type);
129 }
130 }
131 private static void moorings(ArrayList<Feature> features) {
132 for (Feature feature : features) {
133 CatMOR cat = (CatMOR) Renderer.getAttVal(feature, feature.type, 0, Att.CATMOR);
134 switch (cat) {
135 case MOR_DLPN:
136 Renderer.symbol(feature, Harbours.Dolphin, feature.type);
137 break;
138 case MOR_DDPN:
139 Renderer.symbol(feature, Harbours.DeviationDolphin, feature.type);
140 break;
141 case MOR_BLRD:
142 case MOR_POST:
143 Renderer.symbol(feature, Harbours.Bollard, feature.type);
144 break;
145 case MOR_BUOY:
146 BoySHP shape = (BoySHP) Renderer.getAttVal(feature, feature.type, 0, Att.BOYSHP);
147 if (shape == BoySHP.BOY_UNKN) shape = BoySHP.BOY_SPHR;
148 Renderer.symbol(feature, Buoys.Shapes.get(shape), feature.type);
149 break;
150 }
151 }
152 }
153 private static void notices(ArrayList<Feature> features) {}
154 private static void marinas(ArrayList<Feature> features) {}
155 private static void bridges(ArrayList<Feature> features) {}
156 private static void wrecks(ArrayList<Feature> features) {}
157 private static void gauges(ArrayList<Feature> features) {}
158 private static void lights(ArrayList<Feature> features) {
159 for (Feature feature : features) {
160 switch (feature.type) {
161 case LITMAJ:
162 Renderer.symbol(feature, Beacons.LightMajor, feature.type);
163 break;
164 case LITMIN:
165 case LIGHTS:
166 Renderer.symbol(feature, Beacons.LightMinor, feature.type);
167 break;
168 }
169 }
170 }
171 private static void signals(ArrayList<Feature> features) {
172 for (Feature feature : features) {
173 switch (feature.type) {
174 case SISTAT:
175 case SISTAW:
176 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
177 break;
178 case RDOSTA:
179 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
180 break;
181 case RADSTA:
182 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
183 break;
184 case PILBOP:
185 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
186 break;
187 case CGUSTA:
188// Renderer.symbol(feature, Harbours.CGuardStation, feature.type);
189 break;
190 case RSCSTA:
191// Renderer.symbol(feature, Harbours.RescueStation, feature.type);
192 break;
193 }
194 }
195 }
196 private static void floats(ArrayList<Feature> features) {
197 for (Feature feature : features) {
198 switch (feature.type) {
199 case LITVES:
200 Renderer.symbol(feature, Buoys.Super, feature.type);
201 break;
202 case LITFLT:
203 Renderer.symbol(feature, Buoys.Float, feature.type);
204 break;
205 case BOYINB:
206 Renderer.symbol(feature, Buoys.Storage, feature.type);
207 break;
208 }
209 }
210 }
211 private static void platforms(ArrayList<Feature> features) {
212 for (Feature feature : features) {
213 Renderer.symbol(feature, Landmarks.Platform, feature.type);
214 }
215 }
216 private static void buoys(ArrayList<Feature> features) {
217 for (Feature feature : features) {
218 BoySHP shape = (BoySHP) Renderer.getAttVal(feature, feature.type, 0, Att.BOYSHP);
219 Renderer.symbol(feature, Buoys.Shapes.get(shape), feature.type);
220 }
221 }
222 private static void beacons(ArrayList<Feature> features) {
223 for (Feature feature : features) {
224 BcnSHP shape = (BcnSHP) Renderer.getAttVal(feature, feature.type, 0, Att.BCNSHP);
225 if (((shape == BcnSHP.BCN_PRCH) || (shape == BcnSHP.BCN_WTHY)) && (feature.type == Obj.BCNLAT)) {
226 CatLAM cat = (CatLAM) Renderer.getAttVal(feature, feature.type, 0, Att.CATLAM);
227 switch (cat) {
228 case LAM_PORT:
229 if (shape == BcnSHP.BCN_PRCH)
230 Renderer.symbol(feature, Beacons.PerchPort, feature.type);
231 else
232 Renderer.symbol(feature, Beacons.WithyPort, feature.type);
233 break;
234 case LAM_STBD:
235 if (shape == BcnSHP.BCN_PRCH)
236 Renderer.symbol(feature, Beacons.PerchStarboard, feature.type);
237 else
238 Renderer.symbol(feature, Beacons.WithyStarboard, feature.type);
239 break;
240 default:
241 Renderer.symbol(feature, Beacons.Stake, feature.type);
242 }
243 } else {
244 Renderer.symbol(feature, Beacons.Shapes.get(shape), feature.type);
245 }
246 }
247 }
248}
Note: See TracBrowser for help on using the repository browser.