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

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

save

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