Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java @ 1376:28eb4dfe2cbf
Call Collection.doOut to retrieve a map config and use this config to build up an OpenLayers map.
flys-client/trunk@3096 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 28 Oct 2011 06:12:51 +0000 |
parents | 9085cffbb7c4 |
children | b0fe35d4ce6b |
comparison
equal
deleted
inserted
replaced
1375:dc715351527f | 1376:28eb4dfe2cbf |
---|---|
34 import de.intevation.flys.client.shared.model.Data; | 34 import de.intevation.flys.client.shared.model.Data; |
35 import de.intevation.flys.client.shared.model.DataItem; | 35 import de.intevation.flys.client.shared.model.DataItem; |
36 import de.intevation.flys.client.shared.model.DataList; | 36 import de.intevation.flys.client.shared.model.DataList; |
37 import de.intevation.flys.client.shared.model.DefaultData; | 37 import de.intevation.flys.client.shared.model.DefaultData; |
38 import de.intevation.flys.client.shared.model.DefaultDataItem; | 38 import de.intevation.flys.client.shared.model.DefaultDataItem; |
39 import de.intevation.flys.client.shared.model.MapConfig; | |
39 import de.intevation.flys.client.shared.model.Theme; | 40 import de.intevation.flys.client.shared.model.Theme; |
40 import de.intevation.flys.client.shared.model.ThemeList; | 41 import de.intevation.flys.client.shared.model.ThemeList; |
41 import de.intevation.flys.client.shared.model.OutputMode; | 42 import de.intevation.flys.client.shared.model.OutputMode; |
42 | 43 |
43 import de.intevation.flys.client.client.Config; | 44 import de.intevation.flys.client.client.Config; |
80 OutputMode mode, | 81 OutputMode mode, |
81 CollectionView collectionView | 82 CollectionView collectionView |
82 ){ | 83 ){ |
83 super(title, collection, collectionView, mode); | 84 super(title, collection, collectionView, mode); |
84 | 85 |
85 floodMap = new FloodMap(getSrid(), getMaxExtent()); | 86 mapService.doOut(collection, new AsyncCallback<MapConfig>() { |
86 | |
87 mapService.doOut(collection, new AsyncCallback<Void>() { | |
88 public void onFailure(Throwable caught) { | 87 public void onFailure(Throwable caught) { |
89 GWT.log("MAP ERROR: " + caught.getMessage()); | 88 GWT.log("MAP ERROR: " + caught.getMessage()); |
90 } | 89 } |
91 | 90 |
92 public void onSuccess(Void v) { | 91 public void onSuccess(MapConfig c) { |
93 GWT.log("MAP SUCCESS!"); | 92 GWT.log("MAP SUCCESS!"); |
93 | |
94 Bounds max = boundsFromString(c.getMaxExtent()); | |
95 Bounds initial = boundsFromString(c.getInitialExtent()); | |
96 | |
97 if (initial == null) { | |
98 GWT.log("Warning: No initial extent set."); | |
99 initial = max; | |
100 } | |
101 | |
102 setFloodmap(new FloodMap(c.getSrid(), max)); | |
103 | |
104 initLayout(); | |
105 initLayers(); | |
106 initBarriers(); | |
107 | |
108 GWT.log("MAX EXTENT: " + max); | |
109 GWT.log("ZOOM TO: " + initial); | |
110 getMap().zoomToExtent(initial); | |
94 } | 111 } |
95 } | 112 } |
96 ); | 113 ); |
97 | |
98 initLayout(); | |
99 initLayers(); | |
100 initBarriers(); | |
101 } | 114 } |
102 | 115 |
103 | 116 |
104 protected void initLayout() { | 117 protected void initLayout() { |
105 VLayout rootLayout = new VLayout(); | 118 VLayout rootLayout = new VLayout(); |
154 | 167 |
155 protected void initLayers() { | 168 protected void initLayers() { |
156 ThemeList themeList = themePanel.getThemeList(); | 169 ThemeList themeList = themePanel.getThemeList(); |
157 | 170 |
158 int num = themeList.getThemeCount(); | 171 int num = themeList.getThemeCount(); |
159 | 172 Map map = floodMap.getMap(); |
160 Map map = floodMap.getMap(); | |
161 Bounds extent = null; | |
162 Bounds wsplgenExtent = null; | |
163 | 173 |
164 for (int i = num; i >= 0; i--) { | 174 for (int i = num; i >= 0; i--) { |
165 Theme theme = themeList.getThemeAt(i); | 175 Theme theme = themeList.getThemeAt(i); |
166 Layer layer = createWMSLayer(theme); | 176 Layer layer = createWMSLayer(theme); |
167 | 177 |
168 if (layer == null) { | 178 if (layer == null) { |
169 continue; | 179 continue; |
170 } | 180 } |
171 | 181 |
172 map.addLayer(layer); | 182 map.addLayer(layer); |
173 | 183 } |
174 AttributedTheme at = (AttributedTheme) theme; | |
175 String tmp = at.getAttr("extent"); | |
176 | |
177 if (WSPLGEN_FACET.equals(at.getFacet())) { | |
178 // if there is a wsplgen layer, we want to zoom to | |
179 // that place initially | |
180 wsplgenExtent = boundsFromString(tmp); | |
181 } | |
182 | |
183 if (theme.getActive() == 1) { | |
184 if (extent == null) { | |
185 extent = boundsFromString(tmp); | |
186 } | |
187 else { | |
188 Bounds b = boundsFromString(tmp); | |
189 | |
190 if (b != null) { | |
191 extent.extend(b); | |
192 } | |
193 } | |
194 } | |
195 } | |
196 | |
197 extent = wsplgenExtent != null ? wsplgenExtent : extent; | |
198 | |
199 GWT.log("Maps initial extent = " + extent); | |
200 | |
201 map.zoomToExtent(extent != null | |
202 ? extent | |
203 : new Bounds(-90, -180, 90, 180)); | |
204 } | 184 } |
205 | 185 |
206 | 186 |
207 protected void initBarriers() { | 187 protected void initBarriers() { |
208 Vector vector = floodMap.getBarrierLayer(); | 188 Vector vector = floodMap.getBarrierLayer(); |
251 // TODO FILL ME | 231 // TODO FILL ME |
252 GWT.log("TODO: Request redraw."); | 232 GWT.log("TODO: Request redraw."); |
253 } | 233 } |
254 | 234 |
255 | 235 |
236 protected void setFloodmap(FloodMap floodMap) { | |
237 this.floodMap = floodMap; | |
238 } | |
239 | |
240 | |
256 protected Map getMap() { | 241 protected Map getMap() { |
257 return floodMap.getMap(); | 242 return floodMap.getMap(); |
258 } | 243 } |
259 | 244 |
260 | 245 |
315 | 300 |
316 return DEFAULT_SRID; | 301 return DEFAULT_SRID; |
317 } | 302 } |
318 | 303 |
319 | 304 |
320 public Bounds getMaxExtent() { | |
321 ThemeList themeList = getThemeList(); | |
322 | |
323 int num = themeList.getThemeCount(); | |
324 | |
325 Bounds extent = null; | |
326 | |
327 for (int i = 1; i <= num; i++) { | |
328 AttributedTheme theme = (AttributedTheme) themeList.getThemeAt(i); | |
329 | |
330 if (theme == null) { | |
331 continue; | |
332 } | |
333 | |
334 String tmp = theme.getAttr("extent"); | |
335 | |
336 if (theme.getActive() == 1) { | |
337 if (extent == null) { | |
338 extent = boundsFromString(tmp); | |
339 } | |
340 else { | |
341 Bounds b = boundsFromString(tmp); | |
342 | |
343 if (b != null) { | |
344 extent.extend(b); | |
345 } | |
346 } | |
347 } | |
348 } | |
349 | |
350 return extent; | |
351 } | |
352 | |
353 | |
354 protected Bounds boundsFromString(String bounds) { | 305 protected Bounds boundsFromString(String bounds) { |
306 GWT.log("Create Bounds from String: '" + bounds + "'"); | |
355 if (bounds == null || bounds.length() == 0) { | 307 if (bounds == null || bounds.length() == 0) { |
356 return null; | 308 return null; |
357 } | 309 } |
358 | 310 |
359 String[] values = bounds.split(" "); | 311 String[] values = bounds.split(" "); |