Search in sources :

Example 1 with SelectedArea

use of au.org.emii.portal.menu.SelectedArea 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;
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer) SuspendNotAllowedException(org.zkoss.zk.ui.SuspendNotAllowedException)

Example 2 with SelectedArea

use of au.org.emii.portal.menu.SelectedArea 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 3 with SelectedArea

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

the class AreaReportController method onMapSpeciesKosher.

public void onMapSpeciesKosher(Event event) {
    try {
        SelectedArea sa;
        if (!StringConstants.CURRENT_EXTENT.equalsIgnoreCase(areaName)) {
            sa = selectedArea;
        } else {
            sa = new SelectedArea(null, getMapComposer().getViewArea());
        }
        Query baseQuery = null;
        if (event != null && event.getData() != null) {
            baseQuery = new BiocacheQuery(null, null, (String) event.getData(), null, false, null);
        }
        Query query = QueryUtil.queryFromSelectedArea(baseQuery, sa, true, new boolean[] { true, false, false });
        query = query.newFacet(new Facet("occurrence_status_s", "absent", false), false);
        String activeAreaLayerName = getMapComposer().getNextActiveAreaLayerName(areaDisplayName + " geospatial kosher");
        getMapComposer().mapSpecies(query, activeAreaLayerName, StringConstants.SPECIES, -1, LayerUtilitiesImpl.SPECIES, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
    } catch (Exception e) {
        LOGGER.error("error mapping kosher species in area", e);
    }
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea) Facet(au.org.ala.legend.Facet)

Example 4 with SelectedArea

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

the class PhylogeneticDiversityListResults method populateList.

public void populateList() {
    areaPds = new ArrayList<Map<String, String>>();
    areaSpeciesMatches = new ArrayList<Map<String, JSONArray>>();
    try {
        for (int i = 0; i < selectedAreas.size(); i++) {
            SelectedArea sa = selectedAreas.get(i);
            evalArea(sa);
        }
        makeCSV();
        fillPDTreeList();
    } catch (Exception e) {
        LOGGER.error("error reading Phylogenetic Diversity list data", e);
        getMapComposer().showMessage("Unknown error.");
        this.detach();
    }
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea)

Example 5 with SelectedArea

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

the class AreaReportController method onMapSpecies.

public void onMapSpecies(Event event) {
    try {
        SelectedArea sa;
        if (!StringConstants.CURRENT_EXTENT.equalsIgnoreCase(areaName)) {
            sa = selectedArea;
        } else {
            sa = new SelectedArea(null, getMapComposer().getViewArea());
        }
        Query baseQuery = null;
        if (event != null && event.getData() != null) {
            baseQuery = new BiocacheQuery(null, null, (String) event.getData(), null, false, null);
        }
        Query query = QueryUtil.queryFromSelectedArea(baseQuery, sa, true, new boolean[] { true, true, false });
        query = query.newFacet(new Facet("occurrence_status_s", "absent", false), false);
        String activeAreaLayerName = getMapComposer().getNextActiveAreaLayerName(areaDisplayName);
        getMapComposer().mapSpecies(query, activeAreaLayerName, StringConstants.SPECIES, -1, LayerUtilitiesImpl.SPECIES, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
    } catch (Exception e) {
        LOGGER.error("error mapping species in area", e);
    }
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea) Facet(au.org.ala.legend.Facet)

Aggregations

SelectedArea (au.org.emii.portal.menu.SelectedArea)30 MapLayer (au.org.emii.portal.menu.MapLayer)14 Facet (au.org.ala.legend.Facet)12 HttpClient (org.apache.commons.httpclient.HttpClient)6 PostMethod (org.apache.commons.httpclient.methods.PostMethod)6 Query (au.org.ala.spatial.util.Query)5 JSONObject (org.json.simple.JSONObject)5 ArrayList (java.util.ArrayList)4 JSONParser (org.json.simple.parser.JSONParser)4 ParseException (org.json.simple.parser.ParseException)4 IOException (java.io.IOException)3 StringReader (java.io.StringReader)3 Event (org.zkoss.zk.ui.event.Event)3 CSVReader (au.com.bytecode.opencsv.CSVReader)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 JSONArray (org.json.simple.JSONArray)2 Component (org.zkoss.zk.ui.Component)2