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

Last change on this file since 29176 was 29176, checked in by malcolmh, 13 years ago

save

File size: 10.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.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 MainRules (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 Renderer.symbol(feature, catSym, feature.type);
126 Renderer.symbol(feature, fncSym, feature.type);
127 }
128 }
129 private static void moorings(ArrayList<Feature> features) {
130 for (Feature feature : features) {
131 CatMOR cat = (CatMOR) Renderer.getAttVal(feature, feature.type, 0, Att.CATMOR);
132 switch (cat) {
133 case MOR_DLPN:
134 Renderer.symbol(feature, Harbours.Dolphin, feature.type);
135 break;
136 case MOR_DDPN:
137 Renderer.symbol(feature, Harbours.DeviationDolphin, feature.type);
138 break;
139 case MOR_BLRD:
140 case MOR_POST:
141 Renderer.symbol(feature, Harbours.Bollard, feature.type);
142 break;
143 case MOR_BUOY:
144 BoySHP shape = (BoySHP) Renderer.getAttVal(feature, feature.type, 0, Att.BOYSHP);
145 if (shape == BoySHP.BOY_UNKN) shape = BoySHP.BOY_SPHR;
146 Renderer.symbol(feature, Buoys.Shapes.get(shape), feature.type);
147 break;
148 }
149 }
150 }
151 private static void notices(ArrayList<Feature> features) {}
152 private static void marinas(ArrayList<Feature> features) {}
153 private static void bridges(ArrayList<Feature> features) {}
154 private static void wrecks(ArrayList<Feature> features) {}
155 private static void gauges(ArrayList<Feature> features) {}
156 private static void lights(ArrayList<Feature> features) {
157 for (Feature feature : features) {
158 switch (feature.type) {
159 case LITMAJ:
160 Renderer.symbol(feature, Beacons.LightMajor, feature.type);
161 break;
162 case LITMIN:
163 case LIGHTS:
164 Renderer.symbol(feature, Beacons.LightMinor, feature.type);
165 break;
166 }
167 }
168 }
169 private static void signals(ArrayList<Feature> features) {
170 for (Feature feature : features) {
171 switch (feature.type) {
172 case SISTAT:
173 case SISTAW:
174 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
175 break;
176 case RDOSTA:
177 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
178 break;
179 case RADSTA:
180 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
181 break;
182 case PILBOP:
183 Renderer.symbol(feature, Harbours.SignalStation, feature.type);
184 break;
185 case CGUSTA:
186// Renderer.symbol(feature, Harbours.CGuardStation, feature.type);
187 break;
188 case RSCSTA:
189// Renderer.symbol(feature, Harbours.RescueStation, feature.type);
190 break;
191 }
192 }
193 }
194 private static void floats(ArrayList<Feature> features) {
195 for (Feature feature : features) {
196 switch (feature.type) {
197 case LITVES:
198 Renderer.symbol(feature, Buoys.Super, feature.type);
199 break;
200 case LITFLT:
201 Renderer.symbol(feature, Buoys.Float, feature.type);
202 break;
203 case BOYINB:
204 Renderer.symbol(feature, Buoys.Storage, feature.type);
205 break;
206 }
207 }
208 }
209 private static void platforms(ArrayList<Feature> features) {
210 for (Feature feature : features) {
211 Renderer.symbol(feature, Landmarks.Platform, feature.type);
212 }
213 }
214 private static void buoys(ArrayList<Feature> features) {
215 for (Feature feature : features) {
216 BoySHP shape = (BoySHP) Renderer.getAttVal(feature, feature.type, 0, Att.BOYSHP);
217 Renderer.symbol(feature, Buoys.Shapes.get(shape), feature.type);
218 }
219 }
220 private static void beacons(ArrayList<Feature> features) {
221 for (Feature feature : features) {
222 BcnSHP shape = (BcnSHP) Renderer.getAttVal(feature, feature.type, 0, Att.BCNSHP);
223 if (((shape == BcnSHP.BCN_PRCH) || (shape == BcnSHP.BCN_WTHY)) && (feature.type == Obj.BCNLAT)) {
224 CatLAM cat = (CatLAM) Renderer.getAttVal(feature, feature.type, 0, Att.CATLAM);
225 switch (cat) {
226 case LAM_PORT:
227 if (shape == BcnSHP.BCN_PRCH)
228 Renderer.symbol(feature, Beacons.PerchPort, feature.type);
229 else
230 Renderer.symbol(feature, Beacons.WithyPort, feature.type);
231 break;
232 case LAM_STBD:
233 if (shape == BcnSHP.BCN_PRCH)
234 Renderer.symbol(feature, Beacons.PerchStarboard, feature.type);
235 else
236 Renderer.symbol(feature, Beacons.WithyStarboard, feature.type);
237 break;
238 default:
239 Renderer.symbol(feature, Beacons.Stake, feature.type);
240 }
241 } else {
242 Renderer.symbol(feature, Beacons.Shapes.get(shape), feature.type);
243 }
244 }
245 }
246}
Note: See TracBrowser for help on using the repository browser.