Search in sources :

Example 11 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class AddSpeciesInArea method onFinish.

public void onFinish() {
    try {
        SelectedArea sa = getSelectedArea();
        boolean setupMetadata = true;
        MapLayer ml = null;
        Query q = QueryUtil.queryFromSelectedArea(query, sa, true, geospatialKosher);
        if (byLsid) {
            ml = getMapComposer().mapSpecies(q, name, s, featureCount, type, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
        } else if (filter) {
            ml = getMapComposer().mapSpecies(q, name, s, featureCount, type, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
        } else if (filterGrid) {
            ml = getMapComposer().mapSpecies(q, name, s, featureCount, type, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
        } else if (rank != null && taxon != null && q != null) {
            ml = getMapComposer().mapSpecies(q, taxon, rank, -1, LayerUtilitiesImpl.SPECIES, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
            setupMetadata = false;
        } else {
            int resultsCountOccurrences = q.getOccurrenceCount();
            //test limit
            if (resultsCountOccurrences > 0 && resultsCountOccurrences <= Integer.parseInt(CommonData.getSettings().getProperty(StringConstants.MAX_RECORD_COUNT_MAP))) {
                String activeAreaLayerName = getSelectedAreaDisplayName();
                String layerName = CommonData.lang("occurrences_in_area_prefix") + " " + activeAreaLayerName;
                if (multipleSpeciesUploadName != null) {
                    layerName = multipleSpeciesUploadName;
                } else {
                    if (q instanceof BiocacheQuery) {
                        String lsids = ((BiocacheQuery) q).getLsids();
                        if (lsids != null && lsids.length() > 0 && lsids.split(",").length > 1) {
                            layerName = CommonData.lang("species_assemblage_layer_name");
                        }
                    }
                }
                ml = getMapComposer().mapSpecies(q, layerName, StringConstants.SPECIES, resultsCountOccurrences, LayerUtilitiesImpl.SPECIES, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
            } else {
                getMapComposer().showMessage(CommonData.lang("error_too_many_occurrences_for_mapping").replace("<counted_occurrences>", resultsCountOccurrences + "").replace("<max_occurrences>", CommonData.getSettings().getProperty(StringConstants.MAX_RECORD_COUNT_MAP)));
            }
            setupMetadata = false;
        }
        if (setupMetadata) {
            ml.getMapLayerMetadata().setMoreInfo(metadata);
        }
        LOGGER.debug("metadata: " + metadata);
    } catch (Exception e) {
        LOGGER.error("error adding species in area to map", e);
    }
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 12 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class AddSpeciesInArea method loadAreaLayers.

public void loadAreaLayers() {
    try {
        List<MapLayer> layers = null;
        Map m = args;
        if (m != null) {
            for (Object o : m.entrySet()) {
                if (((Map.Entry) o).getKey() instanceof String && ((Map.Entry) o).getKey().equals(StringConstants.POLYGON_LAYERS)) {
                    layers = (List<MapLayer>) ((Map.Entry) o).getValue();
                }
            }
        }
        for (int i = 0; layers != null && i < layers.size(); i++) {
            MapLayer lyr = layers.get(i);
            Radio rAr = new Radio(lyr.getDisplayName());
            rAr.setId(lyr.getDisplayName().replaceAll(" ", "") + i);
            rAr.setValue(lyr.getName());
            rAr.setParent(rgArea);
            rgArea.insertBefore(rAr, rAreaCurrent);
        }
        if (!allSpecies) {
            //set as default in the zul
            rAreaSelected = rAreaWorld;
        } else {
            rAreaWorld.setVisible(false);
            rAreaAustralia.setVisible(false);
            for (int i = 0; i < rgArea.getItemCount(); i++) {
                if (rgArea.getItemAtIndex(i).isVisible()) {
                    rAreaSelected = rgArea.getItemAtIndex(i);
                    rgArea.setSelectedItem(rAreaSelected);
                    Clients.evalJavaScript("jq('#" + rAreaSelected.getUuid() + "-real').attr('checked', true);");
                    break;
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) Radio(org.zkoss.zul.Radio) HashMap(java.util.HashMap) Map(java.util.Map)

Example 13 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class ToolComposer method onCheck$rgSpeciesBk.

public void onCheck$rgSpeciesBk(Event event) {
    if (rgSpeciesBk == null) {
        return;
    }
    Radio selectedItem = rgSpeciesBk.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 (event != null && vboxImportSLBk != null && selectedItem != rSpeciesUploadLSIDBk) {
            vboxImportSLBk.setVisible(false);
        }
        if (selectedItem == rSpeciesSearchBk && divSpeciesSearchBk != null) {
            divSpeciesSearchBk.setVisible(true);
            vboxMultipleBk.setVisible(false);
            if (event != null) {
                toggles();
            }
            return;
        }
        if (divSpeciesSearchBk != null) {
            divSpeciesSearchBk.setVisible(false);
        }
        if (selectedItem == rSpeciesUploadLSIDBk) {
            btnOk.setDisabled(true);
            vboxImportSLBk.setVisible(true);
            vboxMultiple.setVisible(false);
        } else if (selectedItem == rSpeciesUploadSpeciesBk) {
            btnOk.setVisible(true);
        }
        if (rMultipleBk != null && rMultipleBk.isSelected()) {
            vboxMultipleBk.setVisible(true);
        } else {
            vboxMultipleBk.setVisible(false);
        }
        if (event != null) {
            toggles();
        }
        // set default geospatial kosher checkboxes unless a map layers has
        // been chosen
        MapLayer ml;
        Query q;
        if (rgSpeciesBk.getSelectedItem() != null && rgSpeciesBk.getSelectedItem().getValue() != null && (ml = getMapComposer().getMapLayer(rgSpeciesBk.getSelectedItem().getLabel())) != null && (q = ml.getSpeciesQuery()) != null && q instanceof BiocacheQuery) {
            setGeospatialKosherCheckboxesBk(((BiocacheQuery) q).getGeospatialKosher());
        } else {
            setGeospatialKosherCheckboxesBk(defaultGeospatialKosher);
        }
        updateGeospatialKosherCheckboxesBk();
    } catch (Exception e) {
        LOGGER.error("error selecting background species radio", e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) org.zkoss.zk.ui.event(org.zkoss.zk.ui.event) IOException(java.io.IOException)

Example 14 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class RemoteMapImpl method createLocalLayer.

public MapLayer createLocalLayer(int type, String label) {
    MapLayer layer = new MapLayer();
    layer.setName(label);
    layer.setLayer(label);
    layer.setId(label);
    layer.setEnvColour(StringConstants.RED);
    int colour = Util.nextColour();
    int r = (colour >> 16) & 0x000000ff;
    int g = (colour >> 8) & 0x000000ff;
    int b = (colour) & 0x000000ff;
    layer.setBlueVal(b);
    layer.setGreenVal(g);
    layer.setRedVal(r);
    layer.setType(type);
    layer.setSubType(type);
    return layer;
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer)

Example 15 with MapLayer

use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.

the class ContextualMenu method getActions.

List<Action> getActions() {
    List<Action> actions = new ArrayList<Action>();
    List<MapLayer> layers = getVisibleLayers();
    MapLayer speciesLayer = null;
    MapLayer polygonLayer = null;
    MapLayer gridLayer = null;
    MapLayer firstLayer = null;
    for (int i = 0; i < layers.size(); /*&& actions.size() < 5*/
    i++) {
        if (layers.get(i).getSpeciesQuery() != null && layers.get(i).getSubType() != LayerUtilitiesImpl.SCATTERPLOT) {
            if (speciesLayer == null) {
                speciesLayer = layers.get(i);
            }
            if (firstLayer == null) {
                firstLayer = layers.get(i);
            }
        } else if (layers.get(i).isPolygonLayer() && layers.get(i).getSubType() != LayerUtilitiesImpl.ALOC) {
            if (polygonLayer == null) {
                polygonLayer = layers.get(i);
            }
            if (firstLayer == null) {
                firstLayer = layers.get(i);
            }
        } else if (layers.get(i).isGridLayer() && layers.get(i).getSubType() != LayerUtilitiesImpl.MAXENT && layers.get(i).getSubType() != LayerUtilitiesImpl.GDM && layers.get(i).getSubType() != LayerUtilitiesImpl.ALOC) {
            //TODO: grid test
            if (gridLayer == null) {
                gridLayer = layers.get(i);
            }
            if (firstLayer == null) {
                firstLayer = layers.get(i);
            }
        } else if (layers.get(i).getSubType() != LayerUtilitiesImpl.SCATTERPLOT && firstLayer == null) {
            firstLayer = layers.get(i);
        }
    }
    //actions rules
    if (polygonLayer != null) {
        actions.add(new Action("View area report for \"" + polygonLayer.getDisplayName() + "\"", new AreaReportEvent(polygonLayer.getName())));
    }
    if (firstLayer != null) {
        actions.add(new Action("View metadata for \"" + firstLayer.getDisplayName() + "\"", new MetadataEvent(firstLayer.getName())));
    }
    if (polygonLayer != null) {
        actions.add(new Action("Download species list for \"" + polygonLayer.getDisplayName() + "\"", new SpeciesListEvent(polygonLayer.getName())));
    }
    if (speciesLayer != null) {
        actions.add(new Action("Download all records for \"" + speciesLayer.getDisplayName() + "\"" + formatLayerName(polygonLayer), new SamplingEvent(speciesLayer.getName(), (polygonLayer != null) ? polygonLayer.getName() : null, null)));
    } else if (polygonLayer != null) {
        actions.add(new Action("Download all records " + (" for " + "\"" + polygonLayer.getDisplayName() + "\""), new SamplingEvent(null, polygonLayer.getName(), null)));
    }
    if (polygonLayer != null) {
        actions.add(new Action("Generate classification for \"" + polygonLayer.getDisplayName() + "\"", new ClassificationEvent(polygonLayer.getName(), null)));
    }
    if (speciesLayer != null) {
        actions.add(new Action("Produce scatterplot for \"" + speciesLayer.getDisplayName() + "\"" + formatLayerName(polygonLayer), new ScatterplotEvent(speciesLayer.getName(), (polygonLayer != null) ? polygonLayer.getName() : null, null)));
    }
    if (speciesLayer != null) {
        actions.add(new Action("Generate prediction for \"" + speciesLayer.getDisplayName() + "\"" + formatLayerName(polygonLayer), new PredictionEvent(speciesLayer.getName(), (polygonLayer != null) ? polygonLayer.getName() : null, null)));
    }
    if (speciesLayer != null) {
        actions.add(new Action("Produce points to grid for \"" + speciesLayer.getDisplayName() + "\"" + formatLayerName(polygonLayer), new SitesBySpeciesEvent(speciesLayer.getName(), (polygonLayer != null) ? polygonLayer.getName() : null, null)));
    }
    if (speciesLayer != null) {
        actions.add(new Action("Produce GDM using species \"" + speciesLayer.getDisplayName() + "\"" + formatLayerName(polygonLayer), new GDMEvent(speciesLayer.getName(), (polygonLayer != null) ? polygonLayer.getName() : null, null)));
    }
    if (polygonLayer != null) {
        actions.add(new Action("Export area \"" + polygonLayer.getDisplayName() + "\"", new ExportAreaEvent(polygonLayer.getName())));
    }
    if (speciesLayer != null && speciesLayer == layers.get(0)) {
        actions.add(new Action("Display facet of \"" + speciesLayer.getDisplayName() + "\"", new OpenFacetsEvent(speciesLayer.getName())));
    }
    //default actions
    if (actions.isEmpty()) {
        actions.add(new Action("Map species occurrences", new AddToMapEvent(StringConstants.SPECIES)));
        actions.add(new Action("Map area", new AddToMapEvent(StringConstants.AREA)));
        actions.add(new Action("Map layer", new AddToMapEvent(StringConstants.LAYER)));
        actions.add(new Action("Map facet", new AddToMapEvent(StringConstants.FACET)));
    }
    return actions;
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) ArrayList(java.util.ArrayList)

Aggregations

MapLayer (au.org.emii.portal.menu.MapLayer)131 HasMapLayer (au.org.emii.portal.menu.HasMapLayer)34 JSONObject (org.json.simple.JSONObject)24 MapComposer (au.org.emii.portal.composer.MapComposer)20 ParseException (org.json.simple.parser.ParseException)18 IOException (java.io.IOException)16 MapLayerMetadata (au.org.emii.portal.menu.MapLayerMetadata)15 SelectedArea (au.org.emii.portal.menu.SelectedArea)14 Facet (au.org.ala.legend.Facet)12 List (java.util.List)10 XmlArrayList (com.thoughtworks.xstream.persistence.XmlArrayList)9 JSONParser (org.json.simple.parser.JSONParser)9 JSONArray (org.json.simple.JSONArray)8 URL (java.net.URL)7 ArrayList (java.util.ArrayList)7 SuspendNotAllowedException (org.zkoss.zk.ui.SuspendNotAllowedException)7 LegendObject (au.org.ala.legend.LegendObject)6 Component (org.zkoss.zk.ui.Component)6 Geometry (com.vividsolutions.jts.geom.Geometry)5 ParseException (com.vividsolutions.jts.io.ParseException)5