use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class RemoteMapImpl method createWKTLayer.
public MapLayer createWKTLayer(String wkt, String label) {
MapLayer wktLayer = new MapLayer();
wktLayer.setPolygonLayer(true);
LOGGER.debug("adding WKT feature layer " + label);
wktLayer.setName(label);
wktLayer.setLayer(label);
wktLayer.setId(label);
wktLayer.setEnvColour(StringConstants.RED);
int colour = Util.nextColour();
int r = (colour >> 16) & 0x000000ff;
int g = (colour >> 8) & 0x000000ff;
int b = (colour) & 0x000000ff;
wktLayer.setRedVal(r);
wktLayer.setGreenVal(g);
wktLayer.setBlueVal(b);
wktLayer.setType(LayerUtilitiesImpl.WKT);
wktLayer.setWKT(wkt);
if (wktLayer.getMapLayerMetadata() == null) {
wktLayer.setMapLayerMetadata(new MapLayerMetadata());
}
wkt = wkt.replace(" (", "(").replace(", ", ",");
List<Double> bb = Util.getBoundingBox(wkt);
wktLayer.getMapLayerMetadata().setBbox(bb);
wktLayer.setAreaSqKm(String.format("%,.2f", SpatialUtil.calculateArea(wkt) / 1000000.0));
return wktLayer;
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class RemoteMapImpl method createAndTestWMSLayer.
/**
* Create a MapLayer instance and test that an image can be read from
* the URI.
* <p/>
* Image format, and wms layer name and wms type are automatically obtained from the
* URI.
* <p/>
* If there is no version parameter in the uri, we use a sensible
* default (v1.1.1)
*
* @param label Label to use for the menu system
* @param uri URI to read the map layer from (a GetMap request)
* @param opacity Opacity value for this layer
*/
@Override
public MapLayer createAndTestWMSLayer(String label, String uri, float opacity) {
/* it is not necessary to construct and parse a service instance for adding
* a WMS layer since we already know its a WMS layer, so all we have to do
* is populate a MapLayer instance and ask for it to be activated as a
* user defined item
*/
MapLayer mapLayer = new MapLayer();
mapLayer.setName(label);
mapLayer.setUri(uri);
mapLayer.setLayer(layerUtilities.getLayer(uri));
mapLayer.setOpacity(opacity);
mapLayer.setImageFormat(layerUtilities.getImageFormat(uri));
/* attempt to retrieve bounding box if not database tables*/
if (!uri.contains("ALA:Objects") && !uri.contains("ALA:Distributions")) {
List<Double> bbox = layerUtilities.getBBox(uri);
if (bbox != null) {
mapLayer.getMapLayerMetadata().setBbox(bbox);
}
}
/* 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
*/
mapLayer.setId(uri + label.replaceAll("\\s+", ""));
mapLayer.setDescription(label);
// wms version
String version = layerUtilities.getVersionValue(uri);
mapLayer.setType(layerUtilities.internalVersion(version));
return mapLayer;
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method getSelectedAreaHighlight.
public SelectedArea getSelectedAreaHighlight() {
String area = rgAreaHighlight.getSelectedItem().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.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 onCheck$rgSpecies.
public void onCheck$rgSpecies(Event event) {
if (rgSpecies == null) {
return;
}
Radio selectedItem = rgSpecies.getSelectedItem();
try {
if (selectedItem == null && event != null) {
selectedItem = (Radio) ((org.zkoss.zk.ui.event.ForwardEvent) event).getOrigin().getTarget();
}
} catch (Exception e) {
LOGGER.error(StringConstants.FAILED_TO_SET_RADIO, e);
}
try {
if (vboxImportSL != null && event != null && selectedItem != rSpeciesUploadLSID) {
vboxImportSL.setVisible(false);
}
if (vboxImportSLBk != null && event != null && vboxImportSLBk != null && selectedItem != rSpeciesUploadLSIDBk) {
vboxImportSLBk.setVisible(false);
}
// Check to see if we are perform a normal or background upload
if (selectedItem == rSpeciesSearch && divSpeciesSearch != null) {
divSpeciesSearch.setVisible(true);
vboxMultiple.setVisible(false);
if (divLifeform != null)
divLifeform.setVisible(false);
if (event != null) {
toggles();
}
return;
}
if (divSpeciesSearch != null) {
divSpeciesSearch.setVisible(false);
}
if (selectedItem == rSpeciesUploadSpecies) {
btnOk.setVisible(true);
if (vboxMultiple != null)
vboxMultiple.setVisible(false);
if (divLifeform != null)
divLifeform.setVisible(false);
} else if (selectedItem == rSpeciesUploadLSID) {
btnOk.setDisabled(true);
vboxImportSL.setVisible(true);
if (vboxMultiple != null)
vboxMultiple.setVisible(false);
if (divLifeform != null)
divLifeform.setVisible(false);
} else if (rMultiple != null && rMultiple.isSelected()) {
vboxMultiple.setVisible(true);
if (divLifeform != null)
divLifeform.setVisible(false);
} else if (rSpeciesLifeform != null && rSpeciesLifeform.isSelected()) {
if (vboxMultiple != null)
vboxMultiple.setVisible(false);
divLifeform.setVisible(true);
} else {
btnOk.setDisabled(false);
if (vboxMultiple != null)
vboxMultiple.setVisible(false);
if (divLifeform != null)
divLifeform.setVisible(false);
}
if (event != null) {
toggles();
}
// set default geospatial kosher checkboxes unless a map layers has
// been chosen
MapLayer ml;
Query q;
if (rgSpecies.getSelectedItem() != null && rgSpecies.getSelectedItem().getValue() != null && (ml = getMapComposer().getMapLayer(rgSpecies.getSelectedItem().getLabel())) != null && (q = ml.getSpeciesQuery()) != null && q instanceof BiocacheQuery) {
setGeospatialKosherCheckboxes(((BiocacheQuery) q).getGeospatialKosher());
} else {
setGeospatialKosherCheckboxes(defaultGeospatialKosher);
}
updateGeospatialKosherCheckboxes();
} catch (Exception e) {
LOGGER.error("error from selecting a species radio", e);
}
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method onClick$btnOk.
public void onClick$btnOk(Event event) {
if (btnOk.isDisabled()) {
return;
}
boolean successful = false;
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));
//ONLY perform these checks if the "lMultiple" or lMultipleBk" is on the current page
if (Components.isAncestor(currentDiv, lMultiple) && rMultiple.isChecked()) {
// display the dialog and change the radio button to "use existing"...
if (Util.getUserEmail() != null && !"guest@ala.org.au".equals(Util.getUserEmail())) {
showExportSpeciesListDialog(lMultiple);
return;
}
} else if (Components.isAncestor(currentDiv, lMultipleBk) && rMultipleBk.isChecked()) {
if (Util.getUserEmail() != null && !"guest@ala.org.au".equals(Util.getUserEmail())) {
showExportSpeciesListDialog(lMultipleBk);
return;
}
}
if (!currentDiv.getZclass().contains(StringConstants.LAST)) {
if (currentDiv.getZclass().contains(StringConstants.SPECIES) && (rSpeciesUploadSpecies != null && rSpeciesUploadSpecies.isSelected())) {
Boolean test = currentDiv.getZclass().contains(StringConstants.SPECIES) && rSpeciesUploadSpecies.isSelected();
LOGGER.debug("test=" + test);
onClick$btnUpload(event);
} else {
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);
// now include the extra options for step 4
if (nextDiv != null) {
if (nextDiv.getZclass().contains(StringConstants.LAST)) {
loadSummaryDetails();
onLastPanel();
}
btnOk.setLabel(StringConstants.NEXT_GT);
}
currentStep++;
successful = true;
}
} else {
saveLayerSelection();
successful = onFinish();
if (successful) {
currentStep = 1;
}
}
if (successful) {
if (nextDiv != null && rgSpecies != null && (includeAnalysisLayersForUploadQuery || includeAnalysisLayersForAnyQuery)) {
Query q = getSelectedSpecies();
if (q != null) {
q = q.newFacet(new Facet("occurrence_status_s", "absent", false), false);
boolean test = includeAnalysisLayersForAnyQuery || (q instanceof UserDataQuery);
if (selectedLayersCombobox != null && (selectedLayersCombobox.getIncludeAnalysisLayers()) != test) {
selectedLayersCombobox.init(getMapComposer().getLayerSelections(), getMapComposer(), test);
}
if (lbListLayers != null && (lbListLayers.getIncludeAnalysisLayers()) != test) {
String[] selectedLayers = lbListLayers.getSelectedLayers();
lbListLayers.init(getMapComposer(), test, !includeContextualLayers, singleLayerDomain);
lbListLayers.updateDistances();
if (selectedLayers != null && selectedLayers.length > 0) {
lbListLayers.selectLayers(selectedLayers);
}
lbListLayers.renderAll();
}
if (cbLayer != null && (cbLayer.getIncludeAnalysisLayers()) != test) {
cbLayer.setIncludeAnalysisLayers(test);
}
if (cbLayerEnvironmentalOnly != null && (cbLayerEnvironmentalOnly.getIncludeAnalysisLayers()) != test) {
cbLayerEnvironmentalOnly.setIncludeAnalysisLayers(test);
}
if (cbLayer1 != null && (cbLayer1.getIncludeAnalysisLayers()) != test) {
cbLayer1.setIncludeAnalysisLayers(test);
}
if (cbLayer2 != null && (cbLayer2.getIncludeAnalysisLayers()) != test) {
cbLayer2.setIncludeAnalysisLayers(test);
}
if (cbLayerMix != null && (cbLayerMix.getIncludeAnalysisLayers()) != test) {
cbLayerMix.setIncludeAnalysisLayers(test);
}
if (mpLayer1 != null && mpLayer2 != null && mpLayersIncludeAnalysisLayers != test) {
// remove
while (!mpLayer1.getChildren().isEmpty()) {
mpLayer1.removeChild(mpLayer1.getFirstChild());
}
while (!mpLayer2.getChildren().isEmpty()) {
mpLayer2.removeChild(mpLayer2.getFirstChild());
}
// add
for (MapLayer ml : getMapComposer().getGridLayers()) {
addToMpLayers(ml, false);
}
mpLayersIncludeAnalysisLayers = test;
if (mpLayersIncludeAnalysisLayers) {
for (MapLayer ml : getMapComposer().getAnalysisLayers()) {
if (ml.getSubType() != LayerUtilitiesImpl.ALOC) {
addToMpLayers(ml, true);
}
}
}
}
}
}
if (nextDiv != null && nextDiv.getZclass().contains(StringConstants.LAST)) {
updateLayerListText();
}
if (btnBack != null) {
btnBack.setDisabled(false);
}
updateWindowTitle();
}
} catch (Exception e) {
LOGGER.error("error progressing to next screen of tool", e);
}
toggles();
displayTrafficLightInfo();
fixFocus();
}
Aggregations