Mercurial > dive4elements > river
changeset 5794:af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
This reduced GetFeatureInfo to one request per layer and chooses
the layer based on the selected theme
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Apr 23 17:14:07 2013 +0200 @@ -1260,5 +1260,7 @@ String wmsURLBoxTitle(); + String requireTheme(); + } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Apr 23 17:14:07 2013 +0200 @@ -593,6 +593,7 @@ attribution = ©Intevation GmbH 2013<br>Data ©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> wmsURLMenuItem = WMS URL wmsURLBoxTitle = Layer WMS URL +requireTheme = You need to choose a Layer. # Manual Points Editor addpoints = Add points
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Apr 23 17:14:07 2013 +0200 @@ -417,6 +417,7 @@ attribution = ©Intevation GmbH 2013<br>Data ©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> wmsURLMenuItem = WMS URL wmsURLBoxTitle = WMS URL der Kartenebene +requireTheme = Sie m\u00fcssen ein Thema ausw\u00e4hlen. # data cage waterlevels = Wasserst\u00e4nde
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Tue Apr 23 17:14:07 2013 +0200 @@ -415,6 +415,7 @@ attribution = ©Intevation GmbH 2013<br>Data ©<a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> wmsURLMenuItem = WMS URL wmsURLBoxTitle = Layer WMS URL +requireTheme = You need to choose a Layer. # data cage waterlevels = Waterlevels
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/GFIService.java Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/GFIService.java Tue Apr 23 17:14:07 2013 +0200 @@ -15,7 +15,7 @@ public interface GFIService extends RemoteService { public List<FeatureInfo> query( - List<Theme> themes, + Theme theme, String format, String bbox, String projection,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/services/GFIServiceAsync.java Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/GFIServiceAsync.java Tue Apr 23 17:14:07 2013 +0200 @@ -14,7 +14,7 @@ public interface GFIServiceAsync { void query( - List<Theme> themes, + Theme theme, String format, String bbox, String projection,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemePanel.java Tue Apr 23 17:14:07 2013 +0200 @@ -79,7 +79,6 @@ /** The collection view*/ protected CollectionView view; - /** * Setup Grid, navigation bar. * @param collection Collection for which to show themes. @@ -158,6 +157,9 @@ return getCollection().getThemeList(mode.getName()); } + public ListGridRecord[] getSelectedRecords() { + return list.getSelectedRecords(); + } /** * Registers a new OutputParameterChangeHandler.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java Tue Apr 23 17:14:07 2013 +0200 @@ -6,6 +6,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.grid.ListGridRecord; import org.gwtopenmaps.openlayers.client.Map; import org.gwtopenmaps.openlayers.client.LonLat; @@ -17,6 +18,8 @@ import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.services.GFIService; import de.intevation.flys.client.client.services.GFIServiceAsync; +import de.intevation.flys.client.shared.model.FacetRecord; +import de.intevation.flys.client.shared.model.Theme; import de.intevation.flys.client.client.ui.ThemePanel; @@ -71,22 +74,34 @@ LonLat lonlat = e.getLonLat(); Pixel pixel = map.getPixelFromLonLat(lonlat); - gfiService.query( - themePanel.getThemeList().getActiveThemes(), - infoFormat, - map.getExtent().toString(), - map.getProjection(), - (int) map.getSize().getHeight(), - (int) map.getSize().getWidth(), - pixel.x(), pixel.y(), - new AsyncCallback<List<FeatureInfo>>() { - public void onFailure(Throwable e) { - SC.warn(MSG.getString(e.getMessage())); - } + if (themePanel.getSelectedRecords().length == 0) { + SC.say(MSG.requireTheme()); + } - public void onSuccess(List<FeatureInfo> features) { - newGetFeatureInfoWindow(features); - } - }); + for (ListGridRecord rec : themePanel.getSelectedRecords()) { + Theme act_theme = ((FacetRecord)rec).getTheme(); + gfiService.query( + act_theme, + infoFormat, + map.getExtent().toString(), + map.getProjection(), + (int) map.getSize().getHeight(), + (int) map.getSize().getWidth(), + pixel.x(), pixel.y(), + new AsyncCallback<List<FeatureInfo>>() { + @Override + public void onFailure(Throwable e) { + SC.warn(MSG.getString(e.getMessage())); + } + + @Override + public void onSuccess(List<FeatureInfo> features) { + if (features != null && !features.isEmpty()) + newGetFeatureInfoWindow(features); + } + } + ); + break; // More intelligent handling when more then one is selected + } } }
--- a/flys-client/src/main/java/de/intevation/flys/client/server/GFIServiceImpl.java Tue Apr 23 15:32:22 2013 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/GFIServiceImpl.java Tue Apr 23 17:14:07 2013 +0200 @@ -47,7 +47,7 @@ /** - * @param themes + * @param theme * @param format * @param bbox * @param height @@ -58,7 +58,7 @@ * @return */ public List<FeatureInfo> query( - List<Theme> themes, + Theme theme, String format, String bbox, String projection, @@ -71,7 +71,7 @@ logger.info("GFIServiceImpl.query"); String path = createGetFeautureInfoURL( - themes, format, bbox, projection, height, width, x, y); + theme, format, bbox, projection, height, width, x, y); logger.debug("URL=" + path); @@ -96,7 +96,7 @@ /** * @param map - * @param themes + * @param theme * @param format * @param x * @param y @@ -104,7 +104,7 @@ * @return */ protected String createGetFeautureInfoURL( - List<Theme> themes, + Theme theme, String infoFormat, String bbox, String projection, @@ -114,13 +114,13 @@ int y ) throws ServerException { - String url = getUrl(themes); + String url = getUrl(theme); if (url == null || url.length() == 0) { throw new ServerException(ERR_NO_VALID_GFI_URL); } - String layers = createLayersString(themes); + String layers = ((AttributedTheme)theme).getAttr("layers"); StringBuilder sb = new StringBuilder(); sb.append(url); @@ -149,36 +149,13 @@ } - protected String getUrl(List<Theme> themes) { - for (Theme t: themes) { - AttributedTheme attr = (AttributedTheme) t; - - if (attr.getAttrAsBoolean("queryable")) { - return attr.getAttr("url"); - } - } - - return null; - } - + protected String getUrl(Theme theme) { + AttributedTheme attr = (AttributedTheme) theme; - protected String createLayersString(List<Theme> themes) { - StringBuilder sb = new StringBuilder(); - boolean first = true; - - for (Theme theme: themes) { - AttributedTheme layer = (AttributedTheme) theme; - if (layer.getAttrAsBoolean("queryable")) { - if (!first) { - sb.append(","); - } - - sb.append(layer.getAttr("layers")); - first = false; - } + if (attr.getAttrAsBoolean("queryable")) { + return attr.getAttr("url"); } - - return sb.toString(); + return null; }