use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AddFacetController method getSelectedArea.
public SelectedArea getSelectedArea() {
String area = rAreaSelected.getValue();
SelectedArea selectedarea = null;
try {
if (StringConstants.CURRENT.equals(area)) {
selectedarea = new SelectedArea(null, getMapComposer().getViewArea());
} else if (StringConstants.AUSTRALIA.equals(area)) {
selectedarea = new SelectedArea(null, CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT));
} else if (StringConstants.WORLD.equals(area)) {
selectedarea = new SelectedArea(null, CommonData.WORLD_WKT);
} else {
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (MapLayer ml : layers) {
if (area.equals(ml.getName())) {
selectedarea = new SelectedArea(ml, null);
break;
}
}
//for 'all areas'
if (selectedarea == null) {
selectedarea = new SelectedArea(null, area);
}
}
} catch (Exception e) {
LOGGER.error("Unable to retrieve selected area", e);
}
return selectedarea;
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AddFacetController method onClick$btnOk.
public void onClick$btnOk(Event event) {
if (btnOk.isDisabled()) {
return;
}
try {
if (!hasCustomArea && (isAreaCustom() || isAreaHighlightCustom())) {
this.doOverlapped();
this.setTop("-9999px");
this.setLeft("-9999px");
Map<String, Object> winProps = new HashMap<String, Object>();
winProps.put(StringConstants.PARENT, this);
winProps.put(StringConstants.PARENTNAME, "Tool");
winProps.put(StringConstants.SELECTEDMETHOD, selectedMethod);
List<MapLayer> layers = getMapComposer().getPolygonLayers();
if (layers != null && !layers.isEmpty()) {
prevTopArea = layers.get(0);
} else {
prevTopArea = null;
}
Window window = (Window) Executions.createComponents("WEB-INF/zul/add/AddArea.zul", this, winProps);
window.setAttribute("winProps", winProps, true);
window.setParent(this);
window.doModal();
return;
}
Div currentDiv = (Div) getFellowIfAny(StringConstants.ATSTEP + currentStep);
Div nextDiv = (Div) getFellowIfAny(StringConstants.ATSTEP + (currentStep + 1));
if (!currentDiv.getZclass().contains(StringConstants.LAST)) {
currentDiv.setVisible(false);
nextDiv.setVisible(true);
Html previousStepCompletedImg = (Html) getFellowIfAny(StringConstants.IMG_COMPLETED_STEP + (currentStep));
previousStepCompletedImg.setVisible(true);
Label previousStepLabel = (Label) getFellowIfAny(StringConstants.LBLSTEP + (currentStep));
previousStepLabel.setStyle(StringConstants.FONT_WEIGHT_NORMAL);
Label currentStepLabel = (Label) getFellowIfAny(StringConstants.LBLSTEP + (currentStep + 1));
currentStepLabel.setStyle(StringConstants.FONT_WEIGHT_BOLD);
currentStep++;
updateWindowTitle();
fixFocus();
sa = getSelectedArea();
query = QueryUtil.queryFromSelectedArea(query, sa, false, getGeospatialKosher());
if (query != null) {
List<QueryField> fields = query.getFacetFieldList();
Collections.sort(fields, new QueryField.QueryFieldComparator());
String lastGroup = null;
for (QueryField field : fields) {
String newGroup = field.getGroup().getName();
if (!newGroup.equals(lastGroup)) {
Comboitem sep = new Comboitem(StringConstants.SEPERATOR);
sep.setLabel("---------------" + StringUtils.center(newGroup, 19) + "---------------");
sep.setParent(cbColour);
sep.setDisabled(true);
lastGroup = newGroup;
}
Comboitem ci = new Comboitem(field.getDisplayName());
ci.setValue(field.getName());
ci.setParent(cbColour);
}
}
btnBack.setDisabled(false);
btnOk.setDisabled(true);
} else {
if (selectedList.size() == 0) {
btnOk.setDisabled(true);
}
Facet f = Facet.parseFacet(getSelectionFacet());
Query querynew = query.newFacet(f, true);
if (querynew.getOccurrenceCount() <= 0) {
getMapComposer().showMessage(CommonData.lang(StringConstants.NO_OCCURRENCES_SELECTED));
} else {
getMapComposer().mapSpecies(querynew, StringConstants.MY_FACET, StringConstants.SPECIES, -1, LayerUtilitiesImpl.SPECIES, null, 0, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
this.detach();
}
}
} catch (Exception ex) {
LOGGER.error("error adding facet", ex);
}
fixFocus();
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AddFacetController method loadAreaLayers.
public void loadAreaLayers(String selectedAreaName) {
try {
Radiogroup rgArealocal = (Radiogroup) getFellowIfAny("rgArea");
//remove all radio buttons that don't have an id
for (int i = rgArealocal.getItemCount() - 1; i >= 0; i--) {
String id = rgArealocal.getItems().get(i).getId();
if (id == null || id.length() == 0) {
rgArealocal.removeItemAt(i);
} else {
rgArealocal.getItemAtIndex(i).setSelected(false);
}
}
Radio rAreaCurrent = (Radio) getFellowIfAny("rAreaCurrent");
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(rgArealocal);
rgArealocal.insertBefore(rAr, rAreaCurrent);
if (lyr.getName().equals(selectedLayerName)) {
rSelectedLayer = rAr;
rAreaSelected = rAr;
}
}
if (selectedAreaName != null && !selectedAreaName.isEmpty()) {
for (int i = 0; i < rgArealocal.getItemCount(); i++) {
if (rgArealocal.getItemAtIndex(i).isVisible() && rgArealocal.getItemAtIndex(i).getLabel().equals(selectedAreaName)) {
rAreaSelected = rgArealocal.getItemAtIndex(i);
LOGGER.debug("2.resetting indexToSelect = " + i);
rgArealocal.setSelectedItem(rAreaSelected);
break;
}
}
} else if (rSelectedLayer != null) {
rAreaSelected = rSelectedLayer;
rgArealocal.setSelectedItem(rAreaSelected);
} else if (StringConstants.NONE.equals(selectedLayerName)) {
rgArealocal.setSelectedItem(rAreaWorld);
rAreaSelected = rAreaWorld;
rgArealocal.setSelectedItem(rAreaSelected);
} else {
rAreaSelected = rAreaWorld;
rgArealocal.setSelectedItem(rAreaSelected);
}
Clients.evalJavaScript("jq('#" + rAreaSelected.getUuid() + "-real').attr('checked', 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 AddAreaController method onClick$btnOk.
public void onClick$btnOk(Event event) {
if (btnOk.isDisabled()) {
return;
}
String windowName = "";
MapComposer mc = getMapComposer();
String script = "";
boolean overlapped = true;
if (cbAreaSelection.getSelectedItem() == ciBoundingBox) {
windowName = "WEB-INF/zul/add/area/AreaBoundingBox.zul";
script = mc.getOpenLayersJavascript().addBoxDrawingTool();
} else if (cbAreaSelection.getSelectedItem() == ciPolygon) {
windowName = "WEB-INF/zul/add/area/AreaPolygon.zul";
script = mc.getOpenLayersJavascript().addPolygonDrawingTool();
} else if (cbAreaSelection.getSelectedItem() == ciPointAndRadius) {
windowName = "WEB-INF/zul/add/area/AreaPointAndRadius.zul";
script = mc.getOpenLayersJavascript().addRadiusDrawingTool();
} else if (cbAreaSelection.getSelectedItem() == ciRegionSelection) {
overlapped = false;
windowName = "WEB-INF/zul/add/area/AreaRegionSelection.zul";
} else if (cbAreaSelection.getSelectedItem() == ciAddressRadiusSelection) {
overlapped = false;
windowName = "WEB-INF/zul/add/area/AreaAddressRadiusSelection.zul";
} else if (cbAreaSelection.getSelectedItem() == ciRadiusManualSelection) {
overlapped = false;
windowName = "WEB-INF/zul/add/area/AreaRadiusManualSelection.zul";
} else if (cbAreaSelection.getSelectedItem() == ciUploadShapefile) {
windowName = "WEB-INF/zul/add/area/AreaUploadShapefile.zul";
overlapped = false;
} else if (cbAreaSelection.getSelectedItem() == ciUploadKML) {
windowName = "WEB-INF/zul/add/area/AreaUploadKML.zul";
overlapped = false;
} else if (cbAreaSelection.getSelectedItem() == ciMapPolygon) {
List<MapLayer> layers = getMapComposer().getContextualLayers();
boolean visibleLayers = false;
for (MapLayer ml : layers) {
if (ml.isDisplayed()) {
visibleLayers = true;
break;
}
}
if (!visibleLayers) {
//present layer selection window
windowName = "WEB-INF/zul/layer/ContextualLayerSelection.zul";
overlapped = false;
} else {
windowName = "WEB-INF/zul/add/area/AreaMapPolygon.zul";
script = mc.getOpenLayersJavascript().addFeatureSelectionTool();
}
} else if (cbAreaSelection.getSelectedItem() == ciEnvironmentalEnvelope) {
windowName = "WEB-INF/zul/add/area/AreaEnvironmentalEnvelope.zul";
} else if (cbAreaSelection.getSelectedItem() == ciBoxAustralia) {
String wkt = CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT);
String layerName = mc.getNextAreaLayerName(CommonData.lang(StringConstants.AUSTRALIA_BOUNDING_BOX));
MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, layerName);
mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadata(CommonData.lang(StringConstants.AUSTRALIA_BOUNDING_BOX) + " " + wkt));
remoteLogger.logMapArea(layerName, "Area - BoxAustralia", wkt);
} else if (cbAreaSelection.getSelectedItem() == ciBoxWorld) {
String wkt = CommonData.WORLD_WKT;
String layerName = mc.getNextAreaLayerName(CommonData.lang(StringConstants.WORLD_BOUNDING_BOX));
MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, layerName);
mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadata(CommonData.lang(StringConstants.WORLD_BOUNDING_BOX) + " " + wkt));
remoteLogger.logMapArea(layerName, "Area - BoxWorld", wkt);
} else if (cbAreaSelection.getSelectedItem() == ciBoxCurrentView) {
String wkt = mc.getMapComposer().getViewArea();
String layerName = mc.getNextAreaLayerName(CommonData.lang(StringConstants.CURRENT_VIEW_AREA));
MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, layerName);
mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadata(CommonData.lang(StringConstants.CURRENT_VIEW_AREA) + " " + wkt));
remoteLogger.logMapArea(layerName, "Area - BoxCurrentView", wkt);
} else if (cbAreaSelection.getSelectedItem() == ciWKT) {
windowName = "WEB-INF/zul/add/area/AreaWKT.zul";
} else if (cbAreaSelection.getSelectedItem() == ciMergeAreas) {
windowName = "WEB-INF/zul/add/area/AreaMerge.zul";
overlapped = false;
}
if (!windowName.isEmpty()) {
mc.getOpenLayersJavascript().execute(mc.getOpenLayersJavascript().getIFrameReferences() + script);
Window window = (Window) Executions.createComponents(windowName, this.getParent(), args);
try {
if (overlapped) {
window.doOverlapped();
} else {
window.setParent(this.getParent());
window.doModal();
}
} catch (Exception e) {
LOGGER.error("error opening window: " + windowName, e);
}
} else if (StringConstants.ADDTOOLWINDOW.equals(getParent().getId())) {
ToolComposer analysisParent = (ToolComposer) this.getParent();
analysisParent.resetWindow(getMapComposer().getNextAreaLayerName(StringConstants.MY_AREA));
} else if (StringConstants.ADDFACETWINDOW.equals(getParent().getId())) {
AddFacetController analysisParent = (AddFacetController) this.getParent();
analysisParent.resetWindow(getMapComposer().getNextAreaLayerName(StringConstants.MY_AREA));
}
if (cbAreaSelection.getSelectedItem() != null) {
mc.setAttribute(StringConstants.ADDAREAWINDOW, cbAreaSelection.getSelectedItem().getId());
}
this.detach();
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AreaEnvironmentalEnvelope method onClick$filterDone.
public void onClick$filterDone(Event event) {
ok = true;
try {
//create the layer
StringBuilder sbProcessUrl = new StringBuilder();
sbProcessUrl.append(CommonData.getSatServer()).append("/ws/envelope?area=").append(getWkt());
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(sbProcessUrl.toString());
LOGGER.debug(sbProcessUrl.toString());
post.addRequestHeader(StringConstants.ACCEPT, StringConstants.TEXT_PLAIN);
client.executeMethod(post);
String slist = post.getResponseBodyAsString();
String[] list = slist.split("\n");
String pid = list[0];
String url = CommonData.getGeoServer() + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=ALA:envelope_" + pid + "&FORMAT=image%2Fpng";
String activeAreaExtent = list[1];
activeAreaSize = list[2];
//load the layer
layerName = txtLayerName.getText();
MapLayer ml = mc.addWMSLayer(pid, layerName, url, 0.75f, null, null, LayerUtilitiesImpl.ENVIRONMENTAL_ENVELOPE, null, null);
//add colour!
int colour = Util.nextColour();
int r = (colour >> 16) & 0x000000ff;
int g = (colour >> 8) & 0x000000ff;
int b = (colour) & 0x000000ff;
ml.setRedVal(r);
ml.setGreenVal(g);
ml.setBlueVal(b);
ml.setDynamicStyle(true);
ml.setPolygonLayer(true);
getMapComposer().applyChange(ml);
getMapComposer().updateLayerControls();
//make the metadata?
StringBuilder sb = new StringBuilder();
StringBuilder sbLayerList = new StringBuilder();
sb.append("Environmental Envelope<br>");
for (int i = 0; i < selectedLayers.size(); i++) {
JSONObject layer = selectedLayers.get(i);
SPLFilter f = getSPLFilter(layer);
sb.append(f.getLayername()).append(": ").append(f.getFilterString()).append("<br>");
sbLayerList.append(f.getLayername());
if (i < selectedLayers.size() - 1) {
sbLayerList.append(":");
}
}
String activeAreaMetadata = LayersUtil.getMetadata(sb.toString());
getMapComposer().setAttribute("activeLayerName", sbLayerList.toString());
getMapComposer().setAttribute("mappolygonlayer", sb.toString());
String finalWkt = null;
try {
finalWkt = getWkt();
} catch (Exception e) {
LOGGER.error("failed to get WKT", e);
}
this.layerName = ml.getName();
List<Double> bb = new ArrayList<Double>(4);
String[] bs = activeAreaExtent.split(",");
for (int i = 0; i < 4; i++) {
bb.add(Double.parseDouble(bs[i]));
}
ml.getMapLayerMetadata().setBbox(bb);
ml.getMapLayerMetadata().setMoreInfo(activeAreaMetadata);
ml.setWKT(StringConstants.ENVELOPE + "(" + finalWkt + ")");
//not the actual WKT
ml.setEnvelope(finalWkt);
try {
double area = Double.parseDouble(activeAreaSize.replace(",", ""));
activeAreaSize = String.format("%,.2f", area);
} catch (NumberFormatException e) {
LOGGER.error("failed to parse environmental envelope area for: " + activeAreaSize);
}
ml.setAreaSqKm(activeAreaSize);
ml.setFacets(getFacets());
//this also shows active area
removeAllSelectedLayers(true);
} catch (Exception e) {
LOGGER.error("unable to create envelope layer: ", e);
}
//do detach after adding the new layer
mc.updateLayerControls();
}
Aggregations