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

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

save

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