Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AAD-105: WMS legend, WMS feature info, overall search for values
- Loading branch information
Showing
24 changed files
with
1,168 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
map/src/main/java/org/ktunaxa/referral/client/action/WmsFeatureInfoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Ktunaxa Referral Management System. | ||
* | ||
* Copyright (C) see version control system | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.ktunaxa.referral.client.action; | ||
|
||
import org.geomajas.geometry.Coordinate; | ||
import org.geomajas.gwt.client.controller.AbstractGraphicsController; | ||
import org.geomajas.gwt.client.map.layer.InternalClientWmsLayer; | ||
import org.geomajas.gwt.client.map.layer.Layer; | ||
import org.geomajas.gwt.client.spatial.Mathlib; | ||
import org.geomajas.gwt.client.spatial.WorldViewTransformer; | ||
import org.geomajas.gwt.client.widget.MapWidget; | ||
import org.geomajas.gwt2.client.map.feature.JsonFeatureFactory; | ||
import org.geomajas.gwt2.plugin.wms.client.WmsClient; | ||
import org.geomajas.gwt2.plugin.wms.client.layer.WmsLayer; | ||
import org.geomajas.gwt2.plugin.wms.client.layer.WmsLayerConfiguration; | ||
import org.geomajas.gwt2.plugin.wms.client.layer.WmsLayerImpl; | ||
import org.geomajas.gwt2.plugin.wms.client.service.WmsService; | ||
import org.ktunaxa.referral.client.gui.MapLayout; | ||
|
||
import com.google.gwt.event.dom.client.MouseUpEvent; | ||
import com.smartgwt.client.types.ContentsType; | ||
import com.smartgwt.client.widgets.HTMLPane; | ||
import com.smartgwt.client.widgets.Window; | ||
|
||
public class WmsFeatureInfoController extends AbstractGraphicsController { | ||
|
||
/** Number of pixels that describes the tolerance allowed when trying to select features. */ | ||
private int pixelTolerance; | ||
|
||
public WmsFeatureInfoController(MapWidget mapWidget, int pixelTolerance) { | ||
super(mapWidget); | ||
this.pixelTolerance = pixelTolerance; | ||
} | ||
|
||
/** | ||
* On mouse up, execute the search by location, and display a | ||
* {@link org.geomajas.gwt.client.widget.FeatureAttributeWindow} if a result is found. | ||
*/ | ||
public void onMouseUp(MouseUpEvent event) { | ||
Coordinate worldPosition = getWorldPosition(event); | ||
final Window window = new Window(); | ||
window.setWidth(MapLayout.getInstance().getLayerPanel().getWidth()); | ||
window.setHeight(MapLayout.getInstance().getLayerPanel().getHeight()); | ||
window.setCanDragReposition(true); | ||
window.setCanDragResize(true); | ||
StringBuilder sb = null; | ||
WmsLayerConfiguration layerConfig = new WmsLayerConfiguration(); | ||
for (Layer<?> layer : mapWidget.getMapModel().getLayers()) { | ||
if (layer.isShowing() && layer instanceof InternalClientWmsLayer) { | ||
if (sb == null) { | ||
sb = new StringBuilder(); | ||
InternalClientWmsLayer l = (InternalClientWmsLayer)layer; | ||
layerConfig.setBaseUrl(l.getWmsLayer().getConfiguration().getBaseUrl()); | ||
layerConfig.setVersion(l.getWmsLayer().getConfiguration().getVersion()); | ||
layerConfig.setCrs(l.getWmsLayer().getConfiguration().getCrs()); | ||
layerConfig.setFormat(l.getWmsLayer().getConfiguration().getFormat()); | ||
layerConfig.setStyles(""); | ||
layerConfig.setLegendConfig(l.getWmsLayer().getConfiguration().getLegendConfig()); | ||
layerConfig.setTransparent(true); | ||
layerConfig.setWmsServiceVendor(l.getWmsLayer().getConfiguration().getWmsServiceVendor()); | ||
} else { | ||
sb.append(","); | ||
} | ||
sb.append(layer.getId()); | ||
} | ||
} | ||
if(sb != null) { | ||
layerConfig.setLayers(sb.toString()); | ||
WmsLayer dummy = new WmsLayerImpl("all", layerConfig.getCrs(), layerConfig, null, null); | ||
final String url = WmsClient | ||
.getInstance() | ||
.getWmsService() | ||
.getFeatureInfoUrl(dummy, worldPosition, | ||
mapWidget.getMapModel().getMapView().getBounds().toDtoBbox(), | ||
1. / mapWidget.getMapModel().getMapView().getCurrentScale(), | ||
WmsService.GetFeatureInfoFormat.HTML.toString(), 10); | ||
window.setTitle("Features found for "+sb.toString()+":"); | ||
HTMLPane htmlPane = new HTMLPane(); | ||
htmlPane.setContentsURL(url); | ||
htmlPane.setContentsType(ContentsType.PAGE); | ||
window.addItem(htmlPane); | ||
if(!window.isDrawn()) { | ||
window.showNextTo(MapLayout.getInstance().getMap(), "left"); | ||
} | ||
} | ||
|
||
} | ||
|
||
private double calculateBufferFromPixelTolerance() { | ||
WorldViewTransformer transformer = mapWidget.getMapModel().getMapView().getWorldViewTransformer(); | ||
Coordinate c1 = transformer.viewToWorld(new Coordinate(0, 0)); | ||
Coordinate c2 = transformer.viewToWorld(new Coordinate(pixelTolerance, 0)); | ||
return Mathlib.distance(c1, c2); | ||
} | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
map/src/main/java/org/ktunaxa/referral/client/action/WmsFeatureInfoModalAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Ktunaxa Referral Management System. | ||
* | ||
* Copyright (C) see version control system | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.ktunaxa.referral.client.action; | ||
|
||
import org.geomajas.gwt.client.action.ToolbarModalAction; | ||
import org.geomajas.gwt.client.i18n.I18nProvider; | ||
import org.geomajas.gwt.client.util.WidgetLayout; | ||
import org.geomajas.gwt.client.widget.MapWidget; | ||
|
||
import com.smartgwt.client.widgets.events.ClickEvent; | ||
|
||
|
||
public class WmsFeatureInfoModalAction extends ToolbarModalAction { | ||
|
||
private MapWidget mapWidget; | ||
|
||
private WmsFeatureInfoController controller; | ||
|
||
/** Number of pixels that describes the tolerance allowed when trying to select features. */ | ||
private int pixelTolerance = 5; | ||
|
||
// Constructor: | ||
|
||
public WmsFeatureInfoModalAction(MapWidget mapWidget) { | ||
super(WidgetLayout.iconInfo, I18nProvider.getToolbar().featureInfoTitle(), I18nProvider | ||
.getToolbar().featureInfoTooltip()); | ||
this.mapWidget = mapWidget; | ||
controller = new WmsFeatureInfoController(mapWidget, pixelTolerance); | ||
} | ||
|
||
// ToolbarModalAction implementation: | ||
|
||
@Override | ||
public void onSelect(ClickEvent event) { | ||
mapWidget.setController(controller); | ||
} | ||
|
||
@Override | ||
public void onDeselect(ClickEvent event) { | ||
mapWidget.setController(null); | ||
} | ||
|
||
// Getters and setters: | ||
|
||
public int getPixelTolerance() { | ||
return pixelTolerance; | ||
} | ||
|
||
public void setPixelTolerance(int pixelTolerance) { | ||
this.pixelTolerance = pixelTolerance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.