use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class SitesBySpeciesComposer method loadLayer.
void loadLayer(String type, String name, int typeId) {
String mapurl = CommonData.getGeoServer() + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=ALA:" + type + "_" + pid + "&style=" + type + "_" + pid + "&FORMAT=image%2Fpng";
String legendurl = CommonData.getGeoServer() + "/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=10&HEIGHT=1" + "&LAYER=ALA:" + type + "_" + pid + "&STYLE=" + type + "_" + pid;
LOGGER.debug(legendurl);
String layername = getMapComposer().getNextAreaLayerName(name);
getMapComposer().addWMSLayer(pid + "_" + type, layername, mapurl, (float) 0.5, null, legendurl, typeId, null, null);
MapLayer ml = getMapComposer().getMapLayer(pid + "_" + type);
ml.setPid(pid + "_" + type);
String infoUrl = CommonData.getSatServer() + "/output/sitesbyspecies/" + pid + "/" + type + "_metadata.html";
MapLayerMetadata md = ml.getMapLayerMetadata();
md.setMoreInfo(infoUrl + "\n" + name + "\npid:" + pid);
md.setId(Long.valueOf(pid));
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AreaReportComposer method onFinish.
@Override
public boolean onFinish() {
//close any existing area report
Window w = (Window) getPage().getFellowIfAny("popupResults");
if (w != null) {
w.detach();
}
SelectedArea sa = getSelectedArea();
String areaName = getSelectedAreaName();
String areaDisplayName = getSelectedAreaDisplayName();
boolean includeEndemic = getIsEndemic();
MapLayer ml = getMapComposer().getMapLayer(areaName);
double[] bbox = null;
if (ml != null && ml.getMapLayerMetadata().getBbox() != null && ml.getMapLayerMetadata().getBbox().size() == 4) {
bbox = new double[4];
bbox[0] = ml.getMapLayerMetadata().getBbox().get(0);
bbox[1] = ml.getMapLayerMetadata().getBbox().get(1);
bbox[2] = ml.getMapLayerMetadata().getBbox().get(2);
bbox[3] = ml.getMapLayerMetadata().getBbox().get(3);
}
AreaReportController.open(sa, areaName, areaDisplayName, (ml == null) ? null : ml.getAreaSqKm(), bbox, includeEndemic);
detach();
return true;
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method loadAreaLayersHighlight.
public void loadAreaLayersHighlight() {
try {
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (int i = 0; i < layers.size(); i++) {
MapLayer lyr = layers.get(i);
Radio rAr = new Radio(lyr.getDisplayName());
rAr.setId(lyr.getName().replaceAll(" ", "") + "_" + i);
rAr.setValue(lyr.getName());
rAr.setParent(rgAreaHighlight);
rgAreaHighlight.insertBefore(rAr, rAreaCurrentHighlight);
}
rAreaNoneHighlight.setSelected(true);
} catch (Exception e) {
LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
}
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method getSelectedArea.
public SelectedArea getSelectedArea() {
String area = rAreaSelected.getValue();
SelectedArea sa = null;
try {
if (StringConstants.CURRENT.equals(area)) {
sa = new SelectedArea(null, getMapComposer().getViewArea());
} else if (StringConstants.AUSTRALIA.equals(area)) {
sa = new SelectedArea(null, CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT));
} else if (StringConstants.WORLD.equals(area)) {
sa = new SelectedArea(null, CommonData.WORLD_WKT);
} else {
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (MapLayer ml : layers) {
if (area == null || area.equals(ml.getName())) {
sa = new SelectedArea(ml, null);
break;
}
}
}
} catch (Exception e) {
LOGGER.warn("Unable to retrieve selected area", e);
}
return sa;
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method loadAreaHighlightLayers.
public void loadAreaHighlightLayers(String selectedAreaName) {
try {
// remove all radio buttons that don't have an id
for (int i = rgAreaHighlight.getItemCount() - 1; i >= 0; i--) {
String id = rgAreaHighlight.getItems().get(i).getId();
if (id == null || id.length() == 0) {
rgAreaHighlight.removeItemAt(i);
} else {
rgAreaHighlight.getItemAtIndex(i).setSelected(false);
}
}
String selectedLayerName = (String) params.get(StringConstants.POLYGON_LAYER_NAME);
Radio rSelectedLayer = null;
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (int i = 0; i < layers.size(); i++) {
MapLayer lyr = layers.get(i);
Radio rAr = new Radio(lyr.getDisplayName());
rAr.setValue(lyr.getName());
rAr.setParent(rgAreaHighlight);
rgAreaHighlight.insertBefore(rAr, rAreaCurrentHighlight);
if (lyr.getName().equals(selectedLayerName)) {
rSelectedLayer = rAr;
}
}
if (selectedAreaName != null && !selectedAreaName.isEmpty()) {
for (int i = 0; i < rgAreaHighlight.getItemCount(); i++) {
if (rgAreaHighlight.getItemAtIndex(i).isVisible() && rgAreaHighlight.getItemAtIndex(i).getLabel().equals(selectedAreaName)) {
rgAreaHighlight.setSelectedItem(rgAreaHighlight.getItemAtIndex(i));
break;
}
}
} else if (rSelectedLayer != null) {
rgAreaHighlight.setSelectedItem(rAreaSelected);
} else if (StringConstants.NONE.equals(selectedLayerName)) {
rgAreaHighlight.setSelectedItem(rAreaWorld);
} else {
for (int i = 0; i < rgAreaHighlight.getItemCount(); i++) {
if (rgAreaHighlight.getItemAtIndex(i).isVisible()) {
rgAreaHighlight.setSelectedItem(rgAreaHighlight.getItemAtIndex(i));
break;
}
}
}
Clients.evalJavaScript("jq('#" + rgAreaHighlight.getSelectedItem().getUuid() + "-real').attr('checked', true);");
} catch (Exception e) {
LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
}
}
Aggregations