use of org.geotools.data.wms.WebMapServer in project spatial-portal by AtlasOfLivingAustralia.
the class AddWMSLayerComposer method onClick$addAllLayersButton.
public void onClick$addAllLayersButton() {
LOGGER.debug("onClick$addAllLayersButton()");
// hide (any) previous success message
resultLabel.setVisible(false);
// validate - DO NOT SHORT CURCUIT HERE!
// DO NOT PUT TEST INTO IF STATEMENT (DO NOT SHORT CURCUIT HERE!)
boolean amc = validateAutomaticModeCommon();
boolean c = validateCommon();
if (c && amc) {
try {
wmsServer = new WebMapServer(new URL(uri.getValue()));
discoveredLayer = wmsServer.getCapabilities();
MapLayer mapLayer = new MapLayer();
mapLayer.setName(Validate.escapeHtmlAndTrim(label.getValue()));
String ur = uri.getValue();
mapLayer.setUri(ur);
mapLayer.setLayer(layerUtilities.getLayers(ur));
mapLayer.setOpacity(opacitySlider.getCurpos() / 100.0f);
mapLayer.setImageFormat(layerUtilities.getImageFormat(ur));
/* attempt to retrieve bounding box */
List<Double> bbox = layerUtilities.getBBox(ur);
if (bbox != null) {
MapLayerMetadata md = new MapLayerMetadata();
md.setBbox(bbox);
md.setMoreInfo(ur);
mapLayer.setMapLayerMetadata(md);
}
/* we don't want our user to have to type loads
* when adding a new layer so we just assume/generate
* values for the id and description
*/
String name = (nameAutomatically.isChecked()) ? "" : Validate.escapeHtmlAndTrim(label.getValue());
mapLayer.setId(uri + name.replaceAll("\\s+", ""));
mapLayer.setDescription(name);
// wms version
String version = layerUtilities.getVersionValue(ur);
mapLayer.setType(layerUtilities.internalVersion(version));
getMapComposer().addUserDefinedLayerToMenu(mapLayer, true);
updateResult("wms_server_added");
// addWMSServer handles showing any errors for us
} catch (Exception e) {
LOGGER.error("failed to get layer from url", e);
}
}
}
use of org.geotools.data.wms.WebMapServer in project spatial-portal by AtlasOfLivingAustralia.
the class AddWMSLayerComposer method onClick$selectLayersButton.
public void onClick$selectLayersButton() {
LOGGER.debug("onClick$selectLayersButton");
if (validateAutomaticModeCommon()) {
try {
wmsServer = new WebMapServer(new URL(uri.getValue()));
discoveredLayer = wmsServer.getCapabilities();
// want list of all
if (discoveredLayer != null) {
availableLayers = new ArrayList<String[]>();
//skip first layer,
for (int i = 1; i < discoveredLayer.getLayerList().size(); i++) {
availableLayers.add(new String[] { String.valueOf(i), discoveredLayer.getLayerList().get(i).getName() + "," + discoveredLayer.getLayerList().get(i).getTitle() });
}
updateAvailableLayers();
selectLayers.setVisible(true);
selectLayersButton.setDisabled(true);
addDiscoveredLayerButton.setVisible(true);
} else {
// there was an error somewhere..
getMapComposer().showMessage(CommonData.lang("error_adding_layer"));
}
} catch (Exception e) {
LOGGER.error("map request", e);
}
}
}
Aggregations