use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.
the class AreaReportPDF method initCsvSpecies.
private void initCsvSpecies() {
setProgress("Getting information: species list", 0);
if (isCancelled())
return;
csvs.put("Species", query.speciesList());
speciesLinks.put("Species", query.getWS() + "/occurrences/search?q=" + query.getQ());
for (int i = 0; i < StringConstants.SPECIES_GROUPS.length; i++) {
String s = StringConstants.SPECIES_GROUPS[i];
setProgress("Getting information: species list for lifeform " + s, 0);
if (isCancelled())
return;
BiocacheQuery q = query.newFacet(new Facet("species_group", s, true), true);
csvs.put(s, q.speciesList());
speciesLinks.put(s, q.getWS() + "/occurrences/search?q=" + q.getQ());
counts.put(s, String.valueOf(q.getSpeciesCount()));
counts.put(s + " (spatially valid only)", String.valueOf(q.getSpeciesCountKosher()));
}
setProgress("Getting information: threatened species list", 0);
if (isCancelled())
return;
BiocacheQuery q = query.newFacet(Facet.parseFacet(CommonData.speciesListThreatened), true);
csvs.put("Threatened_Species", q.speciesList());
speciesLinks.put("Threatened_Species", q.getWS() + "/occurrences/search?q=" + q.getQ());
counts.put("Threatened_Species", String.valueOf(q.getSpeciesCount()));
setProgress("Getting information: iconic species list", 0);
if (isCancelled())
return;
q = query.newFacet(new Facet("species_list_uid", "dr781", true), true);
csvs.put("Iconic_Species", q.speciesList());
speciesLinks.put("Iconic_Species", q.getWS() + "/occurrences/search?q=" + q.getQ());
counts.put("Iconic_Species", String.valueOf(q.getSpeciesCount()));
setProgress("Getting information: migratory species list", 0);
if (isCancelled())
return;
q = query.newFacet(new Facet("species_list_uid", "dr1005", true), true);
csvs.put("Migratory_Species", q.speciesList());
speciesLinks.put("Migratory_Species", q.getWS() + "/occurrences/search?q=" + q.getQ());
counts.put("Migratory_Species", String.valueOf(q.getSpeciesCount()));
setProgress("Getting information: invasive species list", 0);
if (isCancelled())
return;
q = query.newFacet(Facet.parseFacet(CommonData.speciesListInvasive), true);
csvs.put("Invasive_Species", q.speciesList());
speciesLinks.put("Invasive_Species", q.getWS() + "/occurrences/search?q=" + q.getQ());
counts.put("Invasive_Species", String.valueOf(q.getSpeciesCount()));
}
use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.
the class AreaReportPDF method initImages.
private void initImages() {
double aspectRatio = 1.6;
String type = "png";
int resolution = 0;
String basemap = "Minimal";
mlArea.setColourMode("hatching");
List<Double> bbox = mlArea.getMapLayerMetadata().getBbox();
//30% width buffer in decimal degrees
double step = (bbox.get(2) - bbox.get(0)) * 0.3;
double[] extents = new double[] { bbox.get(0) - step, bbox.get(1) - step, bbox.get(2) + step, bbox.get(3) + step };
step = (bbox.get(2) - bbox.get(0)) * 0.05;
double[] extentsSmall = new double[] { bbox.get(0) - step, bbox.get(1) - step, bbox.get(2) + step, bbox.get(3) + step };
step = (bbox.get(2) - bbox.get(0)) * 10;
double[] extentsLarge = new double[] { bbox.get(0) - step, bbox.get(1) - step, bbox.get(2) + step, bbox.get(3) + step };
if (extentsLarge[2] > 180) {
extentsLarge[2] = 180;
}
if (extentsLarge[0] < -180) {
extentsLarge[0] = -180;
}
if (extentsLarge[1] < -85) {
extentsLarge[1] = -85;
}
if (extentsLarge[3] > 85) {
extentsLarge[3] = 85;
}
setProgress("Getting information: images for map of map", 0);
if (isCancelled())
return;
MapLayer mlSpecies = createSpeciesLayer(query, 0, 0, 255, .6f, false, 9, false);
List<MapLayer> lifeforms = new ArrayList<MapLayer>();
for (int i = 0; i < StringConstants.SPECIES_GROUPS.length; i++) {
String s = StringConstants.SPECIES_GROUPS[i];
setProgress("Getting information: images for map of lifeform " + s, 0);
if (isCancelled())
return;
lifeforms.add(createSpeciesLayer(query.newFacet(new Facet("species_group", s, true), true), 0, 0, 255, .6f, false, 9, false));
}
setProgress("Getting information: images for map of threatened species", 0);
if (isCancelled())
return;
MapLayer threatenedSpecies = createSpeciesLayer(query.newFacet(Facet.parseFacet(CommonData.speciesListThreatened), true), 0, 0, 255, .6f, false, 9, false);
setProgress("Getting information: images for map of iconic species", 0);
if (isCancelled())
return;
MapLayer iconicSpecies = createSpeciesLayer(query.newFacet(new Facet("species_list_uid", "dr781", true), true), 0, 0, 255, .6f, false, 9, false);
setProgress("Getting information: images for map of migratory species", 0);
if (isCancelled())
return;
MapLayer migratorySpecies = createSpeciesLayer(query.newFacet(new Facet("species_list_uid", "dr1005", true), true), 0, 0, 255, .6f, false, 9, false);
setProgress("Getting information: images for map of invasive species", 0);
if (isCancelled())
return;
MapLayer invasiveSpecies = createSpeciesLayer(query.newFacet(Facet.parseFacet(CommonData.speciesListInvasive), true), 0, 0, 255, .6f, false, 9, false);
String[] layers = CommonData.getSettings().getProperty("detailed_area_report_layers").split("\n");
for (String layer : layers) {
if (!layer.isEmpty()) {
String[] split = layer.trim().split("\\|");
String shortname = split[0];
String displayname = split[1];
String geoserver_url = split[2];
String canSetColourMode = split[3];
String description = split[4];
setProgress("Getting information: images for map of layer " + shortname, 0);
if (isCancelled())
return;
MapLayer ml = createLayer(shortname, 1.0f);
if ("Y".equalsIgnoreCase(canSetColourMode)) {
ml.setColourMode("&styles=" + shortname + "&format_options=dpi:600");
}
setProgress("Getting information: making map of " + shortname, 0);
if (isCancelled())
return;
saveImage(shortname, new PrintMapComposer(extents, basemap, new MapLayer[] { mlArea, ml }, aspectRatio, "", type, resolution).get());
}
}
setProgress("Getting information: making map of area", 0);
if (isCancelled())
return;
saveImage("base_area", new PrintMapComposer(extents, basemap, new MapLayer[] { mlArea }, aspectRatio, "", type, resolution).get());
setProgress("Getting information: making map of area overview", 0);
if (isCancelled())
return;
saveImage("base_area_zoomed_out", new PrintMapComposer(extentsLarge, basemap, new MapLayer[] { mlArea }, aspectRatio, "", type, resolution).get());
setProgress("Getting information: making occurrences", 0);
if (isCancelled())
return;
saveImage(StringConstants.OCCURRENCES, new PrintMapComposer(extentsSmall, basemap, new MapLayer[] { mlArea, mlSpecies }, aspectRatio, "", type, resolution).get());
setProgress("Getting information: making threatened species", 0);
if (isCancelled())
return;
saveImage("Threatened_Species", new PrintMapComposer(extentsSmall, basemap, new MapLayer[] { mlArea, threatenedSpecies }, aspectRatio, "", type, resolution).get());
setProgress("Getting information: making iconic species", 0);
if (isCancelled())
return;
saveImage("Iconic_Species", new PrintMapComposer(extentsSmall, basemap, new MapLayer[] { mlArea, iconicSpecies }, aspectRatio, "", type, resolution).get());
setProgress("Getting information: making migratory species", 0);
if (isCancelled())
return;
saveImage("Migratory_Species", new PrintMapComposer(extentsSmall, basemap, new MapLayer[] { mlArea, migratorySpecies }, aspectRatio, "", type, resolution).get());
setProgress("Getting information: making invasive species", 0);
if (isCancelled())
return;
saveImage("Invasive_Species", new PrintMapComposer(extentsSmall, basemap, new MapLayer[] { mlArea, invasiveSpecies }, aspectRatio, "", type, resolution).get());
for (int i = 0; i < StringConstants.SPECIES_GROUPS.length; i++) {
setProgress("Getting information: making map of lifeform " + StringConstants.SPECIES_GROUPS[i], 0);
if (isCancelled())
return;
saveImage("lifeform - " + StringConstants.SPECIES_GROUPS[i], new PrintMapComposer(extentsSmall, basemap, new MapLayer[] { mlArea, lifeforms.get(i) }, aspectRatio, "", type, resolution).get());
}
//save images
setProgress("Getting information: saving maps", 0);
}
use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.
the class AreaReportPDF method initCountThreatenedSpecies.
private void initCountThreatenedSpecies() {
setProgress("Getting information: threatened species", 0);
if (isCancelled())
return;
Facet f = new Facet("state_conservation", "Endangered", true);
counts.put("Endangered Species", String.valueOf(query.newFacet(f, true).getSpeciesCount()));
}
use of au.org.ala.legend.Facet 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();
}
use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.
the class AreaReportPDFComposer method onFinish.
@Override
public boolean onFinish() {
if (pool != null) {
return true;
}
//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();
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);
}
String wktTmp = (ml == null ? sa.getWkt() : (ml.getFacets() == null ? ml.getWKT() : null));
if (wktTmp == null && ml != null && ml.getPid() != null) {
wktTmp = Util.readUrl(CommonData.getLayersServer() + "/shape/wkt/" + ml.getPid());
}
final String queryWkt = (ml == null ? sa.getWkt() : (ml.getFacets() == null ? ml.getWKT() : null));
final String area = areaDisplayName;
final String wkt = wktTmp;
final List<Facet> facets = (ml != null && ml.getFacets() != null ? ml.getFacets() : null);
progress = new ConcurrentHashMap();
progress.put("label", "Starting");
progress.put("percent", 0.0);
Callable pdfAreaReport = new Callable<AreaReportPDF>() {
@Override
public AreaReportPDF call() {
return new AreaReportPDF(wkt, area, facets, queryWkt, progress);
}
};
pool = Executors.newFixedThreadPool(1);
future = pool.submit(pdfAreaReport);
getMapComposer().getOpenLayersJavascript().execute("setTimeout('checkProgress()', 2000);");
divProgress.setVisible(true);
return true;
}
Aggregations